/// <summary> /// 关舱门 /// </summary> public void CloseDoor() { if (SelectedItem == null) { return; } var act = HandOpenCloseDoor.create(handDevice, 3000, SelectedItem.Code, false); act.runAction(handDevice); }
//生成离心机放卡动作 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 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 ActLogic(List <T_GelStep> act_group, List <T_GelStep> act_group_next, double dt) { if (act_group != null && act_group.Count != 0 && act_group[0].State == 0) { int next_state = 2; var seque_act = Sequence.create(); var exper_package = ((ExperimentPackage)act_group[0].ExperPackage); seque_act.exp_pack = exper_package; AbstractCanDevice device = null; foreach (var act in act_group) { resmanager.tip_count += act.InjectCount; } if (act_group[0].InjectCount != 0) { var act_next = act_group_next == null ? null : act_group_next[0]; device = injectorDevice; act_group.Sort((a, b) => { return(((ExperimentPackage)a.ExperPackage).piercer_index > ((ExperimentPackage)b.ExperPackage).piercer_index ? 1 : -1); }); seque_act = generater.GenerateAction(act_group); if (act_next != null && act_next.InjectCount == 0) { seque_act.AddAction(SkCallBackFun.create((ActionBase act_tem) => { inj_wait_time = 9999; return(true); })); } } else { var act = act_group[0]; var act_next = act_group_next == null ? null : act_group_next[0]; var resinfo = resmanager.GetResByCode(exper_package.GetGelMask(), "T_BJ_GelSeat"); if (resinfo == null) { resinfo = resmanager.GetResByCode(exper_package.GetGelMask(), "T_BJ_Centrifuge"); } if ((resinfo == null || !resinfo.PutOk) && act.StepClass != TestStepEnum.LoadGel) { return; } switch (act.StepClass) { case TestStepEnum.LoadGel: { if (actionmanager.getAllActionsCount(handDevice) == 0) { var take_seat = resmanager.GetResByCode(exper_package.GetGelMask(), "T_BJ_GelSeat", "", "3"); var paper_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "4", null, exper_package.is_crossmatching); if (paper_seat != null) { device = handDevice; if (take_seat != null) { generater.GenerateTakeGelFromNormal(take_seat, ref seque_act); } else { seque_act.AddAction(HandTakeGelFromWare.create(handDevice, 3001, gelwareDevice, exper_package.gel_mask_id, exper_package.GetGelMask(), exper_package.GetSampleCode(act.SampleIndex))); } seque_act.AddAction(HandPutGelToNormal.create(handDevice, 3001, gelwareDevice, paper_seat)); if (act_next != null && act_next.StepClass != TestStepEnum.LoadGel) { seque_act.AddAction(SkCallBackFun.create((ActionBase act_tem) => { hand_wait_time = 999999; var ware_act = MoveTo.create(gelwareDevice, 3000, 0); ware_act.runAction(gelwareDevice); return(true); })); } exper_package.piercer_index = paper_seat.CountX; paper_seat.Values[paper_seat.CountX, 0] = new ResInfoData(); seque_act.destroyfun = (ActionBase act_tem) => { paper_seat.Values[paper_seat.CountX, 0] = null; return(true); }; next_state = 2; } else { next_state = 0; } } else { next_state = 0; } } break; case TestStepEnum.KaiKongGel: { int handrx = 0; int injrx = 0; var device_hand = new ActionDevice(handDevice); var device_inj = new ActionDevice(injectorDevice); next_state = 0; if (resinfo.Purpose != "4") { var put_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "4"); if (put_seat == null && resinfo.Purpose != "3") { put_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "3"); } if (put_seat != null) { device = handDevice; ResInfoData put_gel = null; if (resinfo.Purpose == "lxj") { put_gel = generater.GenerateTakeGelFromCent(resinfo, resinfo.CenCode, ref seque_act); } else { put_gel = generater.GenerateTakeGelFromNormal(resinfo, ref seque_act); } generater.GeneratePutGelToNormal(put_seat, put_gel, ref seque_act); next_state = 0; } } else { bool is_next_kaikong = act_next != null ? act_next.StepClass == TestStepEnum.KaiKongGel : false; var paper_seat = resmanager.GetResByCode(exper_package.GetGelMask(), "T_BJ_GelSeat", "", "4"); int yb = is_next_kaikong ? -1 : 0; if (paper_seat != null && device_hand.GetRealX(ref handrx) && (handrx + 1000) < paper_seat.X && ActionDevice.hand_tx < paper_seat.X && device_inj.GetRealX(ref injrx) && (injrx + 1000) < paper_seat.InjectorX && ActionDevice.inj_tx < paper_seat.InjectorX + 1000) { device = piercerDevice; seque_act.AddAction(PaperCard.create(piercerDevice, 3000, paper_seat, yb)); seque_act.AddAction(SkCallBackFun.create((ActionBase acttem) => { exper_package.is_open = true; resmanager.gel_count++; return(true); })); next_state = 2; } } } break; case TestStepEnum.JYJS: { exper_package.is_jyjs = true; next_state = 2; } break; case TestStepEnum.ZKDFY: { next_state = 0; if (resinfo.Purpose == "1") { next_state = 0; exper_package.hatch_cur_time += dt; if (exper_package.hatch_cur_time >= exper_package.hatch_time) { next_state = 2; } } else if (!(resinfo.Purpose == "4" && actionmanager.getAllActionsCount(piercerDevice) != 0)) { var put_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "1"); if (put_seat == null && resinfo.Purpose != "3") { put_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "3"); } if (put_seat != null) { device = handDevice; ResInfoData put_gel = null; if (resinfo.Purpose == "lxj") { put_gel = generater.GenerateTakeGelFromCent(resinfo, resinfo.CenCode, ref seque_act); } else { put_gel = generater.GenerateTakeGelFromNormal(resinfo, ref seque_act); } exper_package.hatch_cur_time = 0; generater.GeneratePutGelToNormal(put_seat, put_gel, ref seque_act); next_state = 0; } else { next_state = 0; } } } break; case TestStepEnum.ZKDLXJ: { if (actionmanager.getAllActionsCount(handDevice) == 0) { next_state = 0; if (resinfo.Purpose != "lxj" && !(resinfo.Purpose == "4" && actionmanager.getAllActionsCount(piercerDevice) != 0)) { //查看可用离心机 var centrifuge_list = resmanager.centrifuge_list.Where(item => item.Status == 1).ToList(); centrifuge_list.Sort((a, b) => { return(a.LastUseTime < b.LastUseTime ? 1 : -1); }); foreach (var seat in centrifuge_list) { CentrifugeMDevice cendev = cenMrg.GetCentrifugeByCode(seat.Code); if (seat.Status == 1 && cendev != null) { device = handDevice; bool is_last_cent = seat == centrifuge_list[centrifuge_list.Count - 1]; bool iscanputcen = IsCanPutCen(cendev); var put_seat = resmanager.GetResByCode("null", "T_BJ_Centrifuge", cendev.Centrifugem.Code.SetValue); if (iscanputcen == false) { put_seat = null; } //放进待定位 if (put_seat == null && resinfo.Purpose != "3" && is_last_cent) { put_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "3"); } if (put_seat != null) { var spaw = Spawn.create(); var put_seque = Sequence.create(); if (put_seat.Purpose == "lxj") { //打开离心机门 var opendoor_act = HandOpenCloseDoor.create(handDevice, 5000, cendev.Centrifugem.Code.SetValue, true); put_seque.AddAction(opendoor_act); } var put_gel = generater.GenerateTakeGelFromNormal(resinfo, ref put_seque); spaw.AddAction(put_seque); seque_act.AddAction(spaw); if (put_seat.Purpose == "lxj") { spaw.AddAction(MoveTo.create(cendev, 30001, -1, -1, put_seat.CenGelP[put_seat.CountX])); generater.GeneratePutGelToCent(cendev.Centrifugem.Code.SetValue, put_seat, put_gel, ref seque_act); } else { generater.GeneratePutGelToNormal(put_seat, put_gel, ref seque_act); } seat.LastUseTime = Engine.getInstance().getSystemMs(); break; } else { next_state = 0; } } } } } else { next_state = 0; } } break; case TestStepEnum.PutPeiGelBack: { var put_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "2"); if (put_seat != null && resinfo.Purpose == "lxj") { device = handDevice; var put_gel = generater.GenerateTakeGelFromCent(resinfo, resinfo.CenCode, ref seque_act); generater.GeneratePutGelToNormal(put_seat, put_gel, ref seque_act); next_state = 2; } } break; case TestStepEnum.XJPD: { var put_seat = resmanager.GetResByCode("", "T_BJ_Camera"); //相机位 var wasted_seat = resmanager.GetResByCode("", "T_BJ_WastedSeat", "", "1"); //垃圾位 var daiding_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "3"); //待定位 if (put_seat != null && wasted_seat != null && !(resinfo.Purpose == "4" && actionmanager.getAllActionsCount(piercerDevice) != 0)) { device = handDevice; ResInfoData put_gel = null; if (resinfo.Purpose == "lxj") { put_gel = generater.GenerateTakeGelFromCent(resinfo, resinfo.CenCode, ref seque_act); } else { put_gel = generater.GenerateTakeGelFromNormal(resinfo, ref seque_act); } seque_act.AddAction(MoveTo.create(handDevice, 3000, -1, -1, 0)); seque_act.AddAction(MoveTo.create(handDevice, 3000, (int)put_seat.X, (int)(put_seat.Y), -1)); seque_act.AddAction(MoveTo.create(handDevice, 3000, -1, -1, (int)(put_seat.Z))); //拍照分析 seque_act.AddAction(SkCallBackFun.create((ActionBase acttem) => { opDevice.CameraLight(true); bool result = true; if (cameraDevice.IsOpen == false) { result = cameraDevice.Open(); } var bm = cameraDevice.CaptureImage(); cameraDevice.Save(bm, exper_package); opDevice.CameraLight(false); return(true); })); //是否还有动作 if (exper_package.action_list.Count > 1 && daiding_seat != null) { seque_act.AddAction(MoveTo.create(handDevice, 3000, -1, -1, 0)); generater.GeneratePutGelToNormal(daiding_seat, put_gel, ref seque_act); } else { seque_act.AddAction(MoveTo.create(handDevice, 3000, -1, -1, 0)); seque_act.AddAction(MoveTo.create(handDevice, 3000, (int)wasted_seat.X, (int)(wasted_seat.Y))); seque_act.AddAction(HandPutCard.create(handDevice, 3000, (int)wasted_seat.ZPut, 0)); seque_act.AddAction(SkCallBackFun.create((ActionBase act_tem) => { DelPackage(exper_package); return(true); })); } next_state = 2; } } break; case TestStepEnum.ECONOMIZECOUNTTIME: { next_state = 0; if (exper_package.is_open) { exper_package.after_kktime -= dt; if (exper_package.after_kktime <= 0) { device = handDevice; next_state = 2; exper_package.after_kktime = 0; ResInfoData put_gel = null; if (resinfo.Purpose == "lxj") { put_gel = generater.GenerateTakeGelFromCent(resinfo, resinfo.CenCode, ref seque_act); } else { put_gel = generater.GenerateTakeGelFromNormal(resinfo, ref seque_act); } var wasted_seat = resmanager.GetResByCode("", "T_BJ_WastedSeat"); //垃圾位 seque_act.AddAction(MoveTo.create(handDevice, 3000, -1, -1, 0)); seque_act.AddAction(MoveTo.create(handDevice, 3000, (int)wasted_seat.X, (int)(wasted_seat.Y))); seque_act.AddAction(HandPutCard.create(handDevice, 3000, (int)wasted_seat.ZPut, 0)); } } } break; } } if (device != null) { seque_act.AddAction(SkCallBackFun.create((ActionBase act) => { foreach (var act_tem in act_group) { act_tem.State = next_state; } return(true); })); foreach (var act_tem in act_group) { act_tem.State = 1; } seque_act.runAction(device); } else { foreach (var act_tem in act_group) { act_tem.State = next_state; } } } }
//离心开始逻辑 public bool CenRunLogic(CentrifugeMDevice cendev) { bool is_allcenact = true; //是否全是离心动作 bool is_allputok = true; //是否全是已放好 bool is_empty = true; //是否为空 bool is_gelfull = false; //是否已满 bool is_gelsoon = false; //是否有卡快要离心 int gel_count = 0; List <ResInfoData> resinfo_list = new List <ResInfoData>(); if (experiment_package_list.Count == 0) { return(false); } foreach (var seat in resmanager.centrifuge_list) { if (seat.Code == cendev.Centrifugem.Code.SetValue) { for (int i = 0; i < seat.Values.Length; i++) { ResInfoData resinfo = (ResInfoData)seat.Values[i, 0]; if (resinfo != null && resinfo.PutOk) { is_empty = false; var exp_pack = GetExpPackageByMask(resinfo.GetGelMask()); if (exp_pack == null) { exp_pack = GetExpPackageByMask(resinfo.GetCodeAt(0)); } System.Diagnostics.Debug.Assert(exp_pack != null); if (exp_pack == null) { return(false); } is_allcenact = is_allcenact && exp_pack.GetActionTypeAt(0) == TestStepEnum.ZKDLXJ; is_allputok = is_allputok && resinfo.PutOk; resinfo_list.Add(resinfo); gel_count++; } } is_gelfull = gel_count >= seat.Values.Length; } } if ((is_gelfull == false && actionmanager.getAllActionsCount(handDevice) != 0) || actionmanager.getAllActionsCount(cendev) != 0) { return(false); } //普通卡位是否有卡快要离心 foreach (var seat in resmanager.gelseat_list) { for (int i = 0; i < seat.Values.Length; i++) { ResInfoData resinfo = (ResInfoData)seat.Values[i, 0]; if (resinfo != null && resinfo.PutOk && resinfo.FindCode("pei*", false) == false) { var exp_pack = GetExpPackageByMask(resinfo.GetGelMask()); if (exp_pack == null) { continue; } is_gelsoon = (exp_pack.GetActionTypeAt(0) == TestStepEnum.ZKDLXJ) || (exp_pack.GetActionTypeAt(0) == TestStepEnum.ZKDFY && exp_pack.GetActionTypeAt(1) == TestStepEnum.ZKDLXJ && exp_pack.hatch_time - exp_pack.hatch_cur_time <= 20000); if (seat.Purpose == 4 && exp_pack.FindAct(TestStepEnum.ZKDLXJ) && exp_pack.FindAct(TestStepEnum.ZKDFY) == false) { is_gelsoon = true; } if (is_gelsoon) { break; } } } if (is_gelsoon) { break; } } //检测是否满足运行条件 if (is_allcenact && is_allputok && !is_empty && (!is_gelsoon || is_gelfull)) { int hspeed = (int)cendev.Centrifugem.HightSpeed.SetValue; int lspeed = (int)cendev.Centrifugem.LowSpeed.SetValue; int htime = (int)cendev.Centrifugem.HightSpeedTime.SetValue; int ltime = (int)cendev.Centrifugem.LowSpeedTime.SetValue; int uphtime = (int)cendev.Centrifugem.AddHSpeedTime.SetValue; int upltime = (int)cendev.Centrifugem.AddLSpeedTime.SetValue; int stime = (int)cendev.Centrifugem.StopSpeedTime.SetValue; //配平卡动作(如果离心机内卡是单数就再放一张配平卡) var seque_pei = Sequence.create(); var seque = Sequence.create(); if (resinfo_list.Count() % 2 != 0) { var spaw = Spawn.create(); var put_seque = Sequence.create(); //得到配平卡 var pei_gel = resmanager.GetResByCode("pei" + cendev.Centrifugem.Code.SetValue, "T_BJ_GelSeat"); var put_gel = generater.GenerateTakeGelFromNormal(pei_gel, ref put_seque); T_GelStep[] pei_step = { new T_GelStep(), new T_GelStep() }; pei_step[0].StepClass = TestStepEnum.ZKDLXJ; pei_step[1].StepClass = TestStepEnum.PutPeiGelBack; var exp_pack = ExperimentPackage.Create(pei_step.ToList(), pei_gel.GetCodeAt(0), "123", 8, 0, 1, 0, false, 0, 0, false); exp_pack.is_jyjs = true; experiment_package_list.Add(exp_pack); resinfo_list.Add(put_gel); var put_seat = resmanager.GetResByCode("null", "T_BJ_Centrifuge", cendev.Centrifugem.Code.SetValue); spaw.AddAction(put_seque); spaw.AddAction(MoveTo.create(cendev, 30001, -1, -1, put_seat.CenGelP[put_seat.CountX])); seque_pei.AddAction(spaw); generater.GeneratePutGelToCent(cendev.Centrifugem.Code.SetValue, put_seat, put_gel, ref seque_pei); } seque_pei.AddAction(HandOpenCloseDoor.create(handDevice, 5000, cendev.Centrifugem.Code.SetValue, false)); seque.AddAction(SkWaitForAction.create(handDevice, seque_pei)); seque.AddAction(CentrifugeStart.create(cendev, 6000000, hspeed, lspeed, htime, ltime, uphtime, upltime, stime)); seque.AddAction(SkCallBackFun.create((ActionBase acttem) => { foreach (var resinfo in resinfo_list) { var exp_pack = GetExpPackageByMask(resinfo.GetGelMask()); if (exp_pack == null) { exp_pack = GetExpPackageByMask(resinfo.GetCodeAt(0)); } System.Diagnostics.Debug.Assert(exp_pack != null); var act = exp_pack.GetActionAt(0); act.State = 2; } return(true); })); seque_pei.runAction(handDevice); seque.runAction(cendev); return(true); } return(false); }
//离心开始逻辑 public bool CenRunLogic(CentrifugeMDevice cendev) { bool is_allcenact = true; //是否全是离心动作 bool is_allputok = true; //是否全是已放好 bool is_empty = true; //是否为空 bool is_gelfull = false; //是否已满 bool is_gelsoon = false; //是否有卡快要离心 int gel_count = 0; List <ResInfoData> resinfo_list = new List <ResInfoData>(); foreach (var seat in resmanager.centrifuge_list) { if (seat.Code == cendev.Centrifugem.Code.SetValue) { for (int i = 0; i < seat.Values.Length; i++) { ResInfoData resinfo = (ResInfoData)seat.Values[i, 0]; if (resinfo != null && resinfo.InjectFinish && resinfo.PutOk) { is_empty = false; is_allcenact = is_allcenact && resinfo.GetActionAt(0) == ActionPoint.ActionPointType.Centrifugal; is_allputok = is_allputok && resinfo.PutOk; resinfo_list.Add(resinfo); gel_count++; } } is_gelfull = gel_count >= seat.Values.Length; } } if ((is_gelfull == false && actionmanager.getAllActionsCount(handDevice) != 0) || actionmanager.getAllActionsCount(cendev) != 0) { return(false); } //普通卡位是否有卡快要离心 foreach (var seat in resmanager.gelseat_list) { for (int i = 0; i < seat.Values.Length; i++) { ResInfoData resinfo = (ResInfoData)seat.Values[i, 0]; if (resinfo != null && resinfo.InjectFinish && resinfo.PutOk) { is_gelsoon = (resinfo.GetActionAt(0) == ActionPoint.ActionPointType.Centrifugal) || (resinfo.GetActionAt(0) == ActionPoint.ActionPointType.Hatch && resinfo.GetActionAt(1) == ActionPoint.ActionPointType.Centrifugal && resinfo.HatchTime - resinfo.HatchCurTime <= 20000); if (seat.Purpose == 4 && resinfo.FindAct(ActionPoint.ActionPointType.Centrifugal) && resinfo.FindAct(ActionPoint.ActionPointType.Hatch) == false) { is_gelsoon = true; } if (is_gelsoon) { break; } } } if (is_gelsoon) { break; } } //检测是否满足运行条件 if (is_allcenact && is_allputok && !is_empty && (!is_gelsoon || is_gelfull)) { int hspeed = (int)cendev.Centrifugem.HightSpeed.SetValue; int lspeed = (int)cendev.Centrifugem.LowSpeed.SetValue; int htime = (int)cendev.Centrifugem.HightSpeedTime.SetValue; int ltime = (int)cendev.Centrifugem.LowSpeedTime.SetValue; int uphtime = (int)cendev.Centrifugem.AddHSpeedTime.SetValue; int upltime = (int)cendev.Centrifugem.AddLSpeedTime.SetValue; int stime = (int)cendev.Centrifugem.StopSpeedTime.SetValue; //配平卡动作(如果离心机内卡是单数就再放一张配平卡) var seque_pei = Sequence.create(); var seque = Sequence.create(); if (resinfo_list.Count() % 2 != 0) { var spaw = Spawn.create(); var put_seque = Sequence.create(); //得到配平卡 var pei_gel = resmanager.GetResByCode("pei" + cendev.Centrifugem.Code.SetValue, "T_BJ_GelSeat"); var put_gel = generater.GenerateTakeGelFromNormal(pei_gel, ref put_seque); put_gel.ActionList.Add(ActionPointType.Centrifugal); put_gel.ActionList.Add(ActionPointType.PutPeiGelBack); put_gel.InjectFinish = true; resinfo_list.Add(put_gel); var put_seat = resmanager.GetResByCode("null", "T_BJ_Centrifuge", cendev.Centrifugem.Code.SetValue); spaw.AddAction(put_seque); spaw.AddAction(MoveTo.create(cendev, 30001, -1, -1, put_seat.CenGelP[put_seat.CountX])); seque_pei.AddAction(spaw); generater.GeneratePutGelToCent(cendev.Centrifugem.Code.SetValue, put_seat, put_gel, ref seque_pei); } seque_pei.AddAction(HandOpenCloseDoor.create(handDevice, 5000, cendev.Centrifugem.Code.SetValue, false)); seque.AddAction(SkWaitForAction.create(handDevice, seque_pei)); seque.AddAction(CentrifugeStart.create(cendev, 300000, hspeed, lspeed, htime, ltime, uphtime, upltime, stime)); seque.AddAction(SkCallBackFun.create((ActionBase acttem) => { foreach (var resinfo in resinfo_list) { if (resinfo.InjectFinish) { resinfo.RemoveActionAt(0); } } return(true); })); seque_pei.runAction(handDevice); seque.runAction(cendev); return(true); } return(false); }
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); }