Пример #1
0
 internal static ArrayList GetMessageStructure(string inputMsgFile, CommunicationManager.ReceiverType RxType, int mid, int sid, string protocol, string version)
 {
     XPathNavigator navigator = new XPathDocument(inputMsgFile).CreateNavigator();
     int num = 2;
     int num2 = 2;
     int num3 = 0;
     if (RxType == CommunicationManager.ReceiverType.SLC)
     {
         num3 = 1;
     }
     ArrayList list = new ArrayList();
     SLCMsgStructure structure = new SLCMsgStructure();
     int num4 = 0;
     XPathExpression expr = navigator.Compile(string.Concat(new object[] { "/protocols/protocol[@name='", protocol, "'][@version='", version, "']/input/message[@mid='", mid, "'][@subid = '", sid, "']/field" }));
     XPathNodeIterator iterator = navigator.Select(expr);
     if (iterator.Count == 0)
     {
         expr = navigator.Compile(string.Concat(new object[] { "/protocols/protocol[@name='", protocol, "'][@version='", version, "']/input/message[@mid='", mid, "'][@subid = '']/field" }));
         iterator = navigator.Select(expr);
     }
     try
     {
         int num5 = 0;
         int num6 = 0;
         while (iterator.MoveNext())
         {
             XPathNavigator navigator2 = iterator.Current.Clone();
             if (navigator2.GetAttribute("name", "").Contains("LOOP"))
             {
                 num5 = int.Parse(navigator2.GetAttribute("numloops", ""));
                 num6 = int.Parse(navigator2.GetAttribute("numlines", ""));
                 for (int i = 0; i < num5; i++)
                 {
                     for (int j = 0; j < num6; j++)
                     {
                         iterator.MoveNext();
                         navigator2 = iterator.Current.Clone();
                         structure.fieldNumber = iterator.CurrentPosition;
                         structure.fieldName = navigator2.GetAttribute("name", "");
                         structure.bytes = int.Parse(navigator2.GetAttribute("bytes", ""));
                         structure.datatype = navigator2.GetAttribute("datatype", "");
                         structure.units = navigator2.GetAttribute("units", "");
                         if (navigator2.GetAttribute("scale", "") == "")
                         {
                             structure.scale = 1.0;
                         }
                         else
                         {
                             structure.scale = double.Parse(navigator2.GetAttribute("scale", ""));
                         }
                         structure.startByte = (((num + num2) + num3) + 1) + num4;
                         structure.endByte = (structure.startByte + structure.bytes) - 1;
                         structure.defaultValue = navigator2.GetAttribute("default", "");
                         num4 += structure.bytes;
                         list.Add(structure);
                     }
                 }
             }
             else
             {
                 structure.fieldNumber = iterator.CurrentPosition;
                 structure.fieldName = navigator2.GetAttribute("name", "");
                 structure.bytes = int.Parse(navigator2.GetAttribute("bytes", ""));
                 structure.datatype = navigator2.GetAttribute("datatype", "");
                 structure.units = navigator2.GetAttribute("units", "");
                 if (navigator2.GetAttribute("scale", "") == "")
                 {
                     structure.scale = 1.0;
                 }
                 else
                 {
                     structure.scale = double.Parse(navigator2.GetAttribute("scale", ""));
                 }
                 structure.startByte = (((num + num2) + num3) + 1) + num4;
                 structure.endByte = (structure.startByte + structure.bytes) - 1;
                 structure.defaultValue = navigator2.GetAttribute("default", "");
                 num4 += structure.bytes;
                 list.Add(structure);
             }
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
     return list;
 }