예제 #1
0
        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);
                }
            }
        }
예제 #2
0
        public ParaValue ref_para = null;                                     //引用的参数
        public ProtDom(Dictionary <string, object> v, DataType t, MC_Prot pd) //从json构造对象
        {                                                                     //这里遇到错误就throw出去,不想throw的才判断
            p_mcp = pd;
            if (v.ContainsKey("id"))
            {
                id = (int)v["id"];
            }
            if (v.ContainsKey("name"))
            {
                name = (string)v["name"];
            }
            type = t;
            while (v.ContainsKey("ref_name"))
            {
                ref_name = (string)v["ref_name"];
                if (!p_mcp.para_dict.ContainsKey(ref_name))
                {
                    break;                                            //引用的参数不对,按没有算
                }
                ref_para = p_mcp.para_dict[ref_name];                 //参数表先于协议加载
                return;
            }
            //没有引用参数,说明是协议内部结构数据
            var tv = new Dictionary <string, object>();

            tv["type"] = "u64";
            tv["name"] = "";
            tv["len"]  = 8;
            ref_para   = new ParaValue_Val(tv, DataType.u64);           //创建一个内部参数对象
        }
예제 #3
0
파일: com_mc.cs 프로젝트: yangzigy/com_mc
        public int update_times = 0;     //刷新倒计时

        public DataDes(ParaValue v)
        {
            val           = v;
            val.update_cb = val_updated;             //注册参数的回调函数
            update_cb     = void_fun;
            update_dis    = void_fun;
        }
예제 #4
0
파일: com_mc.cs 프로젝트: yangzigy/com_mc
 public void val_updated(ParaValue pv)         //当此参数改变时
 {
     update_cb(this);
 }
예제 #5
0
 static public void void_cb(ParaValue pv)
 {
 }