コード例 #1
0
        static private SimulateVariableUnit _Create(string _name)
        {
            SimulateBitUnit sbunit = new SimulateBitUnit();

            if (sbunit._Check_Name(_name))
            {
                sbunit.Name = _name;
                return(sbunit);
            }
            SimulateWordUnit swunit = new SimulateWordUnit();

            if (swunit._Check_Name(_name))
            {
                swunit.Name = _name;
                return(swunit);
            }
            SimulateDWordUnit sdwunit = new SimulateDWordUnit();

            if (sdwunit._Check_Name(_name))
            {
                sdwunit.Name = _name;
                return(sdwunit);
            }
            SimulateFloatUnit sfunit = new SimulateFloatUnit();

            if (sfunit._Check_Name(_name))
            {
                sfunit.Name = _name;
                return(sfunit);
            }
            SimulateUnitSeries ssunit = new SimulateUnitSeries();

            if (ssunit._Check_Name(_name))
            {
                ssunit.Name = _name;
                ssunit.CreateExpand();
                return(ssunit);
            }
            return(null);
        }
コード例 #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);
        }
コード例 #3
0
        static private SimulateVariableUnit _Create(string _name, string type)
        {
            switch (type)
            {
            case "BIT":
                SimulateBitUnit sbunit = new SimulateBitUnit();
                if (sbunit._Check_Name(_name))
                {
                    sbunit.Name = _name;
                    return(sbunit);
                }
                break;

            case "WORD":
                SimulateWordUnit swunit = new SimulateWordUnit();
                if (swunit._Check_Name(_name))
                {
                    swunit.Name = _name;
                    return(swunit);
                }
                break;

            case "DWORD":
                SimulateDWordUnit sdwunit = new SimulateDWordUnit();
                if (sdwunit._Check_Name(_name))
                {
                    sdwunit.Name = _name;
                    return(sdwunit);
                }
                break;

            case "FLOAT":
                SimulateFloatUnit sfunit = new SimulateFloatUnit();
                if (sfunit._Check_Name(_name))
                {
                    sfunit.Name = _name;
                    return(sfunit);
                }
                break;

            case "PULSE":
                SimulatePulseUnit spunit = new SimulatePulseUnit();
                if (spunit._Check_Name(_name))
                {
                    spunit.Name = _name;
                    return(spunit);
                }
                break;

            default:
                SimulateUnitSeries ssunit = new SimulateUnitSeries();
                if (ssunit._Check_Name(_name))
                {
                    ssunit.Name = _name;
                    ssunit.CreateExpand();
                    return(ssunit);
                }
                break;
            }
            return(null);
        }