Пример #1
0
        public static void saveAlertPacketContentToDb(PacketData data)
        {
            string rtu       = data.moduleID;
            string tableName = MonitorOPCServer.getInstance().alertTable;

            if (tableName == null)
            {
                return;
            }

            string sql = string.Format("insert into [{0}]" +
                                       "(rtu,[time],alertPosition,alertValue) values('{1}','{2}',{3},{4}", tableName,
                                       data.moduleID, data.sendTime, data.alertPos, data.alertValue);
            DBUtil db = new DBUtil();

            db.executeNonQuerySQL(sql);
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            MonitorOPCServer monitorServer = MonitorOPCServer.getInstance();
            string           ip            = this.textBox1.Text;
            int port = -1;

            try
            {
                port = Convert.ToInt32(this.textBox2.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("端口需要填写一个数字");
                return;
            }

            int minute = 0;

            if (this.checkBox1.Checked)
            {
                try
                {
                    minute = Convert.ToInt32(this.textBox3.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("超时时间需要填写一个数字");
                    return;
                }

                if (minute <= 0)
                {
                    MessageBox.Show("超时时间需要填写一个大于0的数字");
                    return;
                }
            }
            bool enableOutput = this.checkBox2.Checked;

            monitorServer.startMonitor(ip, port, minute, enableOutput);
            this.button1.Enabled = false;
            this.button2.Enabled = true;
        }
Пример #3
0
        public static void savePacketContentToDb(PacketData data)
        {
            string rtu = data.moduleID;

            if (!MonitorOPCServer.getInstance().dbNameMapping.ContainsKey(rtu))
            {
                return;
            }

            string tableName = MonitorOPCServer.getInstance().dbNameMapping[rtu];

            string sql = string.Format("insert into [{0}]" +
                                       "(rtu,[time],dbm,ch1,ch2,ch3,ch4,ch5,ch6,ch7,ch8,ch9,ch10,ch11,ch12,ch13,ch14,ch15,ch16,ch17,ch18) values" +
                                       "('{1}','{2}',{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21})", tableName,
                                       data.moduleID, data.sendTime, data.packetDataMap["GPRS-Level"], data.packetDataMap["AI1/AC1"], data.packetDataMap["AI2/AC2"]
                                       , data.packetDataMap["AI3/AC3"], data.packetDataMap["AI4/AC4"], data.packetDataMap["AI5/AC5"], data.packetDataMap["AI6/AC6"]
                                       , data.packetDataMap["DI1"], data.packetDataMap["DI2"], data.packetDataMap["DI3"], data.packetDataMap["DI4"]
                                       , data.packetDataMap["DI5"], data.packetDataMap["DI6"], data.packetDataMap["DO1"], data.packetDataMap["DO2"]
                                       , data.packetDataMap["DO3"], data.packetDataMap["DO4"], data.packetDataMap["DO5"], data.packetDataMap["DO6"]);

            DBUtil db = new DBUtil();

            db.executeNonQuerySQL(sql);
        }
Пример #4
0
 private void button2_Click_1(object sender, EventArgs e)
 {
     MonitorOPCServer.getInstance().shoutdownMonitor();
     this.button1.Enabled = true;
     this.button2.Enabled = false;
 }
Пример #5
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     MonitorOPCServer.getInstance().shoutdownMonitor();
 }