private void BuildS1F14(SECSTransaction trans) { trans.Secondary.Root.Name = "CRA"; SECSItem item = trans.Secondary.Root.AddNew("L"); SECSItem itemCommAck = item.AddNew("COMMACK", "Establish communications acknowledge code"); itemCommAck.Format = SECS_FORMAT.BINARY; itemCommAck.Value = 0; SECSItem itemMCInfo = item.AddNew("L"); itemMCInfo.AddNew("MDLN", "Equipment Model Type"); itemMCInfo.Item("MDLN").Format = SECS_FORMAT.ASCII; itemMCInfo.Item("MDLN").Value = "LH620"; itemMCInfo.AddNew("SOFTREV", "Software revision code"); itemMCInfo.Item("SOFTREV").Format = SECS_FORMAT.ASCII; itemMCInfo.Item("SOFTREV").Value = "1.2.0"; trans.Reply(); }
static string wsSML(SECSItem item, int indent) { StringBuilder strReturn = new StringBuilder(""); string str = ""; if (item == null) { return(strReturn.ToString()); } var indentStr = new string(' ', indent); strReturn.Append(indentStr); strReturn.Append("<"); strReturn.Append(ToSML(item.Format)); strReturn.Append(" ["); strReturn.Append(item.ItemCount); strReturn.Append("] "); switch (item.Format) { case SECS_FORMAT.LIST: strReturn.Append("\n"); int count = item.ItemCount; for (int i = 0; i < count; i++) { str = wsSML(item.Item(i), indent + SmlIndent); strReturn.Append(str); } strReturn.Append(indentStr); break; case SECS_FORMAT.ASCII: case SECS_FORMAT.JIS8: strReturn.Append("\'"); strReturn.Append(item.Value); strReturn.Append('\''); break; default: strReturn.Append(item.Value); break; } strReturn.Append(">" + "\n"); return(strReturn.ToString()); }
static void Write(TextWriter writer, SECSItem item, int indent) { if (item == null) { return; } var indentStr = new string(' ', indent); writer.Write(indentStr); writer.Write('<'); writer.Write(ToSML(item.Format)); writer.Write(" ["); writer.Write(item.ItemCount); writer.Write("] "); switch (item.Format) { case SECS_FORMAT.LIST: writer.WriteLine(); int count = item.ItemCount; for (int i = 0; i < count; i++) { Write(writer, item.Item(i), indent + SmlIndent); } writer.Write(indentStr); break; case SECS_FORMAT.ASCII: case SECS_FORMAT.JIS8: writer.Write('\''); writer.Write(item.ToString()); writer.Write('\''); break; default: writer.Write(item.ToString()); break; } writer.WriteLine('>'); }