//离心开始逻辑
        public bool CenRunLogic(CentrifugeMDevice cendev)
        {
            bool is_allcenact = true;  //是否全是离心动作
            bool is_allputok  = true;  //是否全是已放好
            bool is_empty     = true;  //是否为空
            bool is_gelfull   = false; //是否已满
            bool is_gelsoon   = false; //是否有卡快要离心
            int  gel_count    = 0;
            List <ResInfoData> resinfo_list = new List <ResInfoData>();

            if (experiment_package_list.Count == 0)
            {
                return(false);
            }
            foreach (var seat in resmanager.centrifuge_list)
            {
                if (seat.Code == cendev.Centrifugem.Code.SetValue)
                {
                    for (int i = 0; i < seat.Values.Length; i++)
                    {
                        ResInfoData resinfo = (ResInfoData)seat.Values[i, 0];
                        if (resinfo != null && resinfo.PutOk)
                        {
                            is_empty = false;
                            var exp_pack = GetExpPackageByMask(resinfo.GetGelMask());
                            if (exp_pack == null)
                            {
                                exp_pack = GetExpPackageByMask(resinfo.GetCodeAt(0));
                            }
                            System.Diagnostics.Debug.Assert(exp_pack != null);
                            if (exp_pack == null)
                            {
                                return(false);
                            }
                            is_allcenact = is_allcenact && exp_pack.GetActionTypeAt(0) == TestStepEnum.ZKDLXJ;
                            is_allputok  = is_allputok && resinfo.PutOk;
                            resinfo_list.Add(resinfo);
                            gel_count++;
                        }
                    }
                    is_gelfull = gel_count >= seat.Values.Length;
                }
            }
            if ((is_gelfull == false && actionmanager.getAllActionsCount(handDevice) != 0) || actionmanager.getAllActionsCount(cendev) != 0)
            {
                return(false);
            }
            //普通卡位是否有卡快要离心
            foreach (var seat in resmanager.gelseat_list)
            {
                for (int i = 0; i < seat.Values.Length; i++)
                {
                    ResInfoData resinfo = (ResInfoData)seat.Values[i, 0];
                    if (resinfo != null && resinfo.PutOk && resinfo.FindCode("pei*", false) == false)
                    {
                        var exp_pack = GetExpPackageByMask(resinfo.GetGelMask());
                        if (exp_pack == null)
                        {
                            continue;
                        }
                        is_gelsoon = (exp_pack.GetActionTypeAt(0) == TestStepEnum.ZKDLXJ) ||
                                     (exp_pack.GetActionTypeAt(0) == TestStepEnum.ZKDFY &&
                                      exp_pack.GetActionTypeAt(1) == TestStepEnum.ZKDLXJ &&
                                      exp_pack.hatch_time - exp_pack.hatch_cur_time <= 20000);
                        if (seat.Purpose == 4 && exp_pack.FindAct(TestStepEnum.ZKDLXJ) && exp_pack.FindAct(TestStepEnum.ZKDFY) == false)
                        {
                            is_gelsoon = true;
                        }
                        if (is_gelsoon)
                        {
                            break;
                        }
                    }
                }
                if (is_gelsoon)
                {
                    break;
                }
            }
            //检测是否满足运行条件
            if (is_allcenact && is_allputok && !is_empty && (!is_gelsoon || is_gelfull))
            {
                int hspeed  = (int)cendev.Centrifugem.HightSpeed.SetValue;
                int lspeed  = (int)cendev.Centrifugem.LowSpeed.SetValue;
                int htime   = (int)cendev.Centrifugem.HightSpeedTime.SetValue;
                int ltime   = (int)cendev.Centrifugem.LowSpeedTime.SetValue;
                int uphtime = (int)cendev.Centrifugem.AddHSpeedTime.SetValue;
                int upltime = (int)cendev.Centrifugem.AddLSpeedTime.SetValue;
                int stime   = (int)cendev.Centrifugem.StopSpeedTime.SetValue;
                //配平卡动作(如果离心机内卡是单数就再放一张配平卡)
                var seque_pei = Sequence.create();
                var seque     = Sequence.create();
                if (resinfo_list.Count() % 2 != 0)
                {
                    var spaw      = Spawn.create();
                    var put_seque = Sequence.create();
                    //得到配平卡
                    var         pei_gel  = resmanager.GetResByCode("pei" + cendev.Centrifugem.Code.SetValue, "T_BJ_GelSeat");
                    var         put_gel  = generater.GenerateTakeGelFromNormal(pei_gel, ref put_seque);
                    T_GelStep[] pei_step = { new T_GelStep(), new T_GelStep() };
                    pei_step[0].StepClass = TestStepEnum.ZKDLXJ;
                    pei_step[1].StepClass = TestStepEnum.PutPeiGelBack;
                    var exp_pack = ExperimentPackage.Create(pei_step.ToList(), pei_gel.GetCodeAt(0), "123", 8, 0, 1, 0, false, 0, 0, false);
                    exp_pack.is_jyjs = true;
                    experiment_package_list.Add(exp_pack);
                    resinfo_list.Add(put_gel);
                    var put_seat = resmanager.GetResByCode("null", "T_BJ_Centrifuge", cendev.Centrifugem.Code.SetValue);
                    spaw.AddAction(put_seque);
                    spaw.AddAction(MoveTo.create(cendev, 30001, -1, -1, put_seat.CenGelP[put_seat.CountX]));
                    seque_pei.AddAction(spaw);
                    generater.GeneratePutGelToCent(cendev.Centrifugem.Code.SetValue, put_seat, put_gel, ref seque_pei);
                }
                seque_pei.AddAction(HandOpenCloseDoor.create(handDevice, 5000, cendev.Centrifugem.Code.SetValue, false));
                seque.AddAction(SkWaitForAction.create(handDevice, seque_pei));
                seque.AddAction(CentrifugeStart.create(cendev, 6000000, hspeed, lspeed, htime, ltime, uphtime, upltime, stime));
                seque.AddAction(SkCallBackFun.create((ActionBase acttem) =>
                {
                    foreach (var resinfo in resinfo_list)
                    {
                        var exp_pack = GetExpPackageByMask(resinfo.GetGelMask());
                        if (exp_pack == null)
                        {
                            exp_pack = GetExpPackageByMask(resinfo.GetCodeAt(0));
                        }
                        System.Diagnostics.Debug.Assert(exp_pack != null);
                        var act   = exp_pack.GetActionAt(0);
                        act.State = 2;
                    }
                    return(true);
                }));
                seque_pei.runAction(handDevice);
                seque.runAction(cendev);
                return(true);
            }
            return(false);
        }
Пример #2
0
        //把转换为action point
        public ActionPoint GelStepToActionPoint(T_GelStep gel_step, TestStepEnum type)
        {
            if (gel_step.StepClass == TestStepEnum.FPYT && gel_step.GetLiquidInfo().IsDetector&& type != TestStepEnum.MixLiquid && type != TestStepEnum.SpuLiquid)
            {
                type = TestStepEnum.FollowAbsLiquid;
            }
            ActionPoint action_point = new ActionPoint(-1, -1, -1, type);
            var         resmanager   = ResManager.getInstance();
            var         exp_pack     = ((ExperimentPackage)gel_step.ExperPackage);

            if (gel_step.StepClass == TestStepEnum.FPYT)
            {
                //是否为混合
                bool is_mix     = gel_step.is_mix;
                var  fpytinfo   = gel_step.GetFpytInfo();
                var  liquidinfo = gel_step.GetLiquidInfo();
                action_point.deep         = (int)liquidinfo.Deep;
                action_point.deepspeed    = (int)liquidinfo.DeeSpeed;
                action_point.detectordeep = (int)liquidinfo.DetectorDeep;
                action_point.tube         = (int)(fpytinfo.TubeValue >> gel_step.SampleIndex);
                action_point.capacity     = (int)liquidinfo.Vol;
                action_point.absbspeed    = (int)liquidinfo.AbsSpeed;
                action_point.spuspeed     = (int)liquidinfo.SpuSpeed;
                action_point.backcapacity = (int)liquidinfo.BackCapacity;
                action_point.backspeed    = (int)liquidinfo.BackCapacitySpeed;
                action_point.mixtimes     = (int)(gel_step.is_spu?fpytinfo.MixTimes:0);
                action_point.mixdeep      = (int)fpytinfo.MixDeep;
                action_point.spucapacity  = (int)fpytinfo.Vol;
                if (action_point.type == TestStepEnum.AbsLiquid || action_point.type == TestStepEnum.FollowAbsLiquid)
                {
                    ResInfoData abs_tager = null;//吸取的液体
                    if (liquidinfo.LiquidType == "病人红细胞" || liquidinfo.LiquidType == "病人血清")
                    {
                        abs_tager = resmanager.GetResByCode(exp_pack.GetSampleCode(gel_step.SampleIndex), "T_BJ_SampleRack");
                    }
                    else
                    {
                        abs_tager = resmanager.GetResByCode(liquidinfo.LiquidType, "T_BJ_AgentiaWarehouse");
                    }
                    System.Diagnostics.Debug.Assert(abs_tager != null);
                    action_point.x = abs_tager.InjectorX;
                    action_point.y = abs_tager.InjectorY;
                    action_point.z = abs_tager.InjectorZ;
                }
                else if (action_point.type == TestStepEnum.MixLiquid)
                {
                    //查找deep盘
                    ResInfoData deep_plane = resmanager.GetResByCode(gel_step.MixCode, "T_BJ_DeepPlate");
                    if (deep_plane == null)
                    {
                        //deep_plane = resmanager.GetFreeDeepPlate(5);
                        deep_plane = resmanager.GetResByCode("null", "T_BJ_DeepPlate");
                        deep_plane.Values[deep_plane.CountX, deep_plane.CountY] = deep_plane;
                    }
                    System.Diagnostics.Debug.Assert(deep_plane != null);
                    if (deep_plane.FindCode(gel_step.MixCode, false) == false)
                    {
                        deep_plane.AddCode(gel_step.MixCode);
                    }
                    action_point.x = deep_plane.InjectorX;
                    action_point.y = deep_plane.InjectorY;
                    action_point.z = deep_plane.InjectorZ;
                }
                else if (action_point.type == TestStepEnum.SpuLiquid)
                {
                    //查找gel卡
                    ResInfoData gel_seat = resmanager.GetResByCode(exp_pack.GetGelMask(), "T_BJ_GelSeat");
                    System.Diagnostics.Debug.Assert(gel_seat != null);
                    action_point.x        = gel_seat.InjectorX;
                    action_point.y        = gel_seat.InjectorY;
                    action_point.z        = gel_seat.InjectorZ;
                    action_point.tube_gap = gel_seat.InjectorGap;
                }
            }
            return(action_point);
        }