/// <summary> /// /// </summary> /// <param name="deviceType"></param> /// <param name="operaNode"></param> /// <returns></returns> private static Opera CreateSimpleOpera(string deviceType, XmlNode operaNode) { XmlElement e = operaNode as XmlElement; Opera opera = null; SendPart sp = null; ReceivePartCollection rps = new ReceivePartCollection(); string name = GetAttribute(e, DeviceDefineNodeNames.OperaName); string text = GetAttribute(e, DeviceDefineNodeNames.OperaText, true); string args = GetAttribute(e, DeviceDefineNodeNames.OperaArgs, true); foreach (XmlNode node in operaNode.ChildNodes) { switch (node.Name) { case DeviceDefineNodeNames.SendPart: sp = CreateSendPart(node); break; case DeviceDefineNodeNames.ReceivePart: ReceivePart rp = CreateReceivePart(node); rps.Add(rp); break; } } opera = new Opera(deviceType, name, text, args); opera.SendPart = sp; opera.ReceiveParts = rps; log.Info("Create opera '{0}', receivepart count '{1}'", name, rps.Count); return(opera); }
/// <summary> /// /// </summary> /// <param name="sendpartnode"></param> /// <returns></returns> static private SendPart CreateSendPart(XmlNode sendpartnode) { SendPart sp = new SendPart(); sp.DataFieldManager.CRCBegin = GetCRCBegin((XmlElement)sendpartnode); DataField df = null; foreach (XmlNode node in sendpartnode.ChildNodes) { switch (node.Name) { case DeviceDefineNodeNames.DataField: df = CreateDataField(node); df.IsValueVolatile = true; sp.Add(df); break; } } ICRCer crcer = GetCRCer(sendpartnode); sp.DataFieldManager.CRCer = crcer; return(sp); }
/// <summary> /// /// </summary> /// <param name="sendpartnode"></param> /// <returns></returns> private static SendPart CreateSendPart(XmlNode sendpartnode) { SendPart sp = new SendPart(); sp.DataFieldManager.CRCBegin = GetCRCBegin((XmlElement)sendpartnode); DataField df = null; foreach (XmlNode node in sendpartnode.ChildNodes) { switch (node.Name) { case DeviceDefineNodeNames.DataField: df = CreateDataField(node); df.IsValueVolatile = true; sp.Add(df); break; } } ICRCer crcer = GetCRCer(sendpartnode); sp.DataFieldManager.CRCer = crcer; return sp; }