//生成卡仓抓卡动作 public ResInfoData GenerateTakeGelFromWare(ResInfoData take_seat, ref Sequence seque, string gelmask = "") { if (take_seat != null) { //卡仓位移动 //抓手移动到卡仓机位 var move_act = Spawn.create( MoveTo.create(Engine.getInstance().gelwareDevice, 3001, take_seat.StoreX, -1, -1), MoveTo.create(Engine.getInstance().handDevice, 3001, take_seat.X, take_seat.Y)); seque.AddAction(move_act); //抓手抓卡 var take_act = HandTakeCard.create(Engine.getInstance().handDevice, 3001, take_seat.Z, take_seat.ZLimit, take_seat.ZCatch, 0); seque.AddAction(take_act); //把测试卡放在卡仓Gel位中 var geltem = take_seat.Values[take_seat.CountX, 0]; take_seat.Values[take_seat.CountX, 0] = null; take_act.successfun = (ActionBase act) => { ResManager.getInstance().handseat_resinfo = (ResInfoData)geltem; return(true); }; take_act.destroyfun = (ActionBase act) => { take_seat.Values[take_seat.CountX, 0] = geltem; return(true); }; } else { ErrorSystem.WriteActError("卡仓无卡", true, false); } return(take_seat); }
public int GetIntBlock(String CanAddress, int timeout, out bool is_timeout) { int ret = 0; if (CanAddress == null) { ErrorSystem.WriteActError("地址为空", true, false); is_timeout = true; return(ret); } String key = CanAddress.ToUpper(); int timecount = 0; timeout = timeout / 10; is_timeout = false; if (key.Length == 0) { return(ret); } while (!RegisterMap.ContainsKey(key)) { Thread.Sleep(1); timecount++; if (timecount > timeout) { last_error = "错误代码:" + CanAddress + " time:" + timeout * 10 + " src:" + GetStacktRace(); ErrorSystem.WriteCanError(last_error); is_timeout = true; return(0); } } ret = RegisterMap[key]; return(ret); }
public static int g_batch_id = 0; //实验批次号 protected override void OnViewLoaded() { foreach (var sample in Samples) { sample.TestItem1 = false; sample.TestItem2 = false; sample.TestItem3 = false; sample.TestItem4 = false; sample.TestItem5 = false; sample.TestItem6 = false; sample.TestItem7 = false; sample.TestItem8 = false; sample.TestItem9 = false; } op.CanComm.SetListenFun(op.OP.SampleRackCoils[0].Addr, CanFunCodeEnum.UPLOAD_REGISTER, RackChange); var scaner_info = ResManager.getInstance().GetScaner("0"); if (scaner_info == null) { ErrorSystem.WriteActError("扫码器无法识别!", false); } if (scaner_info != null) { scaner = IoC.Get <AbstractScaner>(scaner_info.ScanerType); scaner_port = scaner_info.Port; } visible = true; for (int i = 0; i < 24; i++) { template_code_list.Add(new ScanSampleIndexData(i, string.Format("{0:D2}", i + 1), "*", string.Format("{0:D2}", i + 2))); } if (Samples.Count == 0) { for (int i = 0; i < 24; i++) { for (int j = 0; j < 6; j++) { var sample_code = ""; var resinfo = ResManager.getInstance().SearchGelCard("T_BJ_SampleRack", "", "", i, j); resinfo.SetCode(sample_code); resinfo.Values[resinfo.CountX, resinfo.CountY] = resinfo; resinfo.sampleinfo = new SampleInfo(sample_code, (byte)i, (byte)j); Samples.Add(resinfo.sampleinfo); } } } var samples_sort = Samples.ToList(); samples_sort.Sort((a, b) => { return((a.RackIndex * 100 + a.Index) - (b.RackIndex * 100 + b.Index)); }); Samples.Clear(); foreach (var item in samples_sort) { Samples.Add(item); } base.OnViewLoaded(); }
public bool GetBoolBlock(String CanAddress, bool value, int timeout, bool is_check_value, out bool is_timeout) { bool ret = false; String key = CanAddress.ToUpper(); int timecount = 0; timeout = timeout / 10; is_timeout = false; if (key.Length == 0) { return(ret); } while (!CoilMap.ContainsKey(key) || (value != CoilMap[key] && is_check_value)) { Thread.Sleep(5); timecount++; if (timecount > timeout) { last_error = "错误代码:" + CanAddress + " time:" + timeout * 10 + " src:" + GetStacktRace(); ErrorSystem.WriteCanError(last_error); //Console.WriteLine(last_error); is_timeout = true; return(false); } } ret = CoilMap[key]; return(ret); }
//生成放卡在普通位 public bool GeneratePutGelToNormal(T_Gel gel, ref Sequence seque, string code = "", int seatindex = -1) { var resmanager = ResManager.getInstance(); T_BJ_GelSeat gelselect = (T_BJ_GelSeat)resmanager.SearchGelCard(typeof(T_BJ_GelSeat).Name, gel, false, code, seatindex); if (gelselect != null) { //抓手移动 seque.AddAction(MoveTo.create(300000, (int)gelselect.X, (int)(gelselect.Y + gelselect.Gap * seatindex), 0)); //抓手放卡 seque.AddAction(HandPutCard.create(500000, (int)gelselect.ZPut, 0)); //把测试卡放在Gel位中 gelselect.Values[seatindex, 0] = gel; seque.destroyfun = (ActionBase act) => { gelselect.Values[seatindex, 0] = null; return(true); }; } else { ErrorSystem.WriteActError(gelselect.Code + "位已满"); } return(gelselect != null); }
public void ErrorCode(int tagerid, byte[] data) { string[] error_msg = { "电机归零超时", "电机运动超时", "电机运动中停止" }; int error_index = data[7] % 3; int moto_index = handDevice.Hand.ZMotor.GetMotoIndex(); if (error_index == 2 && moto_index == data[5]) { //初始化电机 var task = new Task(() => { stop(); var act_tem = InitXyz.create(handDevice, 30000, false, false, true); act_tem.init(); long lasttime = getSystemMs(); while (true) { long dt = 100; act_tem.run(dt); Thread.Sleep(100); if (act_tem.isfinish) { break; } } start(); }); task.Start(); } if (error_index != 2) { ErrorSystem.WriteActError(error_msg[error_index], true, false); } }
public bool GetRealPump(AbstractCanDevice node_tem, Enterclose[] injects, ref int[] pump) { bool ret = true; if (node_tem is InjectorDevice) { var device = (InjectorDevice)node_tem; foreach (var inject in injects) { ret = ret && device.CanComm.ReadRegister(inject.PumpMotor.RealDistance.Addr); if (inject.PumpMotor.Factor.SetValue <= 0) { ErrorSystem.WriteActError("加样通道:" + inject.Index + "校正因子不可为0", true, false, 9999); return(false); } if (ret) { pump[inject.Index] = (int)device.CanComm.GetInt(inject.PumpMotor.RealDistance.Addr, 0); pump[inject.Index] = Convert.ToInt32(pump[inject.Index] / Convert.ToDecimal(inject.PumpMotor.Factor.SetValue)); } else { break; } } } return(ret); }
//生成离心机抓卡动作 public bool GenerateTakeGelFromCent(T_Gel gel, ref Sequence seque, string code = "", int seatindex = -1) { var resmanager = ResManager.getInstance(); T_BJ_Centrifuge gelselect = (T_BJ_Centrifuge)resmanager.SearchGelCard(typeof(T_BJ_Centrifuge).Name, gel, true, code, seatindex); var centrifuge = cenMrg.GetCentrifugeByCode(code); if (centrifuge == null) { centrifuge = cenMrg.GetFreeCentrifuge(); } if (gelselect != null) { //离心机位移动 //抓手移动到离心机位 var move_act = Spawn.create( MoveTo.create(centrifuge, 30000, -1, -1, (int)(seatindex * (double)gelselect.Gel0), 5), MoveTo.create(handDevice, 30000, (int)gelselect.HandX, (int)gelselect.HandY)); seque.AddAction(move_act); //抓手抓卡 seque.AddAction(HandTakeCard.create(700000, (int)gelselect.HandZ, (int)gelselect.ZLimit, (int)gelselect.ZCatch, 0)); //把测试卡放在离心Gel位中 gelselect.Values[seatindex, 0] = null; seque.destroyfun = (ActionBase act) => { gelselect.Values[seatindex, 0] = gel; return(true); }; } else { ErrorSystem.WriteActError("离心机位打不到卡"); } return(gelselect != null); }
//生成在普通位抓卡 public ResInfoData GenerateTakeGelFromNormal(ResInfoData take_seat, ref Sequence seque) { if (take_seat != null) { //抓手移动 seque.AddAction(MoveTo.create(Engine.getInstance().handDevice, 3001, (int)take_seat.X, (int)(take_seat.Y), 0)); //抓手抓卡 var take_act = HandTakeCard.create(Engine.getInstance().handDevice, 3001, (int)take_seat.Z, (int)take_seat.ZLimit, (int)take_seat.ZCatch, 0); seque.AddAction(take_act); //把测试卡放在Gel位中 var geltem = take_seat.Values[take_seat.CountX, 0]; if (take_seat.Values != null) { take_seat.Values[take_seat.CountX, 0] = null; } take_act.successfun = (ActionBase act) => { ResManager.getInstance().handseat_resinfo = (ResInfoData)geltem; return(true); }; take_act.destroyfun = (ActionBase act) => { take_seat.Values[take_seat.CountX, 0] = geltem; return(true); }; } else { ErrorSystem.WriteActError("普通位找不到卡", true, false); } return(take_seat); }
public void TakeTipAuto() { //生成装帧动作 if (this.SelectedBJ == null) { return; } if (SelectedBJ is T_BJ_Tip tipseat) { var sequ_taketip = Sequence.create(); var tip_seat = resmanager.GetFreeTipActPoint(injectorDevice.GetSeleteced().Length, 2, tipseat.Name); if (tip_seat != null) { int index = 0; var tip_seat_tem = IMask.Gen(new ActionPoint(-1, -1, -1)); foreach (var ent in injectorDevice.GetSeleteced()) { tip_seat_tem[ent.Index] = tip_seat[index]; index++; } var move_act = InjectMoveActs.create(20000, tip_seat_tem, false); //sequ_taketip.AddAction(InjectMoveTo.create(3000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(0))); sequ_taketip.AddAction(move_act); sequ_taketip.runAction(injectorDevice); } else { ErrorSystem.WriteActError("吸盘盒为空!", true, false, 9999); } } }
public override void run(double dt) { bool resultz = true; sumdt += dt; if (sumdt >= time || istimeout) { istimeout = true; isfinish = true; return; } var device = new ActionDevice(node); var hand = (MachineHandDevice)node; switch (step) { case 0: if (hand.CheckGel() == false) { ErrorSystem.WriteActError("抓手无卡!", true); istimeout = true; isfinish = true; return; } else { step++; } break; case 1: act_movez.run(dt); if (act_movez.getIsFinish()) { step++; } break; case 2: resultz = hand.SwitchHand(true); if (resultz) { step++; } break; case 3: act_movezb.run(dt); if (act_movezb.getIsFinish()) { step++; } break; case 4: isfinish = true; break; } }
public static string GetMessageErrorSystem(ErrorSystem system) { switch (system) { case ErrorSystem.Generic: return("Error system"); default: throw new ArgumentOutOfRangeException(nameof(system), system, null); } }
public Asset RetrunAsset(string name, int Id) { Asset SameAsset = AssetsList.Find(x => x.Id == Id && x.name == name); if (SameAsset == null) { ErrorSystem.AddBigError("assetManager.returnAsset. asset not finded"); } return(SameAsset); }
public Asset RetrunAsset(buyableType Btype, int Id) { Asset SameAsset = AssetsList.Find(x => x.Id == Id && x.typeOfbuyAbleObj == Btype); if (SameAsset == null) { ErrorSystem.AddBigError("assetManager.returnAsset. asset not finded"); } return(SameAsset); }
public void Ok() { var resmanager = ResManager.getInstance(); var actiongen = ActionGenerater.getInstance(); var GelList = (this.View as ScanSampleView).GelList; List <T_GelStep> gelstep_list = new List <T_GelStep>(); foreach (var sample in Samples) { var test_list = sample.GetTestList(); var gel_list = new List <ResInfoData>(); foreach (var test in test_list) { var ware_seat = resmanager.GetResByCode(GelList[test].GelMask + "*", "T_BJ_GelWarehouse", "", "", lastinfo_list); if (ware_seat == null) { ErrorSystem.WriteActError("无卡", true, false); return; } ware_seat.sampleinfo = sample; lastinfo_list.Add(ware_seat); gel_list.Add(ware_seat); } foreach (var ware_seat in gel_list) { var gelend = new T_GelStep(); gelstep_list = gelstep_list.Concat(actiongen.ResolveActions(ware_seat)).ToList(); gelend.StepClass = TestStepEnum.GELEND; gelstep_list.Add(gelend); } } //破孔位还有多小个 int paperseat_count = 9; for (int i = 0; i < gelstep_list.Count; i++) { if (gelstep_list[i].StepClass == TestStepEnum.LoadGel && paperseat_count > 0) { gelstep_list[i].StepIndex = 10000 - i; paperseat_count--; } else { gelstep_list[i].StepIndex = 1000 - i; } } gelstep_list.Sort((T_GelStep a, T_GelStep b) => { return(a.StepIndex < b.StepIndex ? 1 : -1); }); var action_tree = actiongen.DivideIntoGroups(gelstep_list, 1); InjLogicManager.getInstance().AddAction(action_tree); this.RequestClose(); }
//生成离心机放卡动作 public bool GeneratePutGelToCent(string cen_code, ResInfoData put_seat, ResInfoData put_gel, ref Sequence seque) { var centrifuge = Engine.getInstance().cenMrg.GetCentrifugeByCode(cen_code); if (centrifuge == null) { centrifuge = Engine.getInstance().cenMrg.GetFreeCentrifuge(); } if (put_seat != null) { //打开离心机门 var opendoor_act = HandOpenCloseDoor.create(Engine.getInstance().handDevice, 5000, cen_code, true); seque.AddAction(opendoor_act); //离心机位移动 //抓手移动到离心机位 var move_act = Spawn.create( MoveTo.create(centrifuge, 30001, -1, -1, put_seat.CenGelP[put_seat.CountX]), MoveTo.create(Engine.getInstance().handDevice, 3001, (int)put_seat.X, (int)put_seat.CenHandYP[put_seat.CountX])); seque.AddAction(move_act); //抓手放卡 var put_act = HandPutCard.create(Engine.getInstance().handDevice, 3001, (int)put_seat.ZPut); seque.AddAction(put_act); //把测试卡放在离心Gel位中 put_seat.Values[put_seat.CountX, 0] = put_gel; if (put_gel != null) { put_gel.PutOk = false; } put_act.successfun = (ActionBase act) => { if (put_gel != null) { put_gel.PutOk = true; put_gel.SetSeatInfo(put_seat); } ResManager.getInstance().handseat_resinfo = null; return(true); }; put_act.destroyfun = (ActionBase act) => { put_seat.Values[put_seat.CountX, 0] = null; ResManager.getInstance().handseat_resinfo = null; return(true); }; } else { ErrorSystem.WriteActError("离心机位已满", true, false); } return(put_seat != null); }
//生成离心机放卡动作 public bool GeneratePutGelToCent(T_Gel gel, ref Sequence seque, string code = "", int seatindex = -1) { int[] gelseatindex = { 0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11 }; var centrifuge = cenMrg.GetCentrifugeByCode(code); if (centrifuge == null) { centrifuge = cenMrg.GetFreeCentrifuge(); } var gelseat = centrifuge.GetGelSeatsInfo(); var gelseatsetting = centrifuge.GetGelSeatSetting(); bool isfind = seatindex != -1; if (seatindex == -1) { for (int i = 0; i < 12; i++) { int index = gelseatindex[i]; if (gelseat[index] == false) { seatindex = index; isfind = true; break; } } } if (isfind) { //离心机位移动 //抓手移动到离心机位 var move_act = Spawn.create( MoveTo.create(centrifuge, 30000, -1, -1, (int)(seatindex * (double)gelseatsetting.Gel0), 5), MoveTo.create(handDevice, 30000, (int)gelseatsetting.HandX, (int)gelseatsetting.HandY)); seque.AddAction(move_act); //抓手放卡 seque.AddAction(HandPutCard.create(handDevice, 30000, (int)gelseatsetting.ZPut)); //把测试卡放在离心Gel位中 gelseatsetting.Values[seatindex, 0] = gel; seque.destroyfun = (ActionBase act) => { gelseatsetting.Values[seatindex, 0] = null; return(true); }; } else { ErrorSystem.WriteActError("离心机位已满"); } return(isfind); }
public void Ok() { var resmanager = ResManager.getInstance(); var actiongen = ActionGenerater.getInstance(); var GelList = (this.View as ScanSampleView).GelList; List <T_GelStep> gelstep_list = new List <T_GelStep>(); bool isRepeat = Samples.Where(item => item.Barcode != "").GroupBy(i => i.Barcode).Any(g => g.Count() > 1); if (isRepeat) { ErrorSystem.WriteActError("样本条码有重复!", true, false); } else { var samples_list = Samples.Where(item => item.Barcode != "").ToList(); foreach (var sample in samples_list) { if (sample.Barcode != "") { var test_list = sample.GetTestList(); var gel_list = new List <T_Gel>(); foreach (var test in test_list) { var gel = GelList[test].clone(); if (gel.IsCrossMatching) { //交叉配血 //寻找当前木样本架连续位 var sample_list = GetCrossMatchingSampleInfo(sample); foreach (var sample_tem in sample_list) { gel = GelList[test].clone(); var exp_package = ExperimentPackage.Create(actiongen.ResolveActions(gel), gel.GelMask, sample.Barcode, sample_tem.Barcode, sample.GetLever(), gel.GelType, gel.GelRenFen, gel.AfterKKTime, gel.IsUsedGel, gel.ID, gel.IsCrossMatching, g_batch_id, is_double); ExperimentLogic.getInstance().AddPackage(exp_package); } } else { var exp_package = ExperimentPackage.Create(actiongen.ResolveActions(gel), gel.GelMask, sample.Barcode, "", sample.GetLever(), gel.GelType, gel.GelRenFen, gel.AfterKKTime, gel.IsUsedGel, gel.ID, gel.IsCrossMatching, g_batch_id, is_double); ExperimentLogic.getInstance().AddPackage(exp_package); } } } } ExperimentLogic.getInstance().UpDataAction(); this.RequestClose(); g_batch_id++; } }
public void ClsCoilMap(String CanAddress) { if (CanAddress == null) { ErrorSystem.WriteActError("后台设置有误!", true, false, 9999); return; } String key = CanAddress.ToUpper(); lock (BoolLock) { if (this.CoilMap.ContainsKey(key)) { CoilMap.Remove(key); } } }
//生成放卡在普通位 public bool GeneratePutGelToNormal(ResInfoData put_seat, ResInfoData put_gel, ref Sequence seque) { if (put_seat != null) { //抓手移动 seque.AddAction(MoveTo.create(Engine.getInstance().handDevice, 3001, (int)put_seat.X, (int)(put_seat.Y), 0)); //抓手放卡 var put_act = HandPutCard.create(Engine.getInstance().handDevice, 3001, (int)put_seat.ZPut, 0); seque.AddAction(put_act); //把测试卡放在Gel位中 if (put_seat.Values != null) { put_seat.Values[put_seat.CountX, 0] = put_gel; } if (put_gel != null) { put_gel.PutOk = false; } put_act.successfun = (ActionBase act) => { if (put_gel != null) { put_gel.PutOk = true; put_gel.SetSeatInfo(put_seat); } ResManager.getInstance().handseat_resinfo = null; return(true); }; put_act.destroyfun = (ActionBase act) => { if (put_seat.Values != null) { put_seat.Values[put_seat.CountX, 0] = null; } ResManager.getInstance().handseat_resinfo = null; return(true); }; } else { ErrorSystem.WriteActError("普通位已满", true, false); } return(put_seat != null); }
/// <summary> /// 初始化所有设备 /// </summary> /// <returns></returns> public ActionBase InitAllDevice() { var devices = new ValueTuple <AbstractCanDevice, String>[] { (this, "样本扫码器载架初始化失败") , (IoC.Get <PiercerDevice>(), "打孔器初始化失败") , (IoC.Get <CentrifugeMrg>(), "离心管理器初始化失败") //,(IoC.Get<GelWarehouseDevice>(),"卡仓初始化失败") , (IoC.Get <CouveuseMixerDevice>(), "孵育或混匀初始化失败") //,(IoC.Get<MachineHandDevice>(),"机械手初始化失败") //,(IoC.Get<InjectorDevice>(),"加样器初始化失败") }; var seq = Sequence.create(); var spa = Spawn.create(); spa.AddAction(InitXyz.create(this, 10000, true, false, false)); foreach (var device in devices) { var act = device.Item1.InitAll(); if (act != null) { spa.AddAction(act); } } var seq_hand_ware_inj = Sequence.create(); var act_inj = IoC.Get <InjectorDevice>().InitAll(); var act_hand = IoC.Get <MachineHandDevice>().InitAll(); var act_ware = IoC.Get <GelWarehouseDevice>().InitAll(); seq_hand_ware_inj.AddAction(act_inj); seq_hand_ware_inj.AddAction(act_hand); seq_hand_ware_inj.AddAction(act_ware); spa.AddAction(seq_hand_ware_inj); seq.AddAction(Sequence.create(spa, SkCallBackFun.create((ActionBase acttem) => { if (acttem.istimeout == false) { ErrorSystem.WriteActError("开机成功!", true, false); } return(true); }))); CameraLight(false); LedGreen(); return(seq); }
//生成离心机抓卡动作 public ResInfoData GenerateTakeGelFromCent(ResInfoData take_seat, string cen_code, ref Sequence seque) { var centrifuge = Engine.getInstance().cenMrg.GetCentrifugeByCode(cen_code); if (centrifuge == null) { centrifuge = Engine.getInstance().cenMrg.GetFreeCentrifuge(); } if (take_seat != null) { //打开离心机门 var opendoor_act = HandOpenCloseDoor.create(Engine.getInstance().handDevice, 5000, cen_code, true); seque.AddAction(opendoor_act); //离心机位移动 //抓手移动到离心机位 var move_act = Spawn.create( MoveTo.create(centrifuge, 30001, -1, -1, (int)take_seat.CenGelP[take_seat.CountX]), MoveTo.create(Engine.getInstance().handDevice, 3001, (int)take_seat.X, (int)take_seat.CenHandYP[take_seat.CountX])); seque.AddAction(move_act); //抓手抓卡 var take_act = HandTakeCard.create(Engine.getInstance().handDevice, 3001, (int)take_seat.Z, (int)take_seat.ZLimit, (int)take_seat.ZCatch, 0, centrifuge); seque.AddAction(take_act); //把测试卡放在离心Gel位中 var geltem = take_seat.Values[take_seat.CountX, 0]; take_seat.Values[take_seat.CountX, 0] = null; take_act.successfun = (ActionBase act) => { ResManager.getInstance().handseat_resinfo = (ResInfoData)geltem; return(true); }; take_act.destroyfun = (ActionBase act) => { take_seat.Values[take_seat.CountX, 0] = geltem; return(true); }; } else { ErrorSystem.WriteActError("离心机位找不到卡", true, false); } return(take_seat); }
public void AddPlayerInfo(PlayerForDataBase newB) { bool isFind = false; foreach (playerData bForD in playersList) { if (bForD.ID == newB.ID && !isFind) { isFind = true; } } if (isFind) { ErrorSystem.AddBigError("playerListManager.AddPlayerInfo. player is in the data base"); } else { playerData newbuilding = ConvertBuildingDataBaseVersionToBuilding(newB); playersList.Add(newbuilding); } }
//生成卡仓放卡动作 public bool GeneratePutGelToWare(ResInfoData put_seat, ResInfoData put_gel, ref Sequence seque) { if (put_seat != null) { var move_act = Spawn.create( MoveTo.create(Engine.getInstance().gelwareDevice, 3001, (int)(put_seat.StoreX), -1, -1), MoveTo.create(Engine.getInstance().handDevice, 3001, (int)put_seat.X, (int)put_seat.Y)); seque.AddAction(move_act); //抓手放卡 var put_act = HandPutCard.create(Engine.getInstance().handDevice, 3001, (int)put_seat.ZPut); seque.AddAction(put_act); //把测试卡放在离心Gel位中 put_seat.Values[put_seat.CountX, 0] = put_gel; if (put_gel != null) { put_gel.PutOk = false; } put_act.successfun = (ActionBase act) => { if (put_gel != null) { put_gel.PutOk = true; put_gel.SetSeatInfo(put_seat); } ResManager.getInstance().handseat_resinfo = null; return(true); }; put_act.destroyfun = (ActionBase act) => { put_seat.Values[put_seat.CountX, 0] = null; ResManager.getInstance().handseat_resinfo = null; return(true); }; } else { ErrorSystem.WriteActError("卡仓位已满", true, false); } return(put_seat != null); }
public void UpdatePlayerInfo(PlayerForDataBase newB) { bool isFind = false; foreach (playerData bForD in playersList) { if (bForD.ID == newB.ID && !isFind) { bForD.addingCoinRate = newB.addingCoinRate; bForD.addingElixirRate = newB.addingElixirRate; bForD.coin = newB.coin; bForD.elixir = newB.elixir; bForD.lastTimeVariableUpdate = newB.lastTimeVariableUpdate; bForD.remaningShialdInSecond = newB.remaningShialdInSecond; isFind = true; } } if (!isFind) { ErrorSystem.AddBigError("playerListManager.UpdatePlayerInfo. player not find"); } }
public void StopAll(int tagerid, byte[] data) { if (data[5] == 0xff) { var task = new Task(() => { stop(); handDevice.CanComm.StopMotor(handDevice.Hand.XMotor); handDevice.CanComm.StopMotor(handDevice.Hand.YMotor); handDevice.CanComm.StopMotor(handDevice.Hand.ZMotor); injectorDevice.CanComm.StopMotor(injectorDevice.Injector.XMotor); foreach (var ent in injectorDevice.Injector.Entercloses) { injectorDevice.CanComm.StopMotor(ent.YMotor); injectorDevice.CanComm.StopMotor(ent.ZMotor); } ActionManager.getInstance().removeAllActions(); ExperimentLogic.getInstance().DelAllPackage(); ErrorSystem.WriteActError("系统急停!请重新开机", true, false, 999999); start(); }); task.Start(); } }
public override void run(double dt) { bool resultz = true; sumdt += dt; if (sumdt >= time || istimeout) { istimeout = true; isfinish = true; return; } var device = new ActionDevice(node); var hand = (MachineHandDevice)node; switch (step) { case 0: if (hand.CheckGel() == true) { ErrorSystem.WriteActError("抓手有卡!", true); istimeout = true; isfinish = true; return; } else { if (hand.CanComm.SetRegister(hand.Hand.ZMotor.Speed.Addr, hand.Hand.ZMotor.Speed.SetValue)) { step++; } } break; case 1: resultz = hand.Hand.IsOpen || (hand.Hand.IsOpen == false && hand.SwitchHand(true)); if (resultz) { step++; } break; case 2: resultz = device.MoveZ((int)z, true); if (resultz) { step++; } break; case 3: if (device.DoneZ()) { step++; } break; case 4: resultz = device.MoveZ((int)zl, false); if (resultz) { step++; } break; case 5: if (sumdt - lasttime > 50) { lasttime = sumdt; if (hand.CheckGel() == true) { resultz = hand.CanComm.SetCoilOff(hand.Hand.ZMotor.StartCoil.Addr); if (resultz) { step++; } } } break; case 6: bool is_timeout = false; hand.CanComm.ReadRegister(hand.Hand.ZMotor.RealDistance.Addr); curz = hand.CanComm.GetIntBlock(hand.Hand.ZMotor.RealDistance.Addr, 1000, out is_timeout) + (int)zc; if (is_timeout) { ErrorSystem.WriteActError("抓手超时", true); istimeout = true; isfinish = true; return; } else { step++; } break; case 7: resultz = device.MoveZ((int)curz, true); if (resultz) { step++; } break; case 8: resultz = hand.SwitchHand(false); if (resultz) { step++; } break; case 9: resultz = device.MoveZ((int)zb, true); if (resultz) { step++; } break; case 10: isfinish = device.DoneZ(); break; } }
public override void run(double dt) { bool resultz = true; sumdt += dt; if (sumdt >= time || istimeout) { istimeout = true; isfinish = true; return; } var device = new ActionDevice(node); var hand = (MachineHandDevice)node; switch (step) { case 0: if (hand.CheckGel() == false) { ErrorSystem.WriteActError("抓手无卡!", true); istimeout = true; isfinish = true; return; } else { if (hand.CanComm.SetRegister(hand.Hand.ZMotor.Speed.Addr, hand.Hand.ZMotor.Speed.SetValue)) { step++; } } break; case 1: resultz = device.MoveZ((int)z); if (resultz) { step++; } break; case 2: if (device.DoneZ()) { step++; } break; case 3: resultz = hand.SwitchHand(true); if (resultz) { step++; } break; case 4: resultz = device.MoveZ((int)zb); if (resultz) { step++; } break; case 5: isfinish = device.DoneZ(); break; } }
unsafe public override void Can_Rec_Tick() { UInt32 res = new UInt32(); res = VCI_GetReceiveNum(DevType, DevIndex, CanIndex); if (res == 0) { return; } ///////////////////////////////////// UInt32 con_maxlen = 100; IntPtr pt = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(VCI_CAN_OBJ)) * (Int32)con_maxlen); res = VCI_Receive(DevType, DevIndex, CanIndex, pt, con_maxlen, 5); //////////////////////////////////////////////////////// String str = ""; for (UInt32 i = 0; i < res; i++) { VCI_CAN_OBJ?reviceObj = null; try { reviceObj = (VCI_CAN_OBJ)Marshal.PtrToStructure((IntPtr)(pt.ToInt64() + i * Marshal.SizeOf(typeof(VCI_CAN_OBJ))), typeof(VCI_CAN_OBJ)); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (!reviceObj.HasValue) { break; } var obj = reviceObj.Value; var targetID = (byte)(obj.ID >> 3); var mask = (byte)(obj.ID & 0b111); Console.Write("rec: 0x{0:x4} ", obj.ID); for (var j = 0; j < obj.DataLen; j++) { Console.Write("0x{0:x2} ", obj.Data[j]); } TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0); Console.WriteLine("TimeStamp:" + Convert.ToInt64(ts.TotalSeconds).ToString()); if (targetID != (byte)(ID & (0xFF << 3 | mask))) { Console.WriteLine("ID不符,数据丢弃"); continue; } //Console.WriteLine("objlen=" + obj.DataLen); str = "接收到数据: "; str += " 设备ID:0x" + Convert.ToString(targetID, 16); str += " ID掩码:0x" + Convert.ToString(mask, 16); str += " 帧格式:"; if (obj.RemoteFlag == 0) { str += "数据帧 "; } else { str += "远程帧 "; } if (obj.ExternFlag == 0) { str += "标准帧 "; } else { str += "扩展帧 "; } ////////////////////////////////////////// if (obj.RemoteFlag == 0) { str += "数据: "; byte len = (byte)(Math.Min(obj.DataLen % 50, 8)); byte[] data = new byte[len]; for (byte j = 0; j < len; j++) { data[j] = obj.Data[j]; str += " " + ByteUtil.ToHex(obj.Data[j]); } //bool is_mask = (data[0] & 0x07) == 0x07; //data[0] = is_mask ? (byte)(data[0] >> 3) : data[0]; (String CanAddress, CanFunCodeEnum FunCode) = ParseCanData(data); if (FunCode == CanFunCodeEnum.UPLOAD_COIL || FunCode == CanFunCodeEnum.UPLOAD_REGISTER || FunCode == CanFunCodeEnum.READ_COIL || FunCode == CanFunCodeEnum.READ_REGISTER || FunCode == CanFunCodeEnum.WRITE_SINGLE_COIL || FunCode == CanFunCodeEnum.WRITE_SINGLE_REGISTER) { lock (RecSafeData.Lock) { bool is_pass = true; if (FunCode == CanFunCodeEnum.WRITE_SINGLE_COIL || FunCode == CanFunCodeEnum.WRITE_SINGLE_REGISTER) { is_pass = data[3] == 0xb0 || data[4] == 0xff || data[5] == 0xff; } if (is_pass == false) { ErrorSystem.WriteActError("通讯返回错误!", false); } if (is_pass) { string key_str = ByteUtil.ToHex(targetID) + ByteUtil.ToHex(data[0]) + ByteUtil.ToHex(data[1]) + ByteUtil.ToHex(data[2]) + ByteUtil.ToHex(data[3]); if (!Rec_SafeData.ContainsKey(key_str)) { Rec_SafeData.Add(key_str, true); } else { Rec_SafeData[key_str] = true; } if (ListenFunList.ContainsKey(key_str)) { var task = Task.Run(() => { ListenFunList[key_str](targetID, data); }); } } } } switch (FunCode) { case CanFunCodeEnum.READ_COIL: { byte length = 1; String canId = CanAddress.Split('-')[0]; UInt16 addr = ByteUtil.BytesToUInt16(data[2], data[3]); for (byte k = 0; k < length; k++) { byte curData = data[k / 8 + 4]; String key = canId + "-" + Convert.ToString(addr + k, 16).PadLeft(4, '0').ToUpper(); //var val = ((0x01 << (k % 8)) & curData) == 0x01; var val = data[4] == 0xff; SetBool(key, val); } break; } case CanFunCodeEnum.UPLOAD_COIL: { byte length = data[4]; String canId = CanAddress.Split('-')[0]; UInt16 addr = ByteUtil.BytesToUInt16(data[2], data[3]); for (byte k = 0; k < length; k++) { byte curData = data[k / 8 + 5]; String key = canId + "-" + Convert.ToString(addr + k, 16).PadLeft(4, '0').ToUpper(); var val = ((0x01 << (k % 8)) & curData) == 0x01; SetBool(key, val); } break; } case CanFunCodeEnum.READ_REGISTER: case CanFunCodeEnum.UPLOAD_REGISTER: { var val = ByteUtil.BytesToInt(data[4], data[5], data[6], data[7]); SetInt(CanAddress, val); break; } case CanFunCodeEnum.WRITE_MULTI_COIL: { break; } case CanFunCodeEnum.WRITE_SINGLE_COIL: { break; } case CanFunCodeEnum.WRITE_SINGLE_REGISTER: { break; } } } //Console.WriteLine(str); } Marshal.FreeHGlobal(pt); }
public unsafe override bool Send(byte targetId, byte[] data, byte mask, bool is_wait) { string sendmsg = ""; bool is_send_ok = false; lock (Send_Lock) { Thread.Sleep(2); VCI_CAN_OBJ sendobj = new VCI_CAN_OBJ(); //sendobj.Init(); string adressstr = string.Format("{0:D2}-{1:x}{2:x}", targetId, data[2], data[3]); ClsCoilMap(adressstr); sendobj.SendType = 0x00; //02 自发自收 //0x00;//正常发送 sendobj.RemoteFlag = 0x00; //数据帧 sendobj.ExternFlag = 0x00; //标准帧 targetId = (byte)((0xFF << 3 | mask) & targetId); var canid = targetId << 3 | (mask & 0b111); sendobj.ID = System.Convert.ToUInt32(canid); int len = data.Length; sendobj.DataLen = System.Convert.ToByte(len); sendmsg = string.Format("send:0x{0:x4} ", canid); for (var j = 0; j < Math.Min(len, 8); j++) { sendobj.Data[j] = data[j]; sendmsg += string.Format("0x{0:x2} ", data[j]); } TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0); sendmsg += "TimeStamp:" + Convert.ToInt64(ts.TotalSeconds).ToString(); //安全重发 (String CanAddress, CanFunCodeEnum FunCode) = ParseCanData(data); string key_str = ByteUtil.ToHex(data[0]) + ByteUtil.ToHex(targetId) + ByteUtil.ToHex(data[1]) + ByteUtil.ToHex(data[2]) + ByteUtil.ToHex(data[3]); lock (RecSafeData.Lock) { if (!Rec_SafeData.ContainsKey(key_str)) { Rec_SafeData.Add(key_str, false); } else { Rec_SafeData[key_str] = false; } } bool is_find = is_wait ? false : true; for (int i = 0; i < 5; i++) { Console.WriteLine(sendmsg); is_send_ok = VCI_Transmit(DevType, DevIndex, CanIndex, ref sendobj, 1) != 0; if (!is_send_ok) { continue; } if (is_wait) { for (int wait_count = 0; wait_count < 200; wait_count++) { lock (RecSafeData.Lock) { if (Rec_SafeData[key_str]) { Rec_SafeData[key_str] = false; is_find = true; break; } } if (is_find) { break; } Thread.Sleep(1); } } if (is_find) { break; } Thread.Sleep(100); } is_send_ok = is_find; } if (is_send_ok == false) { if (ErrorSystem.WriteActError("板号" + targetId + ":通讯错误!\n错误代码:\n" + sendmsg.Replace("send:", ""), true, true, 20) == false) { lock (ActionManager.lockObj) { var action_manager = ActionManager.getInstance(); var experiment_logic = ExperimentLogic.getInstance(); action_manager.removeAllActions(); experiment_logic.DelAllPackage(); } } } return(is_send_ok); }