Example #1
0
        protected String[] TransSections_ForRealVehC_New_Cmd(String[] FromVehCSections, String[] FromVehCAddresses, out int store_startLength, ref int[] reserve_direction_list)
        {
            int tempcount              = 0;
            int startpointnum          = 0;
            int endpointnum            = 0;
            int directionOfThisSection = 0;

            store_startLength = 0;
            String[] tempSections  = new string[500];
            String[] ToOHTSections = null;
            int      sectionnum    = FromVehCSections.Count();

            int[] restore_the_direction = GetDirection4Sections_New_Cmd(FromVehCSections, FromVehCAddresses);
            reserve_direction_list = restore_the_direction;
            DataTable datable4VehMAP = new ReadCsv()._ReadParamsFromVhSectionData(CsvGlobal.VehCSections);

            DefineStartEndPoint(ref startpointnum, ref endpointnum, FromVehCAddresses, datable4VehMAP, restore_the_direction, sectionnum, out store_startLength);
            if (Veh_VehM_Global.fakeMap != true)
            {
                for (int i = 0; i < FromVehCSections.Count(); i++)
                {
                    directionOfThisSection = restore_the_direction[i];
                    CutSection_ForRealVehC_New_Cmd(FromVehCSections[i], directionOfThisSection, ref tempSections, ref tempcount);
                }
            }
            ToOHTSections = new string[tempcount];
            for (int i = 0; i < tempcount; i++)
            {
                ToOHTSections[i] = tempSections[i];
            }
            return(ToOHTSections);
        }
Example #2
0
        /*
         * Set the start & end number
         */
        protected void DefineStartEndPoint(ref int startpointnum, ref int endpointnum, String[] FromVehCAddresses, DataTable datable4VehMAP, int[] restore_the_direction, int section_num, out int storestartLength)
        {
            int  forwardlength = 0;
            int  reverselength = 0;
            bool startrecheck  = false;
            bool endrecheck    = false;

            storestartLength = 0;
            DataTable datable4VehAddress = new ReadCsv()._ReadParamsFromVhSectionData(CsvGlobal.VehCAddress);

            for (int i = 0; i < datable4VehAddress.Rows.Count; i++)
            {
                if ((string)datable4VehAddress.Rows[i][0] == FromVehCAddresses[0])
                {
                    forwardlength = int.Parse((string)datable4VehAddress.Rows[i][3]);
                    reverselength = int.Parse((string)datable4VehAddress.Rows[i][4]);
                    if (restore_the_direction[0] == 1)
                    {
                        if ((string)datable4VehAddress.Rows[i][1] != "1")
                        {
                            storestartLength = forwardlength;
                            startpointnum    = Int32.Parse((string)datable4VehAddress.Rows[i][5]);
                        }
                    }
                    else if (restore_the_direction[0] == 2)
                    {
                        if ((string)datable4VehAddress.Rows[i][1] != "1")
                        {
                            storestartLength = reverselength;
                            startpointnum    = Int32.Parse((string)datable4VehAddress.Rows[i][6]);
                        }
                    }
                    startrecheck = true;
                }
                if ((string)datable4VehAddress.Rows[i][0] == FromVehCAddresses[FromVehCAddresses.Count() - 1])
                {
                    if (restore_the_direction[section_num - 1] == 1)
                    {
                        if ((string)datable4VehAddress.Rows[i][1] != "1")
                        {
                            endpointnum = Int32.Parse((string)datable4VehAddress.Rows[i][5]);
                        }
                    }
                    else if (restore_the_direction[section_num - 1] == 2)
                    {
                        if ((string)datable4VehAddress.Rows[i][1] != "1")
                        {
                            endpointnum = Int32.Parse((string)datable4VehAddress.Rows[i][6]);
                        }
                    }
                    endrecheck = true;
                }
            }
            if (endrecheck == false || startrecheck == false)
            {
                eqTool.Fun_Log(eqTool.MyLogKind.GeneralProcess, NLog.LogLevel.Info, null, "TransSectioncs : TransSections_ForRealVehC : The address must be wrong");
            }
        }
Example #3
0
        protected String[] TransSections_ForRealVehC(String[] FromVehCSections, String[] FromVehCAddresses, out int store_startLength, ref int [] reserve_direction_list)
        {
            string forward_reverse = "";
            int    tempcount       = 0;

            Veh_VehM_Global.StartendCheck startendCheck = Veh_VehM_Global.StartendCheck.None;
            int startpointnum          = 0;
            int endpointnum            = 0;
            int directionOfThisSection = 0;

            store_startLength = 0;
            String[] tempSections  = new string[500];
            String[] ToOHTSections = null;
            int      sectionnum    = FromVehCSections.Count();

            int[] restore_the_direction = GetDirection4Sections(FromVehCSections, FromVehCAddresses);
            reserve_direction_list = restore_the_direction;
            DataTable datable4VehMAP = new ReadCsv()._ReadParamsFromVhSectionData(CsvGlobal.VehC2VehMap);

            DefineStartEndPoint(ref startpointnum, ref endpointnum, FromVehCAddresses, datable4VehMAP, restore_the_direction, sectionnum, out store_startLength);
            if (Veh_VehM_Global.fakeMap != true)
            {
                for (int i = 0; i < FromVehCSections.Count(); i++)
                {
                    if (i == 0)
                    {
                        startendCheck = Veh_VehM_Global.StartendCheck.startpoint;
                    }
                    else if (i == FromVehCSections.Count() - 1)
                    {
                        startendCheck = Veh_VehM_Global.StartendCheck.endpoint;
                    }
                    else
                    {
                        startendCheck = Veh_VehM_Global.StartendCheck.None;
                    }
                    directionOfThisSection = restore_the_direction[i];
                    CutSection_ForRealVehC(startpointnum, endpointnum, startendCheck, FromVehCSections[i], datable4VehMAP, directionOfThisSection, ref tempSections, ref tempcount, FromVehCSections.Count());
                }
            }
            ToOHTSections = new string[tempcount];
            for (int i = 0; i < tempcount; i++)
            {
                ToOHTSections[i] = tempSections[i];
            }
            return(ToOHTSections);
        }
Example #4
0
        public static void OverrideAnalyze(Veh_VehM_Global.ActionType Last_Cmd, ref string[] LoadSections, ref string[] UnLoadSections)
        {
            DataTable dt = new ReadCsv()._ReadParamsFromVhSectionData(CsvGlobal.NowFileDir);
            //string[] passSections = Veh_VehM_Global.GuideSections;//0304
            int  splitnum = -1;
            bool check    = false;
            int  halfsignal;
            //DataTable dt = ReadCsv._ReadParamsFromVhSectionData();
            string moveAdr   = Veh_VehM_Global.Address;
            string loadAdr   = Veh_VehM_Global.LoadAddress;
            string unloadAdr = Veh_VehM_Global.UnloadAddress;
            string aim_Adr;

            switch (Last_Cmd)
            {
            case Veh_VehM_Global.ActionType.Move:
                aim_Adr = moveAdr;

                break;

            case Veh_VehM_Global.ActionType.Load:
                aim_Adr = loadAdr;

                LoadSections = Veh_VehM_Global.GuideSectionsStartToLoad;
                break;

            case Veh_VehM_Global.ActionType.UnLoad:
                aim_Adr        = unloadAdr;
                UnLoadSections = Veh_VehM_Global.GuideSections;
                break;

            case Veh_VehM_Global.ActionType.Load_Unload:
                if (Veh_VehM_Global.hasCst == VhLoadCSTStatus.Exist)
                {
                }
                else
                {
                    CheckSections Temp = new CheckSections();
                    Temp.Set_New_Section(loadAdr, unloadAdr, ref LoadSections, ref UnLoadSections);
                }
                break;
            }
        }
Example #5
0
        public static bool check_the_start_Address_ForOHT(string section_Num)
        {
            bool      checkthestartaddress = false;
            DataTable dt            = new ReadCsv()._ReadParamsFromVhSectionData(CsvGlobal.NowFileDir);
            int       tempsection   = Int32.Parse(section_Num);
            string    tempsection_1 = tempsection.ToString();

            DataRow[] drselectsection = dt.Select("SEC_ID = '" + tempsection_1 + "'");
            if (drselectsection[0].ItemArray[0] != null)
            {
                string temp = (string)drselectsection[0].ItemArray[6];
                eqTool.Fun_Log(eqTool.MyLogKind.GeneralProcess, NLog.LogLevel.Info, null, "@Veh_VehM_Comm_Data :temp = {0}", temp.ToString());
                eqTool.Fun_Log(eqTool.MyLogKind.GeneralProcess, NLog.LogLevel.Info, null, "@Veh_VehM_Comm_Data :Veh_VehM_Global.Address = {0}", Veh_VehM_Global.Address.ToString());
                if (temp == Veh_VehM_Global.Address)
                {
                    checkthestartaddress = true;
                }
            }
            return(checkthestartaddress);
        }
Example #6
0
        public static string FindSectionOfAddress(string address)
        {
            try
            {
                DataTable dt = new ReadCsv()._ReadParamsFromVhSectionData(CsvGlobal.NowFileDir);
                DataRow[] rowsHaveTargetAddress = dt.Select("TO_ADR_ID = '" + address + "'");

                foreach (var row in rowsHaveTargetAddress)
                {
                    string testSection = row.ItemArray[0].ToString().PadLeft(4, '0');
                    if (Veh_VehM_Global.GuideSections.Contains(testSection))
                    {
                        return(testSection);
                    }
                }
                return(string.Empty);
            }
            catch (Exception ex)
            {
                string err = ex.Message + Environment.NewLine + ex.StackTrace;
                eqTool.Fun_Log(eqTool.MyLogKind.GeneralProcess, NLog.LogLevel.Info, null, err);
                return(err);
            }
        }
Example #7
0
        protected int[] GetDirection4Sections_New_Cmd(String[] FromVehCSections, String[] FromVehCAddresses)
        {
            try
            {
                DataTable addressChecktb      = new ReadCsv()._ReadParamsFromVhSectionData(CsvGlobal.VehCAddress);
                DataTable dt                  = new ReadCsv()._ReadParamsFromVhSectionData(CsvGlobal.VehCSections);
                int[]     DirectionOfSections = new int[100];
                bool      tempcheckflag       = false;
                bool      startpointchck      = false; // if the startpoint isn't the node point;
                int       temp                = 0;
                int[]     firstnum            = new int[FromVehCAddresses.Count()];

                /*
                 * //search for each sections on the datatable SEC_ID
                 */
                for (int i = 0; i < FromVehCSections.Count(); i++)
                {
                    startpointchck = false;
                    tempcheckflag  = false;
                    for (int j = 0; j < dt.Rows.Count; j++)
                    {
                        if ((string)dt.Rows[j][0] == FromVehCSections[i])
                        {
                            temp          = j;
                            tempcheckflag = true;
                            break;
                        }
                    }
                    if (tempcheckflag != true)
                    {
                        eqTool.Fun_Log(eqTool.MyLogKind.GeneralProcess, NLog.LogLevel.Error, null, "@TransSectioncs : GetDirection4Sections : There is no that section.");
                        break;
                    }

                    /*
                     * Search the fromAdr to check the section direction;
                     * Check the default direction.
                     */
                    int start_adr;
                    Console.WriteLine((string)dt.Rows[temp][2]);
                    if ((string)dt.Rows[temp][2] == FromVehCAddresses[i])
                    {
                        DirectionOfSections[i] = (Int32)Veh_VehC_Global.direction.forward;
                        startpointchck         = true;
                    }
                    else if ((string)dt.Rows[temp][2] == FromVehCAddresses[i + 1])
                    {
                        DirectionOfSections[i] = (Int32)Veh_VehC_Global.direction.reverse;
                        startpointchck         = true;
                    }
                    #region Use by Old Cmd ( Have Segment Only)
                    //if (startpointchck == false)
                    //{
                    //    if ((string)dt.Rows[temp][3 - start_adr] == FromVehCAddresses[i])
                    //    {
                    //        DirectionOfSections[i] = (Int32)Veh_VehC_Global.direction.reverse;
                    //        startpointchck = true;
                    //    }
                    //    else if ((string)dt.Rows[temp][3 - start_adr] == FromVehCAddresses[i + 1])
                    //    {
                    //        DirectionOfSections[i] = (Int32)Veh_VehC_Global.direction.forward;
                    //        startpointchck = true;
                    //    }
                    //}
                    //if (startpointchck == false)
                    //{
                    //    for (int j = 0; j < addressChecktb.Rows.Count; j++)
                    //    {
                    //        if ((string)addressChecktb.Rows[j][0] == FromVehCAddresses[i])
                    //        {
                    //            firstnum[i] = int.Parse((string)addressChecktb.Rows[j][5]);
                    //        }
                    //        if ((string)addressChecktb.Rows[j][0] == FromVehCAddresses[i + 1])
                    //        {
                    //            firstnum[i + 1] = int.Parse((string)addressChecktb.Rows[j][5]);
                    //        }
                    //    }
                    //    if (firstnum[i + 1] > firstnum[i])
                    //    {
                    //        DirectionOfSections[i] = (Int32)Veh_VehC_Global.direction.forward;
                    //        startpointchck = true;
                    //    }
                    //    else if (firstnum[i] > firstnum[i + 1])
                    //    {
                    //        DirectionOfSections[i] = (Int32)Veh_VehC_Global.direction.reverse;
                    //        startpointchck = true;
                    //    }
                    //}
                    #endregion
                    if (startpointchck == false)
                    {
                        eqTool.Fun_Log(eqTool.MyLogKind.GeneralProcess, NLog.LogLevel.Info, null, "TransSectioncs : GetDirection4Sections : The address and the map matching must be wrong");
                    }
                }
                return(DirectionOfSections);
            }
            catch (Exception e)
            {
                int[] temp = null;
                return(temp);
            }
        }
Example #8
0
        protected void Set_New_Section(string loadAdr, string unloadAdr, ref string[] LoadSections, ref string[] UnLoadSections)
        {
            DataTable dt = new ReadCsv()._ReadParamsFromVhSectionData(CsvGlobal.NowFileDir);

            string[]  passSections   = Veh_VehM_Global.GuideSections; //0304
            DataRow[] drselectload   = dt.Select("TO_ADR_ID = '" + loadAdr + "'");
            DataRow[] drselectunload = dt.Select("TO_ADR_ID = '" + unloadAdr + "'");
            int       splitnum       = -1;
            bool      check          = false;
            int       halfsignal;

            /////////////////////////////////
            #region Load Sections
            //Load Sections
            /////////////////////////////////
            for (int i = 0; i < drselectload.Count(); i++)
            {
                string loadsectemp = (string)drselectload[i].ItemArray[0];
                string loadsect    = loadsectemp.PadLeft(4, '0');
                check = false;

                for (int j = 0; j < passSections.Count(); j++)
                {
                    if (loadsect == passSections[j])
                    {
                        splitnum = j + 1;
                        check    = true;
                        break;
                    }
                }

                if (check == true) // 181022 Due to that if there has the redrive section, we shouldpick the first one;
                {
                    break;
                }
            }

            if (splitnum == -1)
            {
                Console.WriteLine("Something Wrong ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
                Console.WriteLine("Something Wrong ~~ there should have a section that end at the load address.");
                Console.WriteLine("Something Wrong ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            }
            else
            {
                string[] loadSecArray = new string[splitnum];

                for (int i = 0; i < splitnum; i++)
                {
                    loadSecArray[i] = passSections[i];
                }
                LoadSections = loadSecArray;
            }
            ///<summary>
            ///if there is no section from now to load address , the halfsignal should be 0 ;
            ///</summary>
            if (splitnum != -1)
            {
                halfsignal = splitnum;
            }
            else
            {
                halfsignal = 0;
            }
            #endregion
            /////////////////////////////////
            #region Unload Sections
            //Unload Sections
            /////////////////////////////////
            int unloadStart = 0;
            if (splitnum != -1)
            {
                unloadStart = splitnum - 1;
            }

            for (int i = 0; i < drselectunload.Count(); i++)
            {
                string unloadsectemp = (string)drselectunload[i].ItemArray[0];
                string unloadsect    = unloadsectemp.PadLeft(4, '0');
                check = false;

                for (int j = unloadStart; j < passSections.Count(); j++)
                {
                    if (unloadsect == passSections[j])
                    {
                        splitnum = j + 1;
                        check    = true;
                        break;
                    }
                }

                if (check == true) // 181022 Due to that if there has the redrive section, we shouldpick the first one;
                {
                    break;
                }
            }

            if (splitnum == -1)
            {
                Console.WriteLine("Something Wrong ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
                Console.WriteLine("Something Wrong ~~ there should have a section that end at the unload address.");
                Console.WriteLine("Something Wrong ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            }
            else
            {
                string[] unloadSecArray = new string[splitnum - halfsignal];

                for (int i = halfsignal; i < splitnum; i++)
                {
                    unloadSecArray[i - halfsignal] = passSections[i];
                }
                UnLoadSections = unloadSecArray;
            }
            #endregion
            /////////////////////////////////
        }