cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

ThingWorx Navigate is now Windchill Navigate Learn More

Translate the entire conversation x

How to update the production count using Production Event UID?

Sathishkumar_C
17-Peridot

How to update the production count using Production Event UID?

Trying to update the production (part count) for the past timestmp based on the "Production Event UID". Used the following service,

PTC.SCA.SCO.MnfgCommonProductionUtilsThing.AdjustProductionQuantity_PRD()


The count reflecting into current shift or current production event. The part count considered as current part count from machine.

What is best practices or possible ways to update the part count for past timestamp using production event?

 

@mstarnaud 

3 REPLIES 3

Hi Satishkumar

The big piece which is causing you problems is that the quantity of the production event is always the sum of all the "values" of that event, and the service you found (it's the one in the Operator Dashboard) will always set the time of the new value to Now. So if you have a way to look at the event's total it will look correct, but if you look at the quantity made during a specific time range then it will give different results.

 

What you really want is to add a value (AttributeValue table in SQL) at a specific time, and then attach it to the event that was active at that time : attaching it will cause the event's quantity to re-calculate to include the new value. To do this, instead of using the Operator Dashboard's mechanism (because it always uses Now), we can look at the subscription's mechanism. 

 

To review part of this mechanism, you could look at service ProductionByTagAndTime_AttributeRead which is on the equipments : this one reads awaiting tag values starting from the last read time until now, and saves them in AttributeValue. It has code to find the AttributeUid of the production quantity attribute (this will be required) and at the end it puts all awaiting values in a temporary table (with specific values in the other columns) and sends this table into service PTC.SCA.SCO.DefaultAttributeManager.SaveAttributeValues_ATT. That service will save the AttributeValues into the database and then mark that ProductionEvent as needing a quantity re-calculation, which should be done moments later. Note that these services require a Timestamp instead of a ProductionEventUid : it will find the event that was running at the timestamp you're specifying.

 

I wrote an example service to test this, which has 2 parameters : p_Value and p_Timestamp. It also specifies the AttributeUid which you would need to specify.

//parameters
var p_Value;
var p_Timestamp;
var AttributeUid = 360; //CHANGE THIS
var Username = "Custom_service_name_here";

var attributeValueInfoTable = Resources.InfoTableFunctions.CreateInfoTableFromDataShape({dataShapeName: 'PTC.SCA.SCO.AttributeValue'});
attributeValueInfoTable.AddRow({
    AttributeUID: AttributeUid,
    IsRecalculateTrigger: 1,
    ProductionEventUID: null,
    TimestampEntry: dateFormatISO(new Date()),
    TimestampResult: p_Timestamp,
    Value: p_Value,
    Username: Username,
    IsEventProcessed: 0
});
Things["PTC.SCA.SCO.DefaultAttributeManager"].SaveAttributeValues_ATT({
	AttributeValues: JSON.stringify(Array.from(attributeValueInfoTable.rows).map(row => ({
        AttributeUID: row.AttributeUID,
        IsRecalculateTrigger: row.IsRecalculateTrigger,
        ProductionEventUID: row.ProductionEventUID,
        TimestampEntry: row.TimestampEntry,
        TimestampResult: row.TimestampResult,
        Value: row.Value,
        Username: row.Username,
        IsEventProcessed: row.IsEventProcessed
    })))
 });

It immediately saves the value, and some seconds later the event's quantity will be re-calculated to include the new value. It will automatically find the running event at the specified time. It can be a past event.

 

Note that I tested this in 9.6.1 but I expect that all 9.X versions probably work the same for this.

Thank you for detailed explanation. It's working as expected.

The same approach will work for waste event with Waste Property's attributeuid?

 

Yes, waste uses the same AttributeValues system. I tested this custom service, just changed the AttributeUid to be the waste one, and it's working as expected.

 

Waste is interesting because using the screens, especially the Waste Events screen, you can see the list of events and their related AttributeValues and you can add some values using the screen.

Announcements


Top Tags