/// <summary>
        /// //找出目前所有Park Adr停車的 跟 欲前往的方便得知目前為何沒有停車位
        /// </summary>
        /// <param name="con"></param>
        private void ParkAdrInfoTarce()
        {
            //DBConnection_EF con = DBConnection_EF.GetContext();
            List <APARKZONEDETAIL> lstAllParkDetail = null;

            //using (DBConnection_EF con = new DBConnection_EF())
            using (DBConnection_EF con = DBConnection_EF.GetUContext())
            {
                lstAllParkDetail = parkZoneDetailDao.loadAllParkAdrByParkTypeID(con,
                                                                                scApp.getEQObjCacheManager().getLine().Currnet_Park_Type);
            }
            if (lstAllParkDetail == null)
            {
                return;
            }
            foreach (APARKZONEDETAIL detail in lstAllParkDetail)
            {
                string   park_adr    = detail.ADR_ID;
                string   parkingVhID = detail.CAR_ID ?? string.Empty;
                string   onWayVhID   = string.Empty;
                AVEHICLE onWayVh     = null;
                if (scApp.VehicleBLL.hasVhReserveParkAdr(park_adr, out onWayVh))
                {
                    onWayVhID = onWayVh.VEHICLE_ID;
                }
                string park_warn_info =
                    string.Format("Park adr:[{0}] ,Parking vh id:[{1}] ,On way vh id:[{2}]"
                                  , park_adr
                                  , parkingVhID
                                  , onWayVhID);
                logger_ParkBllLog.Info(park_warn_info);
            }
        }
コード例 #2
0
        private void btn_continuous_Click(object sender, EventArgs e)
        {
            //Equipment noticeCar = scApp.getEQObjCacheManager().getEquipmentByEQPTID(cmb_Vehicle.Text.Trim());
            string vh_id = cmb_Vehicle.Text.Trim();

            Task.Run(() =>
            {
                AVEHICLE noticeCar = scApp.getEQObjCacheManager().getVehicletByVHID(vh_id);

                if (noticeCar.IsPause)
                {
                    Common.LogHelper.Log(logger: NLog.LogManager.GetCurrentClassLogger(), LogLevel: LogLevel.Info, Class: nameof(OHT_Form), Device: "OHTC",
                                         Data: $"Send manual continuous to vh;{vh_id}");
                    scApp.VehicleService.PauseRequest(vh_id, PauseEvent.Continue, SCAppConstants.OHxCPauseType.Normal);
                    //noticeCar.sned_Str39(PauseEvent.Continue, PauseType.OhxC);
                }
                else
                {
                    //scApp.VehicleBLL.noticeVhPass(vh_id);
                    Common.LogHelper.Log(logger: NLog.LogManager.GetCurrentClassLogger(), LogLevel: LogLevel.Info, Class: nameof(OHT_Form), Device: "OHTC",
                                         Data: $"Send manual continuous(block release) to vh;{vh_id}");
                    scApp.VehicleService.noticeVhPass(vh_id);
                }
            });
        }
        private (bool isSuccess, string msg) askVhToCharging(AVEHICLE vh)
        {
            string   vh_current_address = vh.CUR_ADR_ID;
            AADDRESS current_adr        = addressesBLL.cache.GetAddress(vh.CUR_ADR_ID);

            if (current_adr != null &&
                current_adr is CouplerAddress && (current_adr as CouplerAddress).IsWork(unitBLL))
            {
                ICpuplerType cpupler = (current_adr as CouplerAddress);
                string       meg     = $"ask vh:{vh.VEHICLE_ID} to charging. but it is already in charger:{cpupler.ChargerID} ,cpupler num:{cpupler.CouplerNum}";
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                              Data: meg,
                              VehicleID: vh.VEHICLE_ID);
                return(false, meg);
            }
            bool   is_need_to_long_charge = vh.IsNeedToLongCharge();
            string best_coupler_adr       = findBestCoupler(vh_current_address, is_need_to_long_charge);

            LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                          Data: $"ask vh:{vh.VEHICLE_ID} to charging. coupler adr:{best_coupler_adr} ",
                          VehicleID: vh.VEHICLE_ID);
            if (!SCUtility.isEmpty(best_coupler_adr))
            {
                bool is_success = vehicleService.Command.MoveToCharge(vh.VEHICLE_ID, best_coupler_adr);
                return(is_success, "");
            }
            else
            {
                lineService.ProcessAlarmReport(vh, AlarmBLL.VEHICLE_CAN_NOT_FIND_THE_COUPLER_TO_CHARGING, ErrorStatus.ErrSet, $"vehicle:{vh.VEHICLE_ID} can't find coupler to charging");
                return(false, $"vehicle:{vh.VEHICLE_ID} can't find coupler to charging");
            }
        }
        public override void MTL_CarInRequest(object sender, ValueChangedEventArgs args)
        {
            var recevie_function =
                scApp.getFunBaseObj <MtlToOHxC_RequestCarInDataCheck>(MTS.EQPT_ID) as MtlToOHxC_RequestCarInDataCheck;
            var send_function =
                scApp.getFunBaseObj <OHxCToMtl_ReplyCarInDataCheck>(MTS.EQPT_ID) as OHxCToMtl_ReplyCarInDataCheck;

            try
            {
                recevie_function.Read(bcfApp, MTS.EqptObjectCate, MTS.EQPT_ID);
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTSValueDefMapActionNew), Device: DEVICE_NAME_MTL,
                              Data: recevie_function.ToString(),
                              VehicleID: MTS.EQPT_ID);
                ushort vh_num     = recevie_function.CarID;
                ushort hand_shake = recevie_function.Handshake;

                AVEHICLE pre_car_in_vh = scApp.VehicleBLL.cache.getVhByNum(vh_num);
                if (pre_car_in_vh != null)
                {
                    MaintainLift mtl = null;
                    if (SCUtility.isMatche(MTS.EQPT_ID, "MTS"))
                    {
                        mtl = scApp.EquipmentBLL.cache.GetMaintainLift();
                    }
                    var check_result = scApp.MTLService.checkVhAndMTxCarInStatus(MTS, mtl, pre_car_in_vh);
                    send_function.ReturnCode = check_result.isSuccess ? (UInt16)1 : (UInt16)3;
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTSValueDefMapActionNew), Device: DEVICE_NAME_MTL,
                                  Data: $"check mts car in result, is success:{check_result.isSuccess},result:{check_result.result}",
                                  VehicleID: MTS.EQPT_ID);
                }
                else
                {
                    send_function.ReturnCode = 2;
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTSValueDefMapActionNew), Device: DEVICE_NAME_MTL,
                                  Data: $"check mts car in result, vehicle num:{vh_num} not exist.",
                                  VehicleID: MTS.EQPT_ID);
                }
                send_function.Handshake = hand_shake;
                send_function.Write(bcfApp, MTS.EqptObjectCate, MTS.EQPT_ID);

                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTSValueDefMapActionNew), Device: DEVICE_NAME_MTL,
                              Data: send_function.ToString(),
                              VehicleID: MTS.EQPT_ID);
                MTS.SynchronizeTime = DateTime.Now;

                if (send_function.Handshake == 1 && send_function.ReturnCode == 1)
                {
                    scApp.MTLService.processCarInScenario(MTS);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception");
            }
            finally
            {
                scApp.putFunBaseObj <MtlToOHxC_RequestCarInDataCheck>(recevie_function);
                scApp.putFunBaseObj <OHxCToMtl_ReplyCarInDataCheck>(send_function);
            }
        }
 public void askVhToChargerForWait(AVEHICLE vh)
 {
     LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                   Data: $"ask vh:{vh.VEHICLE_ID} to charger idle.",
                   VehicleID: vh.VEHICLE_ID);
     askVhToCharging(vh);
 }
コード例 #6
0
        private void Vh_BatteryCapacityChange(object sender, int batteryCapacity)
        {
            //當車子的電量水位開始低於低電位時,
            //就檢查目前他的狀態,如果一值降低,而且都是在Reserve Stop的狀態
            //AGVC要將目前執行的命令取消
            AVEHICLE vh = sender as AVEHICLE;

            if (vh.BatteryLevel == BatteryLevel.Low &&
                vh.BatteryCapacity <= URGENT_BATTERY_LEVEL)
            {
                //當車子變成低電位時,若還在執行MCS命令,則將他Abort或Cancel掉
                bool is_mcs_cmd = !SCUtility.isEmpty(vh.MCS_CMD);
                if (is_mcs_cmd && vh.IsReservePause)
                {
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                                  Data: $"vh:{vh.VEHICLE_ID} is excute mcs command ,but battery is low(battery capacity={vh.BatteryCapacity}). Begin cancel or abort mcs command:{vh.MCS_CMD}.",
                                  VehicleID: vh.VEHICLE_ID);
                    bool is_success = true;
                    is_success = is_success && vehicleService.PauseRequest(vh.VEHICLE_ID, PauseEvent.Pause, SCAppConstants.OHxCPauseType.Normal);
                    is_success = is_success && vehicleService.FinishExecutionMCSCommand(vh.VEHICLE_ID);
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                                  Data: $"vh:{vh.VEHICLE_ID} is excute mcs command ,but battery is low. Begin cancel or abort mcs command:{vh.MCS_CMD} ,result:{is_success}.",
                                  VehicleID: vh.VEHICLE_ID);
                }
            }
        }
コード例 #7
0
        private AVEHICLE findTheKeyBlockVhID(AVEHICLE avoidVh, AVEHICLE blockedVh)
        {
            if (blockedVh == null)
            {
                return(null);
            }

            if (SCUtility.isMatche(avoidVh.CanNotReserveInfo.ReservedVhID, blockedVh.VEHICLE_ID) &&
                SCUtility.isMatche(blockedVh.CanNotReserveInfo.ReservedVhID, avoidVh.VEHICLE_ID))
            {
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(DeadlockCheck), Device: "OHBC",
                              Data: $"dead lock happend ,find key blocked vh .avoid vh:{avoidVh.VEHICLE_ID} ,blocked vh:{blockedVh.VEHICLE_ID}",
                              VehicleID: avoidVh.VEHICLE_ID,
                              CarrierID: avoidVh.CST_ID);
                return(blockedVh);
            }
            else
            {
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(DeadlockCheck), Device: "OHBC",
                              Data: $"dead lock happend ,can't find key blocked vh .avoid vh:{avoidVh.VEHICLE_ID} ,blocked vh:{blockedVh.VEHICLE_ID}. start find orther block vh",
                              VehicleID: avoidVh.VEHICLE_ID,
                              CarrierID: avoidVh.CST_ID);

                AVEHICLE orther_reserved_vh = scApp.VehicleBLL.cache.getVhByID(blockedVh.CanNotReserveInfo.ReservedVhID);
                int      find_count         = 0;
                return(findTheOrtherKeyBlockVhID(avoidVh, orther_reserved_vh, ref find_count));
            }
        }
コード例 #8
0
        public uctlNewVehicle(AVEHICLE _vh, uctl_Map uctl_Map, PictureBox alarmStatus, PictureBox cstloadStatus)
        {
            InitializeComponent();
            //  this.Size = Resources.Vehicle__Unconnected_.Size;
            Uctl_Map = uctl_Map;
            vh       = _vh;

            this.Width  = this.Width / icon_scale;
            this.Height = this.Height / icon_scale;

            this.Left = this.Width / 2;
            this.Top  = this.Height / 2;

            PicAlarmStatus      = alarmStatus;
            PicCSTLoadStatus    = cstloadStatus;
            PicAlarmStatus.Size =
                new Size(Resources.Alarm__Error_.Width / icon_scale, Resources.Alarm__Error_.Height / icon_scale);
            PicCSTLoadStatus.Size =
                new Size(Resources.Action__Cassette_.Size.Width / icon_scale, Resources.Action__Cassette_.Size.Height / icon_scale);

            font           = new System.Drawing.Font("Consolas", 20F / icon_scale, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            font_Numbering = new System.Drawing.Font("Arial", 28F / icon_scale, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

            PicAlarmStatus.VisibleChanged   += PicAlarmStatus_VisibleChanged;
            PicCSTLoadStatus.VisibleChanged += PicCSTLoadStatus_VisibleChanged;
            this.BackColor = Color.FromArgb(29, 36, 60);
            registerEvent();
            _SetInitialVhToolTip();
            _SetRailToolTip();
        }
コード例 #9
0
        public bool checkAndUpdateVhEntryCycleRunAdr(string vh_id, string adr_id)
        {
            bool             isCyclingAdr    = false;
            ACYCLEZONEMASTER cycleZoneMaster = null;
            ALINE            line            = scApp.getEQObjCacheManager().getLine();
            AVEHICLE         vh = scApp.VehicleBLL.getVehicleByID(vh_id);

            if (!SCUtility.isEmpty(vh.CYCLERUN_ID) &&
                !vh.IS_CYCLING)
            {
                //DBConnection_EF con = DBConnection_EF.GetContext();
                //using (DBConnection_EF con = new DBConnection_EF())
                using (DBConnection_EF con = DBConnection_EF.GetUContext())
                {
                    cycleZoneMaster = cycleZoneMasterDao.getByEntryAdr(con, adr_id);
                    if (cycleZoneMaster == null)
                    {
                        return(false);
                    }
                    if (SCUtility.isMatche(vh.CYCLERUN_ID, cycleZoneMaster.CYCLE_ZONE_ID))
                    {
                        scApp.VehicleBLL.setVhIsInCycleRun(vh_id); //TODO 討論移到144判斷
                        isCyclingAdr = true;
                    }
                }
            }

            return(isCyclingAdr);
        }
コード例 #10
0
        private async void btn_Avoid_Click(object sender, EventArgs e)
        {
            string   vehicle_id = cmb_Vehicle.Text;
            string   avoid_adr  = cmb_toAddress.Text;
            AVEHICLE vh         = scApp.getEQObjCacheManager().getVehicletByVHID(vehicle_id);

            if (vh == null)
            {
                MessageBox.Show("No find vehile.");
                return;
            }
            if (BCFUtility.isEmpty(avoid_adr))
            {
                MessageBox.Show("No find avoid address.");
                return;
            }
            (bool is_success, string result, List <string> guide_address_ids)resule = default((bool is_success, string result, List <string> guide_address_ids));
            await Task.Run(() =>
            {
                resule = scApp.VehicleService.AvoidRequest(vehicle_id, avoid_adr);
            });

            if (resule.is_success)
            {
                MessageBox.Show("Avoid success", "Avoid success.", MessageBoxButtons.OK, MessageBoxIcon.None);
            }
            else
            {
                MessageBox.Show(resule.result, "Avoid fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #11
0
        private void Sec_obj_VehicleLeave(object sender, string vhID)
        {
            App.SCApplication app      = App.SCApplication.getInstance();
            ASECTION          section  = sender as ASECTION;
            AVEHICLE          leave_vh = app.VehicleBLL.cache.getVehicle(vhID);

            if (!ControlSections.Contains(SCUtility.Trim(leave_vh.CUR_SEC_ID, true)))
            {
                string Vh_id = string.Empty;
                if (CurrentVhs.TryRemove(vhID, out Vh_id))
                {
                }
            }

            //判斷是否所有車子都已經不再該管制道路中了。
            var vhs = app.VehicleBLL.cache.loadAllVh();

            foreach (AVEHICLE vh in vhs)
            {
                string vh_current_section = Common.SCUtility.Trim(vh.CUR_SEC_ID, true);
                if (ControlSections.Contains(vh_current_section))
                {
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(TrafficControlInfo), Device: "OHx",
                                  Data: $"vh:{vhID} is leave sec:{section.SEC_ID},but vh:{vh.VEHICLE_ID} in traffic contorl:{ID} of control section:{vh_current_section}," +
                                  $"can't notify section clear event.",
                                  VehicleID: vhID);
                    return;
                }
            }
            TrafficControlSectionIsClear?.Invoke(this, vhID);
        }
 public void doWork(string workKey, BackgroundWorkItem item)
 {
     try
     {
         using (TransactionScope tx = SCUtility.getTransactionScope())
         {
             bool          can_block_pass = true;
             bool          can_hid_pass   = true;
             bool          isSuccess      = false;
             SCApplication scApp          = SCApplication.getInstance();
             //BCFApplication bcfApp, AVEHICLE eqpt, EventType eventType, int seqNum, string req_block_id, string req_hid_secid
             //Node node = item.Param[0] as Node;
             BCFApplication bcfApp        = item.Param[0] as BCFApplication;
             AVEHICLE       eqpt          = item.Param[1] as AVEHICLE;
             EventType      eventType     = (EventType)item.Param[2];
             int            seqNum        = (int)item.Param[3];
             string         req_block_id  = item.Param[4] as string;
             string         req_hid_secid = item.Param[5] as string;
             can_block_pass = scApp.VehicleService.ProcessBlockReqNewNew(bcfApp, eqpt, req_block_id);
             isSuccess      = scApp.VehicleService.replyTranEventReport(bcfApp, eventType, eqpt, seqNum, canBlockPass: can_block_pass, canHIDPass: can_hid_pass);
             if (isSuccess)
             {
                 tx.Complete();
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
     }
 }
コード例 #13
0
        private static CheckBox getCheckBox(AVEHICLE eq)
        {
            CheckBox check_box = new CheckBox();

            check_box.CheckAlign = ContentAlignment.MiddleCenter;
            return(check_box);
        }
コード例 #14
0
 private bool canCreatAvoidCommand(AVEHICLE reservedVh)
 {
     return(reservedVh.isTcpIpConnect &&
            (reservedVh.MODE_STATUS == VHModeStatus.AutoRemote || reservedVh.MODE_STATUS == VHModeStatus.AutoCharging) &&
            reservedVh.ACT_STATUS == VHActionStatus.NoCommand &&
            !cmdBLL.isCMD_OHTCQueueByVh(reservedVh.VEHICLE_ID) &&
            !cmdBLL.HasCMD_MCSInQueue());
 }
コード例 #15
0
 private void update(DBConnection_EF con, AVEHICLE vh)
 {
     //vh_id.UPD_TIME = DateTime.Now.ToString(SCAppConstants.DateTimeFormat_22);
     //bool isDetached = con.Entry(vh_id).State == EntityState.Modified;
     //if (isDetached)
     {
         con.SaveChanges();
     }
 }
コード例 #16
0
        //private void updateCatchManager(DBConnection_EF con, AVEHICLE vh)
        //{
        //    var changedEntity = con.Entry(vh);
        //    AVEHICLE vh_vo = SCApplication.getInstance().getEQObjCacheManager().getVehicletByVHID(vh.VEHICLE_ID);
        //    VehicleObjToShow showObj = SCApplication.getInstance().getEQObjCacheManager().CommonInfo.ObjectToShow_list.
        //        Where(o => o.VEHICLE_ID == vh.VEHICLE_ID).SingleOrDefault();
        //    foreach (string propertyName in changedEntity.CurrentValues.PropertyNames)
        //    {
        //        if (changedEntity.Property(propertyName).IsModified)
        //        {
        //            #region 更新CatchManager的資料
        //            string setPropertyName = string.Empty;
        //            switch (propertyName)
        //            {
        //                case nameof(vh_vo.OBS_PAUSE):
        //                    setPropertyName = nameof(vh_vo.ObstacleStatus);
        //                    break;
        //                case nameof(vh_vo.BLOCK_PAUSE):
        //                    setPropertyName = nameof(vh_vo.BlockingStatus);
        //                    break;
        //                case nameof(vh_vo.CMD_PAUSE):
        //                    setPropertyName = nameof(vh_vo.PauseStatus);
        //                    continue;
        //                default:
        //                    setPropertyName = propertyName;
        //                    break;
        //            }
        //            var prop = typeof(AVEHICLE).GetProperty(setPropertyName);
        //            if (prop != null)
        //            {
        //                prop.SetValue(vh_vo, changedEntity.Property(propertyName).CurrentValue);
        //            }
        //            #endregion 更新CatchManager的資料

        //            #region 更新Show在畫面上 DGV的資料
        //            var prop_for_showObj = typeof(VehicleObjToShow).GetProperty(propertyName);
        //            if (prop_for_showObj != null)
        //            {
        //                prop_for_showObj.SetValue(showObj, changedEntity.Property(propertyName).CurrentValue);
        //            }
        //            #endregion 更新Show在畫面上 DGV的資料
        //        }
        //    }

        //}

        private void updateCatchManager(SCApplication app, DBConnection_EF con, AVEHICLE vh)
        {
            var      changedEntity = con.Entry(vh);
            AVEHICLE vh_vo         = app.getEQObjCacheManager().getVehicletByVHID(vh.VEHICLE_ID);

            //VehicleObjToShow showObj = SCApplication.getInstance().getEQObjCacheManager().CommonInfo.ObjectToShow_list.
            //    Where(o => o.VEHICLE_ID == vh.VEHICLE_ID).SingleOrDefault();
            foreach (string propertyName in changedEntity.CurrentValues.PropertyNames)
            {
                if (changedEntity.Property(propertyName).IsModified)
                {
                    #region 更新CatchManager的資料
                    string setPropertyName = string.Empty;
                    switch (propertyName)
                    {
                    case nameof(vh_vo.OBS_PAUSE):
                        setPropertyName = nameof(vh_vo.ObstacleStatus);
                        break;

                    case nameof(vh_vo.BLOCK_PAUSE):
                        setPropertyName = nameof(vh_vo.BlockingStatus);
                        break;

                    case nameof(vh_vo.CMD_PAUSE):
                        setPropertyName = nameof(vh_vo.PauseStatus);
                        break;

                    default:
                        setPropertyName = propertyName;
                        break;
                    }
                    var prop = typeof(AVEHICLE).GetProperty(setPropertyName);
                    if (prop != null)
                    {
                        prop.SetValue(vh_vo, changedEntity.Property(propertyName).CurrentValue);
                    }
                    #endregion 更新CatchManager的資料

                    #region 更新Show在畫面上 DGV的資料

                    var prop_for_showObj = typeof(VehicleObjToShow).GetProperty(propertyName);
                    if (prop_for_showObj != null)
                    {
                        //prop_for_showObj.SetValue(showObj, changedEntity.Property(propertyName).CurrentValue);
                        //showObj.NotifyPropertyChanged(propertyName);
                    }
                    #endregion 更新Show在畫面上 DGV的資料
                }
            }

            //var vh_Serialize_ = ZeroFormatter.ZeroFormatterSerializer.Serialize(vh_vo);
            //app.getNatsManager().Publish
            //    (string.Format(SCAppConstants.NATS_SUBJECT_VH_INFO_0, vh_vo.VEHICLE_ID.Trim()), vh_Serialize_);

            //app.getRedisCacheManager().ListSetByIndex
            //    (SCAppConstants.REDIS_LIST_KEY_VEHICLES, vh.VEHICLE_ID, vh_vo.ToString());
        }
        /// <summary>
        /// Does the work.
        /// </summary>
        /// <param name="workKey">The work key.</param>
        /// <param name="item">The item.</param>
        public void doWork(string workKey, BackgroundWorkItem item)
        {
            //Do something.
            Service.VehicleService.ReceiveProcessor vehicle_service_receive_proc = item.Param[0] as Service.VehicleService.ReceiveProcessor;
            AVEHICLE vh = item.Param[1] as AVEHICLE;

            ProtocolFormat.OHTMessage.ID_134_TRANS_EVENT_REP receiveStr = item.Param[2] as ProtocolFormat.OHTMessage.ID_134_TRANS_EVENT_REP;
            vehicle_service_receive_proc.doPositionUpdate(vh, receiveStr);
        }
コード例 #18
0
        private void RegularUpdateRealTimeCarInfo(IMaintainDevice mtx, AVEHICLE carOurVh)
        {
            do
            {
                UInt16 car_id      = (ushort)carOurVh.Num;
                UInt16 action_mode = 0;
                if (carOurVh.ACT_STATUS == ProtocolFormat.OHTMessage.VHActionStatus.Commanding)
                {
                    if (!SCUtility.isEmpty(carOurVh.MCS_CMD))
                    {
                        action_mode = CAR_ACTION_MODE_ACTION_FOR_MCS_COMMAND;
                    }
                    else
                    {
                        action_mode = CAR_ACTION_MODE_ACTION;
                    }
                }
                else
                {
                    action_mode = CAR_ACTION_MODE_NO_ACTION;
                }
                UInt16 cst_exist          = (ushort)carOurVh.HAS_CST;
                UInt16 current_section_id = 0;
                UInt16.TryParse(carOurVh.CUR_SEC_ID, out current_section_id);
                UInt16 current_address_id = 0;
                UInt16.TryParse(carOurVh.CUR_ADR_ID, out current_address_id);
                UInt32 buffer_distance = 0;
                UInt16 speed           = (ushort)carOurVh.Speed;

                mtx.CurrentPreCarOurID         = car_id;
                mtx.CurrentPreCarOurActionMode = action_mode;
                mtx.CurrentPreCarOurCSTExist   = cst_exist;
                mtx.CurrentPreCarOurSectionID  = current_section_id;
                mtx.CurrentPreCarOurAddressID  = current_address_id;
                mtx.CurrentPreCarOurDistance   = buffer_distance;
                mtx.CurrentPreCarOurSpeed      = speed;

                mtx.setCarRealTimeInfo(car_id, action_mode, cst_exist, current_section_id, current_address_id, buffer_distance, speed);

                //如果在移動過程中,MTx突然變成手動模式的話,則要將原本在移動的車子取消命令
                if (mtx.MTxMode == MTxMode.Manual ||
                    !mtx.CarOutSafetyCheck)
                {
                    carOutRequestCancle(mtx);
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Warn, Class: nameof(MTLService), Device: "OHTC",
                                  Data: $"Device:{mtx.DeviceID} mtx mode suddenly turned mode:{mtx.MTxMode} or car out safety check change:{mtx.CarOutSafetyCheck}, " +
                                  $"so urgent cancel vh:{mtx.PreCarOutVhID} of command.",
                                  XID: mtx.DeviceID);
                    break;
                }

                SpinWait.SpinUntil(() => false, 200);
            } while (!mtx.CancelCarOutRequest && !mtx.CarOurSuccess);

            //mtx.setCarRealTimeInfo(0, 0, 0, 0, 0, 0, 0);
        }
コード例 #19
0
        private void Vh_BatteryLevelChange(object sender, BatteryLevel e)
        {
            AVEHICLE vh = sender as AVEHICLE;

            try
            {
                //LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                //   Data: $"Battery Level Change,Current Level:{e}.low level:{AVEHICLE.BATTERYLEVELVALUE_LOW},middle level:{AVEHICLE.BATTERYLEVELVALUE_MIDDLE}",
                //   VehicleID: vh.VEHICLE_ID);
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                              Data: $"Battery Level Change,Current Level:{e}.low level:{AVEHICLE.BATTERYLEVELVALUE_LOW},Hight level:{AVEHICLE.BATTERYLEVELVALUE_HIGH}",
                              VehicleID: vh.VEHICLE_ID);
                switch (e)
                {
                case BatteryLevel.Full:
                    vehicleBLL.updataVehicleLastFullyChargerTime(vh.VEHICLE_ID);
                    break;

                case BatteryLevel.Low:
                    //if (vh.MODE_STATUS == VHModeStatus.Manual || vh.MODE_STATUS == VHModeStatus.None)
                    //{
                    //    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                    //       Data: $"vh:{vh.VEHICLE_ID} current mode is:{vh.MODE_STATUS} can't change to auto charge.",
                    //       VehicleID: vh.VEHICLE_ID);
                    //    return;
                    //}
                    //else
                    //{
                    //    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                    //       Data: $"vh:{vh.VEHICLE_ID} current mode is:{vh.MODE_STATUS} change to auto charge.",
                    //       VehicleID: vh.VEHICLE_ID);
                    //}
                    //vehicleService.changeVhStatusToAutoCharging(vh.VEHICLE_ID);
                    if (vh.MODE_STATUS == VHModeStatus.AutoRemote)
                    {
                        LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                                      Data: $"vh:{vh.VEHICLE_ID} current mode is:{vh.MODE_STATUS} change to auto charge.",
                                      VehicleID: vh.VEHICLE_ID);
                        vehicleService.changeVhStatusToAutoCharging(vh.VEHICLE_ID);
                    }
                    else
                    {
                        LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                                      Data: $"vh:{vh.VEHICLE_ID} current mode is:{vh.MODE_STATUS} can't change to auto charge.",
                                      VehicleID: vh.VEHICLE_ID);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Warn, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                              Data: ex,
                              VehicleID: vh?.VEHICLE_ID);
            }
        }
コード例 #20
0
 public void set(AVEHICLE vh, int seqNum, ID_136_TRANS_EVENT_REP gpbMessage)
 {
     SEQ_NUM    = seqNum.ToString();
     EVENT_TYPE = gpbMessage.EventType.ToString();
     if (gpbMessage.ReserveInfos.Count > 0)
     {
         RESERVE_SEC_ID = gpbMessage.ReserveInfos[0].ReserveSectionID;
     }
     CMD_ID = SCUtility.Trim(gpbMessage.CmdID, true);
 }
コード例 #21
0
        private void _SetRailToolTip()
        {
            //AVEHICLE vh = bcApp.SCApplication.VehicleBLL.getVehicleByID(eqpt.VEHICLE_ID);
            AVEHICLE vh = bcApp.SCApplication.getEQObjCacheManager().getVehicletByVHID(eqpt.VEHICLE_ID);

            this.ToolTip.SetToolTip(this.lblPresence,
                                    "Current Adr : " + SCUtility.Trim(vh.CUR_ADR_ID) + "\r\n" +
                                    "Current SEC : " + SCUtility.Trim(vh.CUR_SEC_ID) + "\r\n" +
                                    "Action : " + vh.ACT_STATUS.ToString());
        }
コード例 #22
0
        private void updateCatchManager(SCApplication app, DBConnection_EF con, AVEHICLE vh)
        {
            var      changedEntity = con.Entry(vh);
            AVEHICLE vh_vo         = app.getEQObjCacheManager().getVehicletByVHID(vh.VEHICLE_ID);

            //VehicleObjToShow showObj = SCApplication.getInstance().getEQObjCacheManager().CommonInfo.ObjectToShow_list.
            //    Where(o => o.VEHICLE_ID == vh.VEHICLE_ID).SingleOrDefault();
            foreach (string propertyName in changedEntity.CurrentValues.PropertyNames)
            {
                if (changedEntity.Property(propertyName).IsModified)
                {
                    #region 更新CatchManager的資料
                    string setPropertyName = string.Empty;
                    switch (propertyName)
                    {
                    case nameof(vh_vo.OBS_PAUSE):
                        setPropertyName = nameof(vh_vo.ObstacleStatus);
                        break;

                    case nameof(vh_vo.BLOCK_PAUSE):
                        setPropertyName = nameof(vh_vo.BlockingStatus);
                        break;

                    case nameof(vh_vo.CMD_PAUSE):
                        setPropertyName = nameof(vh_vo.PauseStatus);
                        break;

                    case nameof(vh_vo.BATTERYCAPACITY):
                        setPropertyName = nameof(vh_vo.BatteryCapacity);
                        break;

                    default:
                        setPropertyName = propertyName;
                        break;
                    }
                    var prop = typeof(AVEHICLE).GetProperty(setPropertyName);
                    if (prop != null)
                    {
                        prop.SetValue(vh_vo, changedEntity.Property(propertyName).CurrentValue);
                    }
                    #endregion 更新CatchManager的資料

                    #region 更新Show在畫面上 DGV的資料

                    var prop_for_showObj = typeof(VehicleObjToShow).GetProperty(propertyName);
                    if (prop_for_showObj != null)
                    {
                        //prop_for_showObj.SetValue(showObj, changedEntity.Property(propertyName).CurrentValue);
                        //showObj.NotifyPropertyChanged(propertyName);
                    }
                    #endregion 更新Show在畫面上 DGV的資料
                }
            }
        }
コード例 #23
0
        private async void excuteScanCommand()
        {
            //string fromAdr = string.Empty;
            string vehicleId         = string.Empty;
            string hostsource_portid = cmb_fromAddress.Text;
            string hostdest_portid   = cmb_toAddress.Text;
            string from_adr          = string.Empty;
            string to_adr            = string.Empty;

            string    cmd_id  = string.Empty;
            string    cst_id  = txt_cstID.Text;
            string    box_id  = "box_id";
            string    lot_id  = "lot_id";
            E_VH_TYPE vh_type = E_VH_TYPE.None;

            vehicleId = SCUtility.Trim(cmb_Vehicle.Text, true);
            scApp.PortDefBLL.getAddressID(hostsource_portid, out from_adr, out vh_type);

            cmd_id = scApp.SequenceBLL.getCommandID(SCAppConstants.GenOHxCCommandType.Manual);
            if (BCFUtility.isEmpty(vehicleId))
            {
                MessageBox.Show("No find vehile.");
                return;
            }
            if (BCFUtility.isEmpty(cst_id))
            {
                MessageBox.Show("cst id can't empty.");
                return;
            }
            AVEHICLE vh = scApp.getEQObjCacheManager().getVehicletByVHID(vehicleId);

            sc.BLL.CMDBLL.OHTCCommandCheckResult check_result_info = null;
            await Task.Run(() =>
            {
                //if (SCUtility.isMatche(vh.CUR_ADR_ID, fromAdr))
                //{
                //    scApp.VehicleService.TransferRequset(vehicleId, cmd_id, ActiveType.Scan, "CST02", new string[0], new string[0], fromAdr, "");
                //}
                //else
                {
                    //scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, "CST06",
                    scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, cst_id, E_CMD_TYPE.Scan,
                                                        hostsource_portid, "", 0, 0,
                                                        box_id, lot_id, from_adr);
                    check_result_info = sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.OHTCCommandCheckResult>
                                            (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT);
                }
            });

            if (check_result_info != null && !check_result_info.IsSuccess)
            {
                MessageBox.Show(check_result_info.ToString(), "Command create fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        public bool newReportTransferCommandFinish(ACMD_MCS CMD_MCS, AVEHICLE vh, string resultCode, List <AMCSREPORTQUEUE> reportqueues)
        {
            bool isSuccsess = true;

            if (vh != null)
            {
                isSuccsess = isSuccsess && iBSEMDriver.S6F11SendVehicleUnassinged(vh.VEHICLE_ID, reportqueues);
            }
            isSuccsess = isSuccsess && iBSEMDriver.S6F11SendTransferCompleted(CMD_MCS, vh, resultCode, reportqueues);
            return(isSuccsess);
        }
コード例 #25
0
 private string tryGetCurrentTransferCommand(AVEHICLE vh)
 {
     if (!SCUtility.isEmpty(vh.TRANSFER_ID_1))
     {
         return(SCUtility.Trim(vh.TRANSFER_ID_1));
     }
     else if (!SCUtility.isEmpty(vh.TRANSFER_ID_2))
     {
         return(SCUtility.Trim(vh.TRANSFER_ID_2));
     }
     return("");
 }
コード例 #26
0
 public void Delete(DBConnection_EF conn, AVEHICLE aVEHICLE)
 {
     try
     {
         conn.AVEHICLE.Remove(aVEHICLE);
         conn.SaveChanges();
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        private async void btn_installed_Click(object sender, EventArgs e)
        {
            try
            {
                string   vh_id         = cmb_InstalledVhID.Text;
                string   cst_id        = txt_InstalledCSTID.Text;
                string   transfer_port = cmb_installedTransferPortID.Text;
                AVEHICLE vh            = scApp.VehicleBLL.cache.getVhByID(vh_id);
                if (vh == null)
                {
                    MessageBox.Show($"Plaese select vh.", "Carrier installed fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                else if (vh.HAS_CST == 0)
                {
                    MessageBox.Show($"vh:{vh_id} carrier not exist.can't installed", "Carrier installed fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (SCUtility.isEmpty(transfer_port))
                {
                    MessageBox.Show($"Plaese select transfer port.", "Carrier installed fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (cst_id.Length == CARRIER_ID_FIX_LENGTH)
                {
                    MessageBox.Show($"Plaese check carrier id of length, it need {CARRIER_ID_FIX_LENGTH} words", "Carrier installed fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                txt_InstalledCSTID.Text = SCUtility.Trim(vh.CST_ID, true);
                btn_installed.Enabled   = false;
                await Task.Run(() =>
                {
                    List <AMCSREPORTQUEUE> reportqueues = new List <AMCSREPORTQUEUE>();
                    scApp.ReportBLL.newReportCarrierInstalled(vh.Real_ID, cst_id, transfer_port, reportqueues);
                    scApp.ReportBLL.insertMCSReport(reportqueues);
                    scApp.ReportBLL.newSendMCSMessage(reportqueues);
                });

                Common.LogHelper.Log(logger: NLog.LogManager.GetCurrentClassLogger(), LogLevel: LogLevel.Info, Class: nameof(CarrierMaintenanceForm), Device: "OHTC",
                                     Data: $"Manual carrier installed success, vh id:{vh_id}, cst id:{cst_id}, transfer port:{transfer_port}");

                MessageBox.Show("Carrier installed success", "Carrier installed success.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                await Task.Run(() =>
                {
                    SpinWait.SpinUntil(() => false, 60000);
                });
            }
            catch { }
            finally
            {
                btn_installed.Enabled = true;
            }
        }
コード例 #28
0
 private void connectionCheck(AVEHICLE vh)
 {
     if (!vh.isTcpIpConnect)
     {
         vh.isTcpIpConnect = true;
         BCFApplication.onWarningMsg($"vh:{vh.VEHICLE_ID} Force change connection status to connection !");
         LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(EQTcpIpMapAction), Device: "AGVC",
                       Data: "Force change connection status to connection !",
                       VehicleID: vh.VEHICLE_ID,
                       CarrierID: vh.CST_ID);
     }
 }
コード例 #29
0
        private async void excuteLoadUnloadCommand()
        {
            string   fromSection = cmb_fromSection.Text;
            ASECTION asection    = scApp.MapBLL.getSectiontByID(fromSection);

            string    hostsource = cmb_fromAddress.Text;
            string    hostdest   = cmb_toAddress.Text;
            string    from_adr   = string.Empty;
            string    to_adr     = string.Empty;
            string    cst_id     = txt_cst_id.Text;
            E_VH_TYPE vh_type    = E_VH_TYPE.None;

            scApp.MapBLL.getAddressID(hostsource, out from_adr, out vh_type);
            scApp.MapBLL.getAddressID(hostdest, out to_adr);
            string vehicleId = string.Empty;

            if (BCFUtility.isEmpty(cmb_Vehicle.Text))
            {
                //AVEHICLE firstVh = scApp.VehicleBLL.findBestSuitableVhByFromAdr(fromadr);
                AVEHICLE firstVh = scApp.VehicleBLL.findBestSuitableVhStepByStepFromAdr_New(from_adr, vh_type);
                if (firstVh != null)
                {
                    vehicleId = firstVh.VEHICLE_ID.Trim();
                }
            }
            else
            {
                vehicleId = cmb_Vehicle.Text;
            }

            if (BCFUtility.isEmpty(vehicleId))
            {
                MessageBox.Show("No find idle vehile.");
                return;
            }
            sc.BLL.CMDBLL.OHTCCommandCheckResult check_result_info = null;
            await Task.Run(() =>
            {
                scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, cst_id,
                                                    E_CMD_TYPE.LoadUnload,
                                                    from_adr,
                                                    to_adr, 0, 0);
                check_result_info = sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.OHTCCommandCheckResult>
                                        (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT);
            });

            if (check_result_info != null && !check_result_info.IsSuccess)
            {
                MessageBox.Show(check_result_info.ToString(), "Command create fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                // bcf.App.BCFApplication.onWarningMsg(this, new LogEventArgs("Command create fail.", check_result_info.Num));
            }
        }
コード例 #30
0
        private void whenPauseFinish()
        {
            AVEHICLE vh = scApp.VehicleBLL.getVehicleByID(eqpt.VEHICLE_ID);

            if (eqpt.PauseStatus == VhStopSingle.StopSingleOff &&
                !SCUtility.isEmpty(vh.MCS_CMD))
            {
                double PauseTime_ms = eqpt.watchPauseTime.ElapsedMilliseconds;
                double PauseTime_s  = PauseTime_ms / 1000;
                PauseTime_s = Math.Round(PauseTime_s, 1);
                scApp.SysExcuteQualityBLL.updateSysExecQity_PauseTime(vh.MCS_CMD, PauseTime_s);
            }
        }