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); } } } } }
public void onGoodLifeCycleFinished(GoodOnConveyor good) { if (onRemoveOldGood != null) { onRemoveOldGood(good); } }
static void handleGoodThreadMain(object po) { object[] pa = (object[])po; int chId = (int)pa[0]; GoodOnConveyor good = (GoodOnConveyor)pa[1]; bool upload = (bool)pa[2]; // parameters deserialization finished taskCount++; try { po = new object[] { chId }; Thread.Sleep(TimeA); chHoldNextGoodThreadMain(po); if (upload) { safeUploadGoodThreadMain(po); } else { throwGoodThreadMain(po); } goodLeaveConveyor(good); Thread.Sleep(TimeA); chResetThreadMain(po); } catch { } taskCount--; }
static void onSenser0TriggerOn(int senserId) { GoodOnConveyor good = new GoodOnConveyor(); Goods.Add(good); artificialIntelligenceInterface.onGoodDetected(good); }
public void onGoodDetected(GoodOnConveyor good) { if (onDetectNewGood != null) { onDetectNewGood(good); } }
public void onRfidScanned(GoodOnConveyor good) { new Thread(onRfidScannedThreadMain).Start(new object[] { good }); if (onDetectRfid != null) { onDetectRfid(good); } }
public void onDetectNewGood(GoodOnConveyor good) { ListViewItem item = new ListViewItem(); item.Text = "---- ---- ---- ---- ---- ----"; item.SubItems.Add("0"); item.Tag = good; _list_view_goods_on_conveyor.Invoke(new AddItemToListViewGoodsOnConveyor(addItemToListViewGoodsOnConveyor), item); }
static bool handleGood(int chId, GoodOnConveyor good, bool upload) { bool result = !upload || UploadCount[chId] == 0 || UploadCount[(chId + 2) % 4] == 0; if (result) { new Thread(handleGoodThreadMain).Start(new object[] { chId, good, upload }); } return(result); }
static void onDetectRfid(string tag) { goodRfidTagIsSpecificTag__specificTag = tag; if (!Goods.Exists(goodRfidTagIsSpecificTag)) { GoodOnConveyor good = Goods.Find(goodRfidTagIsNullAndPositionBetweenRFIDScanRange); if (good != null) { good.rfidTag = tag; artificialIntelligenceInterface.onRfidScanned(good); } } }
static void onMainRollerClockwise(int bitId, bool on) { foreach (GoodOnConveyor x in Goods) { x.position += Config.workingUnit; } GoodOnConveyor good = Goods.Find(goodPositionBiggerThanTime1); if (good != null) { goodLeaveConveyor(good); } }
public void onRfidScannedThreadMain(object po) { object[] pa = (object[])po; GoodOnConveyor goodOnConveyor = (GoodOnConveyor)pa[0]; // parameters deserialization finished string rfidTag = goodOnConveyor.rfidTag; Good good; if (GoodDetails.ContainsKey(rfidTag)) { good = GoodDetails[rfidTag]; } else { Console.WriteLine("Post get goods details : {0}", rfidTag); NameValueCollection parameters = new NameValueCollection(); parameters["rfid"] = goodOnConveyor.rfidTag; string result = Encoding.Default.GetString(new WebClient().UploadValues(urlGetGoodDetails, parameters)); Console.WriteLine("Receive goods details of {0} : {1}", rfidTag, result); if ((bool)JsonMapper.ToObject(result)["success"]) { good = JsonMapper.ToObject <Good>(result); good.rfid_tag = rfidTag; GoodDetails.Add(rfidTag, good); } else { Console.Beep(); //ArtificialIntelligence.stop(); return; } } if (!ArtificialIntelligence.GoodsHandleMethod.ContainsKey(rfidTag)) { HandleMethod handleMethod = new HandleMethod(exitPoint(good), false); ArtificialIntelligence.GoodsHandleMethod.Add(rfidTag, handleMethod); if (onReceiveGoodDetails != null) { onReceiveGoodDetails(good, handleMethod); } } }
private void _timer_update_Tick(object sender, EventArgs e) { _button_start.Enabled = !ArtificialIntelligence.running; _button_stop.Enabled = ArtificialIntelligence.running && !ArtificialIntelligence.stopWhenNoTask; _label_task_value.Text = ArtificialIntelligence.taskCount.ToString(); List <ListViewItem> itemNeedToRemove = new List <ListViewItem>(); _list_view_goods_on_conveyor.BeginUpdate(); foreach (ListViewItem x in _list_view_goods_on_conveyor.Items) { GoodOnConveyor good = (GoodOnConveyor)x.Tag; x.SubItems[0].Text = good.rfidTag != null ? good.rfidTag : "---- ---- ---- ---- ---- ----"; x.SubItems[1].Text = ((GoodOnConveyor)x.Tag).position.ToString(); if (good.left) { itemNeedToRemove.Add(x); } } foreach (ListViewItem x in itemNeedToRemove) { _list_view_goods_on_conveyor.Items.Remove(x); } _list_view_goods_on_conveyor.EndUpdate(); }
static bool goodRfidTagIsSpecificTag(GoodOnConveyor good) { return(good.rfidTag == goodRfidTagIsSpecificTag__specificTag); }
static bool goodRfidTagIsNullAndPositionBetweenRFIDScanRange(GoodOnConveyor good) { return(good.rfidTag == null && good.position >= RFIDScanRangeMinimun && good.position < RFIDScanRangeMaxumun); }
static bool goodPositionBiggerThanTime1(GoodOnConveyor good) { return(good.position > Time1); }
static bool goodPositionBetweenSpecificNumber(GoodOnConveyor good) { return(good.position >= goodPositionBetweenSpecificNumber__minLimit && good.position < goodPositionBetweenSpecificNumber__maxLimit); }
static void goodLeaveConveyor(GoodOnConveyor good) { Goods.Remove(good); good.left = true; artificialIntelligenceInterface.onGoodLifeCycleFinished(good); }