|
@@ -73,14 +73,8 @@ int RecipeContext::Moniter()
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- }
|
|
|
- if (recipeExecuteStatus == recipeExecuteStatusValue::ExecStep)
|
|
|
- {
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 2.如果当前状态recipeExecuteStatus == TimeWait
|
|
|
if (recipeExecuteStatus == recipeExecuteStatusValue::TimeWait)
|
|
|
{
|
|
@@ -98,7 +92,9 @@ int RecipeContext::Moniter()
|
|
|
else if (status == OperatorStatusEnum::ALARM) {
|
|
|
//TODO:这里发生了ALARM,且alarm condition处理未能挽回
|
|
|
//增加上报上位机信息
|
|
|
-
|
|
|
+ char Alarmid[10];
|
|
|
+ sprintf(Alarmid, "%d", PMCALARMID);
|
|
|
+ ReportAlarm(Alarmid, "alarm condition TimeWait");
|
|
|
}
|
|
|
else {
|
|
|
//TODO:命令执行过程中
|
|
@@ -110,12 +106,6 @@ int RecipeContext::Moniter()
|
|
|
//2.依次执行RecipeChecker列表中每个检查器的check函数
|
|
|
// i.如果有AlarmRecipeChecker被触发,则进行alarm condition相关处理并返回
|
|
|
//
|
|
|
- //string
|
|
|
- //for (size_t i = 0; i < length; i++)
|
|
|
- //{
|
|
|
-
|
|
|
- //}
|
|
|
-
|
|
|
//3.检查如果收到了abort指令(recipeExecuteCommand = Abort)
|
|
|
// i.清除recipeExecuteCommand指令
|
|
|
// ii.如果没有设置abort recipe,设置recipeExecuteStatus = StepCompleted,返回
|
|
@@ -1259,7 +1249,7 @@ void RecipeContext::executeNextStep()
|
|
|
// 3.设置recipeExecuteStatus = ExecStep
|
|
|
recipeExecuteStatus = recipeExecuteStatusValue::ExecStep;
|
|
|
//数据上报,本步开始
|
|
|
-
|
|
|
+ ReportRuningState(RunningStateValue::RunningRecipe);
|
|
|
char jumpRecipeCmd[32];
|
|
|
sprintf(jumpRecipeCmd, "%s.Recipe.Command", MODULE_NAME);
|
|
|
SC->setStringValue(jumpRecipeCmd, "");
|
|
@@ -1273,7 +1263,10 @@ void RecipeContext::executeNextStep()
|
|
|
}
|
|
|
else if (status == OperatorStatusEnum::ALARM) {
|
|
|
//TODO:这里发生了ALARM,且alarm condition处理未能挽回
|
|
|
- ReportAlarm();
|
|
|
+
|
|
|
+ char Alarmid[10];
|
|
|
+ sprintf(Alarmid, "%d", PMCALARMID);
|
|
|
+ ReportAlarm(Alarmid,"alarm condition ExecStep");
|
|
|
}
|
|
|
else {
|
|
|
//TODO:命令执行过程中
|
|
@@ -1345,9 +1338,6 @@ void RecipeContext::executeNextStep()
|
|
|
|
|
|
// 6.如果step.time == 0,设置recipeExecuteStatus == StepCompleted,返回到1步骤进行循环
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
if (steptimes == 0)
|
|
|
{
|
|
|
recipeExecuteStatus = recipeExecuteStatusValue::StepCompleted;
|
|
@@ -1367,6 +1357,7 @@ void RecipeContext::executeNextStep()
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//上报数据给上位机
|
|
|
void RecipeContext::ReoprtStepCompleted()
|
|
|
{
|
|
@@ -1395,11 +1386,49 @@ void RecipeContext::ReoprtStepCompleted()
|
|
|
}
|
|
|
if (currentRecipeType == currentRecipeTypeValue::SubRecipe)
|
|
|
{
|
|
|
+ OnExecuteSubStepFinishNotifyMsgContext ret;
|
|
|
+ ret.mainStepNumber = currentStepNo;
|
|
|
+ ret.currentLoop = mainStepList.get(currentStepNo)->elapsedLoopCount;
|
|
|
+ ret.loopTotal = mainStepList.get(currentStepNo)->loopCount;
|
|
|
+ ret.subStepNumber = currentOtherStepNo;
|
|
|
+
|
|
|
+ static BYTE rawdata[16];
|
|
|
+ int lenData = StructToBytes<OnExecuteSubStepFinishNotifyMsgContext>::ToBytes(ret, rawdata);
|
|
|
+ ConvertLittleEndianToBigEndian_(rawdata, lenData);
|
|
|
+ static BYTE sendata[16 + 2];
|
|
|
+
|
|
|
+ memcpy(sendata + 2, rawdata, lenData);
|
|
|
+
|
|
|
+ int tagid = 54;
|
|
|
+
|
|
|
+ sendata[0] = static_cast<uint8_t>((tagid >> 8) & 0xFF);
|
|
|
+ sendata[1] = static_cast<uint8_t>(tagid & 0xFF);
|
|
|
+
|
|
|
|
|
|
+ AllDataSession.sendData.push((char*)sendata, lenData + 2);
|
|
|
}
|
|
|
if (currentRecipeType == currentRecipeTypeValue::AlarmRecipe)
|
|
|
{
|
|
|
+ OnExecuteAlarmStepFinishNotifyMsgContext ret;
|
|
|
+ ret.alarmTable = currentOtherRecipeKey;
|
|
|
+ char* cork = CovertIntToChar(currentOtherRecipeKey);
|
|
|
+ ret.currentLoop = mainStepList.get(currentStepNo)->elapsedLoopCount;
|
|
|
+ ret.loopTotal = mainStepList.get(currentStepNo)->loopCount;
|
|
|
+ ret.alarmStepNumber = currentOtherStepNo;
|
|
|
+
|
|
|
+ static BYTE rawdata[16];
|
|
|
+ int lenData = StructToBytes<OnExecuteAlarmStepFinishNotifyMsgContext>::ToBytes(ret, rawdata);
|
|
|
+ ConvertLittleEndianToBigEndian_(rawdata, lenData);
|
|
|
+ static BYTE sendata[16 + 2];
|
|
|
|
|
|
+ memcpy(sendata + 2, rawdata, lenData);
|
|
|
+
|
|
|
+ int tagid = 56;
|
|
|
+
|
|
|
+ sendata[0] = static_cast<uint8_t>((tagid >> 8) & 0xFF);
|
|
|
+ sendata[1] = static_cast<uint8_t>(tagid & 0xFF);
|
|
|
+
|
|
|
+ AllDataSession.sendData.push((char*)sendata, lenData + 2);
|
|
|
}
|
|
|
if (currentRecipeType == currentRecipeTypeValue::AbortRecipe)
|
|
|
{
|
|
@@ -1432,36 +1461,135 @@ void RecipeContext::ReportRuningState(RunningStateValue state)
|
|
|
AllDataSession.sendData.push((char*)sendata, lenData + 2);
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+//开始执行时上报
|
|
|
void RecipeContext::ReportStepNotify()
|
|
|
{
|
|
|
- OnExecuteRecipeStepNotifyMsgContext ret;
|
|
|
- ret.currentLoop = mainStepList.get(currentStepNo)->elapsedLoopCount;
|
|
|
- ret.loopTotal = mainStepList.get(currentStepNo)->loopCount;
|
|
|
- ret.stepNumber = currentStepNo;
|
|
|
+ if (currentRecipeType == currentRecipeTypeValue::NormalRecipe)
|
|
|
+ {
|
|
|
+
|
|
|
+ OnExecuteRecipeStepNotifyMsgContext ret;
|
|
|
+ ret.currentLoop = mainStepList.get(currentStepNo)->elapsedLoopCount;
|
|
|
+ ret.loopTotal = mainStepList.get(currentStepNo)->loopCount;
|
|
|
+ ret.stepNumber = currentStepNo;
|
|
|
+
|
|
|
+ static BYTE rawdata[12];
|
|
|
+ int lenData = StructToBytes<OnExecuteRecipeStepNotifyMsgContext>::ToBytes(ret, rawdata);
|
|
|
+ ConvertLittleEndianToBigEndian_(rawdata, lenData);
|
|
|
+ static BYTE sendata[12 + 2];
|
|
|
+
|
|
|
+ memcpy(sendata + 2, rawdata, lenData);
|
|
|
+
|
|
|
+ int tagid = 53;
|
|
|
+
|
|
|
+ sendata[0] = static_cast<uint8_t>((tagid >> 8) & 0xFF);
|
|
|
+ sendata[1] = static_cast<uint8_t>(tagid & 0xFF);
|
|
|
+
|
|
|
+
|
|
|
+ AllDataSession.sendData.push((char*)sendata, lenData + 2);
|
|
|
+ }
|
|
|
+ if (currentRecipeType == currentRecipeTypeValue::SubRecipe)
|
|
|
+ {
|
|
|
+ OnExecuteSubStepNotifyMsgContext ret;
|
|
|
+ ret.mainStepNumber = currentOtherRecipeKey;
|
|
|
+ char* cork = CovertIntToChar(currentOtherRecipeKey);
|
|
|
+ ret.subLoopCurrent = (subStepListMap.get(cork))->get(currentOtherStepNo)->elapsedLoopCount;
|
|
|
+ ret.subLoopTotal = (subStepListMap.get(cork))->get(currentOtherStepNo)->loopCount;
|
|
|
+ ret.currentLoop = mainStepList.get(currentStepNo)->elapsedLoopCount;
|
|
|
+ ret.loopTotal = mainStepList.get(currentStepNo)->loopCount;
|
|
|
+ ret.subStepNumber = currentOtherStepNo;
|
|
|
+
|
|
|
+ static BYTE rawdata[24];
|
|
|
+ int lenData = StructToBytes<OnExecuteSubStepNotifyMsgContext>::ToBytes(ret, rawdata);
|
|
|
+ ConvertLittleEndianToBigEndian_(rawdata, lenData);
|
|
|
+ static BYTE sendata[24 + 2];
|
|
|
+
|
|
|
+ memcpy(sendata + 2, rawdata, lenData);
|
|
|
+
|
|
|
+ int tagid = 55;
|
|
|
+
|
|
|
+ sendata[0] = static_cast<uint8_t>((tagid >> 8) & 0xFF);
|
|
|
+ sendata[1] = static_cast<uint8_t>(tagid & 0xFF);
|
|
|
+
|
|
|
+ AllDataSession.sendData.push((char*)sendata, lenData + 2);
|
|
|
+ }
|
|
|
+ if (currentRecipeType == currentRecipeTypeValue::AlarmRecipe)
|
|
|
+ {
|
|
|
+ OnExecuteAlarmStepNotifyMsgContext ret;
|
|
|
+ ret.alarmTable = currentOtherRecipeKey;
|
|
|
+ char* cork = CovertIntToChar(currentOtherRecipeKey);
|
|
|
+ ret.currentLoop = mainStepList.get(currentStepNo)->elapsedLoopCount;
|
|
|
+ ret.loopTotal = mainStepList.get(currentStepNo)->loopCount;
|
|
|
+ ret.alarmStepNumber = currentOtherStepNo;
|
|
|
+
|
|
|
+ static BYTE rawdata[16];
|
|
|
+ int lenData = StructToBytes<OnExecuteAlarmStepNotifyMsgContext>::ToBytes(ret, rawdata);
|
|
|
+ ConvertLittleEndianToBigEndian_(rawdata, lenData);
|
|
|
+ static BYTE sendata[16 + 2];
|
|
|
+
|
|
|
+ memcpy(sendata + 2, rawdata, lenData);
|
|
|
+
|
|
|
+ int tagid = 57;
|
|
|
+
|
|
|
+ sendata[0] = static_cast<uint8_t>((tagid >> 8) & 0xFF);
|
|
|
+ sendata[1] = static_cast<uint8_t>(tagid & 0xFF);
|
|
|
+
|
|
|
+ AllDataSession.sendData.push((char*)sendata, lenData + 2);
|
|
|
+ }
|
|
|
+ if (currentRecipeType == currentRecipeTypeValue::AbortRecipe)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void RecipeContext::ReportAlarm( char * alarmNUmber, char * mesg)
|
|
|
+{
|
|
|
|
|
|
- static BYTE rawdata[16];
|
|
|
- int lenData = StructToBytes<OnExecuteRecipeStepNotifyMsgContext>::ToBytes(ret, rawdata);
|
|
|
+ OnAlarmNotifyMsgContext ret;
|
|
|
+ strcpy(ret.alarmNumber, alarmNUmber);
|
|
|
+ strcpy(ret.message, mesg);
|
|
|
+
|
|
|
+ static BYTE rawdata[200];
|
|
|
+ int lenData = StructToBytes<OnAlarmNotifyMsgContext>::ToBytes(ret, rawdata);
|
|
|
ConvertLittleEndianToBigEndian_(rawdata, lenData);
|
|
|
- static BYTE sendata[16 + 2];
|
|
|
+ static BYTE sendata[200 + 2];
|
|
|
|
|
|
memcpy(sendata + 2, rawdata, lenData);
|
|
|
|
|
|
- int tagid = 53;
|
|
|
+ int tagid = 58;
|
|
|
|
|
|
sendata[0] = static_cast<uint8_t>((tagid >> 8) & 0xFF);
|
|
|
sendata[1] = static_cast<uint8_t>(tagid & 0xFF);
|
|
|
|
|
|
-
|
|
|
AllDataSession.sendData.push((char*)sendata, lenData + 2);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-void RecipeContext::ReportAlarm()
|
|
|
+/// <summary>
|
|
|
+/// 上位机屏蔽此接收
|
|
|
+/// </summary>
|
|
|
+/// <param name="AbortStepName"></param>
|
|
|
+/// <param name="MainStepName"></param>
|
|
|
+void RecipeContext::ReportAbort(char* AbortStepName, char* MainStepName)
|
|
|
{
|
|
|
|
|
|
-}
|
|
|
+ OnExecuteAbortStepNotifyMsgContext ret;
|
|
|
+ strcpy(ret.abortStepName, AbortStepName);
|
|
|
+ strcpy(ret.mainStepName, MainStepName);
|
|
|
|
|
|
+ static BYTE rawdata[200];
|
|
|
+ int lenData = StructToBytes<OnExecuteAbortStepNotifyMsgContext>::ToBytes(ret, rawdata);
|
|
|
+ ConvertLittleEndianToBigEndian_(rawdata, lenData);
|
|
|
+ static BYTE sendata[200 + 2];
|
|
|
+
|
|
|
+ memcpy(sendata + 2, rawdata, lenData);
|
|
|
+
|
|
|
+ int tagid = 59;
|
|
|
+
|
|
|
+ sendata[0] = static_cast<uint8_t>((tagid >> 8) & 0xFF);
|
|
|
+ sendata[1] = static_cast<uint8_t>(tagid & 0xFF);
|
|
|
+
|
|
|
+ AllDataSession.sendData.push((char*)sendata, lenData + 2);
|
|
|
+}
|
|
|
|
|
|
|
|
|
void RecipeContext::ParseDataWithRawData()
|
|
@@ -1635,7 +1763,6 @@ void RecipeContext::ParseDataWithRawData()
|
|
|
{
|
|
|
|
|
|
recipeExecuteStatus = recipeExecuteStatusValue::Idle;
|
|
|
-
|
|
|
recipeExecuteCommand = recipeExecuteCommandValue::Execute;
|
|
|
baseDataDownloadStatus = baseDataDownloadStatusValue::Done;
|
|
|
recipeDataDownloadStatus = recipeDataDownloadStatusValue::Done;
|