Esempio n. 1
0
 public Device(String name, XmlNode deviceNode, Protocol protocol)
 {
     this.name = name;
     foreach (XmlNode node in deviceNode.ChildNodes)
     {
         switch (node.Name)
         {
             case "options":
                 foreach (XmlNode optNode in node.ChildNodes)
                 {
                     Option opt = Option.fromXml(optNode);
                     options.Add(opt);
                 }
                 break;
             case "responds_when":
                 responds_when = Rule.fromXml(node, protocol);
                 break;
             case "transactions":
                 foreach (XmlNode tNode in node.ChildNodes)
                 {
                     Transaction t = Transaction.fromXml(tNode, protocol);
                     transactions.Add(t);
                 }
                 break;
             default:
                 throw new NotSupportedException("Unknown node: " + node.Name);
         }
     }
 }
Esempio n. 2
0
 public RuleIsSet(XmlNode node, Protocol protocol)
 {
     if (node.Name == "isnset")
         reverse = true;
     else
         reverse = false;
     variable = node.Attributes["name"].Value;
 }
Esempio n. 3
0
 public static Rule fromXml(XmlNode node, Protocol protocol)
 {
     if (!ruleClasses.ContainsKey(node.Name))
         throw new ArgumentException("Unknown rule " + node.Name);
     return (Rule)ruleClasses[
              node.Name
              ].GetConstructor(new Type[] { typeof(XmlNode), typeof(Protocol) })
              .Invoke(new object[] { node, protocol });
 }
Esempio n. 4
0
 public RuleBlock(XmlNode node, Protocol protocol)
 {
     if (node.Name == "conditional")
         failSilently = true;
     foreach (XmlNode child in node.ChildNodes)
     {
         if(child.Name[0] != '#')
             rules.Add(Rule.fromXml(child, protocol));
     }
     if (node.Attributes["name"] != null)
         name = node.Attributes["name"].Value;
 }
Esempio n. 5
0
        public RuleField(XmlNode node, Protocol p)
        {
            if (node.Attributes["name"] != null)
                name = node.Attributes["name"].Value;
            else
                name = "";

            type = node.Attributes["type"].Value;

            if (node.Attributes["value"] != null)
            {
                value = Expression.fromString(node.Attributes["value"].Value);
            }
        }
Esempio n. 6
0
 public RuleMatch(XmlNode node, Protocol proto)
 {
     if (node.Attributes["name"] != null)
     {
         // <match name=... value=... />
         Expression var = new VariableExpression("$" + node.Attributes["name"].Value);
         Expression value = Expression.fromString(node.Attributes["value"].Value);
         myExpr = new FunctionCallExpression("==", new List<Expression>(new Expression[] { var, value }));
     }
     else
     {
         // <match_expr>...</match_expr>
         myExpr = Expression.fromString(node.InnerText);
     }
 }
Esempio n. 7
0
 public RuleIncMsg(XmlNode node, Protocol proto)
 {
     p = proto;
 }
Esempio n. 8
0
 public void ProtocolConstructorTest()
 {
     protocol = new Protocol("..\\..\\..\\ProtoEngine\\Modbus-serial.xml");
 }
Esempio n. 9
0
 public static Device fromXml(XmlNode deviceNode, Protocol protocol)
 {
     return new Device(deviceNode.Attributes["name"].Value, deviceNode, protocol);
 }
Esempio n. 10
0
 public static DevicePrototype fromXml(XmlNode node, Protocol protocol)
 {
     return new DevicePrototype(node, protocol);
 }
Esempio n. 11
0
 public DevicePrototype(XmlNode node, Protocol protocol)
 {
     device = Device.fromXml(node, protocol);
 }
Esempio n. 12
0
 public RuleSet(XmlNode node, Protocol proto)
 {
     name = node.Attributes["name"].Value;
     value = Expression.fromString(node.Attributes["value"].Value);
 }
Esempio n. 13
0
 public static Transaction fromXml(XmlNode node, Protocol protocol)
 {
     return new Transaction(node, protocol);
 }
Esempio n. 14
0
 public Transaction(XmlNode node, Protocol protocol)
 {
     rule = new RuleBlock(node, protocol);
 }