Esempio n. 1
0
 //返回值0表示该车第一次刷卡,1表示该车为下行,2表示该卡重复刷
 public static bool GetDataStatus(this List<CarControl> datas, CarData data)
 {
     for (int i=0;i<CommonData.datas.Count;i++)
     {
         CarControl item = CommonData.datas[i];
         if (item.isMyCar(data))
             return true;
     }
     return false;
 }
Esempio n. 2
0
        //刷到上行卡时的操作
        public void CarUp(object car)
        {
            try
            {
                //获取站名
                ((CarData)car).stationName = CommonData.stations.GetValueByKey("StationID", (((CarData)car).stationID), "Name").ToString();
                //保存信息
                data = (CarData)car;
                //延迟三秒
                GetStableWeightUp.tag = 1;
                Thread.Sleep(5*1000);

                int s = 0;
                //称重
                lock (GetStableWeightUp.myarray)
                {
            data.allWeight = GetStableWeightUp.getstable(ref s);
                    foreach (double item in GetStableWeightUp.myarray)
                    {
                        data.uplist += item + ",";
                    }
                }
                GetStableWeightUp.tag = 0;
                state = s * 100;
                //拍照
                data.picPath = GetPic();
                //
                DelUpdateUI d = new DelUpdateUI(UpdateUI);
                this.Invoke(d,1);
            }
            catch (Exception ex) { LogWriter.WriteLog(ex.Message+"\n"+ex.StackTrace); }
        }
Esempio n. 3
0
 //反序列化文件
 public void LoadDataByFile(FileStream fs)
 {
     XmlSerializer formatter = new XmlSerializer(typeof(CarData));
     data = (CarData)formatter.Deserialize(fs);
 }
Esempio n. 4
0
        //判断是否为该卡 如果为该卡则执行操作返回true,否则返回false
        public bool isMyCar(CarData car)
        {
            //如果为该卡
            if (data == null)
                Thread.Sleep(1);
            if (car.truckNo == data.truckNo && car.startTime == data.startTime)
            {
                if (bIsDowned)
                    return true;
                //下行
                if (isDown)
                {
                    bIsDowned = true;
                    new Thread(CarDown).Start();

                }
                //上行
                else
                {
                    //isDown = true;
                    tmrDown.Stop();
                    tmrDown.Start();
                    tmrTimeOut.Stop();
                    tmrTimeOut.Start();

                }
                return true;
            }
            return false;
        }
Esempio n. 5
0
 //遍历文件夹,更新数据
 private void UpdateData()
 {
     while (true)
     {
         Thread.Sleep(1000*60);
         try
         {
             OleDbConnection cn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\Windows\\System32\\data\\data.mdb;");
             cn.Open();
             DataTable dt = new DataTable();
             OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM [data]", cn);
             da.Fill(dt);
             string sqls = "";
             foreach (DataRow row in dt.Rows)
             {
                 CarData data = new CarData();
                 data.boxid = row["boxid"].ToString();
                 data.truckNo = row["truckNo"].ToString();
                 data.startTime = row["startTime"].ToString();
                 data.stationID = int.Parse(row["startstationid"].ToString());
                 data.type = int.Parse(row["type"].ToString());
                 data.endTime = row["endTime"].ToString();
                 data.allWeight = double.Parse(row["allWeight"].ToString());
                 data.carWeight = double.Parse(row["downWeight"].ToString());
                 data.downTime = row["downTime"].ToString();
                 data.uplist = row["upList"].ToString();
                 data.downTime = row["downList"].ToString();
                 string sql = "EXEC center_updatedata '" + data.boxid + "','"
         + data.truckNo + "','" + data.parseData(1) + "',"
         + data.stationID + "," + data.type + "," + CommonData.stationID + ",'" + data.parseData(0)
         + "'," + (data.allWeight - data.carWeight) + ",'"
         + data.picPath + "',@status=" + 0 + ",@allWeight="
         + data.allWeight + ",@downWeight=" + data.carWeight + ",@downTime='"
         + data.downTime + "',@uplist='" + data.uplist + "',@downlist='" + data.downlist + "'";
                 BaseOperate op = new BaseOperate();
                 if (!op.getcom(sql))
                     continue;
                 sql = "DELETE FROM [data] WHERE ID = " + int.Parse(row["id"].ToString());
                 OleDbCommand cmd = new OleDbCommand(sql, cn);
                 cmd.ExecuteNonQuery();
             }
             cn.Close();
         }
         catch (Exception ex) { LogWriter.WriteLog(ex.Message + "\n" + ex.StackTrace); }
     }
 }
Esempio n. 6
0
        private CarData GetObjectByMsg(MSG_RO_ACCESS_REPORT msg)
        {
            if (msg.TagReportData == null || msg.TagReportData.Length < 1) return null ;

            ulong ms = msg.TagReportData[0].FirstSeenTimestampUTC.Microseconds - old_time;
            old_time = msg.TagReportData[0].FirstSeenTimestampUTC.Microseconds;

            if (ms <= 0) ms = 1; //>normalize to 1

            //  lbltagspermin.Text = (60000000 / ms).ToString() + "Tags/Min";

            try
            {
                try
                {
                    //textBox2.Text = msg.ToString();

                        string a = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.ToHexWordString();
                        uint a1 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[0];
                        uint a2 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[1];
                        uint a3 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[2];
                        uint a4 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[3];
                        uint a5 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[4];
                        uint a6 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[5];
                        uint a7 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[6];
                        uint a8 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[7];
                        uint a9 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[8];
                        uint a10 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[9];
                        uint a11 = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.data[10];

                    string epc;
                    if (msg.TagReportData[0].EPCParameter[0].GetType() == typeof(PARAM_EPC_96))
                    {
                        epc = ((PARAM_EPC_96)(msg.TagReportData[0].EPCParameter[0])).EPC.ToHexString();
                        //MessageBox.Show("96");
                    }
                    else
                    {
                        epc = ((PARAM_EPCData)(msg.TagReportData[0].EPCParameter[0])).EPC.ToHexString();
                        //MessageBox.Show("EPC");
                    }
                    if (a1.ToString() == "12288" || a1.ToString()== "12544"  || a1.ToString()== "12800" || a1.ToString() == "13056")
                        ;
                    else
                        return null;

                        //uint x = a1 / 256;
                        //char type = (char)x;
                    char type = (char)(a1 >> 8);
                    //车牌号
                    char car1 = (char)(a3 / 256);
                    char car2 = (char)(a3 % 256);

                    char car3 = (char)(a4 / 256);
                    char car4 = (char)(a4 % 256);

                    char car5 = (char)(a5 / 256);
                    char car6 = (char)(a5 % 256);

                    string car = "京" + car1.ToString() + car2.ToString() + car3.ToString() + car4.ToString() + car5.ToString() + car6.ToString();
                    CarData data = new CarData();
                    data.truckNo = car;
                    //时间
                    string time = ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.ToHexString();
                    //time=time.Substring(35, 12);
                    string time2 = time.Substring(30, 12);
                    string year = "20" + time2.Substring(0, 2);
                    string month = time2.Substring(2, 2);
                    string day = time2.Substring(5, 2);
                    string hour = time2.Substring(7, 2);
                    string min = time2.Substring(10, 2);

                    time = year + "-" + month + "-" + day + "," + hour + ":" + min;
                    //出发站点
                    data.startTime = time;
                    char station1 = (char)(a10 / 256);
                    char station2 = (char)(a10 % 256);
                    string station = station1.ToString() + station2.ToString();
                    data.stationID = int.Parse(station);
                    data.endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                    data.boxid = epc;
                    //  listBox2.Items.Add(msg.ToString());
                    try
                    {
                        data.type = int.Parse(type.ToString());
                    }
                    catch { data.type = -1; }
                    return data;
                }
                catch (Exception e)
                {
                    //((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.ToHexWordString();
                   // MessageBox.Show(e.Message);
                }
            }
            catch (Exception ex)
            {

                ((PARAM_C1G2ReadOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).ReadData.ToHexWordString();
                // textBox2.Text = ((PARAM_C1G2WriteOpSpecResult)(msg.TagReportData[0].AccessCommandOpSpecResult[0])).OpSpecID.ToString();
                //MessageBox.Show(ex.Message);
            }
            return null;
        }