예제 #1
0
        private Dictionary <int, StrainChannel> LoadChannels(SerialACT4238Config config)
        {
            Dictionary <int, StrainChannel> strainChannels = new Dictionary <int, StrainChannel>();

            using (SQLiteConnection connection = new SQLiteConnection(config.Database))
            {
                connection.Open();
                string        strainStatement = "select SensorId,ChannelNo,G,R0,K,T0,Constant,InitVal,Desc from StrainChannels where GroupNo ='" + config.id + "'";
                SQLiteCommand command         = new SQLiteCommand(strainStatement, connection);
                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string sensorId  = reader.GetString(0);
                        int    channelNo = reader.GetInt32(1);
                        double g         = reader.GetDouble(2);
                        double r0        = reader.GetDouble(3);
                        double k         = reader.GetDouble(4);
                        double t0        = reader.GetDouble(5);
                        double constant  = reader.GetDouble(6);
                        double initVal   = reader.GetDouble(7);
                        string desc      = reader.GetString(8);
                        int    index     = this.dataGridView1.Rows.Add();
                        this.dataGridView1.Rows[index].Cells[0].Value = desc;

                        StrainChannel channel = new StrainChannel(sensorId, g, r0, k, t0, constant, initVal, desc, index);
                        strainChannels.Add(channelNo, channel);
                    }
                    return(strainChannels);
                }
            }
        }
예제 #2
0
        private void LoadDevices()
        {
            this.deviceList.Clear();
            using (SQLiteConnection connection = new SQLiteConnection(database))
            {
                connection.Open();
                string        strainStatement = "select LocalIP,LocalPort,DeviceId,Path,Type,Desc,RemoteIP,RemotePort from SensorInfo";
                SQLiteCommand command2        = new SQLiteCommand(strainStatement, connection);
                using (SQLiteDataReader reader = command2.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string localIp     = reader.GetString(0);
                        int    localPort   = reader.GetInt32(1);
                        int    deviceId    = reader.GetInt32(2);
                        string path        = reader.GetString(3);
                        string type        = reader.GetString(4);
                        string description = reader.GetString(5);
                        string remoteIp    = reader.GetString(6);
                        int    remotePort  = reader.GetInt32(7);

                        string[]     itemString = { description, remoteIp, remotePort.ToString(), deviceId.ToString(), type, path, localIp };
                        ListViewItem item       = new ListViewItem(itemString);

                        listView1.Items.Add(item);

                        SerialACT4238Config             config   = new SerialACT4238Config(localIp, localPort, remoteIp, remotePort, path, deviceId, type);
                        Dictionary <int, StrainChannel> channels = LoadChannels(config);

                        ACT1238 device = null;

                        if (type == "ACT1238")
                        {
                            device = new ACT1238(config, channels);
                            device.UpdateDataGridView += new EventHandler <UpdateDataGridViewCellsEventArgs>(UpdateGridViewCell);
                        }
                        else
                        {
                        }

                        if (device != null)
                        {
                            this.deviceList.Add(deviceId.ToString(), device);
                        }
                    }
                }
            }
        }