Exemplo n.º 1
0
        public string AddInstrumentCommunication(InstrumentCommunicationSetting CommunicationSetting)
        {
            //if (CommunicationSetting == null || string.IsNullOrEmpty(CommunicationSetting.ID))
            //{
            //    throw new IDNullException("通讯设置ID不可为空!");
            //}

            string sqlCommandText = ModuleConfiguration.SQL_CMD_InsertInstrumentCommunicationSetting;

            this.dmlOperable.ExeSql(sqlCommandText, new Dictionary <string, object>()
            {
                //{ "@ID", long.Parse(CommunicationSetting.ID)},
                { "@InstrumentID", CommunicationSetting.Instrument.ID },
                { "@Type", CommunicationSetting.CommunicationType },
                { "@IpAddress", CommunicationSetting.IpAddress },
                { "@PortNumber", CommunicationSetting.PortNumber },
                { "@SerialPortName", CommunicationSetting.SerialPortName },
                { "@SerialPortBaudRate", CommunicationSetting.SerialPortBaudRate },
                { "@BluetoothDeviceName", CommunicationSetting.BluetoothDeviceName },
                { "@BluetoothAddress", CommunicationSetting.BluetoothAddress },
                { "@BluetoothKey", CommunicationSetting.BluetoothKey },
                { "@Protocol", CommunicationSetting.Protocol },
                { "@AssemblyName", CommunicationSetting.AssemblyName },
                { "@AssemblyPath", CommunicationSetting.AssemblyFilePath },
                { "@ClassName", CommunicationSetting.ClassName },
                { "@Version", CommunicationSetting.Version },
            });

            return(GenerateInstrumentCommunicationSettingID(0)); //CommunicationSetting.ID;
        }
Exemplo n.º 2
0
        public InstrumentCommunicationSetting SetInstrumentCommunication(string SettingID, InstrumentCommunicationSetting CommunicationSetting)
        {
            if (string.IsNullOrEmpty(SettingID))
            {
                throw new IDNullException("仪器设置ID不可为空!");
            }
            int intI = 0;

            if (CommunicationSetting.CommunicationType == CommunicationTypeEnum.TcpIpOverEthernet)
            {
                intI = 3;
            }
            else if (CommunicationSetting.CommunicationType == CommunicationTypeEnum.SerialPort)
            {
                intI = 1;
            }
            else if (CommunicationSetting.CommunicationType == CommunicationTypeEnum.Bluetooth)
            {
                intI = 2;
            }

            //            string sqlCommandText = "UPDATE InstrumentCommnunicationSettings SET " + "ics_Type = " + intI + ", " +
            //"ics_IpAddress = '" + CommunicationSetting.IpAddress + "', " +
            //"ics_PortNumber = " + CommunicationSetting.PortNumber + ", " +
            //"ics_SerialPortName ='" + CommunicationSetting.SerialPortName + "', " +
            //"ics_SerialPortBaudRate =" + CommunicationSetting.SerialPortBaudRate + ", " +
            //"ics_BluetoothDeviceName = '" + CommunicationSetting.BluetoothDeviceName + "'," +
            //"ics_BluetoothAddress = '" + CommunicationSetting.BluetoothAddress + "', " +
            //"ics_BluetoothKey = '" + CommunicationSetting.BluetoothKey + "' WHERE InstrumentID = " + SettingID + "; ";

            string sqlCommandText = ModuleConfiguration.SQL_CMD_UpdateInstrumentCommunicationSetting;

            this.dmlOperable.ExeSql(sqlCommandText, new Dictionary <string, object>()
            {
                { "@InstrumentID", CommunicationSetting.Instrument.ID },
                { "@Type", intI },
                { "@IpAddress", CommunicationSetting.IpAddress },
                { "@PortNumber", CommunicationSetting.PortNumber },
                { "@SerialPortName", CommunicationSetting.SerialPortName },
                { "@SerialPortBaudRate", CommunicationSetting.SerialPortBaudRate },
                { "@BluetoothDeviceName", CommunicationSetting.BluetoothDeviceName },
                { "@BluetoothAddress", CommunicationSetting.BluetoothAddress },
                { "@BluetoothKey", CommunicationSetting.BluetoothKey },
                { "@Protocol", CommunicationSetting.Protocol },
                { "@AssemblyName", CommunicationSetting.AssemblyName },
                { "@AssemblyPath", CommunicationSetting.AssemblyFilePath },
                { "@ClassName", CommunicationSetting.ClassName },
                { "@Version", CommunicationSetting.Version },
            });

            return(CommunicationSetting);
        }