コード例 #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 SimulateFloatModel Create(IEnumerable <SimulateVariableUnit> svunits)
        {
            SimulateFloatUnit  sfunit  = (SimulateFloatUnit)(svunits.First());
            SimulateFloatModel sfmodel = new SimulateFloatModel();
            string             _name   = sfunit.Name;
            int i = 0;

            while (char.IsLetter(_name[i]))
            {
                i++;
            }
            sfmodel.Base   = _name.Substring(0, i);
            sfmodel.Offset = int.Parse(_name.Substring(i));
            sfmodel.size   = svunits.Count();
            sfmodel.values = new SimulateFloatUnit[sfmodel.size];
            i = 0;
            foreach (SimulateVariableUnit svunit in svunits)
            {
                sfmodel.values[i++] = (SimulateFloatUnit)(svunit);
            }
            return(sfmodel);
        }
コード例 #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);
        }