public override ActionBase InitAll() { var seque = Sequence.create(InitXyz.create(this, 10000, true, false, false)); foreach (var ware_seat in ResManager.getInstance().gelwarehouse_list) { seque.AddAction(MoveTo.create(this, 5000, (int)ware_seat.DetectX)); seque.AddAction(SkCallBackFun.create((ActionBase acttem) => { var res = TestGelCard(); if (res != null) { for (int i = 0; i < ware_seat.Count; i++) { ware_seat.Values[i, 0] = null; if (res[i + (int)ware_seat.DoorX]) { var resinfo = new ResInfoData(); ware_seat.Values[i, 0] = resinfo; } } } return(true); })); } seque.AddAction(ScanGelFromWare.create(handDevice, 20000, this)); seque.AddAction(MoveTo.create(this, 5000, 0)); seque.AddAction(InitXyz.create(this, 10000, true, false, false)); return(seque); }
public void StopMixer() { var run_act = Sequence.create(); var mixer_act = ActionManager.getInstance().getAllActions(couveuseMixerDevice); if (mixer_act.Count != 0) { run_act.AddAction(SkCallBackFun.create((ActionBase act_tem) => { if (mixer_act.Count != 0) { mixer_act[0].stop(); } return(true); })); run_act.AddAction(InitXyz.create(10000, false, false, true)); run_act.runAction(couveuseMixerDevice); } }
public void DoTest() { ResManager resmanager = ResManager.getInstance(); var piercer = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "4"); if (piercer != null) { int init_speed = (int)piercerDevice.Pie.ZMotor.InitSpeed.SetValue; for (int i = 0; i < TestCount; i++) { int index = i % 12; var act = Sequence.create(MoveTo.create(30000, -1, index * (int)piercer.PiercerGap + (int)piercer.PiercerY, -1), MoveTo.create(30000, -1, -1, (int)piercer.PiercerZ), SkCallBackFun.create((ActionBase actem) => { piercerDevice.CanComm.SetRegister(piercerDevice.Pie.ZMotor.InitSpeed.Addr, 200); return(true); }), InitXyz.create(3000, false, false, true), SkCallBackFun.create((ActionBase actem) => { piercerDevice.CanComm.SetRegister(piercerDevice.Pie.ZMotor.InitSpeed.Addr, init_speed); return(true); })); act.runAction(piercerDevice); } } }
/// <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); }
/// <summary> /// 探测卡 /// </summary> public void TestGelCard(double index) { if (GelWareList == null || GelWareList.Count == 0 || index >= GelWareList.Count) { return; } GWInfo = ""; var t_gelWare = GelWareList[Convert.ToByte(index)] as T_BJ_GelWarehouse; var seq = Sequence.create( MoveTo.create(5000, (int)t_gelWare.DetectX), SkCallBackFun.create((ActionBase acttem) => { var res = this.gelwareDevice.TestGelCard(); if (res != null) { GWInfo = String.Join(" ", res.Select((item, indexx) => { return(item ? (indexx + 1) + "" : ""); }).ToArray()); } return(true); })); seq.runAction(gelwareDevice); }
public void RackChange(int tagerid, byte [] data) { if (visible == false) { return; } rack_index = GetRackIndex(data[5]); var seq_move = Sequence.create(); if (rack_index >= 0) { var rack_info = ResManager.getInstance().GetSampleRack(rack_index + 1); seq_move.AddAction(MoveTo.create(op, 3000, (int)rack_info.ReaderX)); seq_move.AddAction(SkCallBackFun.create((ActionBase act_tem) => { scaner.CancelAllEvent(); scaner.Open(scaner_port); var res = scaner.Start(false); if (res) { scaner.DataReceived += Scaner_DataReceived; } else { scaner.Close(); } return(true); })); } else { scaner.Stop(); scaner.Close(); seq_move.AddAction(MoveTo.create(op, 3000, 0)); } seq_move.runAction(op); }
//生成加样移动 public void GenerateSampleAddAct(ref Sequence seque, ref int index, ref int[] tager, ref int[] point, ref int[] width, ref bool is_ok) { bool isforward = false; bool isback = false; if (index == 4) { is_ok = true; return; } else { isforward = index - 1 >= 0 ? tager[index] >= point[index - 1] + width[index - 1] : true; isback = index + 1 <= 3 ? tager[index] + width[index] <= point[index + 1] : true; } if (tager[index] < 0) { index++; GenerateSampleAddAct(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } else if (isforward && isback) { //单移 point[index] = tager[index]; int[] y = { -1, -1, -1, -1 }; int[] z = { -1, -1, -1, -1 }; y[index] = point[index] - width[index] * index; z[index] = -1; var move_act = Sequence.create(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, y, z), SKSleep.create(index * 500), MoveTo.create(handDevice, 300000, -1, -1, 100), MoveTo.create(handDevice, 300000, -1, -1, 0)); //查找上一个sp if (seque.actionlist[seque.actionlist.Count() - 1] is Spawn) { var spawn = (Spawn)seque.actionlist[seque.actionlist.Count() - 1]; spawn.AddAction(move_act); } else { var spawn = Spawn.create(); spawn.AddAction(move_act); seque.AddAction(spawn); } index++; GenerateSampleAddAct(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } else if (isforward && isback == false) { //全移 int movew = tager[index] - point[index]; for (int i = index; i < 4; i++) { point[i] = point[i] + movew; } int indexx = index; int y = point[index] - width[index] * index; var move_act = Sequence.create(SkCallBackFun.create((ActionBase act) => { for (int i = 0; i < 4; i++) { injectorDevice.Injector.Entercloses[i].Selected = i >= indexx; } return(true); }), MoveTo.create(injectorDevice, 300000, -1, y, -1)); seque.AddAction(move_act); GenerateSampleAddAct(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } else if (isforward == false && isback) { //等待前面完成 int movew = tager[index] - point[index]; for (int i = 0; i < 4; i++) { point[i] = point[i] + movew; if (point[i] < 0) { is_ok = false; return; } } int y = point[0]; var move_act = Sequence.create(SkCallBackFun.create((ActionBase act) => { for (int i = 0; i < 4; i++) { injectorDevice.Injector.Entercloses[i].Selected = true; } return(true); }), MoveTo.create(injectorDevice, 300000, -1, y, -1)); seque.AddAction(move_act); GenerateSampleAddAct(ref seque, ref index, ref tager, ref point, ref width, ref is_ok); } }
private bool RunLogic(IList <T_LogicStep> steps, out String msg) { msg = null; var seque_root = Sequence.create(); var seque = Sequence.create(); var resmanager = ResManager.getInstance(); var generater = ActionGenerater.getInstance(); int loop_times = 0; foreach (var step in steps) { switch (step.StepEnum) { case LogicStepEnum.Alert: seque.AddAction(SkCallBackFun.create((ActionBase act_tem) => { ErrorSystem.WriteActError(step.Parameters, true, false, 9999); return(true); })); break; case LogicStepEnum.InitAll: var act_init = opDevice.InitAllDevice(); seque.AddAction(act_init); break; case LogicStepEnum.Centrifuge: { CommonAction action = Convert2T <CommonAction>(step.Parameters); var cen = cenMrg.GetCentrifugeByCode(action.Code); if (cen != null) { if (action.DoAction == 0) //正常离心程序 { int hspeed = (int)cen.Centrifugem.HightSpeed.SetValue; int lspeed = (int)cen.Centrifugem.LowSpeed.SetValue; int htime = (int)cen.Centrifugem.HightSpeedTime.SetValue; int ltime = (int)cen.Centrifugem.LowSpeedTime.SetValue; int uphtime = (int)cen.Centrifugem.AddHSpeedTime.SetValue; int upltime = (int)cen.Centrifugem.AddLSpeedTime.SetValue; int stime = (int)cen.Centrifugem.StopSpeedTime.SetValue; var act = CentrifugeStart.create(cen, 3000000, hspeed, lspeed, htime, ltime, uphtime, upltime, stime); seque.AddAction(act); } else if (action.DoAction == 1) //移动指定卡位 { var resinfo = ResManager.getInstance().SearchGelCard("T_BJ_Centrifuge", action.Code, "", (int)action.SeatIndex); var act = MoveTo.create(cen, 30000, -1, -1, resinfo.CenGelP[resinfo.CountX], 5); seque.AddAction(act); } else if (action.DoAction == 2) //开舱门 { var act = HandOpenCloseDoor.create(handDevice, 3000, action.Code, true); seque.AddAction(act); } else if (action.DoAction == 3) //关舱门 { var act = HandOpenCloseDoor.create(handDevice, 3000, action.Code, false); seque.AddAction(act); } else if (action.DoAction == 4) //初始化 { var act = InitXyz.create(cen, 3000, false, false, true); seque.AddAction(act); } } else { ErrorSystem.WriteActError("找不到指定离心机", true, false, 9999); } } break; case LogicStepEnum.Couveuse: { } break; case LogicStepEnum.Delay: { int DelayTime = Convert.ToInt32(step.Parameters); seque.AddAction(SKSleep.create(DelayTime)); } break; case LogicStepEnum.DetectSquid: { DetectAction action = Convert2T <DetectAction>(step.Parameters); List <Enterclose> iinjects = new List <Enterclose>(); foreach (var entindex in action.Indexs) { iinjects.Add(injDevice.Injector.Entercloses[entindex]); } seque.AddAction(InjectDetector.create(3000, iinjects.ToArray(), IMask.Gen((int)action.Start), IMask.Gen((int)action.ZLimit), IMask.Gen(0))); } break; case LogicStepEnum.SimpleAction: { SimpleAction action = Convert2T <SimpleAction>(step.Parameters); AbstractCanDevice device = null; switch (action.Device) { case "加样器": device = injDevice; break; case "机械手": device = handDevice; break; case "卡仓": device = gelwareDevice; break; case "破孔器": device = gelwareDevice; break; } if (action.Action == "移动") { ActionBase act_move = null; int x = action.Direction == "X" ? (int)action.Value : -1; int y = action.Direction == "Y" ? (int)action.Value : -1; int z = action.Direction == "Z"? (int)action.Value:-1; if (action.Direction == "XYZ") { x = y = z = (int)action.Value; } if (device is InjectorDevice) { act_move = InjectMoveTo.create(device, 3000, injDevice.Injector.Entercloses, x, IMask.Gen(y), IMask.Gen(z)); } else { act_move = MoveTo.create(device, 3000, x, y, z); } seque.AddAction(act_move); } else if (action.Action == "初始化") { ActionBase act_move = null; bool x = action.Direction == "X" ? true : false; bool y = action.Direction == "Y" ? true : false; bool z = action.Direction == "Z" ? true : false; if (action.Direction == "XYZ") { x = y = z = true; } if (device is InjectorDevice) { act_move = InitXyz.create(device, 30000, injDevice.Injector.Entercloses, x, y, z); } else { act_move = InitXyz.create(device, 30000, x, y, z); } seque.AddAction(act_move); } } break; case LogicStepEnum.TakeAndPutDownGel: { GelAction[] actions = Convert2T <GelAction[]>(step.Parameters); seque.AddAction(MoveTo.create(handDevice, 3000, -1, -1, 0)); ResInfoData take_seat = null; if (actions[0].BJType == "T_BJ_GelSeat") { take_seat = resmanager.SearchGelCard("T_BJ_GelSeat", "", "", actions[0].Index, 0, true, actions[0].BJName); generater.GenerateTakeGelFromNormal(take_seat, ref seque); } else if (actions[0].BJType == "T_BJ_Centrifuge") { take_seat = resmanager.SearchGelCard("T_BJ_Centrifuge", "", "", actions[0].Index, 0, true, actions[0].BJName); var act = generater.GenerateTakeGelFromCent(take_seat, "", ref seque); } else if (actions[0].BJType == "T_BJ_GelWarehouse") { take_seat = resmanager.SearchGelCard("T_BJ_GelWarehouse", "", "", actions[0].Index, 0, true, actions[0].BJName); var act = generater.GenerateTakeGelFromWare(take_seat, ref seque); } if (actions[1].BJType == "T_BJ_GelSeat") { var put_seat = resmanager.SearchGelCard("T_BJ_GelSeat", "", "", actions[1].Index, 0, true, actions[1].BJName); generater.GeneratePutGelToNormal(put_seat, take_seat, ref seque); } else if (actions[1].BJType == "T_BJ_Centrifuge") { var put_seat = resmanager.SearchGelCard("T_BJ_Centrifuge", "", "", actions[1].Index, 0, true, actions[1].BJName); generater.GeneratePutGelToCent(put_seat.CenCode, put_seat, take_seat, ref seque); } else if (actions[1].BJType == "T_BJ_GelWarehouse") { var put_seat = resmanager.SearchGelCard("T_BJ_GelWarehouse", "", "", actions[1].Index, 0, true, actions[1].BJName); generater.GeneratePutGelToWare(put_seat, take_seat, ref seque); } } break; case LogicStepEnum.TakeGel: { GelAction action = Convert2T <GelAction>(step.Parameters); ResInfoData take_seat = null; if (action.BJType == "T_BJ_GelSeat") { take_seat = resmanager.SearchGelCard("T_BJ_GelSeat", "", "", action.Index, 0, true, action.BJName); generater.GenerateTakeGelFromNormal(take_seat, ref seque); } else if (action.BJType == "T_BJ_Centrifuge") { take_seat = resmanager.SearchGelCard("T_BJ_Centrifuge", "", "", action.Index, 0, true, action.BJName); var act = generater.GenerateTakeGelFromCent(take_seat, "", ref seque); } else if (action.BJType == "T_BJ_GelWarehouse") { take_seat = resmanager.SearchGelCard("T_BJ_GelWarehouse", "", "", action.Index, 0, true, action.BJName); var act = generater.GenerateTakeGelFromWare(take_seat, ref seque); } break; } case LogicStepEnum.PutDownGel: { GelAction action = Convert2T <GelAction>(step.Parameters); ResInfoData take_seat = resmanager.handseat_resinfo; if (action.BJType == "T_BJ_GelSeat") { var put_seat = resmanager.SearchGelCard("T_BJ_GelSeat", "", "", action.Index, 0, true, action.BJName); generater.GeneratePutGelToNormal(put_seat, take_seat, ref seque); } else if (action.BJType == "T_BJ_Centrifuge") { var put_seat = resmanager.SearchGelCard("T_BJ_Centrifuge", "", "", action.Index, 0, true, action.BJName); generater.GeneratePutGelToCent(put_seat.CenCode, put_seat, take_seat, ref seque); } else if (action.BJType == "T_BJ_GelWarehouse") { var put_seat = resmanager.SearchGelCard("T_BJ_GelWarehouse", "", "", action.Index, 0, true, action.BJName); generater.GeneratePutGelToWare(put_seat, take_seat, ref seque); } break; } case LogicStepEnum.TakeTip: { TakeTipAction action = Convert2T <TakeTipAction>(step.Parameters); var ents = injDevice.Injector.Entercloses.Where(ent => ent.Valid && action.Indexs.Contains(ent.Index)).ToArray(); var tipseat = Constants.BJDict[typeof(T_BJ_Tip).Name].Where(item => item.Name == action.TipBoxName).FirstOrDefault() as T_BJ_Tip; List <ActionPoint> tip_seat = new List <ActionPoint>(); foreach (var ent in ents) { int x = (int)(tipseat.X - action.C * tipseat.GapX); int y = (int)(tipseat.Y + action.R * tipseat.GapY); var point = new ActionPoint(); point.x = x; point.y = y; point.z = (int)tipseat.Limit; point.type = TestStepEnum.JXZT; point.index = ent.Index; tip_seat.Add(point); } var sequ_taketip = Sequence.create(); var move_act = InjectMoveActs.create(injDevice, 3000, tip_seat.ToArray(), false); sequ_taketip.AddAction(InjectMoveTo.create(injDevice, 3000, ents, -1, IMask.Gen(-1), IMask.Gen(0))); sequ_taketip.AddAction(move_act); seque.AddAction(sequ_taketip); } break; case LogicStepEnum.OutTip: { TakeTipAction action = Convert2T <TakeTipAction>(step.Parameters); var ents = injDevice.Injector.Entercloses.Where(ent => ent.Valid && action.Indexs.Contains(ent.Index)).ToArray(); var sequ_puttip = Sequence.create(); List <ActionPoint> unload_seat = new List <ActionPoint>(); var inject_unload = resmanager.unload_list; if (inject_unload.Count() == 1) { var unloader = inject_unload[0]; for (int i = 0; i < 4; i++) { var unload_point = new ActionPoint((int)unloader.X, (int)unloader.Y + i * (int)unloader.FZ, (int)unloader.Z, TestStepEnum.JXZT); unload_point.puttip_x = (int)unloader.FirstX; unload_seat.Add(unload_point); } sequ_puttip.AddAction(InjectMoveTo.create(injDevice, 3000, ents, -1, IMask.Gen(-1), IMask.Gen(0))); sequ_puttip.AddAction(InjectMoveActs.create(injDevice, 3000, unload_seat.ToArray(), true)); seque.AddAction(sequ_puttip); } } break; case LogicStepEnum.Piercer: { var paper_seat = resmanager.GetResByCode("", "T_BJ_GelSeat", "", "4"); seque.AddAction(PaperCard.create(pieDevice, 3000, paper_seat, 0)); } break; case LogicStepEnum.LoopStart: { LogicLoop logicLoop = Convert2T <LogicLoop>(step.Parameters); loop_times = logicLoop.Count; seque_root.AddAction(seque); seque = Sequence.create(); } break; case LogicStepEnum.LoopEnd: { var act_repat = Repeat.create(seque, loop_times); seque_root.AddAction(act_repat); seque = Sequence.create(); loop_times = 0; } break; } } seque_root.AddAction(seque); seque_root.runAction(opDevice); return(true); }