Ejemplo n.º 1
0
        public static SimulateVariableModel Create(IEnumerable <SimulateVariableUnit> svunits)
        {
            SimulateVariableUnit svunitf = svunits.First();

            if (svunitf is SimulateBitUnit)
            {
                return(SimulateBitModel.Create(svunits));
            }
            if (svunitf is SimulateWordUnit)
            {
                return(SimulateWordModel.Create(svunits));
            }
            if (svunitf is SimulateDWordUnit)
            {
                return(SimulateDWordModel.Create(svunits));
            }
            if (svunitf is SimulateFloatUnit)
            {
                return(SimulateFloatModel.Create(svunits));
            }
            return(null);
        }
Ejemplo n.º 2
0
        static public new SimulateWordModel Create(IEnumerable <SimulateVariableUnit> svunits)
        {
            SimulateWordUnit  swunit  = (SimulateWordUnit)(svunits.First());
            SimulateWordModel swmodel = new SimulateWordModel();
            string            _name   = swunit.Name;
            int i = 0;

            while (char.IsLetter(_name[i]))
            {
                i++;
            }
            swmodel.Base   = _name.Substring(0, i);
            swmodel.Offset = int.Parse(_name.Substring(i));
            swmodel.size   = svunits.Count();
            swmodel.values = new SimulateWordUnit[swmodel.size];
            i = 0;
            foreach (SimulateVariableUnit svunit in svunits)
            {
                swmodel.values[i++] = (SimulateWordUnit)(svunit);
            }
            return(swmodel);
        }
Ejemplo n.º 3
0
        public static SimulateVariableModel Create(string name, int size, string type)
        {
            int i = 0;

            while (char.IsLetter(name[i]))
            {
                i++;
            }
            string bname  = name.Substring(0, i);
            int    offset = int.Parse(name.Substring(i));
            SimulateVariableModel svmodel = null;

            switch (type)
            {
            case "BIT":
                svmodel = new SimulateBitModel();
                break;

            case "WORD":
                svmodel = new SimulateWordModel();
                break;

            case "DWORD":
                svmodel = new SimulateDWordModel();
                break;

            case "FLOAT":
                svmodel = new SimulateFloatModel();
                break;

            default:
                return(svmodel);
            }
            svmodel.Base   = bname;
            svmodel.Offset = offset;
            svmodel.Size   = size;
            return(svmodel);
        }