Пример #1
0
        private List <PassengerCounterInfo> CreatePassengerCounterList()
        {
            List <PassengerCounterInfo> passengerCounterList = new List <PassengerCounterInfo>();

            // 然后是客流计数设备(摄像头)
            foreach (ListViewItem item in listView2.Items)
            {
                if (!item.Checked)
                {
                    continue;
                }
                PassengerCounterInfo deviceInfo = new PassengerCounterInfo();
                string[]             paraArr    = new string[item.SubItems.Count];
                int idx = 0;
                foreach (ListViewItem.ListViewSubItem subitems in item.SubItems)
                {
                    paraArr[idx] = subitems.Text.Trim();
                    idx++;
                }
                // 服务区编号
                deviceInfo.ServiceArea = Service_area_num;
                // 设备名称
                deviceInfo.DeviceName = paraArr[0];
                // DeviceSN
                deviceInfo.SpotNumber = paraArr[1];
                // Request String
                deviceInfo.RequestString1 = paraArr[2];
                deviceInfo.RequestString2 = paraArr[3];
                // 数据库中对应的表名
                deviceInfo.DbTableName = Db_table_list[1];

                passengerCounterList.Add(deviceInfo);
            }
            return(passengerCounterList);
        }
Пример #2
0
        public static string GetInsertString(string dateTimeStr, string resultStr0, string resultStr1, PassengerCounterInfo deviceInfo)
        {
            string reportStr0 = ", " + resultStr0;
            string reportStr1 = ", " + resultStr1;
            // 摄像头的设备种类编码是003
            string deviceTypeStr = "003";
            // 3位服务区编号 + 3位采集点位置编号 + 3位设备种类编号 + 3位设备地址 = 12位设备编号唯一确定一个具体的设备
            // 因为同一个点, 应该只能有一个摄像头, 所以对于摄像头来说, 3位设备地址由0x01固定值取代
            string deviceSnStr = deviceInfo.ServiceArea.ToString().PadLeft(3, '0') + deviceInfo.SpotNumber.PadLeft(3, '0') + deviceTypeStr + 0x01.ToString().PadLeft(3, '0');
            string insertStr = @"INSERT INTO " + deviceInfo.DbTableName + @"(time_stamp, device_number, value_01, value_02" + @") VALUES('"
                                    + dateTimeStr + @"'," + deviceSnStr + reportStr0 + reportStr1 + @")";

            return insertStr;
        }
Пример #3
0
 /// <summary>
 /// 查询执行
 /// </summary>
 override public void DoInquiry()
 {
     if ((null != DeviceList) &&
         (0 != DeviceList.Count))
     {
         AppendUITextBox("\r\n>------------------------------->");
         AppendUITextBox(DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString());
         // 对列表中的各个设备, 逐一进行查询
         for (int i = 0; i < DeviceList.Count; i++)
         {
             PassengerCounterInfo di = DeviceList[i];
             AppendUITextBox("开始查询 " + di.DeviceName);
             Thread inquiryThread = new Thread(delegate() { InquiryTask(di); });
             inquiryThread.Start();
             System.Threading.Thread.Sleep(300);
         }
     }
 }
Пример #4
0
        /// <summary>
        /// 单个设备查询线程的执行过程
        /// </summary>
        /// <param name="deviceInfo"></param>
        void InquiryTask(PassengerCounterInfo deviceInfo)
        {
            try
            {
                string dateTimeStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                string pc0Str = GetPassengerCountStr(deviceInfo.RequestString1);
                AppendUITextBox("	"+ deviceInfo.DeviceName + " 返回应答: " + pc0Str);
                string pc1Str = GetPassengerCountStr(deviceInfo.RequestString2);
                AppendUITextBox("	"+ deviceInfo.DeviceName + " 返回应答: " + pc1Str);

                if (string.Empty != pc0Str &&
                    string.Empty != pc1Str)
                {
                    string insertStr = GetInsertString(dateTimeStr, pc0Str, pc1Str, deviceInfo);
                    ReportToDBServer(insertStr, deviceInfo.DeviceName);
                }
            }
            catch (Exception ex)
            {
                AppendUITextBox("	"+ deviceInfo.DeviceName + ": 查询失败!");
                System.Diagnostics.Trace.WriteLine(ex.ToString());
            }
        }
Пример #5
0
        public static string GetInsertString(string dateTimeStr, string resultStr0, string resultStr1, PassengerCounterInfo deviceInfo)
        {
            string reportStr0 = ", " + resultStr0;
            string reportStr1 = ", " + resultStr1;
            // 摄像头的设备种类编码是003
            string deviceTypeStr = "003";
            // 3位服务区编号 + 3位采集点位置编号 + 3位设备种类编号 + 3位设备地址 = 12位设备编号唯一确定一个具体的设备
            // 因为同一个点, 应该只能有一个摄像头, 所以对于摄像头来说, 3位设备地址由0x01固定值取代
            string deviceSnStr = deviceInfo.ServiceArea.ToString().PadLeft(3, '0') + deviceInfo.SpotNumber.PadLeft(3, '0') + deviceTypeStr + 0x01.ToString().PadLeft(3, '0');
            string insertStr   = @"INSERT INTO " + deviceInfo.DbTableName + @"(time_stamp, device_number, value_01, value_02" + @") VALUES('"
                                 + dateTimeStr + @"'," + deviceSnStr + reportStr0 + reportStr1 + @")";

            return(insertStr);
        }
Пример #6
0
        /// <summary>
        /// 单个设备查询线程的执行过程
        /// </summary>
        /// <param name="deviceInfo"></param>
        void InquiryTask(PassengerCounterInfo deviceInfo)
        {
            try
            {
                string dateTimeStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                string pc0Str = GetPassengerCountStr(deviceInfo.RequestString1);
                AppendUITextBox("	" + deviceInfo.DeviceName + " 返回应答: " + pc0Str);
                string pc1Str = GetPassengerCountStr(deviceInfo.RequestString2);
                AppendUITextBox("	" + deviceInfo.DeviceName + " 返回应答: " + pc1Str);

                if (	string.Empty != pc0Str
                    &&	string.Empty != pc1Str	)
                {
                    string insertStr = GetInsertString(dateTimeStr, pc0Str, pc1Str, deviceInfo);
                    ReportToDBServer(insertStr, deviceInfo.DeviceName);
                }
            }
            catch (Exception ex)
            {
                AppendUITextBox("	" + deviceInfo.DeviceName + ": 查询失败!");
                System.Diagnostics.Trace.WriteLine(ex.ToString());
            }
        }