Example #1
0
        /// <summary>
        /// 將回傳是否為該Segment的第一台車
        /// </summary>
        /// <param name="vh"></param>
        /// <returns></returns>
        public (bool isFirst, AVEHICLE firstVh) IsFirst(AVEHICLE vh)
        {
            if (Vehicles.Count == 0)
            {
                return(true, null);
            }
            else
            {
                AVEHICLE first_vh = Vehicles.First();

                return(first_vh.Equals(vh), first_vh);
            }
        }
Example #2
0
        public AVEHICLE GetNextVehicle(AVEHICLE vh)
        {
            if (!Vehicles.Contains(vh))
            {
                return(null);
            }
            if (Vehicles.First() == vh)
            {
                return(null);
            }

            var vh_linked_node = Vehicles.Find(vh);

            return(vh_linked_node.Previous.Value);
        }
Example #3
0
        public void Leave(AVEHICLE vh)
        {
            if (vh == null)
            {
                return;
            }
            lock (Vehicles)
            {
                if (Vehicles.Contains(vh))
                {
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                                  Data: $"vh:{vh.VEHICLE_ID} leave segment:{SEG_NUM}",
                                  VehicleID: vh.VEHICLE_ID,
                                  CarrierID: vh.CST_ID);

                    Vehicles.Remove(vh);
                    onLeave(vh);
                }
            }
        }
Example #4
0
        //public bool fireDoorOpen { get; set; }
        //public bool fireDoorCloseGrant { get; set; }
        //public bool fireDoorCrossingSignal { get; set; }

        public void fireDoorCancelAbortCommand(SCApplication scApp)
        {
            //Cancel當前Queue的會找不到路徑的命令。
            List <ACMD_MCS> queue_mcs_cmds = scApp.CMDBLL.loadMCS_Command_Queue();

            foreach (ACMD_MCS cmd in queue_mcs_cmds)
            {
                bool isWalkable       = true;
                bool source_is_a_port = scApp.PortStationBLL.OperateCatch.IsExist(cmd.HOSTSOURCE);
                if (source_is_a_port)
                {
                    APORTSTATION source_port_station = scApp.PortStationBLL.OperateCatch.getPortStation(cmd.HOSTSOURCE);
                    APORTSTATION dest_port_station   = scApp.PortStationBLL.OperateCatch.getPortStation(cmd.HOSTDESTINATION);
                    isWalkable = scApp.GuideBLL.IsRoadWalkable(source_port_station.ADR_ID, dest_port_station.ADR_ID);
                }
                else
                {
                    AVEHICLE     carry_vh          = scApp.VehicleBLL.cache.getVehicleByRealID(cmd.HOSTSOURCE);
                    APORTSTATION dest_port_station = scApp.PortStationBLL.OperateCatch.getPortStation(cmd.HOSTDESTINATION);
                    isWalkable = scApp.GuideBLL.IsRoadWalkable(carry_vh.CUR_ADR_ID, dest_port_station.ADR_ID);
                }



                if (!isWalkable)
                {
                    //await Task.Run(() => mainform.BCApp.scApp.VehicleService.doCancelOrAbortCommandByMCSCmdID(mcs_cmd.CMD_ID, cnacel_type));
                    scApp.VehicleService.doCancelOrAbortCommandByMCSCmdID(cmd.CMD_ID, CMDCancelType.CmdCancel);
                }
            }
            //Abort已經執行,但是會經過防火門的命令。
            List <ACMD_MCS> executing_mcs_cmds = scApp.CMDBLL.loadMCS_Command_Executing();

            foreach (ACMD_MCS cmd in executing_mcs_cmds)
            {
                bool isWalkable       = true;
                bool source_is_a_port = scApp.PortStationBLL.OperateCatch.IsExist(cmd.HOSTSOURCE);
                if (source_is_a_port)
                {
                    APORTSTATION source_port_station = scApp.PortStationBLL.OperateCatch.getPortStation(cmd.HOSTSOURCE);
                    APORTSTATION dest_port_station   = scApp.PortStationBLL.OperateCatch.getPortStation(cmd.HOSTDESTINATION);
                    isWalkable = scApp.GuideBLL.IsRoadWalkable(source_port_station.ADR_ID, dest_port_station.ADR_ID);
                }
                else
                {
                    AVEHICLE     carry_vh          = scApp.VehicleBLL.cache.getVehicleByRealID(cmd.HOSTSOURCE);
                    APORTSTATION dest_port_station = scApp.PortStationBLL.OperateCatch.getPortStation(cmd.HOSTDESTINATION);
                    isWalkable = scApp.GuideBLL.IsRoadWalkable(carry_vh.CUR_ADR_ID, dest_port_station.ADR_ID);
                }

                if (!isWalkable)
                {
                    //await Task.Run(() => mainform.BCApp.scApp.VehicleService.doCancelOrAbortCommandByMCSCmdID(mcs_cmd.CMD_ID, cnacel_type));
                    CMDCancelType cnacel_type = default(CMDCancelType);
                    if (cmd.TRANSFERSTATE < sc.E_TRAN_STATUS.Transferring)
                    {
                        cnacel_type = CMDCancelType.CmdCancel;
                    }
                    else if (cmd.TRANSFERSTATE < sc.E_TRAN_STATUS.Canceling)
                    {
                        cnacel_type = CMDCancelType.CmdAbort;
                    }
                    else
                    {
                        continue;
                    }
                    scApp.VehicleService.doCancelOrAbortCommandByMCSCmdID(cmd.CMD_ID, cnacel_type);
                }
            }
        }
Example #5
0
 public VehicleTimerAction(AVEHICLE _vh, string name, long intervalMilliSec)
     : base(name, intervalMilliSec)
 {
     vh = _vh;
 }
Example #6
0
        public ACMD ConvertToCmd(BLL.PortStationBLL portStationBLL, BLL.SequenceBLL sequenceBLL, AVEHICLE assignVehicle)
        {
            var source_port_station = portStationBLL.OperateCatch.getPortStation(this.HOSTSOURCE);
            var desc_port_station   = portStationBLL.OperateCatch.getPortStation(this.HOSTDESTINATION);
            //如果HostSource port是與車子一樣的話,代表是要去進行Unload的動作
            bool source_is_a_port = portStationBLL.OperateCatch.IsExist(this.HOSTSOURCE);

            string     host_source = source_is_a_port ? this.HOSTSOURCE : "";
            E_CMD_TYPE cmd_type    = source_is_a_port ? E_CMD_TYPE.LoadUnload : E_CMD_TYPE.Unload; //如果Source不是Port的話,則代表是在車上

            string from_adr = source_port_station == null ? string.Empty : source_port_station.ADR_ID;
            string to_adr   = desc_port_station == null ? string.Empty : desc_port_station.ADR_ID;

            return(new ACMD()
            {
                ID = sequenceBLL.getCommandID(SCAppConstants.GenOHxCCommandType.Auto),
                TRANSFER_ID = this.ID,
                VH_ID = assignVehicle.VEHICLE_ID,
                CARRIER_ID = this.CARRIER_ID,
                CMD_TYPE = cmd_type,
                SOURCE = from_adr,
                DESTINATION = to_adr,
                PRIORITY = this.PRIORITY_SUM,
                CMD_INSER_TIME = DateTime.Now,
                CMD_STATUS = E_CMD_STATUS.Queue,
                SOURCE_PORT = host_source,
                DESTINATION_PORT = this.HOSTDESTINATION,
                COMPLETE_STATUS = ProtocolFormat.OHTMessage.CompleteStatus.Move
            });
        }
Example #7
0
        public void RefreshVhOrder(sc.BLL.VehicleBLL vehicleBLL, sc.BLL.SectionBLL sectionBLL)
        {
            lock (Vehicles)
            {
                Vehicles.Clear();
                List <AVEHICLE> vhs = vehicleBLL.cache.loadVhsBySegmentID(this.SEG_NUM);
                foreach (AVEHICLE vh in vhs)
                {
                    if (!Vehicles.Contains(vh))
                    {
                        ASECTION current_section   = sectionBLL.cache.GetSection(vh.CUR_SEC_ID);
                        int      current_sec_index = Sections.IndexOf(current_section);
                        if (current_sec_index == -1)
                        {
                            return;
                        }
                        if (Vehicles.Count > 0)
                        {
                            AVEHICLE next_vh = null;
                            for (int i = current_sec_index; i < Sections.Count; i++)
                            {
                                string   next_sec_id = Sections[i].SEC_ID;
                                AVEHICLE vh_temp     = Vehicles.Where(v => Common.SCUtility.isMatche(v.CUR_SEC_ID, next_sec_id)).
                                                       FirstOrDefault();
                                if (vh_temp != null)
                                {
                                    if (i == current_sec_index)
                                    {
                                        if (vh_temp.ACC_SEC_DIST > vh.ACC_SEC_DIST)
                                        {
                                            next_vh = vh_temp;
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        next_vh = vh_temp;
                                        break;
                                    }
                                }
                            }
                            if (next_vh == null)
                            {
                                Vehicles.AddFirst(vh);
                                LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                                              Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is first",
                                              VehicleID: vh.VEHICLE_ID,
                                              CarrierID: vh.CST_ID);
                            }
                            else
                            {
                                var next_vh_node = Vehicles.Find(next_vh);
                                Vehicles.AddAfter(next_vh_node, vh);

                                LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                                              Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,after {next_vh.VEHICLE_ID}",
                                              VehicleID: vh.VEHICLE_ID,
                                              CarrierID: vh.CST_ID);
                            }
                        }
                        else
                        {
                            Vehicles.AddLast(vh);
                            LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                                          Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is last",
                                          VehicleID: vh.VEHICLE_ID,
                                          CarrierID: vh.CST_ID);
                        }
                    }
                }
            }
        }
Example #8
0
 private void onEntry(AVEHICLE vh)
 {
     VehicleEntry?.Invoke(this, vh);
 }
Example #9
0
 private void onLeave(AVEHICLE vh)
 {
     VehicleLeave?.Invoke(this, vh);
 }
Example #10
0
        private void RefreshVehicleLocalByRelativePosition(AVEHICLE vh, BLL.SectionBLL sectionBLL)
        {
            ASECTION current_section   = sectionBLL.cache.GetSection(vh.CUR_SEC_ID);
            int      current_sec_index = Sections.IndexOf(current_section);

            if (current_sec_index == -1)
            {
                return;
            }
            if (Vehicles.Count > 0)
            {
                AVEHICLE next_vh = null;
                for (int i = current_sec_index; i < Sections.Count; i++)
                {
                    string   next_sec_id = Sections[i].SEC_ID;
                    AVEHICLE vh_temp     = Vehicles.Where(v => Common.SCUtility.isMatche(v.CUR_SEC_ID, next_sec_id)).
                                           FirstOrDefault();
                    if (vh_temp != null)
                    {
                        if (i == current_sec_index)
                        {
                            if (vh_temp.ACC_SEC_DIST > vh.ACC_SEC_DIST)
                            {
                                next_vh = vh_temp;
                                break;
                            }
                        }
                        else
                        {
                            next_vh = vh_temp;
                            break;
                        }
                    }
                }
                if (next_vh == null)
                {
                    Vehicles.AddFirst(vh);
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                                  Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is first",
                                  VehicleID: vh.VEHICLE_ID,
                                  CarrierID: vh.CST_ID);
                }
                else
                {
                    var next_vh_node = Vehicles.Find(next_vh);
                    Vehicles.AddAfter(next_vh_node, vh);

                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                                  Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,after {next_vh.VEHICLE_ID}",
                                  VehicleID: vh.VEHICLE_ID,
                                  CarrierID: vh.CST_ID);
                }
            }
            else
            {
                Vehicles.AddLast(vh);
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                              Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is first",
                              VehicleID: vh.VEHICLE_ID,
                              CarrierID: vh.CST_ID);
            }
        }
Example #11
0
        //public void Entry(AVEHICLE vh, BLL.SectionBLL sectionBLL, bool is_need_recalculate)
        //{
        //    if (vh == null) return;
        //    lock (Vehicles)
        //    {
        //        if (!Vehicles.Contains(vh))
        //        {
        //            if (is_need_recalculate)
        //            {
        //                ASECTION current_section = sectionBLL.cache.GetSection(vh.CUR_SEC_ID);
        //                int current_sec_index = Sections.IndexOf(current_section);
        //                if (current_sec_index == -1) return;
        //                if (Vehicles.Count > 0)
        //                {
        //                    AVEHICLE next_vh = null;
        //                    for (int i = current_sec_index; i < Sections.Count; i++)
        //                    {
        //                        string next_sec_id = Sections[i].SEC_ID;
        //                        AVEHICLE vh_temp = Vehicles.Where(v => Common.SCUtility.isMatche(v.CUR_SEC_ID, next_sec_id)).
        //                                                    FirstOrDefault();
        //                        if (vh_temp != null)
        //                        {
        //                            if (i == current_sec_index)
        //                            {
        //                                if (vh_temp.ACC_SEC_DIST > vh.ACC_SEC_DIST)
        //                                {
        //                                    next_vh = vh_temp;
        //                                    break;
        //                                }
        //                            }
        //                            else
        //                            {
        //                                next_vh = vh_temp;
        //                                break;
        //                            }
        //                        }
        //                    }
        //                    if (next_vh == null)
        //                    {
        //                        Vehicles.AddFirst(vh);
        //                        LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
        //                           Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is first",
        //                           VehicleID: vh.VEHICLE_ID,
        //                           CarrierID: vh.CST_ID);

        //                    }
        //                    else
        //                    {
        //                        var next_vh_node = Vehicles.Find(next_vh);
        //                        Vehicles.AddAfter(next_vh_node, vh);

        //                        LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
        //                           Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,after {next_vh.VEHICLE_ID}",
        //                           VehicleID: vh.VEHICLE_ID,
        //                           CarrierID: vh.CST_ID);
        //                    }
        //                }
        //                else
        //                {
        //                    Vehicles.AddLast(vh);
        //                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
        //                       Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is first",
        //                       VehicleID: vh.VEHICLE_ID,
        //                       CarrierID: vh.CST_ID);
        //                }
        //            }
        //            else
        //            {
        //                Vehicles.AddLast(vh);
        //                LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
        //                   Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is last",
        //                   VehicleID: vh.VEHICLE_ID,
        //                   CarrierID: vh.CST_ID);
        //            }
        //            onEntry(vh);
        //        }
        //    }
        //}
        public void Entry(AVEHICLE vh, BLL.SectionBLL sectionBLL, bool is_need_recalculate)
        {
            if (vh == null)
            {
                return;
            }
            lock (Vehicles)
            {
                bool is_contains = Vehicles.Contains(vh);
                //if (!Vehicles.Contains(vh))
                //{
                if (is_need_recalculate)
                {
                    if (is_contains)
                    {
                        Vehicles.Remove(vh);
                    }
                    ASECTION current_section   = sectionBLL.cache.GetSection(vh.CUR_SEC_ID);
                    int      current_sec_index = Sections.IndexOf(current_section);
                    if (current_sec_index == -1)
                    {
                        return;
                    }
                    if (Vehicles.Count > 0)
                    {
                        AVEHICLE next_vh = null;
                        for (int i = current_sec_index; i < Sections.Count; i++)
                        {
                            string   next_sec_id = Sections[i].SEC_ID;
                            AVEHICLE vh_temp     = Vehicles.Where(v => Common.SCUtility.isMatche(v.CUR_SEC_ID, next_sec_id)).
                                                   FirstOrDefault();
                            if (vh_temp != null)
                            {
                                if (i == current_sec_index)
                                {
                                    if (vh_temp.ACC_SEC_DIST > vh.ACC_SEC_DIST)
                                    {
                                        next_vh = vh_temp;
                                        break;
                                    }
                                }
                                else
                                {
                                    next_vh = vh_temp;
                                    break;
                                }
                            }
                        }
                        if (next_vh == null)
                        {
                            Vehicles.AddFirst(vh);
                            LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                                          Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is first",
                                          VehicleID: vh.VEHICLE_ID,
                                          CarrierID: vh.CST_ID);
                        }
                        else
                        {
                            var next_vh_node = Vehicles.Find(next_vh);
                            Vehicles.AddAfter(next_vh_node, vh);

                            LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                                          Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,after {next_vh.VEHICLE_ID}",
                                          VehicleID: vh.VEHICLE_ID,
                                          CarrierID: vh.CST_ID);
                        }
                    }
                    else
                    {
                        Vehicles.AddLast(vh);
                        LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                                      Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is first",
                                      VehicleID: vh.VEHICLE_ID,
                                      CarrierID: vh.CST_ID);
                    }
                }
                else
                {
                    if (!is_contains)
                    {
                        Vehicles.AddLast(vh);
                        LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(ASEGMENT), Device: "AGVC",
                                      Data: $"vh:{vh.VEHICLE_ID} entry segment:{SEG_NUM} ,is last",
                                      VehicleID: vh.VEHICLE_ID,
                                      CarrierID: vh.CST_ID);
                    }
                }
                if (!is_contains)
                {
                    onEntry(vh);
                }
                //}
            }
        }