예제 #1
0
        /// <summary>
        /// 红外初始化,从配置文件读取参数或者数据库获取
        /// </summary>
        public void Init()
        {
            MySqlConnection conn = null;

            try
            {
                string ip           = INIUtil.Read("DATABASE", "ip", Constant.IniFilePath);
                string strPort      = INIUtil.Read("DATABASE", "port", Constant.IniFilePath);
                string username     = INIUtil.Read("DATABASE", "username", Constant.IniFilePath);
                string password     = INIUtil.Read("DATABASE", "password", Constant.IniFilePath);
                string databaseName = INIUtil.Read("DATABASE", "databaseName", Constant.IniFilePath);

                conn = SqlHelper.GetConnection(ip, Convert.ToInt32(strPort), username, password, databaseName);

                string    MonDev_Index = INIUtil.Read("MonDev", "Index", Constant.IniFilePath);
                string    strSql       = "select * from base_videoserver where MonDev_Index = " + MonDev_Index;
                DataTable data         = SqlHelper.QueryData(conn, strSql, null);

                this.IP = data.Rows[0]["IRStreamIP"].ToString();
                if (!string.IsNullOrEmpty(data.Rows[0]["IRStreamPort"].ToString()))
                {
                    this.port = Convert.ToInt32(data.Rows[0]["IRStreamPort"]);
                }
                telnetCtrl = new IRTelnetCtrl(IP, port, TimeOut);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
예제 #2
0
        public void Init()
        {
            string username = INIUtil.Read("USER", "username", Constant.IniFilePath);

            this.username = username;
            Debug.WriteLine("用户登录信息初始化成功");
        }
예제 #3
0
        private void revVar_timer_tick(object sender, EventArgs e)
        {
            //服务器相关
            label_server.Text         = M_ClientOpt.Pjson.OptJsonQuestConnectStatus().ToString();
            label_loginStatus.Text    = M_ClientOpt.GetLoginStatus().ToString();
            label_heatbeatStatus.Text = M_ClientOpt.globalCtrl.HeartStatus.ToString();
            label12.Text = string.Format("当前服务器IP:{0},端口号:{1}", INIUtil.Read("Server", "ip", Constant.IniFilePath), INIUtil.Read("Server", "port", Constant.IniFilePath));
            label13.Text = string.Format("当前用户登录信息,用户名:{0},密码:{1}", INIUtil.Read("USER", "username", Constant.IniFilePath), INIUtil.Read("USER", "password", Constant.IniFilePath));

            label_IR.Text = M_ClientOpt.globalCtrl.IRScanState().ToString();
            label14.Text  = string.Format("当前红外连接信息,连接IP:{0},端口:{1}", M_ClientOpt.globalCtrl.irCtrl.IP, M_ClientOpt.globalCtrl.irCtrl.port);
            label15.Text  = string.Format("当前可见光连接信息,连接IP:{0},端口:{1},通道:{2},连接名:{3},密码:{4}", M_ClientOpt.globalCtrl.tvCtrl.IP, M_ClientOpt.globalCtrl.tvCtrl.port,
                                          M_ClientOpt.globalCtrl.tvCtrl.channel, M_ClientOpt.globalCtrl.tvCtrl.username, M_ClientOpt.globalCtrl.tvCtrl.password);
            label_FTP.Text      = M_ClientOpt.globalCtrl.GetFtpConnectStatus().ToString();
            label_Database.Text = M_ClientOpt.globalCtrl.GetSqlConnectionStatus().ToString();
            label_cruise.Text   = M_ClientOpt.globalCtrl.cruiseCtrl.cruiseStatus.ToString();
            int TVState = M_ClientOpt.globalCtrl.TVScanState();

            if (TVState == -1)
            {
                label_TV.Text = "已断线";
            }
            else if (TVState == 0)
            {
                label_TV.Text = "未注册";
            }
            else if (TVState == 1)
            {
                label_TV.Text = "登录未预览";
            }
            else if (TVState == 2)
            {
                label_TV.Text = "登录可预览";
            }
        }
예제 #4
0
 public void TestMethod6()
 {
     string          ip           = INIUtil.Read("DATABASE", "ip", Constant.IniFilePath);
     string          strPort      = INIUtil.Read("DATABASE", "port", Constant.IniFilePath);
     string          username     = INIUtil.Read("DATABASE", "username", Constant.IniFilePath);
     string          password     = INIUtil.Read("DATABASE", "password", Constant.IniFilePath);
     string          databaseName = INIUtil.Read("DATABASE", "databaseName", Constant.IniFilePath);
     MySqlConnection conn         = SqlHelper.GetConnection(ip, Convert.ToInt32(strPort), username, password, databaseName);
     string          strSql       = "select * from cruise_spotset where MeasureTask_Index =1";
     DataTable       dt           = SqlHelper.QueryData(conn, strSql, null);
     int             count        = dt.Rows.Count;
     List <SpotSet>  spots        = new List <SpotSet>();
 }
예제 #5
0
        public void TestMethod5()
        {
            string          ip           = INIUtil.Read("DATABASE", "ip", Constant.IniFilePath);
            string          strPort      = INIUtil.Read("DATABASE", "port", Constant.IniFilePath);
            string          username     = INIUtil.Read("DATABASE", "username", Constant.IniFilePath);
            string          password     = INIUtil.Read("DATABASE", "password", Constant.IniFilePath);
            string          databaseName = INIUtil.Read("DATABASE", "databaseName", Constant.IniFilePath);
            MySqlConnection conn         = SqlHelper.GetConnection(ip, Convert.ToInt32(strPort), username, password, databaseName);
            string          strSql       = "SELECT m.MeasureTask_Index,m.PrePosSet_Index,m.DeviceInfo_Index,m.MeaType,m.TaskName,m.GetValueType," +
                                           "p.Position_Index,p.PrePositionNO,p.PrePositionName,p.PrePosType,p.TVZoom,p.IRFocus,p.GoPrePosDelays,p.PanAngle,p.TiltAngle,p.PTZHorAngle,p.PTZVerAngle,p.PaletteType  " +
                                           "from cruise_measuretaskset m, cruise_prepositionset p where m.PrePosSet_Index = p.PrePosSet_Index and p.EnbleMeasure = 1 ";
            //string strSql = "select * from cruise_measuretaskset";

            DataTable datas = SqlHelper.QueryData(conn, strSql, null);
            int       count = datas.Rows.Count;
        }
예제 #6
0
        public bool GetCruiseTasks(int intPosIndex, out List <int> mlstintTastTable)
        {
            //返回任务点的ID列表
            string          ip           = INIUtil.Read("DATABASE", "ip", Constant.IniFilePath);
            string          strPort      = INIUtil.Read("DATABASE", "port", Constant.IniFilePath);
            string          username     = INIUtil.Read("DATABASE", "username", Constant.IniFilePath);
            string          password     = INIUtil.Read("DATABASE", "password", Constant.IniFilePath);
            string          databaseName = INIUtil.Read("DATABASE", "databaseName", Constant.IniFilePath);
            MySqlConnection conn         = SqlHelper.GetConnection(ip, Convert.ToInt32(strPort), username, password, databaseName);
            string          strSql       = "select * from cruise_measuretaskset";
            DataTable       datas        = SqlHelper.QueryData(conn, strSql, null);

            mlstintTastTable = new List <int>();
            for (int i = 0; i < datas.Rows.Count; i++)
            {
                mlstintTastTable.Add(Convert.ToInt32(datas.Rows[i]["MeasureTask_Index"]));
            }
            return(true);
        }
예제 #7
0
        public void SocketServerScan()
        {
            while (true)
            {
                Thread.Sleep(3000);
                Debug.WriteLine(">>>>>>>>>>>>>>>>>>>服务器状态监控线程:" + "服务器连接状态:" + M_ClientOpt.Pjson.OptJsonQuestConnectStatus() + ",用户登录状态:" + M_ClientOpt.GetLoginStatus() + ",心跳检测状态:" + M_ClientOpt.globalCtrl.HeartStatus);

                if (!M_ClientOpt.Pjson.OptJsonQuestConnectStatus())
                {
                    M_ClientOpt.SetLoginStatus();
                    string ip   = INIUtil.Read("Server", "ip", Constant.IniFilePath);
                    string port = INIUtil.Read("Server", "port", Constant.IniFilePath);
                    M_ClientOpt.funEnterMonitorServerPar(ip, Convert.ToInt32(port));
                    M_ClientOpt.funSetupMonitorServer();
                    M_ClientOpt.funbutLoginStatus();
                    connectServerCount++;
                    if (connectServerCount > 20)
                    {
                        connectServerCount = 0;
                        MessageBox.Show("重连服务器失败,请检查服务器是否正常", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    connectServerCount = 0;
                }

                if (!M_ClientOpt.LoginStatus)
                {
                    string username = INIUtil.Read("USER", "username", Constant.IniFilePath);
                    string password = INIUtil.Read("USER", "password", Constant.IniFilePath);
                    M_ClientOpt.funOptbtuUser(username, password);
                    M_ClientOpt.funbutLoginStatus();

                    M_ClientOpt.StartHeartBeat = false;
                }
                else
                {
                    M_ClientOpt.StartHeartBeat = true;
                }
                M_ClientOpt.funbutLoginStatus();
            }
        }
예제 #8
0
        public void UploadPicFilesToFTP(string TVImagefilePath, string IRImagefilePath, out string TVUploadPath, out string IRUploadPath)
        {
            string ftp_ip        = INIUtil.Read("Ftp", "ip", Constant.IniFilePath);
            string ftp_port      = INIUtil.Read("Ftp", "port", Constant.IniFilePath);
            string ftpParentPath = "ftp://" + ftp_ip + ":" + ftp_port + "/" + Constant.ftp_autoCruiseFilePath;

            TVUploadPath = "";
            IRUploadPath = "";
            string[] strTVPathArrays = TVImagefilePath.Split('\\');
            string[] strIRPathArrays = IRImagefilePath.Split('\\');
            if (!string.IsNullOrEmpty(TVImagefilePath))
            {
                TVUploadPath = ftpParentPath + strTVPathArrays[3] + "/" + strTVPathArrays[4];
                // FtpUtil.UploadFile(TVImagefilePath.Split('\\')[1], ftpParentPath, "root", "root");
            }
            if (!string.IsNullOrEmpty(IRImagefilePath))
            {
                IRUploadPath = ftpParentPath + strIRPathArrays[3] + "/" + strIRPathArrays[4];
                //  FtpUtil.UploadFile(IRImagefilePath.Split('\\')[1], ftpParentPath, "root", "root");
            }
        }
예제 #9
0
        public Form1()
        {
            InitializeComponent();
            gLogWriter.StartLog();
            M_ClientOpt.Pjson.frmMain = this;
            M_ClientOpt.frmThis       = this;
            M_ClientOpt.DevMonitorInit();

            M_ClientOpt.globalCtrl.createCrusieThread();    //巡检启动线程
            M_ClientOpt.globalCtrl.createHeartbeatThread(); //定时检测心跳是否正常


            string server_ip   = INIUtil.Read("Server", "ip", Constant.IniFilePath);
            string server_port = INIUtil.Read("Server", "port", Constant.IniFilePath);
            string username    = INIUtil.Read("USER", "username", Constant.IniFilePath);
            string password    = INIUtil.Read("USER", "password", Constant.IniFilePath);

            if (!string.IsNullOrEmpty(server_ip) && !string.IsNullOrEmpty(server_port))
            {
                //1.检查网络连接状态,是否能ping 通服务器
                if (TelnetUtil.PingIpOrDomainName(server_ip))
                {
                    //2.连接到服务器
                    M_ClientOpt.funEnterMonitorServerPar(server_ip, Convert.ToInt32(server_port));
                    M_ClientOpt.funSetupMonitorServer();

                    M_ClientOpt.funbutLoginStatus();
                    bool f = M_ClientOpt.bl_UserClientControlSetup;
                    if (M_ClientOpt.bl_UserClientControlSetup)
                    {
                        // lbConnectState.Text = "已连接";
                        //3.服务器连接成功后,用户登录
                        if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
                        {
                            if (!M_ClientOpt.LoginStatus)
                            {
                                M_ClientOpt.funOptbtuUser(username, password);
                            }
                        }
                        else
                        {
                            MessageBox.Show("ini文件读取失败,请检查...", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        //  lbConnectState.Text = "未连接";
                    }
                }
                else
                {
                    MessageBox.Show("请检查网络,服务器ip和监控端ip是否在同一网关", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("ini文件读取失败,请检查...", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }


            Thread thread_server = new Thread(SocketServerScan);   //服务器登录,用户登录相关线程

            thread_server.Start();

            Thread thread_heatbeat = new Thread(M_ClientOpt.SendHeartBeatCmd);  //定时发送心跳指令

            thread_heatbeat.Start();

            Thread thread_monDev_IR = new Thread(M_ClientOpt.IRStatusScan);    //红外状态监控

            thread_monDev_IR.Start();

            Thread thread_monDev_TV = new Thread(M_ClientOpt.TVStatusScan);    //可见光状态监控

            thread_monDev_TV.Start();

            Thread thread_monDev_FTP = new Thread(M_ClientOpt.FtpStatusScan);   //ftp服务器状态监控

            thread_monDev_FTP.Start();

            Thread thread_monDev_SQL = new Thread(M_ClientOpt.SqlStatusScan);  //数据库状态监控

            thread_monDev_SQL.Start();
        }