예제 #1
0
파일: MDIParent1.cs 프로젝트: tgactga/train
        //定时采集数据,读取温度,上传数据
        private void gatherAndReadData_timer_Tick(object sender, EventArgs e)
        {
            readtempTimeCount++;
            uploadTimeCount++;
            //采集关键数据
            gatherCriticalData();
            //读取温度数据
            if (readtempTimeCount == 8)  //4s 读取温度数据
            {
                readtempTimeCount = 0;
                readTemperature();
            }

            if (uploadTimeCount == 8)   //4s上传关键数据
            {
                uploadTimeCount = 0;
                if (Program.g_isNetState)
                {
                    Program.WriteLog(" TCP通信,上传关键数据");
                    string upStr = new BuildMsgUtil().buildUploadCriticalData(Program.g_criticalDataList);
                    tcputil.SendMsg2Server(2, upStr);
                    Program.WriteLog(" 上传关键数据调用成功");

                    //Program.WriteLog(" TCP通信,上传温度数据");
                    //string uptempStr = new BuildMsgUtil().buildUploadTemperatureData(Program.g_tempCellsTerminalList);
                    //tcputil.SendMsg2Server(3, uptempStr);
                    //Program.WriteLog(" 上传温度数据调用成功");
                }
            }
        }
예제 #2
0
        public string SendMessage(int type, string message)
        {
            Program.WriteLog(type + "接收服务器消息" + message);
            string       senMsg   = "";
            BuildMsgUtil buildMsg = new BuildMsgUtil();

            switch (type.ToString().Trim())
            {
            case "1":       // 实时关键数据
                Program.WriteLog("服务器请求实时关键数据");
                senMsg = buildMsg.buildUploadCriticalData(Program.g_criticalDataList);
                break;

            case "2":
                Program.WriteLog("服务器请求实时温度数据");
                senMsg = new BuildMsgUtil().buildUploadTemperatureData(Program.g_tempCellsTerminalList);
                break;

            case "3":
                Program.WriteLog("服务器请求巡检数据");
                senMsg = new BuildMsgUtil().buildXunjianData(Program.g_inspectionRecord);
                break;

            case "4":
                Program.WriteLog("服务器请求错误日志");
                senMsg = "ERRORLOGS";
                break;

            default:

                break;
            }
            return(senMsg);
            // throw new NotImplementedException();
        }
예제 #3
0
        private void XunJianTipsForm_Load(object sender, EventArgs e)
        {
            Program.WriteLog("==========================>>进入InspectTipsForm(巡检时间到提示)页面");
            Program.g_isShowInspectTipsForm = true;
            if (!Program.g_isInspected)    // 未巡检的时候 上传(如果点击了巡检 直接上传了巡检数据)
            {
                //巡检时间到 上传上次巡检数据
                BuildMsgUtil buildMsgUtil = new BuildMsgUtil();
                buildMsgUtil.buildXunjianData(Program.g_inspectionRecord);
            }

            Program.g_isInspected = false; //初始化

            //蜂鸣器长鸣3s提醒用户巡检时间已到
            da.StartAlarm();
            System.Timers.Timer tt = new System.Timers.Timer(3000);
            tt.AutoReset = false;
            tt.Enabled   = true;
            tt.Elapsed  += new System.Timers.ElapsedEventHandler((object sender1, ElapsedEventArgs e1) =>
            {
                da.StopAlarm();
            });

            Label label1 = new Label();

            label1.Text      = "巡检时间到,请巡检";
            label1.AutoSize  = true;
            label1.Font      = new Font("微软雅黑", 21, FontStyle.Bold);
            label1.ForeColor = Color.Red;
            label1.BackColor = Color.Transparent;
            label1.Location  = new System.Drawing.Point(30, 140);
            this.Controls.Add(label1);

            da.StartFlash();
            //点亮巡检灯,通知用户巡检已经完成,5s后关闭巡检灯
            System.Timers.Timer timer = new System.Timers.Timer(5000);
            timer.AutoReset = false;
            timer.Enabled   = true;
            timer.Elapsed  += new System.Timers.ElapsedEventHandler((object sender1, ElapsedEventArgs e1) =>
            {
                da.StopFlash();
            });
        }