2012年10月5日 星期五

Flexsim使用sink的label屬性來收集時間統計量(最大max cycletime,最小min cycletime,平均average cycletime)


在sink4的OnReset中,先將每個sink4的屬性label先設為零(避免上一次執行結果殘留),接著在sink4的OnEntry中收集








treenode item = parnode(1);
treenode current = ownerobject(c);
int port = parval(2);
{ //************* PickOption Start *************\\
/**Write to GlobalTable*/
settablenum(
/** \nTable: */ /**/"time"/**/,
/** \nRow: */ /**/getlabelnum(item, "serial")/**/,
/** \nColumn: */ /**/3/**/,
/** \nValue: */ /**/time()/**/
);
/**\n\n*/
} //******* PickOption End *******\\
{ //************* PickOption Start *************\\
/**Set Label*/
setlabelnum(
/** \nObject: */ /**/item/**/,
/** \nLabel: */ /**/"outtime"/**/,
/** \nValue: */ /**/time()/**/
);
/**\n\n*/
} //******* PickOption End *******\\
{ //************* PickOption Start *************\\
/**Set Label*/
setlabelnum(
/** \nObject: */ /**/item/**/,
/** \nLabel: */ /**/"cycletime"/**/,
/** \nValue: */ /**/getlabelnum(item, "outtime")-getlabelnum(item, "intime")/**/
);
/**\n\n*/
} //******* PickOption End *******\\
//收集累積的 cycle time
{ //************* PickOption Start *************\\
/**Set Label*/
setlabelnum(
/** \nObject: */ /**/current/**/,
/** \nLabel: */ /**/"accumulatedct"/**/,
/** \nValue: */ /**/getlabelnum(item,"cycletime")+getlabelnum(current, "accumulatedct")/**/
);
/**\n\n*/
} //******* PickOption End *******\\
//收集最小cycle time
if (getlabelnum(item, "serial") == 1)
{
 setlabelnum(current,"minct", getlabelnum(item,"cycletime"));
}
else
{
 if (getlabelnum(current, "minct") > getlabelnum(item, "cycletime"))
 {
  setlabelnum(current,"minct", getlabelnum(item,"cycletime"));
 }
}
//收集最大cycle time
if (getlabelnum(item, "serial") == 1)
{
 setlabelnum(current,"maxct", getlabelnum(item,"cycletime"));
}
else
{
 if (getlabelnum(current, "maxct") < getlabelnum(item, "cycletime"))
 {
  setlabelnum(current,"maxct", getlabelnum(item,"cycletime"));
 }
}
{ //************* PickOption Start *************\\
//收集個數totalnum
/**Increment Value*/
inc(
/** \nNode: */ /**/label(current, "totalnum")/**list:label(item, "labelname")~gettablecell("tablename", 1,1)~node("/Tools/myvalue",model())*/
,
/** \nIncrement By: */ /**/1/**/
);
/**\n\n*/
} //******* PickOption End *******\\
{ //************* PickOption Start *************\\
//計算平均的cycle time: avgct,將累積的cycletime除以個數
/**Set Label*/
setlabelnum(
/** \nObject: */ /**/current/**/,
/** \nLabel: */ /**/"avgct"/**/,
/** \nValue: */ /**/getlabelnum(current,"accumulatedct")/getlabelnum(current,"totalnum")/**/
);
/**\n\n*/
} //******* PickOption End *******\\

沒有留言:

張貼留言