Exemplo n.º 1
0
        //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;
            }
            base.OnViewLoaded();
            this.Piercer   = bjParamService.LoadFromJson <Piercer>();
            this.Piercer   = this.Piercer ?? new Piercer();
            this.PieDevice = new PiercerDevice(CanComm, this.Piercer);

            this.CentSys    = bjParamService.LoadFromJson <CentrifugeSystem>();
            this.CentSys    = this.CentSys ?? new CentrifugeSystem();
            this.CentDevice = new CentrifugeDevice(CanComm, CentSys);

            this.GelWare       = bjParamService.LoadFromJson <GelWarehouse>();
            this.GelWare       = this.GelWare ?? new GelWarehouse();
            this.GelWareDevice = new GelWarehouseDevice(CanComm, GelWare);

            this.Hand = bjParamService.LoadFromJson <MachineHand>();
            this.Hand = this.Hand ?? new MachineHand();
            this.Hand.CheckNull();
            this.HandDevice = new MachineHandDevice(CanComm, Hand);

            this.CouMixer = bjParamService.LoadFromJson <CouveuseMixer>();
            this.CouMixer = this.CouMixer ?? new CouveuseMixer();
            this.CouMixer.checkNull();
            this.CouMixerDevice = new CouveuseMixerDevice(CanComm, CouMixer);

            this.Param    = bjParamService.LoadFromJson <OtherPart>();
            this.Param    = this.Param ?? new OtherPart();
            this.OPDevice = new OtherPartDevice(CanComm, Param);

            this.Centrifuge = bjParamService.LoadFromJson <CentrifugeData>();
            this.Centrifuge = this.Centrifuge ?? CentrifugeData.Create();
            this.CentMrg    = new CentrifugeMrg(CanComm, Centrifuge);
        }