public bool IsPortInSpecifiedSegment(BLL.SectionBLL sectionBLL, string portID, string segmentID)
            {
                APORTSTATION aPORTSTATION = getPortStation(portID);
                ASECTION     aSECTION     = sectionBLL.cache.GetSectionsByAddress(aPORTSTATION.ADR_ID.Trim()).First();

                return(SCUtility.isMatche(aSECTION.SEG_NUM, segmentID));
            }
        public static string tryGetVirturePortID(BLL.PortStationBLL portStationBLL, BLL.EqptBLL eqptBLL, string dest)
        {
            APORTSTATION port_station = portStationBLL.OperateCatch.getPortStation(dest);

            if (port_station == null)
            {
                return(dest);
            }
            var eqpt = port_station.GetEqpt(eqptBLL);

            if (eqpt is AGVStation)
            {
                var agv_station  = eqpt as AGVStation;
                var virtrue_port = agv_station.getAGVVirtruePort();
                if (agv_station.IsVirtrueUse)
                {
                    return(SCUtility.Trim(virtrue_port.PORT_ID, true));
                }
                else
                {
                    return(dest);
                }
            }
            else
            {
                return(dest);
            }
        }
            public APORTSTATION getPortStationByID(string adr_id)
            {
                APORTSTATION portTemp = CacheManager.getALLPortStation().
                                        Where(p => SCUtility.isMatche(p.ADR_ID, adr_id)).
                                        SingleOrDefault();

                return(portTemp);
            }
        /// <summary>
        /// Initializes the start.
        /// </summary>
        public override void initStart()
        {
            scApp     = SCApplication.getInstance();
            tranTasks = scApp.CMDBLL.loadTranTasks();
            dicTranTaskSchedule_Clear_Dirty = new Dictionary <string, List <TranTask> >();

            HashSet <string> all_port = new HashSet <string>();

            foreach (var task in tranTasks)
            {
                all_port.Add(task.SourcePort);
                all_port.Add(task.DestinationPort);
                APORTSTATION port_station = scApp.getEQObjCacheManager().getPortStation(task.SourcePort);
                if (port_station == null)
                {
                    continue;
                }

                if (port_station.ULD_VH_TYPE == E_VH_TYPE.None)
                {
                    if (!dicTranTaskSchedule_Clear_Dirty.ContainsKey("N"))
                    {
                        dicTranTaskSchedule_Clear_Dirty.Add("N", new List <TranTask>());
                    }
                    dicTranTaskSchedule_Clear_Dirty["N"].Add(task);
                }
                else if (port_station.ULD_VH_TYPE == E_VH_TYPE.Clean)
                {
                    if (!dicTranTaskSchedule_Clear_Dirty.ContainsKey("C"))
                    {
                        dicTranTaskSchedule_Clear_Dirty.Add("C", new List <TranTask>());
                    }
                    dicTranTaskSchedule_Clear_Dirty["C"].Add(task);
                }
                else if (port_station.ULD_VH_TYPE == E_VH_TYPE.Dirty)
                {
                    if (!dicTranTaskSchedule_Clear_Dirty.ContainsKey("D"))
                    {
                        dicTranTaskSchedule_Clear_Dirty.Add("D", new List <TranTask>());
                    }
                    dicTranTaskSchedule_Clear_Dirty["D"].Add(task);
                }
            }
            AllCanExcutePort = all_port.ToList();

            if (dicTranTaskSchedule_Clear_Dirty.ContainsKey("N"))
            {
                SourcePorts_None = dicTranTaskSchedule_Clear_Dirty["N"].Select(task => task.SourcePort).Distinct().ToList();
            }
            if (dicTranTaskSchedule_Clear_Dirty.ContainsKey("C"))
            {
                SourcePorts_Clear = dicTranTaskSchedule_Clear_Dirty["C"].Select(task => task.SourcePort).Distinct().ToList();
            }
            if (dicTranTaskSchedule_Clear_Dirty.ContainsKey("D"))
            {
                SourcePorts_Dirty = dicTranTaskSchedule_Clear_Dirty["D"].Select(task => task.SourcePort).Distinct().ToList();
            }
        }
            public void updatePortStationCSTExistStatus(string port_id, string cst_id)
            {
                APORTSTATION port_station = CacheManager.getPortStation(port_id);

                if (port_station != null)
                {
                    port_station.CST_ID = cst_id;
                }
            }
            public bool CheckSegmentInActiveByPortID(BLL.SegmentBLL segmentBLL, BLL.SectionBLL sectionBLL, string port_id)
            {
                bool         SegmentInActive = true;
                APORTSTATION aPORTSTATION    = getPortStation(port_id);
                ASECTION     aSECTION        = sectionBLL.cache.GetSectionsByAddress(aPORTSTATION.ADR_ID.Trim()).First();

                SegmentInActive = segmentBLL.cache.IsSegmentActive(aSECTION.SEG_NUM);
                return(SegmentInActive);
            }
            public void updatePortStationStatus(string portID, E_PORT_STATUS portStatus)
            {
                APORTSTATION port_station = CacheManager.getPortStation(portID);

                if (port_station != null)
                {
                    port_station.PORT_STATUS = portStatus;
                }
            }
        public bool CheckSegmentInActiveByPortID(string port_id)
        {
            bool         SegmentInActive = true;
            APORTSTATION aPORTSTATION    = scApp.MapBLL.getPortByPortID(port_id);
            ASECTION     aSECTION        = scApp.SectionDao.loadByFromOrToAdr(commObjCacheManager, aPORTSTATION.ADR_ID.Trim()).First();

            SegmentInActive = scApp.MapBLL.IsSegmentActive(aSECTION.SEG_NUM);
            return(SegmentInActive);
        }
        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
            });
        }
示例#10
0
            public bool IsAGVStationPort(EqptBLL eqptBLL, string portID)
            {
                APORTSTATION port_station = CacheManager.getPortStation(portID);

                if (port_station == null)
                {
                    return(false);
                }
                return(port_station.GetEqptType(eqptBLL) == SCAppConstants.EqptType.AGVStation);
            }
            public APORTSTATION get(string _id)
            {
                APORTSTATION rtnPortStation = null;

                using (DBConnection_EF con = DBConnection_EF.GetUContext())
                {
                    rtnPortStation = portStationDao.getByID(con, _id);
                }
                return(rtnPortStation);
            }
        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 APORTSTATION getPortByAdrID(string adr_id)
        {
            APORTSTATION portTemp = null;

            //using (DBConnection_EF con = new DBConnection_EF())
            using (DBConnection_EF con = DBConnection_EF.GetUContext())
            {
                portTemp = portDAO.getByAdrID(con, adr_id);
            }
            return(portTemp);
        }
            public APORTSTATION getPortStationByAdrID(string adrID)
            {
                if (SCUtility.isEmpty(adrID))
                {
                    return(null);
                }
                APORTSTATION portTemp = CacheManager.getALLPortStation().Where(port_station => port_station.ADR_ID.Trim() == adrID.Trim()).
                                        SingleOrDefault();

                return(portTemp);
            }
 private (string adrID, string portID) getAdrPortID(string adrOrPortID)
 {
     if (Raid_PortNameType_AdrID.Checked)
     {
         return(adrOrPortID, adrOrPortID);
     }
     else
     {
         APORTSTATION port_station = scApp.PortStationBLL.OperateCatch.getPortStation(adrOrPortID);
         return(port_station == null ? adrOrPortID : port_station.ADR_ID, adrOrPortID);
     }
 }
 public bool updatePortStatus(string portID, E_PORT_STATUS status)
 {
     try
     {
         APORTSTATION port_station = CacheManager.getPortStation(portID);
         port_station.PORT_STATUS = status;
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
         return(false);
     }
     return(true);
 }
示例#17
0
 public bool updatePortIncludeCycleTest(string portID, bool isIncludeCycleTest)
 {
     try
     {
         APORTSTATION port_station = CacheManager.getPortStation(portID);
         port_station.IncludeCycleTest = isIncludeCycleTest;
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
         return(false);
     }
     return(true);
 }
 public bool updatePriority(string portID, int priority)
 {
     try
     {
         APORTSTATION port_station = CacheManager.getPortStation(portID);
         port_station.PRIORITY = priority;
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
         return(false);
     }
     return(true);
 }
            public void updatePortStationStatus(string port_id, E_PORT_STATUS port_status)
            {
                APORTSTATION portTemp = null;

                using (DBConnection_EF con = DBConnection_EF.GetUContext())
                {
                    portTemp = portStationDao.getByID(con, port_id);
                    if (portTemp != null)
                    {
                        portTemp.PORT_STATUS = port_status;
                        portStationDao.update(con, portTemp);
                    }
                }
            }
        public void updatePortStation()
        {
            var port_stations = app.PortStationBLL.OperateDB.loadPortStation();

            foreach (var new_port_station in port_stations)
            {
                APORTSTATION port_station = PORTSTATIONs.
                                            Where(port => port.PORT_ID.Trim() == new_port_station.PORT_ID.Trim()).
                                            FirstOrDefault();
                port_station.set(new_port_station);
            }

            PortStationUpdateComplete?.Invoke(this, EventArgs.Empty);
        }
示例#21
0
 public bool updatePortUnloadVhType(string portID, E_VH_TYPE vhType)
 {
     try
     {
         APORTSTATION port_station = CacheManager.getPortStation(portID);
         port_station.ULD_VH_TYPE = vhType;
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
         return(false);
     }
     return(true);
 }
示例#22
0
        public void sendTranCmd(string source_port, string destn_port)
        {
            APORTSTATION port_station = scApp.getEQObjCacheManager().getPortStation(source_port);
            //if (port_station != null && !port_station.HAS_CST)
            //{
            //    return;
            //}
            string cst_id  = $"CST{(++cst_id_seq).ToString("000")}";
            string cmdType = string.Concat(source_port, "To", destn_port);
            string cmdID   = DateTime.Now.ToString("yyyyMMddHHmmssfffff");

            scApp.CMDBLL.doCreatMCSCommand(cmdID, "10", "0", cst_id, source_port, destn_port, SECSConst.HCACK_Confirm);
            scApp.SysExcuteQualityBLL.creatSysExcuteQuality(cmdID, cst_id, source_port, destn_port);
        }
 public bool updateServiceStatus(string portID, ProtocolFormat.OHTMessage.PortStationServiceStatus status)
 {
     try
     {
         APORTSTATION port_station = CacheManager.getPortStation(portID);
         port_station.PORT_SERVICE_STATUS = status;
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
         return(false);
     }
     return(true);
 }
        public bool getPortID(string adr_id, out string portid)
        {
            APORTSTATION port = scApp.MapBLL.getPortByAdrID(adr_id);

            if (port != null)
            {
                portid = port.PORT_ID.Trim();
                return(true);
            }
            else
            {
                portid = adr_id;
                return(false);
            }
        }
 public bool add(APORTSTATION portStation)
 {
     try
     {
         using (DBConnection_EF con = DBConnection_EF.GetUContext())
         {
             portStationDao.add(con, portStation);
         }
     }
     catch
     {
         return(false);
     }
     return(true);
 }
示例#26
0
        private async void CycleRunTest()
        {
            scApp.PortStationBLL.updatePortStatusByRedis();
            List <AZONE> zones = scApp.ZoneBLL.cache.LoadZones();

            foreach (var zone in zones)
            {
                Task <(bool is_success, object result)> find_idle_vh_result = findIdleForCycleVehicle(zone.ZONE_ID);
                Task <(bool is_success, object result)> find_can_unload_agv_station_result = findCanUnloadAGVStation(zone.ZONE_ID);
                Task <(bool is_success, object result)> find_can_load_agv_station_result   = findCanLoadAGVStation(zone.ZONE_ID);

                var check_results = await Task.WhenAll(find_idle_vh_result, find_can_unload_agv_station_result, find_can_load_agv_station_result);

                bool is_success = check_results.Where(result => result.is_success == false).Count() == 0;
                if (is_success)
                {
                    List <AVEHICLE> idle_vhs = check_results[0].result as List <AVEHICLE>;
                    if (idle_vhs == null || idle_vhs.Count == 0)
                    {
                        continue;
                    }
                    AVEHICLE     idle_vh = idle_vhs[0];
                    APORTSTATION can_unload_agv_station_port = check_results[1].result as APORTSTATION;
                    APORTSTATION can_load_agv_station_port   = check_results[2].result as APORTSTATION;
                    if (idle_vh == null || can_unload_agv_station_port == null || can_load_agv_station_port == null)
                    {
                        continue;
                    }

                    //foreach (var idle_vh in idle_vhs)
                    //{
                    if (scApp.GuideBLL.IsRoadWalkable(idle_vh.CUR_ADR_ID, can_load_agv_station_port.ADR_ID) &&
                        scApp.GuideBLL.IsRoadWalkable(can_load_agv_station_port.ADR_ID, can_unload_agv_station_port.ADR_ID))
                    {
                        scApp.VehicleService.Command.Loadunload(idle_vh.VEHICLE_ID,
                                                                can_load_agv_station_port.CassetteID,
                                                                can_load_agv_station_port.ADR_ID, can_unload_agv_station_port.ADR_ID,
                                                                can_load_agv_station_port.PORT_ID, can_unload_agv_station_port.PORT_ID);
                    }
                    else
                    {
                        LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(RandomGeneratesCommandTimerActionTiming), Device: string.Empty,
                                      Data: $"Can't find the path.");
                    }
                    //}
                }
            }
        }
 public bool add(APORTSTATION portStation)
 {
     try
     {
         using (DBConnection_EF con = DBConnection_EF.GetUContext())
         {
             portStationDao.add(con, portStation);
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
         return(false);
     }
     return(true);
 }
示例#28
0
        private Task <(bool is_success, object result)> findHasCSTAndInculdCycleTestAGVStation(string zoneID)
        {
            var          agv_stations = scApp.PortStationBLL.OperateCatch.loadAGVPortStation(zoneID);
            APORTSTATION agv_station  = null;

            if (agv_stations == null)
            {
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(RandomGeneratesCommandTimerActionTiming), Device: string.Empty,
                              Data: $"No find can unload agv station,{zoneID}");
            }
            else
            {
                agv_station = agv_stations.Where(station => !SCUtility.isEmpty(station.CST_ID) && station.IncludeCycleTest).
                              FirstOrDefault();
            }
            return(Task.FromResult((agv_station != null, (object)agv_station)));
        }
        public bool getAddressID(string adr_port_id, out string adr, out E_VH_TYPE vh_type)
        {
            APORTSTATION port = scApp.MapBLL.getPortByPortID(adr_port_id);

            if (port != null)
            {
                adr     = port.ADR_ID.Trim();
                vh_type = port.ULD_VH_TYPE;
                return(true);
            }
            else
            {
                adr     = adr_port_id;
                vh_type = E_VH_TYPE.None;
                return(false);
            }
        }
示例#30
0
        private void CycleRunOnlyMove()
        {
            List <AVEHICLE> vhs = scApp.VehicleBLL.cache.loadAllVh();

            foreach (AVEHICLE vh in vhs)
            {
                if (vh.isTcpIpConnect &&
                    vh.MODE_STATUS == ProtocolFormat.OHTMessage.VHModeStatus.AutoRemote &&
                    vh.ACT_STATUS == ProtocolFormat.OHTMessage.VHActionStatus.NoCommand &&
                    !SCUtility.isEmpty(vh.CUR_ADR_ID) &&
                    //scApp.CMDBLL.canAssignCmdNew(vh.VEHICLE_ID, E_CMD_TYPE.Move).canAssign)
                    scApp.CMDBLL.canAssignCmdNew(vh, E_CMD_TYPE.Move).canAssign)
                {
                    //找一份目前儲位的列表
                    if (agvStations == null || agvStations.Count == 0)
                    {
                        agvStations = scApp.PortStationBLL.OperateCatch.loadAllPortStation().ToList();
                    }
                    //如果取完還是空的 就跳出去
                    if (agvStations == null || agvStations.Count == 0)
                    {
                        return;
                    }
                    //刪除目前Vh所在的port位置
                    foreach (var port_station in agvStations.ToList())
                    {
                        if (SCUtility.isMatche(port_station.ADR_ID, vh.CUR_ADR_ID))
                        {
                            agvStations.Remove(port_station);
                        }
                    }

                    //隨機找出讓車子移至下一個Port的地方
                    int          task_RandomIndex = rnd_Index.Next(agvStations.Count - 1);
                    APORTSTATION p         = agvStations[task_RandomIndex];
                    bool         isSuccess = true;
                    if (scApp.GuideBLL.IsRoadWalkable(vh.CUR_ADR_ID, p.ADR_ID))
                    {
                        isSuccess &= scApp.VehicleService.Command.Move(vh.VEHICLE_ID, p.ADR_ID).isSuccess;
                    }
                    agvStations.Remove(p);
                }
            }
        }