Example #1
0
        public static String ReadString(string VariableName, string code)
        {
            DeviceManager devicemanager = DeviceManager.getInstance();
            BaseDevice    device        = devicemanager.getDevice(code);
            DeviceType    devicetype    = device.CurrentDeviceType;

            switch (devicetype)
            {
            case DeviceType.Analysis:
                Convert.ChangeType(device, Assembly.Load("Instrument").GetType("Instrument.MultiTunnelVirtualDevice"));
                break;

            case DeviceType.Clone:
                Convert.ChangeType(device, Assembly.Load("Instrument").GetType("Instrument.CloneSelectionVirtualDevice"));
                break;

            case DeviceType.Dispen:
                Convert.ChangeType(device, Assembly.Load("Instrument").GetType("Instrument.AutoDispenVirtualDevice"));
                break;

            case DeviceType.Liquid:
                Convert.ChangeType(device, Assembly.Load("Instrument").GetType("Instrument.LiquidProcessVirtualDevice"));
                break;

            case DeviceType.Matrix:
                Convert.ChangeType(device, Assembly.Load("Instrument").GetType("Instrument.MatrixSystemVirtualDevice"));
                break;

            case DeviceType.Storage:
                Convert.ChangeType(device, Assembly.Load("Instrument").GetType("Instrument.MicroStorageVirtualDevice"));
                break;

            default:
                Convert.ChangeType(device, Assembly.Load("Instrument").GetType("Instrument.DemoVirtualDevice"));
                break;
            }

            Type         type = device.GetType();
            PropertyInfo pi   = type.GetProperty(VariableName);
            FieldInfo    fi   = type.GetField(VariableName);

            if (pi != null)
            {
                return((String)pi.GetValue(device, null));
            }
            if (fi != null)
            {
                return((String)fi.GetValue(device));
            }
            if (pi == null && fi == null)
            {
                Console.WriteLine("找不到变量:" + VariableName);
            }
            return(null);
        }
Example #2
0
        public static void WriteArray(string VariableName, string code, object[] value)
        {
            DeviceManager devicemanager = DeviceManager.getInstance();
            BaseDevice    device        = devicemanager.getDevice(code);
            Type          type          = device.GetType();
            PropertyInfo  pi            = type.GetProperty(VariableName);
            FieldInfo     fi            = type.GetField(VariableName);

            if (fi != null)
            {
                fi.SetValue(device, value);
            }
        }
Example #3
0
        public static object[] ReadArray(string VariableName, string code)
        {
            DeviceManager devicemanager = DeviceManager.getInstance();
            BaseDevice    device        = devicemanager.getDevice(code);
            Type          type          = device.GetType();
            PropertyInfo  pi            = type.GetProperty(VariableName);
            FieldInfo     fi            = type.GetField(VariableName);

            if (fi != null)
            {
                return((object[])fi.GetValue(device));
            }
            else
            {
                throw new Exception("找不到变量或变量类型不对:" + VariableName);
            }
        }