Пример #1
0
        /// <summary>
        /// 获取一个监视表格内所有被监视的软元件
        /// </summary>
        /// <param name="table">监视表格</param>
        static private void GetRegisters(MonitorVariableTable table)
        {
            foreach (ElementModel emodel in table.Elements)
            {
                string ivname = emodel.ShowName;
                if (!regids.ContainsKey(ivname))
                {
                    IValueModel ivmodel = null;
                    switch (emodel.ShowType)
                    {
                    case "BOOL":
                        ivmodel = ValueParser.ParseBitValue(ivname);
                        break;

                    case "WORD":
                    case "UWORD":
                    case "BCD":
                        ivmodel = ValueParser.ParseWordValue(ivname);
                        break;

                    case "DWORD":
                    case "UDWORD":
                        ivmodel = ValueParser.ParseDoubleWordValue(ivname);
                        break;

                    case "FLOAT":
                        ivmodel = ValueParser.ParseFloatValue(ivname);
                        break;
                    }
                    regs.Add(ivmodel);
                    regids.Add(ivname, regids.Count());
                }
            }
        }
Пример #2
0
        static private void Read(MainMonitor mmoni)
        {
            int sz = ReadE16();

            sz += eid;
            while (eid < sz)
            {
                string name = ReadTextE8();
                MonitorVariableTable mvtable = new MonitorVariableTable(name, mmoni);
                int count = (int)edata[eid++];
                while (count-- > 0)
                {
                    int          regid   = ReadE16();
                    IValueModel  ivmodel = regs[regid];
                    ElementModel emodel  = new ElementModel();
                    emodel.IsIntrasegment = ivmodel.IsVariable;
                    if (ivmodel is BitValue)
                    {
                        emodel.ShowType = "BOOL";
                    }
                    if (ivmodel is WordValue)
                    {
                        emodel.ShowType = "WORD";
                    }
                    if (ivmodel is DoubleWordValue)
                    {
                        emodel.ShowType = "DWORD";
                    }
                    if (ivmodel is FloatValue)
                    {
                        emodel.ShowType = "FLOAT";
                    }
                    emodel.ShowName = ivmodel.ValueString;
                    mvtable.AddElement(emodel);
                }
            }
        }