public void AddPackage(ExperimentPackage experiment_package) { lock (mylock) { experiment_package_list.Add(experiment_package); } }
public void DelPackage(ExperimentPackage experiment_package) { lock (mylock) { if (experiment_package != null) { experiment_package_del_list.Add(experiment_package); } } }
public ExperimentPackage GetCombinationExpPackage(ExperimentPackage expack) { foreach (var exp in experiment_package_list) { if (exp != expack && exp.GetGelMask().IndexOf(expack.GetGelMask()) != -1) { //没有开孔,已开孔加样还没结束,等待使用 var pier_seat = resmanager.GetResByCode(exp.GetGelMask(), "T_BJ_GelSeat", "1"); if (pier_seat == null) { pier_seat = resmanager.GetResByCode(exp.GetGelMask(), "T_BJ_GelSeat", "3"); } if (exp.is_used_gel && exp.GetCurRenFen() + 1 <= exp.ren_fen && exp.action_list.Count != 0 && exp.after_kktime > 0 && (!exp.is_open || exp.is_open && pier_seat != null && exp.FindAct(TestStepEnum.JYJS) || exp.action_list[0].StepClass == TestStepEnum.ECONOMIZECOUNTTIME)) { return(exp); } } } return(null); }
//离心开始逻辑 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 static ExperimentPackage Create(List <T_GelStep> aaction_list, string gelmask, string samplebar, string volunteerbar, int lever, int geltype, int renfen, int afterkktime, bool isusedgel, int gel_test_id, bool is_crossmatching, int batch_id, bool is_double) { var exp = new ExperimentPackage(); exp.lever = lever; exp.AddSampleCode(samplebar); exp.AddvolunteerCode(volunteerbar); exp.gel_mask_id = ResManager.getInstance().AddGelMaskByID(gelmask); exp.start_time = DateTime.Now.ToString("yyyyMMddHHmmss"); exp.start_time_data = DateTime.Now; exp.gel_test_id = gel_test_id; exp.batch_id = batch_id; exp.is_crossmatching = is_crossmatching; exp.is_open = false; exp.package_id = g_package_id; exp.is_double = is_double; g_package_id++; foreach (var act in aaction_list) { act.ExperPackage = exp; exp.action_list.Add(new LogicAction(act)); } //省卡模式 exp.gel_type = geltype; exp.ren_fen = renfen; exp.after_kktime = afterkktime * 60 * 1000; exp.is_used_gel = isusedgel; var economize = new T_GelStep(); economize.ExperPackage = exp; economize.StepClass = TestStepEnum.ECONOMIZECOUNTTIME; if (isusedgel) { exp.action_list.Add(new LogicAction(economize)); } int index = 0; bool is_sort_index_ok = false; foreach (var act in exp.action_list) { act.GetGelStep().StepIndex = index; act.GetGelStep().SampleIndex = 0; if (is_sort_index_ok == false) { exp.sort_index = exp.gel_test_id; } if (act.GetGelStep().StepClass == TestStepEnum.ZKDFY) { ZKDFYStepParameter parameter = act.GetGelStep().StepParamters.ToInstance <ZKDFYStepParameter>(); exp.hatch_time = parameter.YsTime; if (is_sort_index_ok == false) { exp.sort_index += 100000; is_sort_index_ok = true; } } index++; } exp.UpdataSampleIndex(); if (is_crossmatching) { exp.SortCrossMatching(); } return(exp); }
//省卡合并 public void Combination(ExperimentPackage expack) { is_jyjs = false; //添加病人code AddSampleCode(expack.GetSampleCode(0)); AddvolunteerCode(expack.GetAddvolunteerCode(0)); //更新gel_mask_id if (expack.gel_mask_id < gel_mask_id) { gel_mask_id = expack.gel_mask_id; is_open = expack.is_open; } //更新所有动作的指向病人code foreach (var act in expack.action_list) { act.GetGelStep().SampleIndex = samples_barcode.Count() - 1; } //合并在加样结束前 int jyjs_index = 0; for (int i = 0; i < action_list.Count(); i++) { if (action_list[i].GetGelStep().StepClass == TestStepEnum.JYJS) { jyjs_index = i; break; } } //插入所有分配液体 //if (jyjs_index != 0) expack.action_list.Reverse(); foreach (var act in expack.action_list) { if (jyjs_index == 0) { action_list.Add(act); } else if (act.GetGelStep().StepClass == TestStepEnum.FPYT) { action_list.Insert(jyjs_index, act); jyjs_index++; } } //人份满了就把省卡去掉 if (ren_fen == samples_barcode.Count()) { for (int i = action_list.Count - 1; i >= 0; i--) { if (action_list[i].GetGelStep().StepClass == TestStepEnum.ECONOMIZECOUNTTIME) { action_list.Remove(action_list[i]); } } } //只留一个省卡 bool is_find_econtime = false; for (int i = action_list.Count - 1; i >= 0; i--) { if (action_list[i].GetGelStep().StepClass == TestStepEnum.ECONOMIZECOUNTTIME) { if (is_find_econtime) { action_list.Remove(action_list[i]); } is_find_econtime = true; } } //如果已开孔把开孔去掉 if (is_open) { for (int i = action_list.Count - 1; i >= 0; i--) { if (action_list[i].GetGelStep().StepClass == TestStepEnum.KaiKongGel) { action_list.Remove(action_list[i]); } } } //排序 for (int i = 0; i < action_list.Count(); i++) { foreach (var actt in action_list[i].GetAllActions()) { actt.GetGelStep().ExperPackage = this; } if (is_crossmatching == false) { action_list[i].GetGelStep().StepIndex = i; } } action_list = action_list.OrderBy(c => c.GetGelStep().SampleIndex).ToList(); action_list = action_list.OrderBy(c => c.GetGelStep().StepIndex).ToList(); //交叉配血 if (is_crossmatching) { SortCrossMatching(); } UpdataSampleIndex(); expack.action_list.Clear(); expack.samples_barcode.Clear(); expack.volunteers_barcode.Clear(); }