static void safeUploadGoodThreadMain(object po) { object[] pa = (object[])po; int chId = (int)pa[0]; // parameters deserialization finished int crId = chId % 2; lock (Locker[(int)ConveyorPart.Crossover1 + crId]) { if (UploadCount[(chId + 2) % 4] > 0) { if (UploadCount[chId] == 0) { if (chId >= 2) { ConveyorBasicController.crB(crId); ConveyorCleverController.waitForCrossover(crId, ConveyorCrState.Backward, TimeC); } else { ConveyorBasicController.crF(crId); ConveyorCleverController.waitForCrossover(crId, ConveyorCrState.Forward, TimeC); } } else { return; } } ConveyorBasicController.crS(crId); ConveyorCleverController.waitForCrossover(crId, ConveyorCrState.Stop, TimeA); unsafeUploadGoodThreadMain(po); } }
static void onEveryWorkingUnit(int unitTime) { if (stopWhenNoTask && taskCount == 0) { ConveyorBasicController.mrS(0); ConveyorCleverController.cleanDelegate(); RfidCleverController.cleanDelegate(); running = false; } else if (!stopWhenNoTask) { for (int t = 0; t < ChQueue.Length; t++) { goodPositionBetweenSpecificNumber__minLimit = ChTime[t] - TimeD; goodPositionBetweenSpecificNumber__maxLimit = goodPositionBetweenSpecificNumber__minLimit + unitTime; GoodOnConveyor good = Goods.Find(goodPositionBetweenSpecificNumber); if (good != null && good.rfidTag != null && GoodsHandleMethod.ContainsKey(good.rfidTag)) { HandleMethod handleMethod = GoodsHandleMethod[good.rfidTag]; if (handleMethod.exitPoint == t) { handleGood(ChQueue[t], good, handleMethod.upload); } } } } }
private void MainForm_Load(object sender, EventArgs e) { Server.init(this); ConveyorBasicController.init(this); ConveyorCleverController.init(); RfidBasicController.init(); RfidCleverController.init(); _timer_update.Enabled = true; }
static void chResetThreadMain(object po) { object[] pa = (object[])po; int chId = (int)pa[0]; // parameters deserialization finished ConveyorBasicController.stD(chId * 2 + (chId <= 1 ? 1 : 0)); ConveyorBasicController.chD(chId); if (!stopWhenNoTask || taskCount != 0) { ConveyorBasicController.mrC(0); } }
static void chHoldNextGoodThreadMain(object po) { object[] pa = (object[])po; int chId = (int)pa[0]; // parameters deserialization finished int stId = (int)chId * 2 + (chId <= 1 ? 1 : 0); int inputBitIndex = (int)ConveyorInputDevice.Senser5 + chId; ConveyorCleverController.waitForInput(inputBitIndex, false, 1); ConveyorCleverController.waitForInput(inputBitIndex, true, 1); ConveyorBasicController.stU(stId); ConveyorCleverController.waitForMainRoller(ConveyorMRState.Clockwise, TimeB); ConveyorBasicController.mrS(chId); ConveyorBasicController.chU(chId); ConveyorCleverController.waitForChangeover(chId, ConveyorChState.Up, TimeA); }
static void throwGoodThreadMain(object po) { object[] pa = (object[])po; int chId = (int)pa[0]; // parameters deserialization finished int crId = chId % 2; if (chId >= 2) { ConveyorBasicController.chB(chId); ConveyorCleverController.waitForChangeover(chId, ConveyorChState.Up | ConveyorChState.Backward, TimeC); } else { ConveyorBasicController.chF(chId); ConveyorCleverController.waitForChangeover(chId, ConveyorChState.Up | ConveyorChState.Forward, TimeC); } ConveyorBasicController.chS(chId); }
public static void start(ArtificialIntelligenceInterface artificialIntelligenceInterface) { if (ConveyorBasicController.connected && Server.connected && RfidBasicController.connected) { ArtificialIntelligence.artificialIntelligenceInterface = artificialIntelligenceInterface; ConveyorBasicController.resetAll(); Goods.Clear(); GoodsHandleMethod.Clear(); taskCount = 0; stopWhenNoTask = false; for (int t = 0; t < ChQueue.Length; t++) { UploadCount[t] = 0; } for (int t = 0; t < Locker.Length; t++) { Locker[t] = new object(); } ConveyorBasicController.mrC(0); ConveyorCleverController.OnSenserTriggerOn[0] = onSenser0TriggerOn; ConveyorCleverController.onEveryWorkingUnit = onEveryWorkingUnit; ConveyorCleverController.OnOutputOn[(int)ConveyorOutputDevice.MainRollerClockwise] = onMainRollerClockwise; RfidCleverController.onDetectRfid = onDetectRfid; running = true; } else { if (!ConveyorBasicController.connected) { artificialIntelligenceInterface.onStartFailed("Conveyor connect fail"); } if (!Server.connected) { artificialIntelligenceInterface.onStartFailed("Server connect fail"); } if (!RfidBasicController.connected) { artificialIntelligenceInterface.onStartFailed("RFID reader connect fail"); } } }
static void unsafeUploadGoodThreadMain(object po) { object[] pa = (object[])po; int chId = (int)pa[0]; // parameters deserialization finished int crId = chId % 2; UploadCount[chId]++; if (chId >= 2) { ConveyorBasicController.chF(chId); ConveyorBasicController.crF(crId); ConveyorCleverController.waitForCrossover(crId, ConveyorCrState.Forward, TimeC); } else { ConveyorBasicController.chB(chId); ConveyorBasicController.crB(crId); ConveyorCleverController.waitForCrossover(crId, ConveyorCrState.Backward, TimeC); } ConveyorBasicController.chS(chId); ConveyorBasicController.crS(crId); }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { ConveyorBasicController.stop(); }
private void _button_cr_forward_Click(object sender, EventArgs e) { ConveyorBasicController.crF(Convert.ToInt32(new Regex(@"\d+").Match(((Button)sender).Name).ToString()) - 1); }
private void _button_mr_stop_Click(object sender, EventArgs e) { ConveyorBasicController.mrS(1); }
private void _button_mr_anticlockwise_Click(object sender, EventArgs e) { ConveyorBasicController.mrA(1); }