|
|
@ -4,13 +4,15 @@ import a8k.app.hardware.driver.CodeScanerDriver; |
|
|
|
import a8k.app.service.param.hbotpos.Hbot2DCodeScanParamMgr; |
|
|
|
import a8k.teststate.VirtualDevice; |
|
|
|
import a8k.app.a8ktype.type.ConsumableOneChRawResult; |
|
|
|
import a8k.app.a8ktype.type.ConsumableScanRawResult; |
|
|
|
import a8k.app.a8ktype.device.Pos2d; |
|
|
|
import a8k.app.a8ktype.exception.AppException; |
|
|
|
import a8k.utils.DoAction; |
|
|
|
import jakarta.annotation.Resource; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
@Component |
|
|
|
public class ConsumablesScanCtrlService { |
|
|
@ -28,65 +30,76 @@ public class ConsumablesScanCtrlService { |
|
|
|
// VIRTUAL |
|
|
|
// |
|
|
|
|
|
|
|
ConsumableScanRawResult virtualConsumablesScanRawResult = new ConsumableScanRawResult(); |
|
|
|
|
|
|
|
synchronized public void setVirtualConsumablesScanResult(Integer ch, ConsumableOneChRawResult result) { |
|
|
|
virtualConsumablesScanRawResult.ch[ch] = result; |
|
|
|
String[] virtualPbscanResult = new String[6]; |
|
|
|
String[] virtualLittBSScanResult = new String[6]; |
|
|
|
String[] virtualLarBSScanResult = new String[6]; |
|
|
|
|
|
|
|
synchronized public void setVirtualConsumablesScanResult(Integer ch, String PBScanResult, String littBSScanResult, String larBSScanResult) { |
|
|
|
virtualPbscanResult[ch] = PBScanResult; |
|
|
|
virtualLittBSScanResult[ch] = littBSScanResult; |
|
|
|
virtualLarBSScanResult[ch] = larBSScanResult; |
|
|
|
} |
|
|
|
|
|
|
|
// |
|
|
|
// PUBLIC |
|
|
|
// |
|
|
|
public ConsumableScanRawResult doScanConsumablesAction(List<Integer> channels) throws AppException { |
|
|
|
if (virtualDevice.isEnable()) { |
|
|
|
return virtualConsumablesScanRawResult; |
|
|
|
} |
|
|
|
public List<ConsumableOneChRawResult> doScanConsumablesAction(List<Integer> channels) throws AppException { |
|
|
|
List<ConsumableOneChRawResult> result = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
ConsumableScanRawResult result = new ConsumableScanRawResult(); |
|
|
|
String[] pbscanResult = new String[6]; |
|
|
|
String[] littBSScanResult = new String[6]; |
|
|
|
String[] larBSScanResult = new String[6]; |
|
|
|
for (int i = 0; i < 6; i++) { |
|
|
|
if (!channels.contains(i)) |
|
|
|
continue; |
|
|
|
result.ch[i].PBScanResult = scanPB(i); |
|
|
|
pbscanResult[i] = virtualDevice.isEnable() ? virtualPbscanResult[i] : scanPB(i); |
|
|
|
} |
|
|
|
for (int i = 0; i < 6; i++) { |
|
|
|
if (!channels.contains(i)) |
|
|
|
continue; |
|
|
|
result.ch[i].littBSScanResult = scanLittBS(i); |
|
|
|
littBSScanResult[i] = virtualDevice.isEnable() ? virtualLittBSScanResult[i] : scanLittBS(i); |
|
|
|
} |
|
|
|
for (int i = 0; i < 6; i++) { |
|
|
|
if (!channels.contains(i)) |
|
|
|
continue; |
|
|
|
result.ch[i].larBSScanResult = scanLarBS(i); |
|
|
|
larBSScanResult[i] = virtualDevice.isEnable() ? virtualLarBSScanResult[i] : scanLarBS(i); |
|
|
|
} |
|
|
|
hbotMoveTo(new Pos2d(0, 0)); |
|
|
|
/* |
|
|
|
* 清空 result 中的所有\r |
|
|
|
*/ |
|
|
|
|
|
|
|
DoAction.doIt("扫描耗材", () -> hbotMoveTo(new Pos2d(0, 0))); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 6; i++) { |
|
|
|
if (result.ch[i].PBScanResult != null) { |
|
|
|
result.ch[i].PBScanResult = result.ch[i].PBScanResult.replaceAll("\r", ""); |
|
|
|
} |
|
|
|
if (result.ch[i].littBSScanResult != null) { |
|
|
|
result.ch[i].littBSScanResult = result.ch[i].littBSScanResult.replaceAll("\r", ""); |
|
|
|
} |
|
|
|
if (result.ch[i].larBSScanResult != null) { |
|
|
|
result.ch[i].larBSScanResult = result.ch[i].larBSScanResult.replaceAll("\r", ""); |
|
|
|
} |
|
|
|
if (!channels.contains(i)) |
|
|
|
continue; |
|
|
|
ConsumableOneChRawResult oneChResult = new ConsumableOneChRawResult(i); |
|
|
|
if (pbscanResult[i] != null) |
|
|
|
oneChResult.PBScanResult = pbscanResult[i].replaceAll("\r", ""); |
|
|
|
if (littBSScanResult[i] != null) |
|
|
|
oneChResult.littBSScanResult = littBSScanResult[i].replaceAll("\r", ""); |
|
|
|
if (larBSScanResult[i] != null) |
|
|
|
oneChResult.larBSScanResult = larBSScanResult[i].replaceAll("\r", ""); |
|
|
|
result.add(oneChResult); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
public ConsumableOneChRawResult doScanOneCh(Integer ch) throws AppException { |
|
|
|
if (virtualDevice.isEnable()) { |
|
|
|
return virtualConsumablesScanRawResult.ch[ch]; |
|
|
|
} |
|
|
|
|
|
|
|
ConsumableOneChRawResult result = new ConsumableOneChRawResult(ch); |
|
|
|
result.PBScanResult = scanPB(ch); |
|
|
|
result.littBSScanResult = scanLittBS(ch); |
|
|
|
result.larBSScanResult = scanLarBS(ch); |
|
|
|
return result; |
|
|
|
} |
|
|
|
// public ConsumableOneChRawResult doScanOneCh(Integer ch) throws AppException { |
|
|
|
// if (virtualDevice.isEnable()) { |
|
|
|
// for (ConsumableOneChRawResult result : virtualConsumablesScanResult) { |
|
|
|
// if (Objects.equals(result.chNum, ch)) |
|
|
|
// return result; |
|
|
|
// } |
|
|
|
// return new ConsumableOneChRawResult(ch); |
|
|
|
// } |
|
|
|
// |
|
|
|
// ConsumableOneChRawResult result = new ConsumableOneChRawResult(ch); |
|
|
|
// result.PBScanResult = scanPB(ch); |
|
|
|
// result.littBSScanResult = scanLittBS(ch); |
|
|
|
// result.larBSScanResult = scanLarBS(ch); |
|
|
|
// return result; |
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|