/// <summary>
        /// 用來註冊可能可以釋放Block的Section路段
        /// 當觸發的Leave Section,就會使用To Address來確認是否為某的Block的釋放點
        /// 當觸發的Entry Section,就會使用From Address來確認是否為某的Block的釋放點
        /// </summary>
        private void RegisterReleaseAddressOfKeySection()
        {
            List <ABLOCKZONEMASTER> block_zone_masters   = mapBLL.loadAllBlockZoneMaster();
            List <ASECTION>         from_adr_of_sections = new List <ASECTION>();
            List <ASECTION>         to_adr_of_sections   = new List <ASECTION>();

            foreach (var block_zone_master in block_zone_masters)
            {
                if (!SCUtility.isEmpty(block_zone_master.LEAVE_ADR_ID_1))
                {
                    from_adr_of_sections.AddRange(sectionBLL.cache.GetSectionsByFromAddress(block_zone_master.LEAVE_ADR_ID_1));
                    to_adr_of_sections.AddRange(sectionBLL.cache.GetSectionsByToAddress(block_zone_master.LEAVE_ADR_ID_1));
                }
                if (!SCUtility.isEmpty(block_zone_master.LEAVE_ADR_ID_2))
                {
                    from_adr_of_sections.AddRange(sectionBLL.cache.GetSectionsByFromAddress(block_zone_master.LEAVE_ADR_ID_2));
                    to_adr_of_sections.AddRange(sectionBLL.cache.GetSectionsByToAddress(block_zone_master.LEAVE_ADR_ID_2));
                }
            }
            from_adr_of_sections = from_adr_of_sections.Distinct().ToList();
            foreach (ASECTION from_adr_of_section in from_adr_of_sections)
            {
                from_adr_of_section.VehicleEntry += From_adr_of_section_VehicleEntry;
            }
            to_adr_of_sections = to_adr_of_sections.Distinct().ToList();
            foreach (ASECTION to_adr_of_section in to_adr_of_sections)
            {
                to_adr_of_section.VehicleLeave += To_adr_of_section_VehicleLeave;
            }
        }
        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);
        }
            public List <string> loadReserveSection(string vhID)
            {
                string           key_pattern                 = string.Format(SCAppConstants.REDIS_KEY_ADDRESS_RESERVE_INFO_0, "*");
                var              all_reserve_key             = redisCacheManager.SearchKey(key_pattern).ToArray();
                List <string>    all_reserve_value_vh_sec_id = null;
                HashSet <string> sections = new HashSet <string>();

                if (all_reserve_key.Count() > 0)
                {
                    all_reserve_value_vh_sec_id = redisCacheManager.StringGet(all_reserve_key).
                                                  Select(redis_value => redis_value.ToString()).
                                                  ToList();
                    foreach (string reserve_vh_section in all_reserve_value_vh_sec_id)
                    {
                        string[] reserve_vh_section_array = reserve_vh_section.Split('#');
                        string   reserve_vh = reserve_vh_section_array[0];
                        if (SCUtility.isMatche(vhID, reserve_vh))
                        {
                            string reserve_by_section = string.Empty;
                            if (reserve_vh_section_array.Count() > 1)
                            {
                                reserve_by_section = reserve_vh_section_array[1];
                            }
                            if (!SCUtility.isEmpty(reserve_by_section))
                            {
                                sections.Add(reserve_by_section);
                            }
                        }
                    }
                }
                return(sections.ToList());
            }
        List <ProtocolFormat.OHTMessage.ReserveInfo> GetEntrySectionInfos(string entrySectionInfos)
        {
            List <ProtocolFormat.OHTMessage.ReserveInfo> reserve_infos = new List <ReserveInfo>();

            if (SCUtility.isEmpty(entrySectionInfos))
            {
                return(reserve_infos);
            }
            if (entrySectionInfos.Contains("-"))
            {
                string[] infos = entrySectionInfos.Split('-');
                foreach (string reserve in infos)
                {
                    string[] reserve_temp = reserve.Split('/'); // section_id/dir
                    var      reserve_info = new ProtocolFormat.OHTMessage.ReserveInfo()
                    {
                        ReserveSectionID = reserve_temp[0],
                        DriveDirction    = GetDriveDirction(reserve_temp[1])
                    };
                    reserve_infos.Add(reserve_info);
                }
            }
            else
            {
                string[] reserve_temp = entrySectionInfos.Split('/'); // section_id/dir
                var      reserve_info = new ProtocolFormat.OHTMessage.ReserveInfo()
                {
                    ReserveSectionID = reserve_temp[0],
                    DriveDirction    = GetDriveDirction(reserve_temp[1])
                };
                reserve_infos.Add(reserve_info);
            }
            return(reserve_infos);
        }
Пример #5
0
        public virtual ALARM setAlarmReport(string nodeID, string eq_id, string error_code, string errorDesc)
        {
            lock (lock_obj_alarm)
            {
                if (IsAlarmExist(eq_id, error_code))
                {
                    return(null);
                }
                //AlarmMap alarmMap = alarmMapDao.getAlarmMap(eq_id, error_code);
                AlarmMap alarmMap = alarmMapDao.getAlarmMap(nodeID, error_code);
                string   strNow   = BCFUtility.formatDateTime(DateTime.Now, SCAppConstants.TimestampFormat_19);
                ALARM    alarm    = new ALARM()
                {
                    EQPT_ID       = eq_id,
                    RPT_DATE_TIME = DateTime.Now,
                    ALAM_CODE     = error_code,
                    ALAM_LVL      = alarmMap == null ? E_ALARM_LVL.None : alarmMap.ALARM_LVL,
                    ALAM_STAT     = ProtocolFormat.OHTMessage.ErrorStatus.ErrSet,
                    ALAM_DESC     = alarmMap == null ? errorDesc : alarmMap.ALARM_DESC,
                };
                if (SCUtility.isEmpty(alarm.ALAM_DESC))
                {
                    alarm.ALAM_DESC = $"Unknow error:{error_code}";
                }
                using (DBConnection_EF con = DBConnection_EF.GetUContext())
                {
                    alarmDao.insertAlarm(con, alarm);
                    CheckSetAlarm();
                }

                return(alarm);
            }
        }
        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");
            }
        }
Пример #7
0
        public bool upDateVIDCarrierLocInfo(string eq_id, string carrier_location)
        {
            bool isSuccess = true;

            using (DBConnection_EF con = DBConnection_EF.GetUContext())
            {
                AVIDINFO vid_info = vidIvfoDAO.getByID(con, eq_id);
                if (vid_info != null)
                {
                    vid_info.CARRIER_LOC = carrier_location;
                    if (SCUtility.isEmpty(carrier_location))
                    {
                        vid_info.CARRIER_INSTALLED_TIME = null;
                    }
                    else
                    {
                        vid_info.CARRIER_INSTALLED_TIME = DateTime.Now;
                    }
                    vidIvfoDAO.update(con);
                }
                else
                {
                    //TODO Exception log
                }
            }
            return(isSuccess);
        }
        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);
        }
        private void NTBPortTest() //A0.01
        {
            //確認卡夾在哪些位置上
            List <CassetteData> cassetteDatas = scApp.CassetteDataBLL.loadCassetteData();
            //NTB算是CVport 的一種
            List <AVEHICLE> vhs = scApp.VehicleBLL.cache.loadVhs();

            //是否有要執行且可執行之 NTB to Shelf命令
            foreach (AVEHICLE vh in vhs)
            {
                if (vh.isTcpIpConnect &&
                    vh.MODE_STATUS == ProtocolFormat.OHTMessage.VHModeStatus.AutoRemote &&
                    vh.ACT_STATUS == ProtocolFormat.OHTMessage.VHActionStatus.NoCommand &&
                    vh.HAS_BOX == 0 &&
                    !SCUtility.isEmpty(vh.CUR_ADR_ID) &&
                    !scApp.CMDBLL.isCMD_OHTCExcuteByVh(vh.VEHICLE_ID))
                {
                    GenerateNtbToShelf(vh, cassetteDatas);
                }
            }
            //是否有要執行且可執行之 Shelf to NTB命令
            foreach (AVEHICLE vh in vhs)
            {
                if (vh.isTcpIpConnect &&
                    vh.MODE_STATUS == ProtocolFormat.OHTMessage.VHModeStatus.AutoRemote &&
                    vh.ACT_STATUS == ProtocolFormat.OHTMessage.VHActionStatus.NoCommand &&
                    vh.HAS_BOX == 0 &&
                    !SCUtility.isEmpty(vh.CUR_ADR_ID) &&
                    !scApp.CMDBLL.isCMD_OHTCExcuteByVh(vh.VEHICLE_ID))
                {
                    GenerateShelfToNtb(vh, cassetteDatas);
                }
            }
        }
Пример #10
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);
                }
            }
        }
Пример #11
0
 //2020.07.14 Hsinyu Chang: doCheckIPLinkStatus的平行迴圈改寫
 //因 1)foreach中的每個元素沒有資料相依
 //   2)ping為I/O bound,用sequential loop會有大部分時間在空等
 //   3)ping結果有時效性
 //Note: 目前作法要等到parallel foreach的每個元素都ping完才會更新資料,尚有優化空間
 private void doCheckIPLinkStatusParallel()
 {
     if (System.Threading.Interlocked.Exchange(ref syncCheckIP_Point, 1) == 0)
     {
         try
         {
             Parallel.ForEach(dicCommInfo, keyPair => {
                 CommuncationInfo Info = keyPair.Value;
                 if (!SCUtility.isEmpty(Info.Getway_IP))
                 {
                     Info.IsCommunactionSuccess = PingIt(Info.Getway_IP);
                 }
                 if (!SCUtility.isEmpty(Info.Remote_IP))
                 {
                     Info.IsConnectinoSuccess = PingIt(Info.Remote_IP);
                 }
             });
             line.setConnectionInfo(dicCommInfo);
         }
         catch (Exception ex)
         {
             logger.Error(ex, "Exception");
         }
         finally
         {
             System.Threading.Interlocked.Exchange(ref syncCheckIP_Point, 0);
         }
     }
 }
Пример #12
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);
        }
Пример #13
0
 internal string getIPAddress(BCFApplication bcfApp)
 {
     if (SCUtility.isEmpty(TcpIpAgentName))
     {
         return(string.Empty);
     }
     return(ITcpIpControl.getRemoteIPAddress(bcfApp, TcpIpAgentName));
 }
Пример #14
0
 internal System.Net.IPEndPoint getIPEndPoint(BCFApplication bcfApp)
 {
     if (SCUtility.isEmpty(TcpIpAgentName))
     {
         return(null);
     }
     return(ITcpIpControl.RemoteEndPoint(bcfApp, TcpIpAgentName));
 }
Пример #15
0
        private async Task search()
        {
            try
            {
                if (SCUtility.isEmpty(m_StartDTCbx.Value.ToString()))
                {
                    TipMessage_Type_Light.Show("Failure", String.Format("Please select start time."), BCAppConstants.WARN_MSG);
                    return;
                }
                if (SCUtility.isEmpty(m_EndDTCbx.Value.ToString()))
                {
                    TipMessage_Type_Light.Show("Failure", String.Format("Please select end time."), BCAppConstants.WARN_MSG);
                    return;
                }
                if (DateTime.Compare(System.Convert.ToDateTime(m_StartDTCbx.Value), System.Convert.ToDateTime(m_EndDTCbx.Value)) == 1)
                {
                    TipMessage_Type_Light.Show("Failure", String.Format("Start time must occur earlier than end time. Please re-enter start time and end time."), BCAppConstants.WARN_MSG);
                    return;
                }
                if (DateTime.Compare(System.Convert.ToDateTime(m_StartDTCbx.Value), System.Convert.ToDateTime(m_EndDTCbx.Value)) < 0)
                {
                    btn_Search.IsEnabled = false;
                    DateTime dateTimeFrom = System.Convert.ToDateTime(m_StartDTCbx.Value);
                    DateTime dateTimeTo   = System.Convert.ToDateTime(m_EndDTCbx.Value);
                    //string keyword = string.Empty;
                    //if (SCUtility.isMatche(McsCmdLog_CstID.Text, ""))
                    //{
                    //    keyword = string.Empty;
                    //}
                    //else
                    //{
                    //    keyword = McsCmdLog_CstID.Text.Trim();
                    //}
                    dateTimeFrom = new DateTime(dateTimeFrom.Year, dateTimeFrom.Month, dateTimeFrom.Day, dateTimeFrom.Hour, dateTimeFrom.Minute, dateTimeFrom.Second, DateTimeKind.Local);
                    dateTimeTo   = new DateTime(dateTimeTo.Year, dateTimeTo.Month, dateTimeTo.Day, dateTimeTo.Hour, dateTimeTo.Minute, dateTimeTo.Second, DateTimeKind.Local);
                    string cmd_id = CommunLog_MCSCmdID.Text;
                    string vh_id  = CommunLog_VhID.Text;
                    List <RecordReportInfo> record_report_info = null;
                    await Task.Run(() => record_report_info = sysExcuteQualityQueryService.loadRecodeReportInfo(dateTimeFrom, dateTimeTo, vh_id, cmd_id));

                    if (record_report_info.Count <= 0)
                    {
                        TipMessage_Type_Light.Show("Warning", "There is no matching data for your query.", BCAppConstants.WARN_MSG);
                    }
                    else
                    {
                        record_report_info = record_report_info.OrderBy(info => info.Timestamp).ToList();
                        uctl_ElasticQuery_sys_process_log.setDataItemsSource(record_report_info);
                    }
                    btn_Search.IsEnabled = true;
                    return;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception");
            }
        }
 public void turnOnMonitorVh()
 {
     if (!SCUtility.isEmpty(vh.CUR_ADR_ID))
     {
         updateVehicleModeStatus();
         updateVehicleActionStatus();
         updateVehiclePosition();
     }
 }
        public static void setCallContextKey_ServiceID(string service_id)
        {
            string xid = System.Runtime.Remoting.Messaging.CallContext.GetData(CALL_CONTEXT_KEY_WORD_SERVICE_ID) as string;

            if (SCUtility.isEmpty(xid))
            {
                System.Runtime.Remoting.Messaging.CallContext.SetData(LogHelper.CALL_CONTEXT_KEY_WORD_SERVICE_ID, service_id);
            }
        }
Пример #18
0
        private async Task search()
        {
            try
            {
                if (SCUtility.isEmpty(m_StartDTCbx.Value.ToString()))
                {
                    TipMessage_Type_Light.Show("Failure", String.Format("Please select start time."), BCAppConstants.WARN_MSG);
                    return;
                }
                if (SCUtility.isEmpty(m_EndDTCbx.Value.ToString()))
                {
                    TipMessage_Type_Light.Show("Failure", String.Format("Please select end time."), BCAppConstants.WARN_MSG);
                    return;
                }
                if (DateTime.Compare(System.Convert.ToDateTime(m_StartDTCbx.Value), System.Convert.ToDateTime(m_EndDTCbx.Value)) == 1)
                {
                    TipMessage_Type_Light.Show("Failure", String.Format("Start time must occur earlier than end time. Please re-enter start time and end time."), BCAppConstants.WARN_MSG);
                    return;
                }
                if (DateTime.Compare(System.Convert.ToDateTime(m_StartDTCbx.Value), System.Convert.ToDateTime(m_EndDTCbx.Value)) < 0)
                {
                    btn_Search.IsEnabled = false;
                    DateTime dateTimeFrom = System.Convert.ToDateTime(m_StartDTCbx.Value);
                    DateTime dateTimeTo   = System.Convert.ToDateTime(m_EndDTCbx.Value);
                    string   keyword      = string.Empty;
                    if (SCUtility.isMatche(McsCmdLog_CstID.Text, ""))
                    {
                        keyword = string.Empty;
                    }
                    else
                    {
                        keyword = McsCmdLog_CstID.Text.Trim();
                    }

                    dateTimeFrom = new DateTime(dateTimeFrom.Year, dateTimeFrom.Month, dateTimeFrom.Day, dateTimeFrom.Hour, dateTimeFrom.Minute, dateTimeFrom.Second, DateTimeKind.Local);
                    dateTimeTo   = new DateTime(dateTimeTo.Year, dateTimeTo.Month, dateTimeTo.Day, dateTimeTo.Hour, dateTimeTo.Minute, dateTimeTo.Second, DateTimeKind.Local);
                    List <ASYSEXCUTEQUALITY> system_qualitys = null;
                    await Task.Run(() => system_qualitys = sysExcuteQualityQueryService.loadSysexcutequalities(dateTimeFrom, dateTimeTo));

                    if (system_qualitys.Count <= 0)
                    {
                        TipMessage_Type_Light.Show("Warning", "There is no matching data for your query.", BCAppConstants.WARN_MSG);
                    }
                    else
                    {
                        system_qualitys = system_qualitys.OrderBy(info => info.CMD_INSERT_TIME).ToList();
                        uctl_ElasticQuery_CMDExcute_1.setDataItemsSource(system_qualitys);
                    }
                    btn_Search.IsEnabled = true;
                    return;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception");
            }
        }
Пример #19
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);
        }
        private async Task search()
        {
            try
            {
                if (SCUtility.isEmpty(m_StartDTCbx.Value.ToString()))
                {
                    TipMessage_Type_Light.Show("Failure", String.Format("Please select start time."), BCAppConstants.WARN_MSG);
                    return;
                }
                if (SCUtility.isEmpty(m_EndDTCbx.Value.ToString()))
                {
                    TipMessage_Type_Light.Show("Failure", String.Format("Please select end time."), BCAppConstants.WARN_MSG);
                    return;
                }
                if (DateTime.Compare(System.Convert.ToDateTime(m_StartDTCbx.Value), System.Convert.ToDateTime(m_EndDTCbx.Value)) == 1)
                {
                    TipMessage_Type_Light.Show("Failure", String.Format("Start time must occur earlier than end time. Please re-enter start time and end time."), BCAppConstants.WARN_MSG);
                    return;
                }
                if (DateTime.Compare(System.Convert.ToDateTime(m_StartDTCbx.Value), System.Convert.ToDateTime(m_EndDTCbx.Value)) < 0)
                {
                    btn_Search.IsEnabled = false;
                    DateTime dateTimeFrom = System.Convert.ToDateTime(m_StartDTCbx.Value);
                    DateTime dateTimeTo   = System.Convert.ToDateTime(m_EndDTCbx.Value);

                    dateTimeFrom = new DateTime(dateTimeFrom.Year, dateTimeFrom.Month, dateTimeFrom.Day, dateTimeFrom.Hour, dateTimeFrom.Minute, dateTimeFrom.Second, DateTimeKind.Local);
                    dateTimeTo   = new DateTime(dateTimeTo.Year, dateTimeTo.Month, dateTimeTo.Day, dateTimeTo.Hour, dateTimeTo.Minute, dateTimeTo.Second, DateTimeKind.Local);
                    string every_hour_interval = EveryHourInterval.Text;
                    string alarm_code          = AlarmCode.Text;
                    string vh_id         = cb_VehicleIDs.Text;
                    bool   include_set   = ck_IsSet.IsChecked.HasValue ? ck_IsSet.IsChecked.Value : false;
                    bool   include_clear = ck_IsClear.IsChecked.HasValue ? ck_IsClear.IsChecked.Value : false;
                    List <AlarmObjToShow> alarms_obj_to_show = null;
                    await Task.Run(() =>
                    {
                        var alarms         = AlarmBLL.loadAlarmByConditions(dateTimeFrom, dateTimeTo, include_set, include_clear, vh_id, alarm_code);
                        alarms_obj_to_show = alarms.Select(alarm => new AlarmObjToShow(alarm, AlarmBLL)).ToList();
                    });

                    if (alarms_obj_to_show.Count <= 0)
                    {
                        TipMessage_Type_Light.Show("Warning", "There is no matching data for your query.", BCAppConstants.WARN_MSG);
                    }
                    else
                    {
                        uctl_AlarmList.setDataItemsSource(alarms_obj_to_show);
                    }
                    btn_Search.IsEnabled = true;
                    return;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception");
            }
        }
        public ATRANSFER ToTRANSFER(BLL.PortStationBLL portStationBLL, BLL.EqptBLL eqprBLL)
        {
            string cmdID    = REPITEMS.COMMINFO.COMMAINFOVALUE.COMMANDID.CPVAL;
            string priority = REPITEMS.COMMINFO.COMMAINFOVALUE.PRIORITY.CPVAL;
            string replace  = REPITEMS.COMMINFO.COMMAINFOVALUE.REPLACE.CPVAL;
            string cstID    = REPITEMS.TRANINFO.TRANSFERINFOVALUE.CARRIERIDINFO.CPVAL;
            string source   = REPITEMS.TRANINFO.TRANSFERINFOVALUE.SOUINFO.CPVAL;
            string dest     = REPITEMS.TRANINFO.TRANSFERINFOVALUE.DESTINFO.CPVAL;

            dest = tryGetVirturePortID(portStationBLL, eqprBLL, dest);
            string lot_id = tryGetLotID();

            if (!int.TryParse(priority, out int ipriority))
            {
                NLog.LogManager.GetCurrentClassLogger().Warn("command id :{0} of priority parse fail. priority valus:{1}"
                                                             , cmdID
                                                             , priority);
            }
            if (!int.TryParse(replace, out int ireplace))
            {
                NLog.LogManager.GetCurrentClassLogger().Warn("command id :{0} of priority parse fail. priority valus:{1}"
                                                             , cmdID
                                                             , replace);
            }
            int port_priority = 0;

            if (!SCUtility.isEmpty(source))
            {
                APORTSTATION source_portStation = portStationBLL.OperateCatch.getPortStation(source);
                if (source_portStation == null)
                {
                    NLog.LogManager.GetCurrentClassLogger().Warn($"MCS cmd of hostsource port[{source} not exist.]");
                }
                else
                {
                    port_priority = source_portStation.PRIORITY;
                }
            }

            return(new ATRANSFER
            {
                CARRIER_ID = cstID,
                ID = cmdID,
                COMMANDSTATE = 0,
                HOSTSOURCE = source,
                HOSTDESTINATION = dest,
                PRIORITY = ipriority,
                PAUSEFLAG = "0",
                CMD_INSER_TIME = DateTime.Now,
                TIME_PRIORITY = 0,
                PORT_PRIORITY = port_priority,
                PRIORITY_SUM = ipriority + port_priority,
                REPLACE = ireplace,
                LOT_ID = lot_id
            });
        }
Пример #22
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            lbl_mtl_alive.Text                      = MTL.Is_Eq_Alive.ToString();
            lbl_mtl_current_car_id.Text             = MTL.CurrentCarID;
            lbl_mtl_has_vh.Text                     = MTL.HasVehicle.ToString();
            lbl_mtl_stop_single.Text                = MTL.StopSingle.ToString();
            lbl_mtl_mode.Text                       = MTL.MTxMode.ToString();
            lbl_mtl_location.Text                   = MTL.MTLLocation.ToString();
            lbl_mtl_moving_status.Text              = MTL.MTLMovingStatus.ToString();
            lbl_mtl_encoder.Text                    = MTL.Encoder.ToString();
            lbl_mtl_in_position.Text                = MTL.VhInPosition.ToString();
            btn_mtl_m2o_u2d_safetycheck.Checked     = MTL.CarOutSafetyCheck;
            btn_mtl_m2o_d2u_safetycheck.Checked     = MTL.CarInSafetyCheck;
            btn_mtl_o2m_u2d_caroutInterlock.Checked = MTL.CarOutInterlock;
            btn_mtl_o2m_d2u_moving.Checked          = MTL.CarInMoving;

            lbl_mts_alive.Text                      = MTS.Is_Eq_Alive.ToString();
            lbl_mts_current_car_id.Text             = MTS.CurrentCarID;
            lbl_mts_has_vh.Text                     = MTS.HasVehicle.ToString();
            lbl_mts_stop_single.Text                = MTS.StopSingle.ToString();
            lbl_mts_mode.Text                       = MTS.MTxMode.ToString();
            lbl_mts_in_position.Text                = MTS.VhInPosition.ToString();
            btn_mts_m2o_u2d_safetycheck.Checked     = MTS.CarOutSafetyCheck;
            btn_mts_m2o_d2u_safetycheck.Checked     = MTS.CarInSafetyCheck;
            btn_mts_o2m_u2d_caroutInterlock.Checked = MTS.CarOutInterlock;
            btn_mts_o2m_d2u_moving.Checked          = MTS.CarInMoving;
            lbl_mts_front_door_value.Text           = MTS.MTSFrontDoorStatus.ToString();
            lbl_mts_back_door_value.Text            = MTS.MTSBackDoorStatus.ToString();

            if (!mtl_prepare_car_out_info.Enabled)
            {
                txt_mtl_car_id.Text          = MTL.CurrentPreCarOurID.ToString();
                txt_mtl_action_mode.Text     = MTL.CurrentPreCarOurActionMode.ToString();
                txt_mtl_cst_exist.Text       = MTL.CurrentPreCarOurCSTExist.ToString();
                txt_mtl_current_sec_id.Text  = MTL.CurrentPreCarOurSectionID.ToString();
                txt_mtl_current_adr_id.Text  = MTL.CurrentPreCarOurAddressID.ToString();
                txt_mtl_buffer_distance.Text = MTL.CurrentPreCarOurDistance.ToString();
                txt_mtl_speed.Text           = MTL.CurrentPreCarOurSpeed.ToString();
                //btn_mtl_o2m_u2d_caroutInterlock.Checked = MTL.CarOutInterlock;
                //btn_mtl_o2m_d2u_moving.Checked = MTL.CarInMoving;
            }
            if (!mts_prepare_car_out_info.Enabled)
            {
                txt_mts_car_id.Text          = MTS.CurrentPreCarOurID.ToString();
                txt_mts_action_mode.Text     = MTS.CurrentPreCarOurActionMode.ToString();
                txt_mts_cst_exist.Text       = MTS.CurrentPreCarOurCSTExist.ToString();
                txt_mts_current_sec_id.Text  = MTS.CurrentPreCarOurSectionID.ToString();
                txt_mts_current_adr_id.Text  = MTS.CurrentPreCarOurAddressID.ToString();
                txt_mts_buffer_distance.Text = MTS.CurrentPreCarOurDistance.ToString();
                txt_mts_speed.Text           = MTS.CurrentPreCarOurSpeed.ToString();
                //btn_mts_o2m_u2d_caroutInterlock.Checked = MTS.CarOutInterlock;
                //btn_mts_o2m_d2u_moving.Checked = MTS.CarInMoving;
            }
            MTLCarOutExcuting = !SCUtility.isEmpty(MTL.PreCarOutVhID);
            MTSCarOutExcuting = !SCUtility.isEmpty(MTS.PreCarOutVhID);
        }
        //A0.07 Add End

        public static Boolean isLogin(WindownApplication app)
        {
            string loginUserID = app.LoginUserID;

            if (SCUtility.isEmpty(loginUserID))
            {
                return(false);
            }
            return(true);
        }
 public List <ASEGMENT> GetSegments(string addressID)
 {
     if (SCUtility.isEmpty(addressID))
     {
         return(null);
     }
     return(CommObjCacheManager.getSegments().
            Where(seg => seg.RealFromAddress.Trim() == addressID.Trim()).
            ToList());
 }
        protected virtual void SubInit()
        {
            this.StartPosition = FormStartPosition.CenterScreen;

            if (!SCUtility.isEmpty(TitleName))
            {
                formTitleLb.Text = TitleName;
                this.Text        = TitleName;
            }
        }
Пример #26
0
 public ASEGMENT GetSegment(string id)
 {
     if (SCUtility.isEmpty(id))
     {
         return(null);
     }
     return(CommObjCacheManager.getSegments().
            Where(seg => seg.SEG_NUM.Trim() == id.Trim()).
            SingleOrDefault());
 }
        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);
        }
        private void tryCreatMCSCommand(E_VH_TYPE vh_type, List <string> load_port_lst)
        {
            int vh_count = scApp.VehicleBLL.getActVhCount(vh_type);

            if (vh_count == 0 || load_port_lst == null)
            {
                return;
            }
            int          unfinished_cmd_count     = scApp.CMDBLL.getCMD_MCSIsUnfinishedCount(load_port_lst);
            int          task_RandomIndex         = 0;
            TranTask     tranTask                 = null;
            APORTSTATION source_port_station      = null;
            APORTSTATION destination_port_station = null;
            string       carrier_id               = null;
            string       find_task_type           = vh_type.ToString().Substring(0, 1);;

            if (unfinished_cmd_count < vh_count)
            {
                bool is_find = false;
                if (!dicTranTaskSchedule_Clear_Dirty.ContainsKey(find_task_type))
                {
                    return;
                }
                var task_list_clean = dicTranTaskSchedule_Clear_Dirty[find_task_type].ToList();
                do
                {
                    task_RandomIndex         = rnd_Index.Next(task_list_clean.Count - 1);
                    tranTask                 = task_list_clean[task_RandomIndex];
                    source_port_station      = scApp.getEQObjCacheManager().getPortStation(tranTask.SourcePort);
                    destination_port_station = scApp.getEQObjCacheManager().getPortStation(tranTask.DestinationPort);
                    if ((source_port_station != null && !SCUtility.isEmpty(source_port_station.CST_ID)) &&
                        scApp.CMDBLL.getCMD_MCSIsUnfinishedCountByCarrierID(source_port_station.CST_ID) == 0 &&
                        (destination_port_station != null && SCUtility.isEmpty(destination_port_station.CST_ID)) &&
                        scApp.CMDBLL.getCMD_MCSIsUnfinishedCountByPortID(destination_port_station.PORT_ID) == 0)
                    {
                        carrier_id = source_port_station.CST_ID;
                        is_find    = true;
                    }
                    else
                    {
                        task_list_clean.RemoveAt(task_RandomIndex);
                        if (task_list_clean.Count == 0)
                        {
                            return;
                        }
                    }
                    SpinWait.SpinUntil(() => false, 1);
                } while (!is_find);

                if (is_find)
                {
                    sendTranCmd(carrier_id, tranTask.SourcePort, tranTask.DestinationPort);
                }
            }
        }
 public void setLoginUserID(string user_id)
 {
     if (SCUtility.isEmpty(user_id))
     {
         this.UASShowLoginUserIDLbl.Text = "";
     }
     else
     {
         this.UASShowLoginUserIDLbl.Text = user_id.Trim();
     }
 }
Пример #30
0
 public void turnOnMonitorVh()
 {
     if (!SCUtility.isEmpty(eqpt.CUR_ADR_ID))
     {
         changeVehicleStatus();
         moveVehiclePosition();
         updateVhCurrentProcProgress();
     }
     registerEvent();
     this.Visible = true;
 }