feat(production): 修改删除订单问题
This commit is contained in:
+46
-68
@@ -582,91 +582,69 @@ void DeviceService::beginProductionAction(
|
||||
}
|
||||
|
||||
m_productionActionBusy = true;
|
||||
inspectProductionAction(
|
||||
action,
|
||||
[this, action, trayNo, slotNo, addresses, callback, beforeSend](
|
||||
bool success, const ProductionActionStatus &status,
|
||||
const QString &error) {
|
||||
if (!success) {
|
||||
m_productionActionBusy = false;
|
||||
if (callback) {
|
||||
callback(VisionWriteOutcome::NotSent, error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (status.command || status.feedback) {
|
||||
m_productionActionBusy = false;
|
||||
if (callback) {
|
||||
callback(VisionWriteOutcome::NotSent,
|
||||
"PLC command or feedback is still active before a new action");
|
||||
}
|
||||
return;
|
||||
auto sendCommand =
|
||||
[this, callback](VisionWriteOutcome outcome, const QString &error) {
|
||||
// An unacknowledged command may already be running. Do not
|
||||
// permit another action until it has been reconciled.
|
||||
m_productionActionActive = outcome != VisionWriteOutcome::NotSent;
|
||||
m_productionActionBusy = false;
|
||||
if (callback) {
|
||||
callback(outcome, error);
|
||||
}
|
||||
};
|
||||
|
||||
auto sendCommand =
|
||||
[this, callback](VisionWriteOutcome outcome, const QString &error) {
|
||||
// An unacknowledged command may already be running. Do not
|
||||
// permit another action until it has been reconciled.
|
||||
m_productionActionActive = outcome != VisionWriteOutcome::NotSent;
|
||||
m_productionActionBusy = false;
|
||||
if (callback) {
|
||||
callback(outcome, error);
|
||||
}
|
||||
};
|
||||
auto writeCommand = [this, sendCommand, beforeSend](bool success,
|
||||
const QString &error) {
|
||||
if (!success) {
|
||||
sendCommand(VisionWriteOutcome::NotSent, error);
|
||||
return;
|
||||
}
|
||||
// Action commands must never use the legacy automatic retry
|
||||
// path, even when no persistence hook is supplied.
|
||||
m_modbus->writeVisionCoil(m_productionCommandAddress, true,
|
||||
sendCommand, beforeSend);
|
||||
};
|
||||
|
||||
auto writeCommand = [this, sendCommand, beforeSend](bool success,
|
||||
const QString &error) {
|
||||
if (!success) {
|
||||
sendCommand(VisionWriteOutcome::NotSent, error);
|
||||
if (action == PhotoMoveAction || action == RackPick
|
||||
|| action == RackPlace) {
|
||||
m_modbus->writeHoldingRegister(
|
||||
addresses.trayNumber,
|
||||
static_cast<quint16>(trayNo),
|
||||
[this, addresses, slotNo, writeCommand](
|
||||
bool traySuccess, const QString &trayError) {
|
||||
if (!traySuccess) {
|
||||
writeCommand(false, trayError);
|
||||
return;
|
||||
}
|
||||
// Action commands must never use the legacy automatic retry
|
||||
// path, even when no persistence hook is supplied.
|
||||
m_modbus->writeVisionCoil(m_productionCommandAddress, true,
|
||||
sendCommand, beforeSend);
|
||||
};
|
||||
|
||||
if (action == PhotoMoveAction || action == RackPick
|
||||
|| action == RackPlace) {
|
||||
m_modbus->writeHoldingRegister(
|
||||
addresses.trayNumber,
|
||||
static_cast<quint16>(trayNo),
|
||||
addresses.slotNumber,
|
||||
static_cast<quint16>(slotNo),
|
||||
[this, addresses, slotNo, writeCommand](
|
||||
bool traySuccess, const QString &trayError) {
|
||||
if (!traySuccess) {
|
||||
writeCommand(false, trayError);
|
||||
bool slotSuccess, const QString &slotError) {
|
||||
if (!slotSuccess) {
|
||||
writeCommand(false, slotError);
|
||||
return;
|
||||
}
|
||||
m_modbus->writeHoldingRegister(
|
||||
addresses.slotNumber,
|
||||
static_cast<quint16>(slotNo),
|
||||
addresses.slotRowNumber,
|
||||
static_cast<quint16>((slotNo - 1) / 7 + 1),
|
||||
[this, addresses, slotNo, writeCommand](
|
||||
bool slotSuccess, const QString &slotError) {
|
||||
if (!slotSuccess) {
|
||||
writeCommand(false, slotError);
|
||||
bool rowSuccess, const QString &rowError) {
|
||||
if (!rowSuccess) {
|
||||
writeCommand(false, rowError);
|
||||
return;
|
||||
}
|
||||
m_modbus->writeHoldingRegister(
|
||||
addresses.slotRowNumber,
|
||||
static_cast<quint16>((slotNo - 1) / 7 + 1),
|
||||
[this, addresses, slotNo, writeCommand](
|
||||
bool rowSuccess, const QString &rowError) {
|
||||
if (!rowSuccess) {
|
||||
writeCommand(false, rowError);
|
||||
return;
|
||||
}
|
||||
m_modbus->writeHoldingRegister(
|
||||
addresses.slotColumNumber,
|
||||
static_cast<quint16>((slotNo - 1) % 7 + 1),
|
||||
writeCommand);
|
||||
});
|
||||
addresses.slotColumNumber,
|
||||
static_cast<quint16>((slotNo - 1) % 7 + 1),
|
||||
writeCommand);
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
writeCommand(true, QString());
|
||||
});
|
||||
writeCommand(true, QString());
|
||||
}
|
||||
|
||||
void DeviceService::inspectProductionAction(
|
||||
|
||||
Reference in New Issue
Block a user