Example: Technical Efficiency KPI
This example creates a new KPI named Technical Efficiency (ISO_22400). The technical efficiency of a work unit is the relationship between the actual production time (APT) and the sum of the actual production time (APT) and actual unit delay time (ADET), including delays and malfunction-caused interruptions.
APT/(APT+ADET)
The actual unit delay time (ADET) KPI element is created as part of this example. The code samples in this example assume that the Rework Ratio KPI has already been implemented.
1. Create a new Thing Shape named ACME_CORP.KPI.TechnicalEfficiencyThingShape with the following properties:
TechnicalEfficiency_currentValue, with Base Type=Number
TechnicalEfficiency_lastCalculatedTime, with Base Type=DateTime
TechnicalEfficiency_unitOfMeasure, with Base Type= String
Ensure that the Persistent checkbox is selected for each of these properties.
2. Implement the following services on the ACME_CORP.KPI.TechnicalEfficiencyThingShape Thing Shape:
Get_TechnicalEfficiency_CurrentValue
Get_TechnicalEfficiency_ThresholdValues
Get_TechnicalEfficiency_Trend
TechnicalEfficiency_Calculate
Set_TechnicalEfficiency_CurrentValue
3. On the Thing Template of each equipment type for which this KPI is to be calculated, override the GetKPINames service to add the ACME_CORP.KPI.TechnicalEfficiencyThingShape Thing Shape. For example:
var kpiInfoJSON = new Object();
// JSON of KPI information we want to test if they are implemented on "me"
// For custom KPI, please add into this JSON and following given format
// Warning the order is important
kpiInfoJSON.kpiInfoArray = [
{kpiThingShapeName: 'PTC.SCA.SCO.AvailabilityThingShape', kpiName: 'Availability'},
{kpiThingShapeName: 'PTC.SCA.SCO.QualityRatioThingShape', kpiName: 'QualityRatio'},
{kpiThingShapeName: 'PTC.SCA.SCO.EffectivenessThingShape', kpiName: 'Effectiveness'},
{kpiThingShapeName: 'PTC.SCA.SCO.OEEThingShape', kpiName: 'OEE'},
{kpiThingShapeName: 'ACME_CORP.KPI.ReworkRatioThingShape', kpiName: 'ReworkRatio'},
{kpiThingShapeName: 'ACME_CORP.KPI.TechnicalEfficiencyThingShape', kpiName: 'TechnicalEfficiency'}

];
var result = Things["PTC.SCA.SCO.DefaultKPIManager"].GetImplementedKPIsOnThing({
thingName: me.name,
kpiInfo: kpiInfoJSON
});
4. Declare the thresholds for the Technical Efficiency KPI. On the Configuration page of the PTC.SCA.SCO.DefaultKPIManager Thing, add a new configuration table.
a. On the PTC.SCA.SCO.DefaultKPIManager Thing, add a configuration table with the following values:
Table NameTechnicalEfficiencyThresholdValues
Data ShapePTC.SCA.SCO.KPIThresholdValues
Allow Multiple Rows—Ensure that this checkbox is selected.
b. Add rows to the TechnicalEfficiencyThresholdValues configuration table for the desired value ranges.
5. Define the actual unit delay time (ADET) KPI element.
a. Create a property on the ACME_CORP.KPI.TechnicalEfficiencyThingShape Thing Shape named actualUnitDelayTime_ADET, with a Base Type of Number, and the Persistent checkbox selected.
b. Create a new service on the ACME_CORP.KPI.TechnicalEfficiencyThingShape Thing Shape named actualUnitDelayTime_ADET_Calculate with the following code:
var adet = me.CalculateTimeElement({
elementName: "ADET", /* STRING */
TimeInfo : TimeInfo
});

me.actualUnitDelayTime_ADET = adet;
var result = adet;
c. On the Thing Template of each equipment type for which this KPI is to be calculated, override the GetKPIElementNames service. Add the new property to the KPI element list. For example:
result = "actualProductionTime_APT,goodQuantity_GQ,plannedBusyTime_PBT,plannedRunTimePerItem_PRI,producedQuantity_PQ,reworkQuantity_RQ,actualUnitDelayTime_ADET";
d. Update the TechnicalEfficiency_Calculate service created in step 2 to include the new actual unit delay time (ADET) KPI element. For example:
customLogger = logger.getLoggerContext().getLogger(logger.getName()+".com.ptc.sca.sco.KPICalculation.TechnicalEfficiency");
var technicalEfficiency = 0;
var aptTime = me.actualProductionTime_APT;
var adetTime = me.actualUnitDelayTime_ADET;
customLogger.debug("TechnicalEfficiency_Calculate aptTime:"+aptTime+" adetTime:"+adetTime);
if ( aptTime !== 0){
technicalEfficiency = aptTime / (aptTime+adetTime);
}else{
technicalEfficiency = 1;
}
customLogger.debug("TechnicalEfficiency_Calculate TechnicalEfficiency:"+technicalEfficiency);
me.Set_TechnicalEfficiency_CurrentValue({
value: technicalEfficiency
});
me.TechnicalEfficiency_lastCalculatedTime = Date.now();
var result = technicalEfficiency;
6. As the actual unit delay time (ADET) KPI element is a time element, update the appropriate status definitions to include ADET as a timeElement value. Statuses with timeElement values are considered when the specified KPI elements are calculated. For this example, configure the Custom1 status to have a timeElement value of ADET,PBT, so that the Custom1 status is taken into account when the ADET and PBT are calculated.
Screenshot thowing the Custom1 status configured as described in this step of the example.
For more information, see Configuring Equipment Statuses.
Was this helpful?