예제 #1
0
 /// <summary>
 /// tidy analog quantity parameters
 /// </summary>
 private static void TidyAnalogQuantityParameters(DataTable dt, OutputInfo outputInfo)
 {
     foreach (DataRow row in dt.Rows)
     {
         TidyAnalogQuantityParameters(row, outputInfo);
     }
 }
예제 #2
0
        /// <summary>
        /// tidy analog quantity parameters
        /// </summary>
        private static void TidyAnalogQuantityParameters(string filePath, OutputInfo outputInfo)
        {
            _dt = ExcelRead.ReadExcel(filePath, "analog quantity");

            if (_dt == null)
            {
                return;
            }

            TidyAnalogQuantityParameters(_dt, outputInfo);
        }
예제 #3
0
        /// <summary>
        /// tidy analog quantity parameters
        /// </summary>
        private static void TidyAnalogQuantityParameters(DataRow row, OutputInfo outputInfo)
        {
            var value = Convert.ToString(row[0]);

            if (!value.Contains("word"))
            {
                return;
            }

            switch (value)
            {
                case "word0":
                    outputInfo.UnitID = Convert.ToString(row[4]);
                    return;
                case "word1":
                    outputInfo.ProtocolVersion = Convert.ToString(row[4]);
                    return;
            }

            var item = new ItemInfo();

            value = value.Replace("word", "");
            var id = Convert.ToInt32(value);
            item.ID = Convert.ToString(1000 + id);

            item.Name = Convert.ToString(row[3]);
            if (item.Name.Contains("obligate"))
            {
                return;
            }

            item.Paramtype = "0";

            item.Permission = "1";
            if (Convert.ToString(row[2]) == "/")
            {
                item.Permission = "0";
            }

            value = Convert.ToString(row[5]);
            switch (value)
            {
                case "0.1":
                    item.Precision = "1";
                    break;
                case "0.01":
                    item.Precision = "2";
                    break;
                default:
                    item.Precision = "0";
                    break;
            }

            item.Valuetype = item.Precision == "0" ? "int" : "float";

            if (item.Valuetype == "int")
            {
                //word1:P2*256+P3
                item.Expression = "P" + Convert.ToString(id * 2) + "*256+P" + Convert.ToString(id * 2 + 1);
            }
            else
            {
                //word1:W2/10, precision: 0.1
                item.Expression = "W" + Convert.ToString(id * 2) + "/" + Convert.ToString(Math.Pow(10, Convert.ToInt32(item.Precision)));
            }

            item.Unit = Convert.ToString(row[6]);

            value = Convert.ToString(row[4]);
            if (!value.Contains("value"))
            {
                item.Result = Common.ReplaceChar(value) + ",";
            }

            outputInfo.AnalogQuantityList.Add(item);
        }
예제 #4
0
 /// <summary>
 /// clear resource
 /// </summary>
 private static void ClearResource(OutputInfo outputInfo)
 {
     outputInfo.SwitchingValueList.Clear();
     outputInfo.AnalogQuantityList.Clear();
 }
예제 #5
0
        /// <summary>
        /// tidy switching value parameters
        /// </summary>
        private static void TidySwitchingValueParameters(DataRow row, OutputInfo outputInfo)
        {
            var value = Convert.ToString(row[3]);

            if (!value.Contains("bit"))
            {
                return;
            }

            var item = new ItemInfo();

            value = value.Replace("bit", "");
            var id = Convert.ToInt32(value)/8;
            item.ID = Convert.ToString(5000 + Convert.ToInt32(value));

            item.Name = Convert.ToString(row[4]);
            if (item.Name.Contains("obligate"))
            {
                return;
            }

            item.Paramtype = Convert.ToString(row[6]).Contains("status") ? "0" : "1";

            item.Permission = "1";
            if (Convert.ToString(row[2]) == "/")
            {
                item.Permission = "0";
            }

            item.Valuetype = "bool";
            item.Precision = "0";

            //byte0~bit7:P0b7
            item.Expression = "P" + Convert.ToString(id) + "b" + Convert.ToString(Convert.ToInt32(value) % 8);

            item.Unit = "";

            if (item.Paramtype == "0")
            {
                item.Result = Common.ReplaceChar(Convert.ToString(row[5])) + ",";
            }

            outputInfo.SwitchingValueList.Add(item);
        }
예제 #6
0
 /// <summary>
 /// tidy parameters
 /// </summary>
 public static void TidyParameters(string filePath, OutputInfo outputInfo)
 {
     ClearResource(outputInfo);
     TidyAnalogQuantityParameters(filePath, outputInfo);
     TidySwitchingValueParameters(filePath, outputInfo);
 }
예제 #7
0
 /// <summary>
 /// tidy switching value parameters
 /// </summary>
 private static void TidySwitchingValueParameters(DataTable dt, OutputInfo outputInfo)
 {
     foreach (DataRow row in dt.Rows)
     {
         TidySwitchingValueParameters(row, outputInfo);
     }
 }
예제 #8
0
        /// <summary>
        /// tidy switching value parameters
        /// </summary>
        private static void TidySwitchingValueParameters(string filePath, OutputInfo outputInfo)
        {
            _dt = ExcelRead.ReadExcel(filePath, "switching value");

            if (_dt == null)
            {
                return;
            }

            TidySwitchingValueParameters(_dt, outputInfo);
        }
예제 #9
0
 /// <summary>
 /// output switching value
 /// </summary>
 private static void OutputSwitchingValues(OutputInfo outputInfo)
 {
     Antlr4.StringTemplate.Template template = InitializeTemplate();
     template.Add("ItemInfos", outputInfo.SwitchingValueList);
     AutoOutput.WriteFile(OutputPath + "SwitchingValues.xml", template.Render());
 }
예제 #10
0
 /// <summary>
 /// output analog quantity
 /// </summary>
 private static void OutputAnalogQuantities(OutputInfo outputInfo)
 {
     Antlr4.StringTemplate.Template template = InitializeTemplate();
     template.Add("ItemInfos", outputInfo.AnalogQuantityList);
     AutoOutput.WriteFile(OutputPath + "AnalogQuantities.xml", template.Render());
 }
예제 #11
0
 /// <summary>
 /// output code
 /// </summary>
 public static void OutputInternal(OutputInfo outputInfo)
 {
     OutputAnalogQuantities(outputInfo);
     OutputSwitchingValues(outputInfo);
 }