コード例 #1
0
        public (bool isSuccess, string result) processCarOutScenario(MaintainSpace mtx, AVEHICLE preCarOutVh)
        {
            string pre_car_out_vh_id          = preCarOutVh.VEHICLE_ID;
            string pre_car_out_vh_ohtc_cmd_id = preCarOutVh.OHTC_CMD;
            string pre_car_out_vh_cur_adr_id  = preCarOutVh.CUR_ADR_ID;
            bool   isSuccess;
            string result = "";

            mtx.CancelCarOutRequest = false;
            mtx.CarOurSuccess       = false;
            mtx.SetCarOutInterlock(true);
            isSuccess = VehicleService.doReservationVhToMaintainsSpace(pre_car_out_vh_id);
            if (isSuccess && SCUtility.isEmpty(pre_car_out_vh_ohtc_cmd_id))
            {
                //在收到OHT的ID:132-命令結束後或者在變為AutoLocal後此時OHT沒有命令的話則會呼叫此Function來創建一個Transfer command,讓Vh移至移動至System out上
                isSuccess = VehicleService.doAskVhToSystemOutAddress(pre_car_out_vh_id, mtx.MTS_ADDRESS);
            }
            if (isSuccess)
            {
                //carOutVhID = pre_car_out_vh_id;
                mtx.PreCarOutVhID = pre_car_out_vh_id;
                Task.Run(() => RegularUpdateRealTimeCarInfo(mtx, preCarOutVh));
            }
            else
            {
                mtx.SetCarOutInterlock(false);
                isSuccess = false;
                result    = $"Reservation vh to mtl fail.";
            }

            return(isSuccess, result);
        }
コード例 #2
0
 private void CarOutFinish(MaintainSpace mtx)
 {
     LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTLService), Device: SCAppConstants.DeviceName.DEVICE_NAME_MTx,
                   Data: $"Process CarOutFinish!",
                   XID: mtx.DeviceID);
     mtx.SetCarOutInterlock(false);
 }
コード例 #3
0
        public (bool isSuccess, string result) processCarOutScenario(MaintainLift mtx, AVEHICLE preCarOutVh)
        {
            string pre_car_out_vh_id          = preCarOutVh.VEHICLE_ID;
            string pre_car_out_vh_ohtc_cmd_id = preCarOutVh.OHTC_CMD;
            string pre_car_out_vh_cur_adr_id  = preCarOutVh.CUR_ADR_ID;
            bool   isSuccess;
            string result = "OK";

            mtx.CancelCarOutRequest = false;
            mtx.CarOurSuccess       = false;
            CarOutStart(mtx);
            //接著要開始等待MTS的兩個門都放下來之後,才可以將OHT開過來
            if (mtx.DokingMaintainDevice is MaintainSpace)
            {
                MaintainSpace dockingMaintainSpace = mtx.DokingMaintainDevice as MaintainSpace;
                if (!SpinWait.SpinUntil(() => dockingMaintainSpace.MTSBackDoorStatus == MTSDoorStatus.Open &&
                                        dockingMaintainSpace.MTSFrontDoorStatus == MTSDoorStatus.Open,
                                        MTS_DOOR_OPEN_TIME_OUT_ms))
                {
                    isSuccess = false;
                    result    = $"Process car out scenario,but mts:{dockingMaintainSpace.DeviceID} status not ready " +
                                $"{nameof(dockingMaintainSpace.MTSBackDoorStatus)}:{dockingMaintainSpace.MTSBackDoorStatus}," +
                                $"{nameof(dockingMaintainSpace.MTSFrontDoorStatus)}:{dockingMaintainSpace.MTSFrontDoorStatus}";
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Warn, Class: nameof(MTLService), Device: SCAppConstants.DeviceName.DEVICE_NAME_MTx,
                                  Data: result,
                                  XID: dockingMaintainSpace.DeviceID);
                    CarOutFinish(mtx);
                    return(isSuccess, result);
                }
            }

            //isSuccess = VehicleService.doReservationVhToMaintainsBufferAddress(pre_car_out_vh_id, MTL_CAR_OUT_BUFFER_ADDRESS);
            isSuccess = VehicleService.doReservationVhToMaintainsBufferAddress(pre_car_out_vh_id, mtx.MTL_SYSTEM_OUT_ADDRESS);
            if (isSuccess && SCUtility.isEmpty(pre_car_out_vh_ohtc_cmd_id))
            {
                //在收到OHT的ID:132-命令結束後或者在變為AutoLocal後此時OHT沒有命令的話則會呼叫此Function來創建一個Transfer command,讓Vh移至移動至System out上
                if (SCUtility.isMatche(pre_car_out_vh_cur_adr_id, mtx.MTL_SYSTEM_OUT_ADDRESS))
                {
                    VehicleService.doAskVhToMaintainsAddress(pre_car_out_vh_id, mtx.MTL_ADDRESS);
                }
                else
                {
                    VehicleService.doAskVhToSystemOutAddress(pre_car_out_vh_id, mtx.MTL_SYSTEM_OUT_ADDRESS);
                }
            }
            if (isSuccess)
            {
                //carOutVhID = pre_car_out_vh_id;
                mtx.PreCarOutVhID = pre_car_out_vh_id;
                Task.Run(() => RegularUpdateRealTimeCarInfo(mtx, preCarOutVh));
            }
            else
            {
                //mtx.SetCarOutInterlock(false);
                CarOutFinish(mtx);
                isSuccess = false;
                result    = $"Reservation vh to mtl fail.";
            }
            return(isSuccess, result);
        }
コード例 #4
0
        private void cmb_mts_SelectedIndexChanged(object sender, EventArgs e)
        {
            string device_id = (sender as ComboBox).Text;

            MTS = bcApp.SCApplication.getEQObjCacheManager().getEquipmentByEQPTID(device_id) as MaintainSpace;
            MTSValueDefMapActionBase = MTS.getMapActionByIdentityKey(nameof(MTSValueDefMapActionNew)) as MTxValueDefMapActionBase;
        }
コード例 #5
0
        public (bool isSuccess, string result) processCarOutScenario(MaintainSpace mtx, AVEHICLE preCarOutVh)
        {
            string pre_car_out_vh_id          = preCarOutVh.VEHICLE_ID;
            string pre_car_out_vh_ohtc_cmd_id = preCarOutVh.OHTC_CMD;
            string pre_car_out_vh_cur_adr_id  = preCarOutVh.CUR_ADR_ID;
            bool   isSuccess;
            string result = "";

            mtx.CancelCarOutRequest = false;
            mtx.CarOurSuccess       = false;

            if (!SpinWait.SpinUntil(() => mtx.CarOutSafetyCheck == true, 30000))
            {
                isSuccess = false;
                result    = $"Process car out scenario,but mts:{mtx.DeviceID} status not ready " +
                            $"{nameof(mtx.CarOutSafetyCheck)}:{mtx.CarOutSafetyCheck}";
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTLService), Device: SCAppConstants.DeviceName.DEVICE_NAME_MTx,
                              Data: result,
                              XID: mtx.DeviceID);
                return(false, result);
            }

            CarOutStart(mtx);
            //if (!SpinWait.SpinUntil(() => mtx.MTSBackDoorStatus == MTSDoorStatus.Open, 20000))
            //需要判斷MTS的門是否已經開啟
            if (!SpinWait.SpinUntil(() => mtx.MTSBackDoorStatus == MTSDoorStatus.Open, MTS_DOOR_OPEN_TIME_OUT_ms))
            {
                result = $"mts:{mtx.DeviceID}, status not ready  {nameof(mtx.MTSBackDoorStatus)}:{mtx.MTSBackDoorStatus} after interlock on 20 sec, can't excute car out";
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTLService), Device: SCAppConstants.DeviceName.DEVICE_NAME_MTx,
                              Data: result,
                              XID: mtx.DeviceID);
                CarOutFinish(mtx);
                return(false, result);
            }
            isSuccess = VehicleService.doReservationVhToMaintainsSpace(pre_car_out_vh_id);
            if (isSuccess && SCUtility.isEmpty(pre_car_out_vh_ohtc_cmd_id))
            {
                //在收到OHT的ID:132-命令結束後或者在變為AutoLocal後此時OHT沒有命令的話則會呼叫此Function來創建一個Transfer command,讓Vh移至移動至System out上
                isSuccess = VehicleService.doAskVhToSystemOutAddress(pre_car_out_vh_id, mtx.MTS_ADDRESS);
            }
            if (isSuccess)
            {
                //carOutVhID = pre_car_out_vh_id;
                mtx.PreCarOutVhID = pre_car_out_vh_id;
                Task.Run(() => RegularUpdateRealTimeCarInfo(mtx, preCarOutVh));
            }
            else
            {
                //mtx.SetCarOutInterlock(false);
                CarOutFinish(mtx);
                isSuccess = false;
                result    = $"Reservation vh to mtl fail.";
            }
            return(isSuccess, result);
        }
コード例 #6
0
 private void CarInFinish(MaintainSpace mts)
 {
     LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTLService), Device: SCAppConstants.DeviceName.DEVICE_NAME_MTx,
                   Data: $"Process CarInFinish!",
                   XID: mts.DeviceID);
     mts.SetCarInMoving(false);
     if (mts.DokingMaintainDevice != null)
     {
         if (mts.DokingMaintainDevice is MaintainLift)
         {
             mts.DokingMaintainDevice.SetCarOutInterlock(false);
         }
     }
 }
コード例 #7
0
        public void start(SCApplication app)
        {
            scApp = app;
            List <AEQPT> eqpts = app.getEQObjCacheManager().getAllEquipment();

            foreach (var eqpt in eqpts)
            {
                if (eqpt is IMaintainDevice)
                {
                    IMaintainDevice maintainDevice = eqpt as IMaintainDevice;
                    if (maintainDevice is MaintainSpace)
                    {
                        MaintainSpace maintainSpace = eqpt as MaintainSpace;
                        maintainSpace.addEventHandler(nameof(MTLService), nameof(maintainSpace.Plc_Link_Stat), PublishMTSInfo);
                        maintainSpace.addEventHandler(nameof(MTLService), nameof(maintainSpace.Is_Eq_Alive), PublishMTSInfo);
                        maintainSpace.addEventHandler(nameof(MTLService), nameof(maintainSpace.MTxMode), PublishMTSInfo);
                        maintainSpace.addEventHandler(nameof(MTLService), nameof(maintainSpace.Interlock), PublishMTSInfo);
                        maintainSpace.addEventHandler(nameof(MTLService), nameof(maintainSpace.CurrentCarID), PublishMTSInfo);
                        maintainSpace.addEventHandler(nameof(MTLService), nameof(maintainSpace.CurrentPreCarOurDistance), PublishMTSInfo);
                        maintainSpace.addEventHandler(nameof(MTLService), nameof(maintainSpace.SynchronizeTime), PublishMTSInfo);
                        maintainSpace.addEventHandler(nameof(MTLService), nameof(maintainSpace.CarOutInterlock), PublishMTSInfo);
                        maintainSpace.addEventHandler(nameof(MTLService), nameof(maintainSpace.CarInMoving), PublishMTSInfo);
                    }
                    else if (maintainDevice is MaintainLift)
                    {
                        MaintainLift maintainLift = eqpt as MaintainLift;
                        maintainLift.addEventHandler(nameof(MTLService), nameof(maintainLift.Plc_Link_Stat), PublishMTLInfo);
                        maintainLift.addEventHandler(nameof(MTLService), nameof(maintainLift.Is_Eq_Alive), PublishMTLInfo);
                        maintainLift.addEventHandler(nameof(MTLService), nameof(maintainLift.MTxMode), PublishMTLInfo);
                        maintainLift.addEventHandler(nameof(MTLService), nameof(maintainLift.Interlock), PublishMTLInfo);
                        maintainLift.addEventHandler(nameof(MTLService), nameof(maintainLift.CurrentCarID), PublishMTLInfo);
                        maintainLift.addEventHandler(nameof(MTLService), nameof(maintainLift.MTLLocation), PublishMTLInfo);
                        maintainLift.addEventHandler(nameof(MTLService), nameof(maintainLift.CurrentPreCarOurDistance), PublishMTLInfo);
                        maintainLift.addEventHandler(nameof(MTLService), nameof(maintainLift.SynchronizeTime), PublishMTLInfo);
                        maintainLift.addEventHandler(nameof(MTLService), nameof(maintainLift.CarOutInterlock), PublishMTLInfo);
                        maintainLift.addEventHandler(nameof(MTLService), nameof(maintainLift.CarInMoving), PublishMTLInfo);
                    }
                }
            }

            VehicleService = app.VehicleService;
            vehicleBLL     = app.VehicleBLL;
            reportBLL      = app.ReportBLL;
            //  mtl = app.getEQObjCacheManager().getEquipmentByEQPTID("MTL") as MaintainLift;
        }
コード例 #8
0
 private void interlock_change_refreshUI()
 {
     try
     {
         MaintainLift MTL = app.ObjCacheManager.GetMTLMTSByID("MTL") as MaintainLift;
         //displayForInterlock(MTL.EQPT_ID, MTL.Interlock);
         displayForInterlockNew(MTL.EQPT_ID, MTL.CarOutSafetyCheck, MTL.CarInMoving);
         MaintainSpace MTS = app.ObjCacheManager.GetMTLMTSByID("MTS") as MaintainSpace;
         //displayForInterlock(MTS.EQPT_ID, MTS.Interlock);
         displayForInterlockNew(MTS.EQPT_ID, MTS.CarOutSafetyCheck, MTS.CarInMoving);
         MaintainSpace MTS2 = app.ObjCacheManager.GetMTLMTSByID("MTS2") as MaintainSpace;
         //displayForInterlock(MTS2.EQPT_ID, MTS2.Interlock);
         displayForInterlockNew(MTS2.EQPT_ID, MTS2.CarOutSafetyCheck, MTS2.CarInMoving);
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
     }
 }
        private void refreshUI()
        {
            grid_MTLMTS1.Items.Refresh();
            grid_MTS2.Items.Refresh();

            MaintainLift MTL = app.ObjCacheManager.GetMTLMTSByID("MTL") as MaintainLift;

            displayForInterlock(MTL.EQPT_ID, MTL.Interlock);
            displayForVehicleLift(MTL.EQPT_ID, MTL.MTLLocation.ToString(), !string.IsNullOrWhiteSpace(MTL.CurrentCarID));

            MaintainSpace MTS = app.ObjCacheManager.GetMTLMTSByID("MTS") as MaintainSpace;

            displayForInterlock(MTS.EQPT_ID, MTS.Interlock);
            displayForVehicleLift(MTS.EQPT_ID, null, !string.IsNullOrWhiteSpace(MTS.CurrentCarID));
            MaintainSpace MTS2 = app.ObjCacheManager.GetMTLMTSByID("MTS2") as MaintainSpace;

            displayForInterlock(MTS2.EQPT_ID, MTS2.Interlock);
            displayForVehicleLift(MTS2.EQPT_ID, null, !string.IsNullOrWhiteSpace(MTS2.CurrentCarID));
        }
コード例 #10
0
 public void PublishMTSInfo(object sender, PropertyChangedEventArgs e)
 {
     try
     {
         MaintainSpace eqpt = sender as MaintainSpace;
         if (sender == null)
         {
             return;
         }
         byte[] line_serialize = BLL.LineBLL.Convert2GPB_MTLMTSInfo(eqpt);
         scApp.getNatsManager().PublishAsync
             (SCAppConstants.NATS_SUBJECT_MTLMTS, line_serialize);
         //TODO 要改用GPP傳送
         //var line_Serialize = ZeroFormatter.ZeroFormatterSerializer.Serialize(line);
         //scApp.getNatsManager().PublishAsync
         //    (string.Format(SCAppConstants.NATS_SUBJECT_LINE_INFO), line_Serialize);
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception:");
     }
 }
コード例 #11
0
        public void processCarInScenario(MaintainSpace mts)
        {
            //在收到MTL的 Car in safety check後,就可以叫Vh移動至Car in 的buffer區(MTL Home)
            //不過要先判斷vh是否已經在Auto模式下如果是則先將它變成AutoLocal的模式
            if (!SpinWait.SpinUntil(() => mts.CarInSafetyCheck && mts.MTxMode == MTxMode.Auto, 10000))
            {
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTLService), Device: "OHTC",
                              Data: $"mts:{mts.DeviceID}, status not ready  CarInSafetyCheck:{mts.CarInSafetyCheck},Mode:{mts.MTxMode} ,can't excute car in",
                              XID: mts.DeviceID);
                return;
            }
            AVEHICLE car_in_vh = vehicleBLL.cache.getVhByAddressID(mts.MTS_ADDRESS);

            if (car_in_vh != null && car_in_vh.isTcpIpConnect)
            {
                if (car_in_vh.MODE_STATUS == ProtocolFormat.OHTMessage.VHModeStatus.Manual)
                {
                    VehicleService.ModeChangeRequest(car_in_vh.VEHICLE_ID, ProtocolFormat.OHTMessage.OperatingVHMode.OperatingAuto);

                    if (SpinWait.SpinUntil(() => car_in_vh.MODE_STATUS == VHModeStatus.AutoMts, 10000))
                    {
                        mts.SetCarInMoving(true);
                        VehicleService.doAskVhToSystemInAddress(car_in_vh.VEHICLE_ID, mts.MTS_SYSTEM_IN_ADDRESS);
                    }
                    else
                    {
                        LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTLService), Device: "OHTC",
                                      Data: $"Process car in scenario:{mts.DeviceID} fail. ask vh change to auto mode time out",
                                      VehicleID: car_in_vh.VEHICLE_ID);
                    }
                }
                else if (car_in_vh.MODE_STATUS == ProtocolFormat.OHTMessage.VHModeStatus.AutoMts)
                {
                    mts.SetCarInMoving(true);
                    VehicleService.doAskVhToSystemInAddress(car_in_vh.VEHICLE_ID, mts.MTS_SYSTEM_IN_ADDRESS);
                }
            }
        }
コード例 #12
0
        public void putMTL_MTSCheckInfo(sc.ProtocolFormat.OHTMessage.MTL_MTS_INFO newMTLMTSInfo)
        {
            if (newMTLMTSInfo == null)
            {
                return;
            }
            AEQPT eqpt = Eqpts.Where(e => e.EQPT_ID == newMTLMTSInfo.StationID.Trim()).SingleOrDefault();

            if (eqpt is MaintainSpace)
            {
                MaintainSpace MTS = eqpt as MaintainSpace;
                MTS.Plc_Link_Stat            = newMTLMTSInfo.NetworkLink ? sc.App.SCAppConstants.LinkStatus.LinkOK : sc.App.SCAppConstants.LinkStatus.LinkFail;
                MTS.Is_Eq_Alive              = newMTLMTSInfo.Alive;
                MTS.MTxMode                  = newMTLMTSInfo.Mode ? sc.ProtocolFormat.OHTMessage.MTxMode.Auto : sc.ProtocolFormat.OHTMessage.MTxMode.Manual;
                MTS.Interlock                = newMTLMTSInfo.Interlock;
                MTS.CurrentCarID             = newMTLMTSInfo.CarID;
                MTS.CurrentPreCarOurDistance = Convert.ToUInt32(newMTLMTSInfo.Distance);
                MTS.SynchronizeTime          = Convert.ToDateTime(newMTLMTSInfo.SynchronizeTime);
                MTS.CarOutInterlock          = newMTLMTSInfo.CarOutInterlock;
                MTS.CarInMoving              = newMTLMTSInfo.CarInMoving;
            }
            else if (eqpt is MaintainLift)
            {
                MaintainLift MTL = eqpt as MaintainLift;
                MTL.Plc_Link_Stat            = newMTLMTSInfo.NetworkLink ? sc.App.SCAppConstants.LinkStatus.LinkOK : sc.App.SCAppConstants.LinkStatus.LinkFail;
                MTL.Is_Eq_Alive              = newMTLMTSInfo.Alive;
                MTL.MTxMode                  = newMTLMTSInfo.Mode ? sc.ProtocolFormat.OHTMessage.MTxMode.Auto : sc.ProtocolFormat.OHTMessage.MTxMode.Manual;
                MTL.Interlock                = newMTLMTSInfo.Interlock;
                MTL.CurrentCarID             = newMTLMTSInfo.CarID;
                MTL.MTLLocation              = newMTLMTSInfo.MTLLocation == MTLLocation.Bottorn.ToString() ? MTLLocation.Bottorn : newMTLMTSInfo.MTLLocation == MTLLocation.Upper.ToString() ? MTLLocation.Upper : MTLLocation.None;
                MTL.CurrentPreCarOurDistance = Convert.ToUInt32(newMTLMTSInfo.Distance);
                MTL.SynchronizeTime          = Convert.ToDateTime(newMTLMTSInfo.SynchronizeTime);
                MTL.CarOutInterlock          = newMTLMTSInfo.CarOutInterlock;
                MTL.CarInMoving              = newMTLMTSInfo.CarInMoving;
            }

            MTLMTSInfoUpdate?.Invoke(this, EventArgs.Empty);
        }
コード例 #13
0
 public virtual void setContext(BaseEQObject baseEQ)
 {
     this.eqpt = baseEQ as MaintainSpace;
 }
コード例 #14
0
        private void refreshUI()
        {
            try
            {
                grid_MTLMTS1.Items.Refresh();
                grid_MTS2.Items.Refresh();

                MaintainLift MTL = app.ObjCacheManager.GetMTLMTSByID("MTL") as MaintainLift;
                //displayForInterlock(MTL.EQPT_ID, MTL.Interlock);
                displayForInterlockNew(MTL.EQPT_ID, MTL.CarOutSafetyCheck, MTL.CarInMoving);
                displayForVehicleLift(MTL.EQPT_ID, MTL.MTLLocation.ToString(), !string.IsNullOrWhiteSpace(MTL.CurrentCarID));

                MaintainSpace MTS = app.ObjCacheManager.GetMTLMTSByID("MTS") as MaintainSpace;
                //displayForInterlock(MTS.EQPT_ID, MTS.Interlock);
                displayForInterlockNew(MTS.EQPT_ID, MTS.CarOutSafetyCheck, MTS.CarInMoving);
                displayForVehicleLift(MTS.EQPT_ID, null, !string.IsNullOrWhiteSpace(MTS.CurrentCarID));
                MaintainSpace MTS2 = app.ObjCacheManager.GetMTLMTSByID("MTS2") as MaintainSpace;
                //displayForInterlock(MTS2.EQPT_ID, MTS2.Interlock);
                displayForInterlockNew(MTS2.EQPT_ID, MTS2.CarOutSafetyCheck, MTS2.CarInMoving);
                displayForVehicleLift(MTS2.EQPT_ID, null, !string.IsNullOrWhiteSpace(MTS2.CurrentCarID));
                grid_CMDDetail.Items.Refresh();
                //if (cb_VehicleID.SelectedItem != null)
                //{
                //    string select_vh_id = (string)cb_VehicleID.SelectedItem;
                //    if (!string.IsNullOrEmpty(select_vh_id))
                //    {
                //        AVEHICLE select_vh = app.ObjCacheManager.GetVEHICLE(select_vh_id);
                //        if (!select_vh.isTcpIpConnect)
                //        {
                //            btn_CarOutReq.IsEnabled = false;
                //        }
                //        else
                //        {
                //            btn_CarOutReq.IsEnabled = true;
                //        }
                //        //if (select_vh.MODE_STATUS == VHModeStatus.AutoRemote)
                //        //{
                //        //    btn_AutoR.IsEnabled = false;
                //        //    btn_AutoMTS.IsEnabled = true;
                //        //    btn_AutoMTL.IsEnabled = true;
                //        //    btn_Cmd.IsEnabled = false;
                //        //    //cb_MvToStation.Items.Clear();
                //        //}
                //        //else if (select_vh.MODE_STATUS == VHModeStatus.AutoMts)
                //        //{
                //        //    btn_AutoR.IsEnabled = true;
                //        //    btn_AutoMTS.IsEnabled = false;
                //        //    btn_AutoMTL.IsEnabled = true;
                //        //    btn_Cmd.IsEnabled = true;
                //        //    //cb_MvToStation.Items.Clear();
                //        //    ////cb_MvToStation.Items.Add("MTS1");
                //        //    ////cb_MvToStation.Items.Add("MTS2");
                //        //}
                //        //else if (select_vh.MODE_STATUS == VHModeStatus.AutoMtl)
                //        //{
                //        //    btn_AutoR.IsEnabled = true;
                //        //    btn_AutoMTS.IsEnabled = true;
                //        //    btn_AutoMTL.IsEnabled = false;
                //        //    btn_Cmd.IsEnabled = true;
                //        //    //cb_MvToStation.Items.Clear();
                //        //    //cb_MvToStation.Items.Add("MTL1");
                //        //}
                //        //else
                //        //{
                //        //    btn_AutoR.IsEnabled = true;
                //        //    btn_AutoMTS.IsEnabled = true;
                //        //    btn_AutoMTL.IsEnabled = true;
                //        //    btn_Cmd.IsEnabled = false;
                //        //    //cb_MvToStation.Items.Clear();
                //        //}
                //    }
                //    else
                //    {
                //        //btn_AutoR.IsEnabled = false;
                //        //btn_AutoMTS.IsEnabled = false;
                //        //btn_AutoMTL.IsEnabled = false;
                //        //btn_Cmd.IsEnabled = false;
                //        btn_CarOutReq.IsEnabled = false;
                //        //cb_MvToStation.Items.Clear();
                //    }
                //}
                //else
                //{
                //    //btn_AutoR.IsEnabled = false;
                //    //btn_AutoMTS.IsEnabled = false;
                //    //btn_AutoMTL.IsEnabled = false;
                //    //btn_Cmd.IsEnabled = false;
                //    btn_CarOutReq.IsEnabled = false;
                //    //cb_MvToStation.Items.Clear();
                //}
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception");
            }
        }
コード例 #15
0
        public override void MTL_CarOutRequest(object sender, ValueChangedEventArgs args)
        {
            var recevie_function =
                scApp.getFunBaseObj <MtlToOHxC_MtlCarOutRepuest>(MTL.EQPT_ID) as MtlToOHxC_MtlCarOutRepuest;
            var send_function =
                scApp.getFunBaseObj <OHxCToMtl_MtlCarOutReply>(MTL.EQPT_ID) as OHxCToMtl_MtlCarOutReply;

            try
            {
                recevie_function.Read(bcfApp, MTL.EqptObjectCate, MTL.EQPT_ID);
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTLValueDefMapActionNew), Device: DEVICE_NAME_MTL,
                              Data: recevie_function.ToString(),
                              VehicleID: MTL.EQPT_ID);
                int    pre_car_out_vh_num = recevie_function.CarID;
                ushort hand_shake         = recevie_function.Handshake;
                if (hand_shake == 1)
                {
                    send_function.ReturnCode = 1;
                    if (recevie_function.Canacel == 1)
                    {
                        scApp.MTLService.carOutRequestCancle(MTL);
                        LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTSValueDefMapActionNew), Device: DEVICE_NAME_MTL,
                                      Data: $"Process MTL car out cancel",
                                      VehicleID: MTL.EQPT_ID);
                    }
                    else
                    {
                        AVEHICLE      pre_car_out_vh       = scApp.VehicleBLL.cache.getVhByNum(pre_car_out_vh_num);
                        MaintainSpace maintainSpace        = scApp.EquipmentBLL.cache.GetMaintainSpace();//todo 之後會有兩個MTS 要知道是哪個MTS
                        var           car_out_check_result = scApp.MTLService.checkVhAndMTxCarOutStatus(this.MTL, maintainSpace, pre_car_out_vh);
                        send_function.ReturnCode = car_out_check_result.isSuccess ? (ushort)1 : (ushort)2;
                        LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTLValueDefMapActionNew), Device: DEVICE_NAME_MTL,
                                      Data: $"Process MTL car out request, is success:{car_out_check_result.isSuccess},result:{car_out_check_result.result}",
                                      VehicleID: MTL.EQPT_ID);
                    }
                }
                else
                {
                    send_function.ReturnCode = 0;
                }
                send_function.Handshake = hand_shake == 0 ? (ushort)0 : (ushort)1;
                send_function.Write(bcfApp, MTL.EqptObjectCate, MTL.EQPT_ID);

                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTLValueDefMapActionNew), Device: DEVICE_NAME_MTL,
                              Data: send_function.ToString(),
                              VehicleID: MTL.EQPT_ID);
                MTL.SynchronizeTime = DateTime.Now;
                //if (send_function.Handshake == 1 && send_function.ReturnCode == 1)
                if (send_function.Handshake == 1 && send_function.ReturnCode == 1 && recevie_function.Canacel != 1)
                {
                    AVEHICLE pre_car_out_vh = scApp.VehicleBLL.cache.getVhByNum(pre_car_out_vh_num);
                    scApp.MTLService.processCarOutScenario(MTL, pre_car_out_vh);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception");
            }
            finally
            {
                scApp.putFunBaseObj <MtlToOHxC_MtlCarOutRepuest>(recevie_function);
                scApp.putFunBaseObj <OHxCToMtl_MtlCarOutReply>(send_function);
            }
        }
コード例 #16
0
        public void processCarInScenario(MaintainSpace mts)
        {
            CarInStart(mts);
            //在收到MTL的 Car in safety check後,就可以叫Vh移動至Car in 的buffer區(MTL Home)
            //不過要先判斷vh是否已經在Auto模式下如果是則先將它變成AutoLocal的模式
            if (!SpinWait.SpinUntil(() => mts.CarInSafetyCheck && mts.MTxMode == MTxMode.Auto, 10000))
            {
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Warn, Class: nameof(MTLService), Device: SCAppConstants.DeviceName.DEVICE_NAME_MTx,
                              Data: $"mts:{mts.DeviceID}, status not ready CarInSafetyCheck:{mts.CarInSafetyCheck},Mode:{mts.MTxMode} ,can't excute car in",
                              XID: mts.DeviceID);
                CarInFinish(mts);
                return;
            }

            //在車子要Car In的時候,要判斷MTS的前門是否已經開啟
            if (!SpinWait.SpinUntil(() => mts.MTSFrontDoorStatus == MTSDoorStatus.Open, MTS_DOOR_OPEN_TIME_OUT_ms))
            {
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTLService), Device: SCAppConstants.DeviceName.DEVICE_NAME_MTx,
                              Data: $"mts:{mts.DeviceID}, status not ready {nameof(mts.MTSFrontDoorStatus)}:{ mts.MTSFrontDoorStatus} ,can't excute car in",
                              XID: mts.DeviceID);
                CarInFinish(mts);
                return;
            }

            AVEHICLE car_in_vh = vehicleBLL.cache.getVhByAddressID(mts.MTS_ADDRESS);

            //if (car_in_vh != null && car_in_vh.isTcpIpConnect)
            if (car_in_vh != null)
            {
                if (car_in_vh.isTcpIpConnect)
                {
                    if (car_in_vh.MODE_STATUS == ProtocolFormat.OHTMessage.VHModeStatus.Manual)
                    {
                        VehicleService.ModeChangeRequest(car_in_vh.VEHICLE_ID, ProtocolFormat.OHTMessage.OperatingVHMode.OperatingAuto);

                        if (SpinWait.SpinUntil(() => car_in_vh.MODE_STATUS == VHModeStatus.AutoMts, 10000))
                        {
                            //mts.SetCarInMoving(true);
                            VehicleService.doAskVhToSystemInAddress(car_in_vh.VEHICLE_ID, mts.MTS_SYSTEM_IN_ADDRESS);
                        }
                        else
                        {
                            LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTLService), Device: SCAppConstants.DeviceName.DEVICE_NAME_MTx,
                                          Data: $"Process car in scenario:{mts.DeviceID} fail. ask vh change to auto mode time out",
                                          XID: mts.DeviceID,
                                          VehicleID: car_in_vh.VEHICLE_ID);
                            CarInFinish(mts);
                        }
                    }
                    else if (car_in_vh.MODE_STATUS == ProtocolFormat.OHTMessage.VHModeStatus.AutoMts)
                    {
                        //mts.SetCarInMoving(true);
                        VehicleService.doAskVhToSystemInAddress(car_in_vh.VEHICLE_ID, mts.MTS_SYSTEM_IN_ADDRESS);
                    }
                }
                else
                {
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTLService), Device: SCAppConstants.DeviceName.DEVICE_NAME_MTx,
                                  Data: $"Process car in scenario fail, mts:{mts.DeviceID}. because on mts of vh:{car_in_vh.VEHICLE_ID} is disconnect ",
                                  XID: mts.DeviceID,
                                  VehicleID: car_in_vh.VEHICLE_ID);
                    //mts.SetCarInMoving(false);
                    CarInFinish(mts);
                }
            }
            else
            {
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTLService), Device: SCAppConstants.DeviceName.DEVICE_NAME_MTx,
                              Data: $"Process car in scenario fail, mts:{mts.DeviceID}. because no vh in mts",
                              XID: mts.DeviceID);
                //mts.SetCarInMoving(false);
                CarInFinish(mts);
            }
        }