//x轴移动约束 public bool MoveXConstrains(int x, double dt) { if (node is MachineHandDevice || node is InjectorDevice) { contime += dt; if (contime > 500) { contime = 0; MachineHandDevice handDevice = Engine.getInstance().handDevice; InjectorDevice injectorDevice = Engine.getInstance().injectorDevice; OtherPartDevice opDevice = Engine.getInstance().opDevice; int hand_rx = 0; int inj_rx = 0; var hand_device = new ActionDevice(handDevice); var inj_device = new ActionDevice(injectorDevice); hand_device.GetRealX(ref hand_rx); inj_device.GetRealX(ref inj_rx); if (node is MachineHandDevice) { hand_tx = x; } if (node is InjectorDevice) { inj_tx = x; } int hand_cx = hand_rx != hand_old_rx ? hand_tx : hand_rx; int inj_cx = inj_rx != inj_old_rx ? inj_tx : inj_rx; int total_space = opDevice.OP.AvoidanceTotal.SetValue; int limt_space = opDevice.OP.AvoidanceSpace.SetValue; int l_space = total_space - (hand_cx + inj_cx) - limt_space; int hand_lx = hand_cx + l_space; int inj_lx = inj_cx + l_space; hand_old_rx = hand_rx; inj_old_rx = inj_rx; bool is_hand_in_con_space = hand_rx >= hand_tx ? false : hand_tx >= hand_lx; bool is_inj_in_con_space = inj_rx >= inj_tx ? false : inj_tx >= inj_lx; //System.Diagnostics.Debug.Assert(!(is_hand_in_con_space && is_inj_in_con_space)); is_all_in_con_space = is_hand_in_con_space && is_inj_in_con_space; if (node is MachineHandDevice) { return(is_hand_in_con_space == false); } else if (node is InjectorDevice) { return(is_inj_in_con_space == false); } } return(false); } return(true); }
protected override void OnViewLoaded() { if (Loaded) { return; } Loaded = true; base.OnViewLoaded(); this.injector = this.BjParamService.LoadFromJson <Injector>(); if (injector != null) { injector.checkNull(); } this.injector = this.injector ?? new Injector(Constants.EntercloseCount); injectorDevice = new InjectorDevice(CanComm, injector); }