public int GetPressure(Enterclose ent) { bool is_timeout = false; CanComm.ReadRegister(ent.PumpMotor.Pressure.Addr); int pressure = CanComm.GetIntBlock(ent.PumpMotor.Pressure.Addr, 2000, out is_timeout); return(is_timeout?-1:pressure); }
public Injector(byte count) { XMotor = new Electromotor(); TMotor = new Electromotor(); Entercloses = new Enterclose[count]; for (byte i = 0; i < count; i++) { Entercloses[i] = new Enterclose(i); } }
//按小组生成动作 public Sequence GenerateAction(List <T_GelStep> act_group, SampleInfo sample_info, ref int[] point) { //更新坐标计算针头个数 int zt_count = 0; foreach (var act in act_group) { zt_count += act.InjectCount; act.UpdataPoints(sample_info); } var resmanager = ResManager.getInstance(); Enterclose[] enters = new Enterclose[zt_count];//使用加样器个数 for (int i = 0; i < zt_count; i++) { enters[i] = injectorDevice.Injector.Entercloses[i]; } int[] width = { 0, 0, 0, 0 }; int[] tipgp = { 0, 0, 0, 0 }; for (int i = 0; i < 4; i++) { width[i] = (int)injectorDevice.Injector.Entercloses[1].YZero; tipgp[i] = (int)injectorDevice.Injector.Entercloses[i].MinDistance; } //生成装帧动作 var tip_seat = resmanager.GetFreeTipActPoint(zt_count, 2); var sequ_taketip = GenerateInjectActGroup(tip_seat, ref point, width, tipgp); //生成加样动作 var sequ_takesample = Sequence.create(); var act_tree = DivideXIntoGroups(act_group); int inject_beg = 0; int[] point = { 0, 0, 0, 0 }; for (int i = 0; i < 4; i++) { point[i] = (int)injectorDevice.Injector.Entercloses[i].YMotor.CurrentDistance; if (point[i] == 0) { point[i] += (int)injectorDevice.Injector.Entercloses[i].YZero; } } foreach (var act_g in act_tree) { var sque_movey = Sequence.create(); int index = 0; bool is_ok = false; int[] tager = { -1, -1, -1, -1 }; int[] width = { 0, 0, 0, 0 }; for (int i = 0; i < 4; i++) { width[i] = (int)injectorDevice.Injector.Entercloses[1].YZero; if (i < act_g.Count()) { tager[inject_beg + i] = act_g[i].Abs_Y; } } GenerateInjectActGroup(ref sque_movey, ref index, ref tager, ref point, ref width, ref is_ok); inject_beg += act_g.Count(); if (is_ok) { sequ_takesample.AddAction(MoveTo.create(30000, act_g[0].Abs_X, -1, -1));//移动X sequ_takesample.AddAction(sque_movey); } } ////生成混合液体 //var sequ_mixsample = Sequence.create(); //foreach (var act in act_group) //{ // if (act.IsMix()) // { // sequ_mixsample.AddAction(MoveTo.create(30000, act.Mix_X, act.Mix_Y, -1)); // sequ_mixsample.AddAction(InjectMoveTo.create(30000,enters,-1,IMask.Gen(-1),IMask.Gen(act.Mix_Z))); // if (act.StepClass == TestStepEnum.FPXSY) // { // for (int i = 0; i < 3; i++) // { // absorbs[0] = 1000; // sequ_mixsample.AddAction(InjectAbsorb.create(30000, enters, 100, absorbs)); // absorbs[0] = -1000; // sequ_mixsample.AddAction(InjectAbsorb.create(30000, enters, 100, absorbs)); // } // } // if (act.IsSpu() == false) // { // absorbs[0] = 1000; // sequ_mixsample.AddAction(InjectAbsorb.create(30000, enters, 100, absorbs)); // } // sequ_mixsample.AddAction(InjectMoveTo.create(30000, enters, -1, IMask.Gen(-1), IMask.Gen(0))); // } //} ////生成分配动作 //var sequ_putsample = Sequence.create(); //foreach (var act in act_group) //{ // if (act.IsSpu()) // { // sequ_putsample.AddAction(MoveTo.create(30000, act.Spu_X, act.Spu_Y, -1)); // sequ_putsample.AddAction(InjectMoveTo.create(30000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(act.Spu_Z))); // absorbs[0] = 1000; // sequ_putsample.AddAction(InjectAbsorb.create(30000, injectorDevice.GetSeleteced(), 100, absorbs)); // sequ_putsample.AddAction(InjectMoveTo.create(30000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(0))); // } //} var action_list = Sequence.create(); ////生成脱针动作 //var sequ_puttip = Sequence.create(); //var inject_unload = resmanager.unload_list; //if (inject_unload.Count() == 1) //{ // sequ_puttip.AddAction(InjectPutTip.create(30000, (int)inject_unload[0].Z, 800, (int)inject_unload[0].FirstX, 0, new TakeTipData((int)inject_unload[0].X, (int)inject_unload[0].Y, 0, 1))); // sequ_puttip.AddAction(InitXyz.create(30000, injectorDevice.GetSeleteced(), false, false, true)); //} 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); }
//按小组生成动作 public Sequence GenerateAction(List <T_GelStep> act_group) { //更新坐标计算吸头个数 int zt_count = 0; foreach (var act in act_group) { 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>(); foreach (var act_abs in act_group) { var abs_point = GelStepToActionPoint(act_abs, TestStepEnum.AbsLiquid); abs_seat.Add(abs_point); } sequ_takesample.AddAction(InjectMoveActs.create(3001, abs_seat.ToArray(), true)); //生成混合液体 var sequ_mixsample = Sequence.create(); List <ActionPoint> mix_seat = new List <ActionPoint>(); foreach (var act_mix in act_group) { if (act_mix.is_mix) { var mix_point = GelStepToActionPoint(act_mix, TestStepEnum.MixLiquid); mix_seat.Add(mix_point); } } sequ_mixsample.AddAction(InjectMoveActs.create(3001, mix_seat.ToArray(), true)); //生成分配动作 var sequ_putsample = Sequence.create(); List <ActionPoint> spu_seat = new List <ActionPoint>(); int spu_index = 0; foreach (var act_spu in act_group) { if (act_spu.is_spu) { var spu_point = GelStepToActionPoint(act_spu, TestStepEnum.SpuLiquid); var tubelist = spu_point.GetTubeList(); for (int i = 0; i < tubelist.Count(); i++) { var points = IMask.Gen(new ActionPoint(-1, -1, -1)); points[spu_index] = (ActionPoint)spu_point.Clone(); points[spu_index].x = (int)(spu_point.x + tubelist[i] * spu_point.tube_gap); if (tubelist.Count() != 1 && i >= 0 && i < tubelist.Count() - 1) { points[spu_index].zb = points[spu_index].z - 1500; if (points[spu_index].zb <= 0) { points[spu_index].zb = 0; } } sequ_putsample.AddAction(InjectMoveActs.create(3001, points.ToArray(), true)); } } spu_index++; } //生成脱针动作 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); }
//按小组生成动作 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); }
public void checkNull() { XMotor = XMotor ?? new Electromotor(); TMotor = TMotor ?? new Electromotor(); Entercloses = Entercloses ?? new Enterclose[Constants.EntercloseCount]; if (Entercloses.Length > Constants.EntercloseCount) { var ets = new Enterclose[Constants.EntercloseCount]; Array.Copy(Entercloses, ets, Constants.EntercloseCount); Entercloses = ets; } else if (Entercloses.Length < Constants.EntercloseCount) { var ets = new Enterclose[Constants.EntercloseCount]; Array.Copy(Entercloses, ets, Entercloses.Length); Entercloses = ets; } for (byte i = 0; i < Constants.EntercloseCount; i++) { var et = Entercloses[i]; if (et == null) { et = new Enterclose(i); } et.PumpMotor = et.PumpMotor ?? new DoubleSpeedMotor(); et.YMotor = et.YMotor ?? new DoubleSpeedMotor(); et.ZMotor = et.ZMotor ?? new DoubleSpeedMotor(); if (et.ZMotor.SecondSpeed == null) { et.ZMotor.SecondSpeed = new PLCParameter <int>(); } if (et.PumpMotor.SecondSpeed == null) { et.PumpMotor.SecondSpeed = new PLCParameter <int>(); } if (et.YMotor.SecondSpeed == null) { et.YMotor.SecondSpeed = new PLCParameter <int>(); } if (et.ZMotor.DownSpeed == null) { et.ZMotor.DownSpeed = new PLCParameter <int>(); } if (et.PumpMotor.DownSpeed == null) { et.PumpMotor.DownSpeed = new PLCParameter <int>(); } if (et.YMotor.DownSpeed == null) { et.YMotor.DownSpeed = new PLCParameter <int>(); } //et.Valid = true; et.Pressure = et.Pressure ?? new PLCParameter <int>(); et.ExistTipCoil = et.ExistTipCoil ?? new PLCParameter <bool>(); //et.PumpMotor.ProgramZero = 0; //et.ValidCoil = et.ValidCoil ?? new PLCParameter<bool>(); } }