public Dictionary <string, ProtDom> prot_dict = new Dictionary <string, ProtDom>(); //协议字典 public PD_Obj(Dictionary <string, object> v, DataType t, MC_Prot pd) : base(v, t, pd) { if (!v.ContainsKey("prot_list")) { return; } ArrayList list = v["prot_list"] as ArrayList; foreach (var item in list) { var tv = item as Dictionary <string, object>; string s; if (tv.ContainsKey("name")) { s = tv["name"] as string; } else { s = name + "._" + prot_list.Count.ToString(); //若没有显式指明名称,分配自动名称 } prot_list.Add(s); var p = MC_Prot.factory(tv, p_mcp); //递归创建自己的子协议域 p.father_Dom = this; //给上层引用赋值 p.name = s; //覆盖子节点的名称 prot_dict[s] = p; } }
public Dictionary <string, PD_LineObj> textline_dict = new Dictionary <string, PD_LineObj>(); //文本协议字典 public void formJson(Dictionary <string, object> v) //初始化 { if (v.ContainsKey("para_dict")) { ArrayList list = v["para_dict"] as ArrayList; foreach (var item in list) { var tv = item as Dictionary <string, object>; string s = tv["name"] as string; para_dict[s] = ParaValue.factory(tv); //构建参数 } } if (v.ContainsKey("prot_root")) { prot_root = MC_Prot.factory(v["prot_root"] as Dictionary <string, object>, this); //递归创建自己的子协议域 } //文本行协议 if (v.ContainsKey("textline_dict")) { ArrayList list = v["textline_dict"] as ArrayList; foreach (var item in list) { var tv = item as Dictionary <string, object>; string s = ""; if (tv.ContainsKey("name")) { s = tv["name"] as string; } int col_n = (int)tv["col_n"]; //必须描述此协议的列数 s += "-" + col_n.ToString(); textline_dict[s] = new PD_LineObj(tv, DataType.str, this); } } }
public Dictionary <int, ProtDom> prot_map = new Dictionary <int, ProtDom>(); //各协议描述符头部,由int对协议进行索引 public PD_Switch(Dictionary <string, object> v, DataType t, MC_Prot pd) : base(v, t, pd) { ref_type = v["ref_type"] as string; if (v.ContainsKey("cfg_str_type")) { cfg_str_type = v["cfg_str_type"] as string; // } var dict = v["prot_map"] as Dictionary <string, object>; //各协议由字典组织 foreach (var item in dict) { int k = 0; if (cfg_str_type == "hex") { k = int.Parse(item.Key, System.Globalization.NumberStyles.HexNumber); } else { int.TryParse(item.Key, out k); } var tv = item.Value as Dictionary <string, object>; var p = MC_Prot.factory(tv, p_mcp); //递归创建自己的子协议域 p.father_Dom = this; //给上层引用赋值 prot_map[k] = p; } }