public static ExperimentLogic getInstance()
 {
     if (experimentlogic == null)
     {
         experimentlogic = new ExperimentLogic();
     }
     return(experimentlogic);
 }
示例#2
0
        public void init()
        {
            action_manager                  = ActionManager.getInstance();
            res_manager                     = ResManager.getInstance();
            experiment_logic                = ExperimentLogic.getInstance();
            experiment_logic.handDevice     = handDevice;
            experiment_logic.piercerDevice  = piercerDevice;
            experiment_logic.gelwareDevice  = gelwareDevice;
            experiment_logic.injectorDevice = injectorDevice;
            experiment_logic.cenMrg         = cenMrg;
            experiment_logic.cameraDevice   = cameraDevice;
            experiment_logic.opDevice       = opDevice;
            InitRes();
            handDevice.CanComm.SetListenFun(handDevice.Hand.ZMotor.GetErrorAdress(), CanFunCodeEnum.UPLOAD_COIL, ErrorCode);
            gelwareDevice.CanComm.SetListenFun(gelwareDevice.GelWare.DoorCoil.Addr, CanFunCodeEnum.UPLOAD_COIL, GelWareDoor);
            opDevice.CanComm.SetListenFun(opDevice.OP.EmergencyStopCoil.Addr, CanFunCodeEnum.UPLOAD_COIL, StopAll);


            isstop = false;
        }
示例#3
0
 public void StopAll(int tagerid, byte[] data)
 {
     if (data[5] == 0xff)
     {
         var task = new Task(() =>
         {
             stop();
             handDevice.CanComm.StopMotor(handDevice.Hand.XMotor);
             handDevice.CanComm.StopMotor(handDevice.Hand.YMotor);
             handDevice.CanComm.StopMotor(handDevice.Hand.ZMotor);
             injectorDevice.CanComm.StopMotor(injectorDevice.Injector.XMotor);
             foreach (var ent in injectorDevice.Injector.Entercloses)
             {
                 injectorDevice.CanComm.StopMotor(ent.YMotor);
                 injectorDevice.CanComm.StopMotor(ent.ZMotor);
             }
             ActionManager.getInstance().removeAllActions();
             ExperimentLogic.getInstance().DelAllPackage();
             ErrorSystem.WriteActError("系统急停!请重新开机", true, false, 999999);
             start();
         });
         task.Start();
     }
 }
示例#4
0
 public void runLoop(double time)
 {
     lock (lockObj)
     {
         occupydev_list.Clear();
         //运行动作
         double dt = time - lasttime;
         for (int i = 0; i < actionlist.Count; i++)
         {
             //设备动作冲突解决
             bool is_occupy = false;
             bool is_sleep  = actionlist[i].getRuningSleepAct().Count != 0;
             //占用设备不运行
             System.Diagnostics.Debug.Assert(actionlist[i].node != null);
             if (findDevInOccList(actionlist[i].node) && is_sleep == false)
             {
                 continue;
             }
             is_occupy = getAllRuningActionsCount(actionlist[i].node, actionlist[i]) != 0;
             if (actionlist[i].isstop == false && (is_occupy == false || is_sleep))
             {
                 if (!actionlist[i].isInit())
                 {
                     actionlist[i].init();
                 }
                 if (actionlist[i].istimeout == false)
                 {
                     actionlist[i].run(dt);
                     if (is_sleep == false)
                     {
                         occupydev_list.Add(actionlist[i].node);
                     }
                 }
             }
         }
         //删除完成的动作
         for (int i = actionlist.Count - 1; i >= 0; i--)
         {
             bool isdelete = actionlist[i].getIsDelete();
             if (actionlist[i].isfinish || isdelete)
             {
                 var actiontem = actionlist[i];
                 if (isdelete)
                 {
                     ExperimentLogic.getInstance().DrodAllPackage(actiontem.exp_pack);
                 }
                 actionlist.Remove(actiontem);
                 actiontem.Destroy();
             }
         }
         //添加新动作
         actionlist = actionlist.Concat(actiontemlist).ToList <ActionBase>();
         actiontemlist.Clear();
         if (is_sort)
         {
             actionlist.Sort((a, b) => { return(a.sort_index > b.sort_index ? 1 : -1); });
             is_sort = false;
         }
         lasttime = time;
     }
 }