|
|
@@ -0,0 +1,187 @@
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @author seagle
|
|
|
+ * @date 2025-8-19
|
|
|
+ * @Description
|
|
|
+ * 按PMC框架重写的SetCommand
|
|
|
+ */
|
|
|
+
|
|
|
+#include"SetCommand.h"
|
|
|
+#include"SC.h"
|
|
|
+#include"string.h"
|
|
|
+#include"pmc_types.h"
|
|
|
+#include "DEVICE.h"
|
|
|
+#include "errcode.h"
|
|
|
+#include "EV.h"
|
|
|
+#include"IoSensor.h"
|
|
|
+#include"RecipeContext.h"
|
|
|
+#include"FurnaceSignalTower.h"
|
|
|
+#include"debug.h"
|
|
|
+SetCommandModule* setCommandModule;
|
|
|
+
|
|
|
+void SetCommandModule::initialize()
|
|
|
+{
|
|
|
+ char cmd[MAX_NAME_LEN];
|
|
|
+#pragma region SetCommand.Hold
|
|
|
+ sprintf(cmd, "SetCommand.Hold");
|
|
|
+ auto opNode = OP->subscribe(cmd);
|
|
|
+ opNode->addExec([]()->OperatorStatusEnum {
|
|
|
+ RecipeContext* context = RecipeContext::GetInstance();
|
|
|
+ if (context != NULL) {
|
|
|
+ context->pause();
|
|
|
+ }
|
|
|
+ return OperatorStatusEnum::SUCCESS;
|
|
|
+ });
|
|
|
+#pragma region SetCommand.Hold+Buzzer
|
|
|
+ sprintf(cmd, "SetCommand.Hold + Buzzer");
|
|
|
+ opNode = OP->subscribe(cmd);
|
|
|
+ opNode->addExec([]()->OperatorStatusEnum {
|
|
|
+ RecipeContext* context = RecipeContext::GetInstance();
|
|
|
+ if (context != NULL) {
|
|
|
+ context->pause();
|
|
|
+ context->buzzerOn();
|
|
|
+ }
|
|
|
+ return OperatorStatusEnum::SUCCESS;
|
|
|
+ });
|
|
|
+#pragma region SetCommand.Buzzer
|
|
|
+ sprintf(cmd, "SetCommand.Buzzer");
|
|
|
+ opNode = OP->subscribe(cmd);
|
|
|
+ opNode->addExec([]()->OperatorStatusEnum {
|
|
|
+ RecipeContext* context = RecipeContext::GetInstance();
|
|
|
+ if (context != NULL) {
|
|
|
+ context->buzzerOn();
|
|
|
+ }
|
|
|
+ return OperatorStatusEnum::SUCCESS;
|
|
|
+ });
|
|
|
+#pragma region SetCommand.Leak Check1/2/3
|
|
|
+ for (int leakIndex = 1; leakIndex <= 3; leakIndex++) {
|
|
|
+ sprintf(cmd, "SetCommand.Leak Check%d", leakIndex);
|
|
|
+ opNode = OP->subscribe(cmd,this);
|
|
|
+ opNode->addExec([]()->OperatorStatusEnum {
|
|
|
+ auto* op = OP->currentRoot;
|
|
|
+ SetCommandModule* device = (SetCommandModule*)op->device;
|
|
|
+ device->leakCheckIndex = op->name[strlen(op->name) - 1] - '0';
|
|
|
+ device->leakCheckTable = NULL;
|
|
|
+ device->beginPressure = 0;
|
|
|
+ device->sensor = NULL;
|
|
|
+ RecipeContext* context = RecipeContext::GetInstance();
|
|
|
+ if (context != NULL) {
|
|
|
+ char sIndex[5];
|
|
|
+ sprintf(sIndex,"%d",device->leakCheckIndex);
|
|
|
+ auto dicNode = context->leakCheckDic.get(sIndex);
|
|
|
+ if (dicNode != NULL) {
|
|
|
+ device->leakCheckTable = dicNode->getByIndex(0);
|
|
|
+ device->sensor=(IoPressureMeter *)DEVICE->getDevice(MODULE_NAME,device->leakCheckTable->DeviceName);
|
|
|
+ if (device->sensor == NULL) {
|
|
|
+ device->sensor = IoPressureMeter::poVG13;
|
|
|
+ }
|
|
|
+ device->beginPressure = device->sensor->aiFeedback.getDoubleValue();
|
|
|
+ if (device->beginPressure > device->leakCheckTable->HighLimit && GT_ZERO(device->leakCheckTable->HighLimit)) {
|
|
|
+ //基准压力超过PH
|
|
|
+ strcpy(OP->alarmText,EV->parseErrCode(ALARM_LEAK_PH,"PH=%f;BP=%f;", device->leakCheckTable->HighLimit, device->beginPressure));
|
|
|
+
|
|
|
+ AlarmCondition ac;
|
|
|
+ ac.alarmCommandEnum = device->leakCheckTable->HightLimitCommandEnum;
|
|
|
+ ac.alarmCallRecipeIndex = device->leakCheckTable->HightCallRecipeIndex;
|
|
|
+ //ac.alarmJumpStepName = "TODO:None";
|
|
|
+ ac.alarmJumpStepNo = device->leakCheckTable->HightLimitJumpStepNo;
|
|
|
+ return device->doAlarmConditionAlarm(&ac);
|
|
|
+ }
|
|
|
+ else if (device->beginPressure > device->leakCheckTable->LowLimit && GT_ZERO(device->leakCheckTable->LowLimit)) {
|
|
|
+ //基准压力超过PL
|
|
|
+ strcpy(OP->alarmText, EV->parseErrCode(ALARM_LEAK_PL, "PL=%f;BP=%f;", device->leakCheckTable->LowLimit, device->beginPressure));
|
|
|
+
|
|
|
+ AlarmCondition ac;
|
|
|
+ ac.alarmCommandEnum = device->leakCheckTable->LowLimitCommandEnum;
|
|
|
+ ac.alarmCallRecipeIndex = device->leakCheckTable->LowCallRecipeIndex;
|
|
|
+ //ac.alarmJumpStepName =TODO None
|
|
|
+ ac.alarmJumpStepNo = device->leakCheckTable->LowLimitJumpStepNo;
|
|
|
+ return device->doAlarmConditionAlarm(&ac);
|
|
|
+ }
|
|
|
+ else if (device->beginPressure < device->leakCheckTable->BasePressureLimit && GT_ZERO(device->leakCheckTable->BasePressureLimit)) {
|
|
|
+ //基准压力小于BPLIMIT
|
|
|
+ strcpy(OP->alarmText, EV->parseErrCode(ALARM_LEAK_BPLIMIT, "BP=%f;BPLIMIT=%s", device->beginPressure, device->leakCheckTable->BasePressureLimit));
|
|
|
+
|
|
|
+ AlarmCondition ac;
|
|
|
+ ac.alarmCommandEnum = device->leakCheckTable->BasePressureLimitCommandEnum;
|
|
|
+ ac.alarmCallRecipeIndex = device->leakCheckTable->BaseCallRecipeIndex;
|
|
|
+ //ac.alarmJumpStepName = TODO None
|
|
|
+ ac.alarmJumpStepNo = device->leakCheckTable->BasePressureLimitJumpStepNo;
|
|
|
+ return device->doAlarmConditionAlarm(&ac);
|
|
|
+ }
|
|
|
+ op->setTimes(device->leakCheckTable->DelayTime, 0, 0, device->leakCheckTable->CheckTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //tryTimes在初始化部分不清除,而是在reset清除
|
|
|
+ return OperatorStatusEnum::SUCCESS;
|
|
|
+ });
|
|
|
+ opNode->addReset([]()->OperatorStatusEnum {
|
|
|
+ auto* op = OP->currentRoot;
|
|
|
+ SetCommandModule* device = (SetCommandModule*)op->device;
|
|
|
+ device->tryTimes = 0;
|
|
|
+ return OperatorStatusEnum::SUCCESS;
|
|
|
+ });
|
|
|
+ opNode->addCheck([]()->OperatorStatusEnum {
|
|
|
+ auto* op = OP->currentRoot;
|
|
|
+ SetCommandModule* device = (SetCommandModule*)op->device;
|
|
|
+ RecipeContext* context = RecipeContext::GetInstance();
|
|
|
+ if (op->isTimeout.value) {
|
|
|
+ double currentPressure = device->sensor->aiFeedback.getDoubleValue();
|
|
|
+ if (currentPressure - device->beginPressure > device->leakCheckTable->LeakLimit) {
|
|
|
+ device->tryTimes++;
|
|
|
+ if (device->tryTimes < device->leakCheckTable->RetryLimit) {
|
|
|
+ strcpy(OP->alarmText, EV->parseErrCode(WARNING_LEAK, "leak=%f;limit=%f", currentPressure - device->beginPressure, device->leakCheckTable->LeakLimit));
|
|
|
+ if (context != NULL) {
|
|
|
+
|
|
|
+ char sPreStepName[64];
|
|
|
+ sPreStepName[0] = 0;
|
|
|
+ char scName[64];
|
|
|
+ sprintf(scName, "%s.Recipe.Command", MODULE_NAME);
|
|
|
+ if (context->currentRecipeType == RecipeTypeEnum::NormalRecipe) {
|
|
|
+ int preStepNo = context->currentStepNo - 1;
|
|
|
+ if (preStepNo >= 0) {
|
|
|
+ sprintf(sPreStepName, "Jump:%s", context->mainStepList.get(preStepNo)->name);
|
|
|
+ SC->setStringValue(scName, sPreStepName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (context->currentRecipeType == RecipeTypeEnum::SubRecipe) {
|
|
|
+ int preStepNo = context->currentOtherStepNo-1;
|
|
|
+ if (preStepNo >= 0) {
|
|
|
+ char subKey[10];
|
|
|
+ sprintf(subKey,"%d",context->currentOtherRecipeKey);
|
|
|
+ auto subStepList = context->subStepListMap.get(subKey);
|
|
|
+ if (subStepList != NULL) {
|
|
|
+ sprintf(sPreStepName, "Jump:%s", subStepList->get(preStepNo)->name);
|
|
|
+ SC->setStringValue(scName, sPreStepName);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //超过限制次数
|
|
|
+ device->tryTimes = 0;
|
|
|
+ strcpy(OP->alarmText, EV->parseErrCode(ALARM_LEAK, "times=%d", device->tryTimes));
|
|
|
+
|
|
|
+
|
|
|
+ AlarmCondition ac;
|
|
|
+ ac.alarmCommandEnum = device->leakCheckTable->ErrorCommandEnum;
|
|
|
+ ac.alarmCallRecipeIndex = device->leakCheckTable->ErrorCallRecipeIndex;
|
|
|
+ //ac.alarmJumpStepName = TODO None
|
|
|
+ ac.alarmJumpStepNo = device->leakCheckTable->ErrorJumpStepNo;
|
|
|
+ return device->doAlarmConditionAlarm(&ac);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return OperatorStatusEnum::SUCCESS; //返回成功为了能顺利跳回上一步
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return OperatorStatusEnum::RUNNING;
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|