|
|
@@ -48,7 +48,7 @@ int RecipeContext::Moniter() {
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ report();
|
|
|
while (true) {
|
|
|
if (recipeExecuteCommand != RecipeExecuteCommandEnum::Default) {
|
|
|
command = recipeExecuteCommand;
|
|
|
@@ -86,6 +86,7 @@ int RecipeContext::Moniter() {
|
|
|
if (oldStatus == recipeExecuteStatus) {
|
|
|
break;
|
|
|
}
|
|
|
+ report();
|
|
|
}
|
|
|
else {
|
|
|
if (recipeExecuteCommand != RecipeExecuteCommandEnum::Hold && recipeExecuteCommand != RecipeExecuteCommandEnum::Skip && recipeExecuteCommand != RecipeExecuteCommandEnum::Jump) {
|
|
|
@@ -214,6 +215,8 @@ BOOL RecipeContext::judgeStep()
|
|
|
// TRUE - recipe未结束,且执行指针定位到了可执行的步骤上
|
|
|
// FALSE - recipe执行结束,或发生了语法错误
|
|
|
//流程:
|
|
|
+ stepName[0] = 0;
|
|
|
+ nextStepName[0] = 0;
|
|
|
while (true)
|
|
|
{
|
|
|
if (currentRecipeType == RecipeTypeEnum::NormalRecipe)
|
|
|
@@ -263,6 +266,13 @@ BOOL RecipeContext::judgeStep()
|
|
|
if (mainStepList.get(currentStepNo)->isLoopEndStep)
|
|
|
{
|
|
|
currentStepInfo = mainStepList.get(currentStepNo);
|
|
|
+ strcpy(stepName, currentStepInfo->name);
|
|
|
+ if (currentStepInfo->elapsedLoopCount + 1 >= currentStepInfo->loopCount) {
|
|
|
+ strcpy(nextStepName, mainStepList.get(currentStepNo+1)->name);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ strcpy(nextStepName, mainStepList.get(currentStepInfo->loopStartStep)->name);
|
|
|
+ }
|
|
|
return true;//循环结束也是像普通步骤一样先执行,循环判断放在next函数中
|
|
|
}
|
|
|
|
|
|
@@ -290,11 +300,20 @@ BOOL RecipeContext::judgeStep()
|
|
|
{
|
|
|
mainStepList.get(currentStepNo)->elapsedSubRecipeLoopCount = 0;
|
|
|
currentStepInfo = mainStepList.get(currentStepNo);
|
|
|
+ strcpy(stepName, currentStepInfo->name);
|
|
|
+ if (currentStepNo<mainStepList.length-1) {
|
|
|
+ strcpy(nextStepName, mainStepList.get(currentStepNo + 1)->name);
|
|
|
+ }
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
// e)返回TRUE(normal recipe的正常无跳转步骤)
|
|
|
currentStepInfo = mainStepList.get(currentStepNo);
|
|
|
+ strcpy(stepName, currentStepInfo->name);
|
|
|
+ if (currentStepNo < mainStepList.length - 1) {
|
|
|
+ strcpy(nextStepName, mainStepList.get(currentStepNo + 1)->name);
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -364,11 +383,35 @@ BOOL RecipeContext::judgeStep()
|
|
|
if (node->get(currentOtherStepNo)->isLoopEndStep)
|
|
|
{
|
|
|
currentStepInfo = node->get(currentOtherStepNo);
|
|
|
+ strcpy(stepName, currentStepInfo->name);
|
|
|
+ if (currentStepInfo->elapsedLoopCount + 1 >= currentStepInfo->loopCount) {
|
|
|
+ if (currentOtherStepNo < node->length - 1) {
|
|
|
+ strcpy(nextStepName, node->get(currentOtherStepNo+1)->name);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ strcpy(nextStepName, node->get(currentStepInfo->loopStartStep)->name);
|
|
|
+ }
|
|
|
return true;//循环结束也是像普通步骤一样先执行,循环判断放在next函数中
|
|
|
}
|
|
|
|
|
|
// f)返回TRUE(sub recipe的正常无跳转步)
|
|
|
currentStepInfo = node->get(currentOtherStepNo);
|
|
|
+ strcpy(stepName, currentStepInfo->name);
|
|
|
+ if (currentStepNo < node->length - 1) {
|
|
|
+ strcpy(nextStepName, node->get(currentOtherStepNo + 1)->name);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (mainStepList.get(currentStepNo)->elapsedSubRecipeLoopCount >= mainStepList.get(currentStepNo)->subRecipeLoopCount) {
|
|
|
+ strcpy(nextStepName, mainStepList.get(currentStepNo)->name);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ strcpy(nextStepName, node->get(0)->name);
|
|
|
+ }
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -431,11 +474,24 @@ BOOL RecipeContext::judgeStep()
|
|
|
if (node->get(currentOtherStepNo)->isLoopEndStep)
|
|
|
{
|
|
|
currentStepInfo = node->get(currentOtherStepNo);
|
|
|
+ strcpy(stepName, currentStepInfo->name);
|
|
|
+ if (currentStepInfo->elapsedLoopCount + 1 >= currentStepInfo->loopCount) {
|
|
|
+ if (currentOtherStepNo < node->length - 1) {
|
|
|
+ strcpy(nextStepName, node->get(currentOtherStepNo + 1)->name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ strcpy(nextStepName, node->get(currentStepInfo->loopStartStep)->name);
|
|
|
+ }
|
|
|
return true;//循环结束也是像普通步骤一样先执行,循环判断放在next函数中
|
|
|
|
|
|
}
|
|
|
// e)返回TRUE(abort recipe的正常无跳转步)
|
|
|
currentStepInfo = node->get(currentOtherStepNo);
|
|
|
+ strcpy(stepName, currentStepInfo->name);
|
|
|
+ if (currentStepNo < node->length - 1) {
|
|
|
+ strcpy(nextStepName, node->get(currentOtherStepNo + 1)->name);
|
|
|
+ }
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
@@ -479,10 +535,23 @@ BOOL RecipeContext::judgeStep()
|
|
|
if (node->get(currentOtherStepNo)->isLoopEndStep)
|
|
|
{
|
|
|
currentStepInfo = node->get(currentOtherStepNo);
|
|
|
+ strcpy(stepName, currentStepInfo->name);
|
|
|
+ if (currentStepInfo->elapsedLoopCount + 1 >= currentStepInfo->loopCount) {
|
|
|
+ if (currentOtherStepNo < node->length - 1) {
|
|
|
+ strcpy(nextStepName, node->get(currentOtherStepNo + 1)->name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ strcpy(nextStepName, node->get(currentStepInfo->loopStartStep)->name);
|
|
|
+ }
|
|
|
return true;//循环结束也是像普通步骤一样先执行,循环判断放在next函数中
|
|
|
|
|
|
}
|
|
|
currentStepInfo = node->get(currentOtherStepNo);
|
|
|
+ strcpy(stepName, currentStepInfo->name);
|
|
|
+ if (currentStepNo < node->length - 1) {
|
|
|
+ strcpy(nextStepName, node->get(currentOtherStepNo + 1)->name);
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -519,6 +588,7 @@ BOOL RecipeContext::next()
|
|
|
{
|
|
|
//上位机把循环次数多加了1,所以下面看起来循环少一次,其实正好
|
|
|
mainStepList.get(currentStepNo)->elapsedLoopCount++;
|
|
|
+ report();
|
|
|
if (mainStepList.get(currentStepNo)->elapsedLoopCount < mainStepList.get(currentStepNo)->loopCount)
|
|
|
{
|
|
|
currentStepNo = mainStepList.get(currentStepNo)->loopStartStep;
|
|
|
@@ -533,7 +603,7 @@ BOOL RecipeContext::next()
|
|
|
else {
|
|
|
currentStepNo++;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -563,6 +633,7 @@ BOOL RecipeContext::next()
|
|
|
if (stepInfo->isLoopEndStep)
|
|
|
{
|
|
|
stepInfo->elapsedLoopCount++;
|
|
|
+ report();
|
|
|
if (stepInfo->elapsedLoopCount <stepInfo->loopCount)
|
|
|
{
|
|
|
currentOtherStepNo = stepInfo->loopStartStep;
|
|
|
@@ -809,40 +880,7 @@ void RecipeContext::updateTime(BOOL newStep)
|
|
|
elapsedStepTime = 0;
|
|
|
remainStepTime = currentStepInfo->time*1000;
|
|
|
|
|
|
- if (startTime == 0)
|
|
|
- {
|
|
|
- int backupCurrentStepNo = currentStepNo;
|
|
|
- int backupCurrentOtherStepNo = currentOtherStepNo;
|
|
|
- RecipeTypeEnum backupCurrentRecipeType = (RecipeTypeEnum)currentRecipeType;
|
|
|
- RecipeStepInfo* backupRecipeStepInfo = currentStepInfo;
|
|
|
- while (next())
|
|
|
- {
|
|
|
- RecipeStepInfo* testStepInfo = getCurrentStepInfo();
|
|
|
- if (testStepInfo != NULL) {
|
|
|
- remainTotalTime += testStepInfo->time*1000;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- currentStepNo = backupCurrentStepNo;
|
|
|
- currentRecipeType = backupCurrentRecipeType;
|
|
|
- currentOtherStepNo = backupCurrentOtherStepNo;
|
|
|
- currentStepInfo = backupRecipeStepInfo;
|
|
|
- holdStepTime = 0;
|
|
|
- if (startTime ==0)
|
|
|
- {
|
|
|
- //const SYSTEMTIME Currontsystemtime;
|
|
|
- //FILETIME cuttentFileTime;
|
|
|
- //TcSystemTimeToFileTime(&Currontsystemtime, &cuttentFileTime);
|
|
|
-
|
|
|
- //// 转换为 ULONGLONG
|
|
|
- //ULONGLONG ulFileTime = (static_cast<ULONGLONG>(cuttentFileTime.dwHighDateTime) << 32) | cuttentFileTime.dwLowDateTime;
|
|
|
-
|
|
|
- startTime = sysTime;//当前时间
|
|
|
-
|
|
|
- // 再调用 TcEncodeFileTime 转换为字符串
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -874,7 +912,29 @@ void RecipeContext::updateTime(BOOL newStep)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+void RecipeContext::countTime()
|
|
|
+{
|
|
|
+ currentStepNo = -1;
|
|
|
+ currentOtherStepNo = 0;
|
|
|
+ currentRecipeType = RecipeTypeEnum::NormalRecipe;
|
|
|
+ while (next())
|
|
|
+ {
|
|
|
+ RecipeStepInfo* testStepInfo = getCurrentStepInfo();
|
|
|
+ if (testStepInfo != NULL) {
|
|
|
+ remainTotalTime += testStepInfo->time * 1000;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ currentStepNo = -1;
|
|
|
+ currentOtherStepNo = 0;
|
|
|
+ currentRecipeType = RecipeTypeEnum::NormalRecipe;
|
|
|
+ holdStepTime = 0;
|
|
|
+ startTime = sysTime;//当前时间
|
|
|
+ elapsedStepTime = 0;
|
|
|
+ elapsedTotalTime = 0;
|
|
|
+ holdStepTime = 0;
|
|
|
+ holdTotalTime = 0;
|
|
|
+ remainStepTime = 0;
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1020,6 +1080,7 @@ void RecipeContext::report() {
|
|
|
report(NULL, RecipeReportCommandEnum::None);
|
|
|
}
|
|
|
void RecipeContext::report(const char *message,RecipeReportCommandEnum command) {
|
|
|
+
|
|
|
short tagId = 0;
|
|
|
switch (this->recipeExecuteStatus) {
|
|
|
case RecipeExecuteStatusEnum::ExecStep:
|
|
|
@@ -1055,8 +1116,22 @@ void RecipeContext::report(const char *message,RecipeReportCommandEnum command)
|
|
|
tagId = (short)ReportTagIdEnum::AlarmTrigger;
|
|
|
}
|
|
|
static RecipeReport reportInfo;
|
|
|
- reportInfo.elapsedLoopCount = 0;
|
|
|
- reportInfo.loopCount = 0;
|
|
|
+ if (reportInfo.tagId == tagId && reportInfo.stepNo == currentStepNo && reportInfo.otherRecipeKey == currentOtherRecipeKey
|
|
|
+ && reportInfo.recipeType == (unsigned char)currentRecipeType && reportInfo.otherStepNo == currentOtherStepNo
|
|
|
+ && reportInfo.status == (unsigned char)recipeExecuteStatus && reportInfo.command ==(unsigned char) command ) {
|
|
|
+ //信息没有变化的1秒刷一次
|
|
|
+ if (elapsedTotalTime - reportInfo.elapsedTotalTime < 1000) {
|
|
|
+ if (currentStepInfo != NULL && currentStepInfo->isLoopEndStep && currentStepInfo->elapsedLoopCount != reportInfo.elapsedLoopCount) {
|
|
|
+ //循环次数变更,需要强制通知
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //reportInfo.elapsedLoopCount = 0;
|
|
|
+ //reportInfo.loopCount = 0;
|
|
|
reportInfo.subElapsedLoopCount = 0;
|
|
|
reportInfo.subLoopCount = 0;
|
|
|
reportInfo.elapsedStepTime = elapsedStepTime;
|
|
|
@@ -1071,24 +1146,41 @@ void RecipeContext::report(const char *message,RecipeReportCommandEnum command)
|
|
|
reportInfo.startTime = startTime;
|
|
|
reportInfo.stepNo = currentStepNo;
|
|
|
reportInfo.tagId = tagId;
|
|
|
+ if (currentStepNo == 0) {
|
|
|
+ reportInfo.loopCount = 0; //源数据N+1,反馈N
|
|
|
+ reportInfo.elapsedLoopCount = 0; //源数据0-N,反馈0-N
|
|
|
+ reportInfo.subElapsedLoopCount = 0; //源数据1-N,反馈1-N
|
|
|
+ reportInfo.subLoopCount = 0; //元数据N,反馈N
|
|
|
+ }
|
|
|
+ if (currentRecipeType == RecipeTypeEnum::SubRecipe)
|
|
|
+ {
|
|
|
|
|
|
- switch (currentRecipeType) {
|
|
|
- case RecipeTypeEnum::NormalRecipe:
|
|
|
- if (currentStepNo > 0 && currentStepInfo!=NULL) {
|
|
|
- reportInfo.loopCount = currentStepInfo->loopCount;
|
|
|
- reportInfo.elapsedLoopCount = currentStepInfo->elapsedLoopCount;
|
|
|
- }
|
|
|
- case RecipeTypeEnum::SubRecipe:
|
|
|
- if (currentStepNo >= 0) {
|
|
|
- reportInfo.subElapsedLoopCount = mainStepList.get(currentStepNo)->elapsedLoopCount;
|
|
|
- reportInfo.subLoopCount = mainStepList.get(currentStepNo)->loopCount;
|
|
|
- }
|
|
|
- break;
|
|
|
- case RecipeTypeEnum::AbortRecipe:
|
|
|
- case RecipeTypeEnum::AlarmRecipe:
|
|
|
- case RecipeTypeEnum::ResetRecipe:
|
|
|
- break;
|
|
|
+ if (currentStepNo >= 0) {
|
|
|
+ reportInfo.subElapsedLoopCount = mainStepList.get(currentStepNo)->elapsedSubRecipeLoopCount;
|
|
|
+ reportInfo.subLoopCount = mainStepList.get(currentStepNo)->subRecipeLoopCount;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ reportInfo.subElapsedLoopCount = 0;
|
|
|
+ reportInfo.subLoopCount = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ reportInfo.subElapsedLoopCount = 0;
|
|
|
+ reportInfo.subLoopCount = 0;
|
|
|
}
|
|
|
+ if (currentStepNo > 0 && currentStepInfo!=NULL) {
|
|
|
+ if (currentStepInfo->isLoopEndStep && currentStepInfo->elapsedLoopCount>0) {
|
|
|
+ reportInfo.loopCount = currentStepInfo->loopCount-1;
|
|
|
+ reportInfo.elapsedLoopCount = currentStepInfo->elapsedLoopCount;
|
|
|
+
|
|
|
+ }
|
|
|
+ if (reportInfo.elapsedLoopCount > reportInfo.loopCount) {
|
|
|
+ reportInfo.loopCount = 0;
|
|
|
+ reportInfo.elapsedLoopCount = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if (tagId == (short)ReportTagIdEnum::AlarmTrigger) {
|
|
|
if (message == NULL) {
|
|
|
message = OP->alarmText;
|
|
|
@@ -1109,6 +1201,8 @@ void RecipeContext::report(const char *message,RecipeReportCommandEnum command)
|
|
|
reportInfo.status= (unsigned char)recipeExecuteStatus;
|
|
|
reportInfo.time = sysTime;
|
|
|
reportInfo.command = (unsigned char)command;
|
|
|
+ strcpy(reportInfo.stepName, stepName);
|
|
|
+ strcpy(reportInfo.nextStepName, nextStepName);
|
|
|
static char sendData[sizeof(RecipeReport) + 32];
|
|
|
*(short*)sendData = reportInfo.tagId;
|
|
|
int len = reportInfo.serialize(sendData + 2, sizeof(sendData) - 2);
|
|
|
@@ -1219,7 +1313,7 @@ void RecipeContext::ParseDataWithRawData()
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- if (recipeExecuteStatus == RecipeExecuteStatusEnum::RecipeCompleted || recipeExecuteStatus == RecipeExecuteStatusEnum::Unknown)
|
|
|
+ if (recipeExecuteStatus == RecipeExecuteStatusEnum::Unknown)
|
|
|
{
|
|
|
recipeExecuteStatus = RecipeExecuteStatusEnum::Idle;
|
|
|
}
|
|
|
@@ -1421,8 +1515,8 @@ void RecipeContext::ParseDataWithRawDataOnce(char *buffer,int rawDataLength)
|
|
|
|
|
|
int len = tempCorrectionDic.length;
|
|
|
|
|
|
- sprintf(OP->alarmText, "tempCorrectionDic.length = %d", len);
|
|
|
- ReportAlarm();
|
|
|
+ LOG->Log(tlInfo, "tempCorrectionDic.length = %d", len);
|
|
|
+
|
|
|
}
|
|
|
}else if (tagid == 10)
|
|
|
{
|
|
|
@@ -1471,14 +1565,7 @@ void RecipeContext::ParseDataWithRawDataOnce(char *buffer,int rawDataLength)
|
|
|
}else if (cks->CKey == (int)CommandKey::Abort)
|
|
|
{
|
|
|
recipeExecuteCommand = RecipeExecuteCommandEnum::Abort;
|
|
|
- //TODO:需要迁移到事件处理中
|
|
|
- {
|
|
|
- //TODO:abort应该调用abort recipe...
|
|
|
- recipeExecuteStatus = RecipeExecuteStatusEnum::Error;
|
|
|
- recipeExecuteCommand = RecipeExecuteCommandEnum::Abort;
|
|
|
-
|
|
|
- ClearDicAndLisrData();
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
}else if (cks->CKey == (int)CommandKey::Hold)
|
|
|
{
|
|
|
@@ -1572,7 +1659,7 @@ char* RecipeContext::CovertIntToChar(int key)
|
|
|
|
|
|
void RecipeContext::ClearDicAndLisrData()
|
|
|
{
|
|
|
- AllDataSession.sendData.clear();
|
|
|
+ //AllDataSession.sendData.clear(); 系统会自动不停地发反馈,不需要在这里clear,否则有可能丢数据
|
|
|
AllDataSession.recvData.clear();
|
|
|
mainStepList.clear();
|
|
|
subStepListMap.clear();
|
|
|
@@ -1636,7 +1723,7 @@ bool RecipeContext::checkRecipeCommand() {
|
|
|
}
|
|
|
else {
|
|
|
recipeExecuteStatus = RecipeExecuteStatusEnum::StepCompleted;
|
|
|
- report();
|
|
|
+ //report();
|
|
|
}
|
|
|
|
|
|
return true;
|