public override List <Experiment> LoadList(string sortOrder, string searchString) { IQueryable <Experiment> experiments = Db.Experiments; experiments = ExperimentLogic.FilterExperiments(experiments, searchString); return(SortList(experiments.ToList(), sortOrder)); }
public void LoadEL(Experiment ex) { ELLoadTime = timer.ElapsedMillisecond; Type eltype = null; if (!string.IsNullOrEmpty(ex.LogicPath)) { if (File.Exists(ex.LogicPath)) { var assembly = ex.LogicPath.CompileFile(); eltype = assembly.GetExportedTypes()[0]; } else { eltype = Type.GetType(ex.LogicPath); } } if (eltype == null) { ex.LogicPath = uicontroller.config.ExLogic; eltype = Type.GetType(ex.LogicPath); Debug.LogWarning($"No Valid ExperimentLogc For {ex.ID}, Use {ex.LogicPath} Instead."); } el = gameObject.AddComponent(eltype) as ExperimentLogic; el.ex = ex; uicontroller.condpanel.forceprepare.isOn = el.regeneratecond; AddEL(el); }
public List <Experiment> LoadList(string sortOrder, string searchString = "") { IQueryable <Experiment> queryExperiments = dummyExperiments.AsQueryable(); queryExperiments = ExperimentLogic.FilterExperiments(queryExperiments, searchString); return(SortList(queryExperiments.ToList(), sortOrder)); }
private void btnInit_Click(object sender, EventArgs e) { btnInitBackground.Enabled = true; btnStart.Enabled = true; EnergyLogic = new EnergyCellLogic(); AtomLogic = new AtomLogic(); ExperimentLogic = new ExperimentLogic(); }
public void AddEL(ExperimentLogic el) { if (elhistory.Count > 0) { elhistory.Last().enabled = false; } elhistory.Add(el); InheritEx(); RemoveDuplicateEx(); AddELCallback(); }
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 UpData(object sender, EventArgs e) { if (is_updata) { ResultList.Clear(); List <ExperimentPackage> explist = new List <ExperimentPackage>(ExperimentLogic.getInstance().experiment_package_list.ToArray()); foreach (var exp in explist) { if (exp.action_list.Count != 0) { var gel = ResManager.getInstance().GetGelTestByTestId(exp.gel_test_id); if (gel != null) { string time_str = exp.hatch_cur_time != 0?exp.hatch_cur_time + "/" + exp.hatch_time:""; ResultList.Add(new ExperimentManagementData(gel.GelName + "(" + exp.GetGelMask() + ")", exp.start_time, "正常", exp.action_list[0].GetGelStep().StepName + time_str, exp.action_list.Count)); } } } } }
public List <Experiment> SortList(List <Experiment> experiments, string sortOrder) { return(ExperimentLogic.SortExperiments(experiments, sortOrder)); }
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); }
//按小组生成动作 public Sequence GenerateAction(List <T_GelStep> act_group) { //更新坐标计算吸头个数 int zt_count = 0; foreach (var act in act_group) { act.InjIndex = zt_count; zt_count += act.InjectCount; } var resmanager = ResManager.getInstance(); Enterclose[] enters = new Enterclose[zt_count];//使用加样器个数 for (int i = 0; i < zt_count; i++) { enters[i] = Engine.getInstance().injectorDevice.Injector.Entercloses[i]; } //生成装帧动作 var tip_seat = resmanager.GetFreeTipActPoint(zt_count, 2); var sequ_taketip = InjectMoveActs.create(3001, tip_seat, false); //生成加样动作 var sequ_takesample = Sequence.create(); List <ActionPoint> abs_seat = new List <ActionPoint>(); int abs_index = 0; var abs_width_rate = IMask.Gen(1.0f); foreach (var act_abs in act_group) { var abs_point = GelStepToActionPoint(act_abs, TestStepEnum.AbsLiquid, null); var agentseat = resmanager.GetAgentiaWarehouseSeat(abs_point.liquid_type); if (agentseat != null) { abs_width_rate[act_abs.InjIndex] = !act_abs.GetLiquidInfo().IsAgentia ? 0.7693f : 1.1f; abs_point.y += (int)(agentseat.Gap * abs_index) * (agentseat.Count == 1 ? 1 : 0); } abs_seat.Add(abs_point); abs_index++; } sequ_takesample.AddAction(InjectMoveActs.create(3001, abs_seat.ToArray(), true, abs_width_rate)); //计算混合是否需要分配(当前卡在第一卡位时且只有一个试验) var inj_exp_list = ExperimentLogic.getInstance().GetInjExpPackageList(); foreach (var act_mix in act_group) { var exp = (ExperimentPackage)act_mix.ExperPackage; var piperseat = resmanager.GetResByCode(exp.GetGelMask(), "T_BJ_GelSeat", "", "4"); if (piperseat.CountX == 0 && inj_exp_list.Count == 1) { act_mix.is_spu = act_mix.InjIndex == 0; } else { act_mix.is_spu = act_mix.LiquidTypeIndex == act_mix.GetFpytInfo().LiquidList.Count - 1; } } //得到可用深盘 var mix_list = act_group.Where(item => item.is_mix == true).ToList(); mix_list = mix_list.Where((x, x_index) => x_index == (mix_list.FindIndex(y => y.MixCode == x.MixCode))).ToList(); int mix_inj_count = mix_list.Count; var mix_deep_seat = resmanager.GetFreeDeepPlate(mix_inj_count, 2); //生成混合液体 var sequ_mixsample = Sequence.create(); var mix_seat = IMask.Gen(new ActionPoint(-1, -1, -1)); int mix_index = 0; foreach (var act_mix in act_group) { if (act_mix.is_mix) { var mix_point = GelStepToActionPoint(act_mix, TestStepEnum.MixLiquid, mix_deep_seat[mix_index % mix_inj_count]); mix_seat[act_mix.InjIndex] = mix_point; mix_index++; } } sequ_mixsample.AddAction(InjectMoveActs.create(3001, mix_seat.ToArray(), true)); //生成分配动作 var sequ_putsample = Sequence.create(); //查找卡位 List <ActionPoint> spupoint_list = new List <ActionPoint>(); foreach (var act_spu in act_group) { if (act_spu.is_spu) { var spu_point = GelStepToActionPoint(act_spu, TestStepEnum.SpuLiquid, null); spu_point.index = act_spu.InjIndex; spupoint_list.Add(spu_point); } } var hit_count = IMask.Gen(0); for (int i = 0; i < 8; i++) { bool is_find = false; var points = IMask.Gen(new ActionPoint(-1, -1, -1)); foreach (var spuc in spupoint_list) { bool is_hit = (spuc.tube & (0x01 << i)) != 0; if (is_hit) { var tubelist = spuc.GetTubeList(); points[spuc.index] = (ActionPoint)spuc.Clone(); points[spuc.index].x = (int)(spuc.x + i * spuc.tube_gap); points[spuc.index].y = (int)spuc.y; if (tubelist.Count() != 1 && hit_count[spuc.index] < tubelist.Count() - 1) { points[spuc.index].zb = points[spuc.index].z - 1500; if (points[spuc.index].zb <= 0) { points[spuc.index].zb = 0; } } hit_count[spuc.index]++; is_find = true; } } if (is_find) { sequ_putsample.AddAction(InjectMoveActs.create(3001, points.ToArray(), true)); } } //生成脱针动作 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.PutTip); unload_point.puttip_x = (int)unloader.FirstX; unload_seat.Add(unload_point); } sequ_puttip.AddAction(InjectMoveActs.create(3001, unload_seat.ToArray(), true)); } var action_list = Sequence.create(); action_list.node = Engine.getInstance().injectorDevice; action_list.AddAction(sequ_taketip); action_list.AddAction(sequ_takesample); action_list.AddAction(sequ_mixsample); action_list.AddAction(sequ_putsample); action_list.AddAction(sequ_puttip); return(action_list); }
private void InitGrid(DataGrid dg, IList <VBJ> list) { if (dg == null) { return; } dg.AutoGenerateColumns = false; dg.CanUserAddRows = false; dg.CanUserSortColumns = false; dg.CanUserDeleteRows = false; dg.Columns.Clear(); DataGridTextColumn indexCol = new DataGridTextColumn(); indexCol.Header = ""; indexCol.Width = 30; Binding bv = new Binding("Index"); bv.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; indexCol.Binding = bv; indexCol.IsReadOnly = true; dg.Columns.Add(indexCol); DataList = new List <DGContent>(); int index = 0; foreach (var bj in list) { DataGridTextColumn col = new DataGridTextColumn(); col.Header = bj.Name; col.Width = 100; Binding bindingValue = new Binding("Y" + index) { Mode = BindingMode.TwoWay }; bindingValue.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; col.Binding = bindingValue; col.IsReadOnly = CanSave ^ true; dg.Columns.Add(col); if (bj is VBJ vbj) { var p = typeof(DGContent).GetProperty("Y" + (index)); if (p == null) { break; } int row = vbj.Values.GetLength(0); for (int i = 0; i < row; i++) { if (DataList.Count < i + 1) { DataList.Add(new DGContent() { Index = i + 1 }); } var item = DataList[i]; string value = ""; if (vbj.Values[i, 0] is ResInfoData resinfo) { if (vbj is T_BJ_GelWarehouse) { if (resinfo.gel != null) { value = resinfo.gel.GelName + " " + resinfo.GetGelMask(); } else if (resinfo.codes.Count != 0) { value = resinfo.GetCodeAt(0); } else { value = "未扫描"; } } else if (vbj is T_BJ_GelSeat) { var gel_mask = resinfo.GetGelMask(); value += gel_mask; if (gel_mask == "") { value += resinfo.GetCodeAt(0); } var exp = ExperimentLogic.getInstance().GetExpPackageByMask(gel_mask); if (exp != null) { foreach (var samplecode in exp.samples_barcode) { value += " " + samplecode; } } } else if (vbj is T_BJ_SampleRack) { value = resinfo.GetSampleBarcode(); } else if (vbj is T_BJ_Centrifuge) { var gel_mask = resinfo.GetGelMask(); value += gel_mask; if (gel_mask == "") { value += resinfo.GetCodeAt(0); } var exp = ExperimentLogic.getInstance().GetExpPackageByMask(gel_mask); if (exp != null) { foreach (var samplecode in exp.samples_barcode) { value += " " + samplecode; } } value += " " + resinfo.Purpose; } } else if (vbj.Values[i, 0] != null) { value = vbj.Values[i, 0].ToString(); } p.SetValue(item, value); //items.Add(item); } } index++; } dg.ItemsSource = DataList; }