예: 재작업 비율 KPI
이 예에서는 재작업 비율(ISO_22400)이라는 새 KPI를 만듭니다. 재작업 비율은 작업 단위, 제품, 생산 주문 또는 결함 유형에 대한 RQ(재작업 수량)와 PQ(생산 수량) 간의 관계입니다.
RQ/PQ
RQ(재작업 수량) KPI 요소는 이 예제의 일부로 작성됩니다.
1. 다음 속성을 사용하여 ACME_CORP.KPI.ReworkRatioThingShape라는 새 사물 형태를 만듭니다.
ReworkRatio_currentValue, 기본 유형=Number
ReworkRatio_lastCalculatedTime, 기본 유형=DateTime
ReworkRatio_unitOfMeasure, 기본 유형=String
이러한 각 속성에 대해 지속 확인란이 선택되어 있는지 확인합니다.
2. ACME_CORP.KPI.ReworkRatioThingShape 사물 형태에 다음 서비스를 구현합니다.
Get_ReworkRatio_CurrentValue
Get_ReworkRatio_ThresholdValues
Get_ReworkRatio_Trend
ReworkRatio_Calculate
Set_ReworkRatio_CurrentValue
3. 이 KPI를 계산할 각 장비 유형의 사물 템플릿에서 GetKPINames 서비스를 무시합니다. 다음 예제 코드와 같이 ACME_CORP.KPI.ReworkRatioThingShape 사물 형태를 추가합니다.
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'}
];
var result = Things["PTC.SCA.SCO.DefaultKPIManager"].GetImplementedKPIsOnThing({
thingName: me.name,
kpiInfo: kpiInfoJSON
});
4. 재작업 비율 KPI에 대한 한계 허용치를 선언합니다. PTC.SCA.SCO.DefaultKPIManager 사물의 구성 페이지에서 새 구성 테이블을 추가합니다.
a. PTC.SCA.SCO.DefaultKPIManager 사물에서 다음 값을 사용하여 구성 테이블을 추가합니다.
테이블 이름 - ReworkRatioThresholdValues
데이터 셰이프 - PTC.SCA.SCO.KPIThresholdValues
여러 행 허용 - 이 확인란이 선택되어 있는지 확인합니다.
b. 다음 이미지와 같이 ReworkRatioThresholdValues 구성 테이블에 원하는 값 범위에 대한 행을 추가합니다.
5. RQ(재작업 수량) KPI 요소를 정의합니다.
a. ACME_CORP.KPI.ReworkRatioThingShape 사물 형태에 reworkQuantity_RQ라는 속성을 만듭니다(기본 유형Number이고 지속 확인란이 선택됨).
b. 다음 코드를 사용하여 ACME_CORP.KPI.ReworkRatioThingShape 사물 형태에 reworkQuantity_RQ_Calculate라는 새 서비스를 만듭니다.
function isUndefinedOrNull(value){
return (value === null || typeof(value) === "undefined" );
}
result = me.reworkQuantity_RQ;
//Register first value to cache
me.RegisterValueToKPICache({
key: "reworkQuantity_RQ_firstValue" /* STRING */,
value: result, /* NUMBER */
TimeInfo : TimeInfo
});
c. 이 KPI를 계산할 각 장비 유형의 사물 템플릿에서 GetKPIElementNames 서비스를 무시합니다. 새 속성을 목록에 추가합니다. 예:
result = "actualProductionTime_APT,goodQuantity_GQ,plannedBusyTime_PBT,plannedRunTimePerItem_PRI,producedQuantity_PQ,reworkQuantity_RQ";
d. 2단계에서 만든 ReworkRatio_Calculate 서비스를 업데이트하여 새 RQ(재작업 수량) KPI 요소를 포함합니다. 예를 들면, 다음과 같습니다.
var customLogger = logger.getLoggerContext().getLogger(logger.getName()+".com.ptc.sca.sco.KPICalculation.ReworkRatio");
var reworkRatio = me.reworkQuantity_RQ;
var producedQuantity = me.producedQuantity_PQ;
if (TimeInfo.getRowCount() > 0){
var row = TimeInfo.getRow(0);
var startTime = row.StartTimeDate;
var generatedID= row.GeneratedID;
// result from service GetKPIElementStartValue: INFOTABLE dataShape: "PTC.SCA.SCO.KPIElementValue"
var reworkQuantity_RQ_firstValue = me.GetKPICacheValue({
generatedID: generatedID/* STRING */,
name: "reworkQuantity_RQ_firstValue" /* STRING */
});
var producedQuantity_PQ_firstValue = me.GetKPICacheValue({
generatedID: generatedID/* STRING */,
name: "producedQuantity_PQ_firstValue" /* STRING */
});
var producedTotalQuantity = 0;
var producedReworkQuantity = 0;
if ( (typeof producedQuantity_PQ_firstValue !== 'undefined') && (typeof reworkQuantity_RQ_firstValue !== 'undefined') ){
producedTotalQuantity = (producedQuantity - producedQuantity_PQ_firstValue);
producedReworkQuantity = (reworkRatio - reworkQuantity_RQ_firstValue);
if ( producedTotalQuantity === 0 ){
// Until items are produced, rework ratio cannot be measured and will default to 1
// with producedReworkQuantity greater than 0, then the service will return 0.
reworkRatio = producedReworkQuantity > 0 ? 0: 1;
}
else{
reworkRatio = producedReworkQuantity / producedTotalQuantity;
}

customLogger.debug("ReworkRatio_Calculate: produced quantity value when time info started - last produced quantity :"+ producedQuantity_PQ_firstValue+"-"+producedQuantity);
customLogger.debug("ReworkRatio_Calculate: rework quantity value when time info started - last good quantity: "+ reworkQuantity_RQ_firstValue+"-"+reworkRatio);
customLogger.debug("ReworkRatio_Calculate: produced Rework Quantity / produced total quantity = quality ratio: " +producedReworkQuantity+ " / " + producedTotalQuantity + " = " + reworkRatio);
}
else{
customLogger.warn("ReworkRatio_Calculate for "+me.name+" could not retrieve the good quantity or produced quantity at the start of the time info.");
}
}
else{
customLogger.warn("ReworkRatio_Calculate for "+me.name+" could not retrieve the current time info. ReworkRatio = 0.");
}
var result = reworkRatio;
me.Set_ReworkRatio_CurrentValue({
value: result
});
var now = new Date();
me.ReworkRatio_lastCalculatedTime = now;