Beispiel #1
0
        /// <summary>
        /// 处理巡更控制器的自动上报数据
        /// </summary>
        /// <param name="remoteIP"></param>
        /// <param name="address"></param>
        /// <param name="innerDatas"></param>
        /// <returns></returns>
        public XGData ProcessXGARD(string remoteIP, int address, byte[] innerDatas)
        {
            Record r = Record.Analyze(innerDatas);

            //return new XGData( r.CardSN, address, r.DateTime, true );
            if (r != null)
            {
                XGData xgData = new XGData(r.CardSN, address, r.DateTime, true);

                // TODO: save xg ard and Match XgTask with the xgdata
                //
                // insert ard xg data to db
                //
                XGDB.InsertXGData(remoteIP, xgData);

                // insert a new task to taskScheduler, the task remove the last ard xgdata
                //
                XGStation xgst = Singles.S.GetXGStation(remoteIP, address);
                if (xgst == null)
                {
                    xgst = new XGStation("xgst" + DateTime.Now, remoteIP, address);
                }

                CommCmdBase cmd  = new AutoReportCommand(xgst);
                Task        task = new Task(cmd, new ImmediateTaskStrategy());
                Singles.S.TaskScheduler.Tasks.Add(task);

                return(xgData);
            }

            return(null);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fromIP"></param>
        /// <param name="bs"></param>
        public void Process(string fromIP, byte[] bs)
        {
            GrDataPicker grdp = new GrDataPicker();

            byte[][] grdatas = grdp.Picker(bs);

            if (grdatas != null)
            {
                foreach (byte[] aGrData in grdatas)
                {
                    if (GRCommandMaker.IsRealData(aGrData))
                    {
                        GrRealDataParser grrdparser = new GrRealDataParser(aGrData);
                        GRRealData       rd         = grrdparser.ToValue() as GRRealData;
                        if (rd != null)
                        {
                            CommTaskResultProcessor.Default.ProcessGRRealData(
                                fromIP,
                                rd.FromAddress,
                                rd
                                );
                        }
                    }
                }
            }

            XgDataPicker xgdp = new XgDataPicker();

            byte[][] xgdatas = xgdp.Picker(bs);
            if (xgdatas != null)
            {
                foreach (byte[] aXgData in xgdatas)
                {
                    if (XGCommandMaker.IsXgRecord(aXgData))
                    {
                        XgRecordParser xgrp   = new XgRecordParser(aXgData);
                        XGData         xgdata = xgrp.ToValue() as XGData;
                        if (xgdata != null)
                        {
                            XGDB.InsertXGData(
                                fromIP, //cmd.Station.DestinationIP,
                                xgdata
                                );
                        }
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cmd"></param>
        private void ProcessReadRecordCmd(ReadRecordCommand cmd)
        {
            XGData xgData = cmd.XGData;

            if (xgData != null)
            {
//                XGDB.InsertXGData ( cmd.XGData );
//                XGTask[] matchedXgTasks = Singles.S.XGScheduler.Tasks.MatchXGData( cmd.XGData );
//                foreach ( XGTask t in matchedXgTasks )
//                {
//                    t.IsComplete = true;
                // ?TODO: save complete task to db
                //
                XGDB.InsertXGData(cmd.Station.DestinationIP, xgData);
            }
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cmd"></param>
        private void ProcessReadRecordCmd(ReadRecordCommand cmd)
        {
            if (cmd.XGData != null)
            {
                // 2007.03.11 Modify
                //
                //XGDB.InsertXGData ( cmd.XGData );
                XGDB.InsertXGData(cmd.Station.DestinationIP, cmd.XGData);

                XGTask[] matchedXgTasks = Singles.S.XGScheduler.Tasks.MatchXGData(cmd.XGData);
                foreach (XGTask t in matchedXgTasks)
                {
                    t.IsComplete = true;
                }
            }
        }