コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tableMappingName"></param>
        /// <param name="dbColName"></param>
        /// <param name="dgShowName"></param>
        /// <param name="boolColumnIndex"></param>
        /// <returns></returns>
        static public DataGridTableStyle CreateDataGridTableStyle(string tableMappingName, string[] dbColName, string[] dgShowName, int[] boolColumnIndex)
        {
            ArgumentChecker.CheckNotNull(dbColName);
            ArgumentChecker.CheckNotNull(dgShowName);
            if (dbColName.Length != dgShowName.Length)
            {
                throw new ArgumentException("dbColName.Length != dgShowName.Length");
            }

            DataGridTableStyle dgts = new DataGridTableStyle();

            dgts.MappingName = tableMappingName;

            DataGridColumnStyle dgcs = null;

            for (int i = 0; i < dbColName.Length; i++)
            {
                if (InArray(boolColumnIndex, i))
                {
                    dgcs = new DataGridBoolColumn();
                }
                else
                {
                    dgcs = new DataGridTextBoxColumn();
                }

                dgcs.MappingName = dbColName[i];
                dgcs.HeaderText  = dgShowName[i];

                dgts.GridColumnStyles.Add(dgcs);
            }

            return(dgts);
        }
コード例 #2
0
//        static public void InsertXGData( XGData data )
//        {
//            //2007.03.11 replace with InsertXGData ( string remoteIP, XGData data )
//            throw new NotImplementedException ( "insertXGData( XGData data" );
//
//            ArgumentChecker.CheckNotNull( data );
//            string s = string.Format( @"insert into tbl_xgdata(station_address, card_sn, station_time,
//                computer_time, isAuto)
//                values({0}, '{1}', '{2}', '{3}', {4})", data.FromAddress, data.CardSN, data.XGStationDateTime,
//                data.DateTime, data.IsAutoReport ? 1 : 0 );
//
//            DbClient.ExecuteNonQuery( s );
//        }

        /// <summary>
        /// insert a xg data to tbl_xgdata
        /// </summary>
        /// <param name="remoteIP"> form gprs station ip</param>
        /// <param name="data"> xg data </param>
        static public void InsertXGData(string remoteIP, XGData data)
        {
            ArgumentChecker.CheckNotNull(data);

            // find xgstation_id with remoteIP, id not find xgstation_id then return
            //
            int xgStId = XGDB.GetXGStaionID(remoteIP, data.FromAddress);

            // 2007-10-25 Added not find xgStId
            //
            if (xgStId == 0)
            {
                return;
            }

            // find card_id and person with card sn, if not find
            // card sn then the sn to tbl_card and return the id
            //
            int    cardId;
            string person;

            bool b = XGDB.GetCardIdAndPerson(data.CardSN, true, out cardId, out person);

            if (b)
            {
                // insert xgdata to tbl_xgdata
                //
                string sql = string.Format(@"insert into tbl_xgdata ( xgstation_id, card_id, xgtime, person ) 
                    values ( {0}, {1}, '{2}', '{3}')",
                                           xgStId, cardId, data.XGStationDateTime, person);

                DbClient.ExecuteNonQuery(sql);
            }
        }
コード例 #3
0
        /// <summary>
        /// 判断从供热实时数据中获取的报警数据中是否包含报警值
        /// </summary>
        /// <remarks>
        /// 供热实时数据中包含报警数据(同自动上报的报警数据),该报警数据中可能包含或不包含报警数据。
        /// 不包含报警值时,报警数据不存入数据库,
        /// 包含报警值时,处理同自动上报的报警数据。
        /// </remarks>
        /// <param name="ad"></param>
        /// <returns></returns>
        private bool IsIncludeAlarm(GRAlarmData ad)
        {
            ArgumentChecker.CheckNotNull(ad);
            if (ad.cycPump1 || ad.cycPump2 || ad.cycPump3)
            {
                return(true);
            }
            if (ad.oneGivePress_lo || ad.oneGiveTemp_lo)
            {
                return(true);
            }
            if (ad.powerOff || ad.recruitPump1 || ad.recruitPump2)
            {
                return(true);
            }
            if (ad.twoBackPress_hi || ad.twoBackPress_lo || ad.twoGivePress_hi || ad.twoGiveTemp_hi)
            {
                return(true);
            }
            if (ad.watLevel_hi || ad.watLevel_lo)
            {
                return(true);
            }

            return(false);
        }
コード例 #4
0
        //public int MatchRecord( XGAutoReportData  record )
        public int MatchRecord(XGData data)
        {
            ArgumentChecker.CheckNotNull(data);
            if (_tasks == null)
            {
                return(0);
            }

            int matchedCount = 0;

            for (int i = 0; i < _tasks.Count; i++)
            {
                XGTask task = _tasks[i];
                if (task.IsActive &&
                    !task.IsComplete &&
                    task.MatchXGData(data))
                {
                    //task.XgTaskResult  = XGTaskResult.CreateSuccessResult( task, record.DateTime );
                    task.XgTaskResult = data;
                    task.IsComplete   = true;
                    matchedCount++;
                }
            }
            return(matchedCount);
        }
コード例 #5
0
ファイル: UIEventProcessor.cs プロジェクト: wwkkww1983/bt
        /// <summary>
        ///
        /// </summary>
        /// <param name="parent"></param>
        private void GrCtrl(Form parent)
        {
            ArgumentChecker.CheckNotNull(parent);
            frmControl f = new frmControl();

            //f.MdiParent = parent;
            f.ShowDialog();
        }
コード例 #6
0
        static public void UpdateXGStation(int id, XGStation st)
        {
            ArgumentChecker.CheckNotNull(st);
            string s = string.Format("update tbl_xgstation set name = '{0}', address = {1} where xgstation_id = {2}",
                                     st.StationName, st.Address, id);

            DbClient.ExecuteNonQuery(s);
        }
コード例 #7
0
ファイル: XGTask.cs プロジェクト: wwkkww1983/bt
        public bool MatchXGData(XGData data)
        {
            ArgumentChecker.CheckNotNull(data);

            return(!IsComplete &&
                   (_card.SerialNumber == data.CardSN) &&
                   (_xgStation.Address == data.FromAddress) &&
                   (MatchXgTime(data.XGStationDateTime)));
        }
コード例 #8
0
ファイル: Main.cs プロジェクト: wwkkww1983/bt
 static private void AddTasks(TasksCollection dest, TasksCollection src)
 {
     ArgumentChecker.CheckNotNull(dest);
     ArgumentChecker.CheckNotNull(src);
     for (int i = 0; i < src.Count; i++)
     {
         Task t = src[i];
         dest.Add(t);
     }
 }
コード例 #9
0
ファイル: frmControlProcess.cs プロジェクト: wwkkww1983/bt
        /// <summary>
        ///
        /// </summary>
        /// <param name="t"></param>
        public frmControlProcess(Task t)
            : this()
        {
            ArgumentChecker.CheckNotNull(t);
            _task = t;
//            t.BeforeExecuteTask += new EventHandler(t_BeforeExecuteTask);
//            t.AfterExecuteTask  += new EventHandler(t_AfterExecuteTask);
//            t.AfterProcessReceived += new EventHandler(t_AfterProcessReceived);
            RegisterTaskEvent(_task);
        }
コード例 #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="remoteIP"></param>
        /// <param name="address"></param>
        /// <param name="ad"></param>
        public void InsertGRAlarmDataToDb(string remoteIP, int address, GRAlarmData ad)
        {
            ArgumentChecker.CheckNotNull(ad);
            int grStId = XGDB.GetGRStationID(remoteIP, address);

            if (grStId != -1)
            {
                InsertGRAlarmDataToDB(grStId, ad);
            }
        }
コード例 #11
0
        static public void UpdateCard(int id, Card card)
        {
            ArgumentChecker.CheckNotNull(card);
            //2007.03.30 Added team
            //
            string team = card.Tag.ToString();

            string s = string.Format(@"UPDATE tbl_card SET sn = '{0}', person = '{1}' , remark = '{3}' , team = '{4}'
                WHERE (card_id = {2})", card.SerialNumber, card.Person, id, card.Remark, team);

            DbClient.ExecuteNonQuery(s);
        }
コード例 #12
0
        private void clearTask_BeforeExecuteTask(object sender, EventArgs e)
        {
            //RemoveAllCommand c = sender as RemoveAllCommand ;
            Task t = sender as Task;

            ArgumentChecker.CheckNotNull(t);
            if (t.Tag != null)
            {
                XGTask xgt = t.Tag as XGTask;
                xgt.ReadLocalXgDataComplete();
            }
        }
コード例 #13
0
        public frmPressAlarmSet(GRStation grSt)
        {
            //
            // Windows 窗体设计器支持所必需的
            //
            InitializeComponent();

            //
            // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            //
            ArgumentChecker.CheckNotNull(grSt);
            _grSt = grSt;
        }
コード例 #14
0
ファイル: frmXGTaskItem.cs プロジェクト: wwkkww1983/bt
        private void FillComboBox(ComboBox cmb, DataTable tbl, int colIndex)
        {
            ArgumentChecker.CheckNotNull(cmb);
            ArgumentChecker.CheckNotNull(tbl);

            foreach (DataRow r in tbl.Rows)
            {
                cmb.Items.Add(r[colIndex]);
            }
            if (cmb.Items.Count != 0)
            {
                cmb.SelectedIndex = 0;
            }
        }
コード例 #15
0
ファイル: XGTask.cs プロジェクト: wwkkww1983/bt
        public XGTask(XGStation xgStation, Card card, XGTime time)
        {
            ArgumentChecker.CheckNotNull(xgStation);
            ArgumentChecker.CheckNotNull(card);
            ArgumentChecker.CheckNotNull(time);

            _xgStation    = xgStation;
            _xgTime       = time;
            _card         = card;
            _isComplete   = false;
            _isActive     = false;
            this._Active += new EventHandler(XGTask_Active);
            _Inactive    += new EventHandler(XGTask_Inactive);
        }
コード例 #16
0
        /// <summary>
        /// 处理由自动上报数据处理器接收到的供热实时数据
        /// </summary>
        /// <param name="remoteIP"></param>
        /// <param name="address"></param>
        /// <param name="rd"></param>
        public void ProcessGRRealData(string remoteIP, int address, GRRealData rd)
        {
            ArgumentChecker.CheckNotNull(rd);

            InsertGRRealDataToDb(remoteIP, address, rd);

            GRAlarmData adFromRealData = rd.GrAlarmData;

            if (IsIncludeAlarm(adFromRealData))
            {
                ARDProcessor.Default.InsertGRAlarmDataToDb(remoteIP, address, adFromRealData);
            }

            Singles.S.GRStRds.ChangeWithRemoteIP(remoteIP, address, rd);
        }
コード例 #17
0
        public frmTempLine(GRStation grSt)
        {
            //
            // Windows 窗体设计器支持所必需的
            //
            InitializeComponent();

            //
            // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            //
            ArgumentChecker.CheckNotNull(grSt);
            _grSt = grSt;
            this.dataGrid1.DataSource = CreateDataTable();
            this.txtStationName.Text  = grSt.StationName;
        }
コード例 #18
0
        static public void InsertGRStation(GRStation st)
        {
            ArgumentChecker.CheckNotNull(st);
            string s;

            if (st.Tag != null)
            {
                int gprsStationId = Convert.ToInt32(st.Tag);
                s = string.Format("insert into tbl_grstation( name, address, gprs_station_id ) values( '{0}', {1}, {2} )",
                                  st.StationName, st.Address, gprsStationId);
            }
            else
            {
                s = string.Format("insert into tbl_grstation( name, address ) values( '{0}', {1} )",
                                  st.StationName, st.Address);
            }
            DbClient.ExecuteNonQuery(s);
        }
コード例 #19
0
        static public void InsertCard(Card card)
        {
            ArgumentChecker.CheckNotNull(card);

            // card.Tag save team info
            //
            string team = card.Tag == null ? string.Empty : card.Tag.ToString();

            string s = string.Format("INSERT INTO tbl_card(sn, person, remark, team) VALUES ('{0}', '{1}', '{2}','{3}')",
                                     card.SerialNumber,
                                     card.Person,
                                     card.Remark,
                                     //card.Tag.ToString()  );
                                     team
                                     );

            DbClient.ExecuteNonQuery(s);
        }
コード例 #20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Process(object sender, EventArgs e)
        {
            ArgumentChecker.CheckNotNull(sender);
            TaskScheduler sch  = (TaskScheduler)sender;
            Task          task = sch.ActiveTask;

            ArgumentChecker.CheckNotNull(task);

            CommCmdBase     cmd             = task.CommCmd;
            CommResultState commResultState = task.LastCommResultState;

            if (commResultState != CommResultState.Correct)
            {
                if (XGConfig.Default.LogCommFail)
                {
                    string s = string.Format("Send\t\t: {0}, {1}\r\nReceived\t: {2}, {3}\r\nCommResult\t: {4}\r\nCmdType\t\t: {5}\r\n",
                                             task.LastSendDateTime, CT.BytesToString(task.LastSendDatas),
                                             task.LastReceivedDateTime, CT.BytesToString(task.LastReceived),
                                             commResultState.ToString(), cmd.GetType().Name);
                    FileLog.CommFail.Add(s);
                }
                return;
            }

            if (cmd is ReadRecordCommand)
            {
                ReadRecordCommand readRecordCmd = cmd as ReadRecordCommand;
                ProcessReadRecordCmd(readRecordCmd);
            }

            if (cmd is ReadTotalCountCommand)
            {
                ReadTotalCountCommand readCountCmd = cmd as ReadTotalCountCommand;
                ProcessReadTotalCountCmd(readCountCmd, task);
            }
        }
コード例 #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cpps"></param>
        /// <param name="remoteIP"></param>
        private void RemoveExist(CommPortProxysCollection cpps, string remoteIP)
        {
            ArgumentChecker.CheckNotNull(cpps);
            //foreach( CommPortProxy c in cpps )

            bool removed = true;

            while (removed)
            {
                removed = false;

                for (int i = 0; i < cpps.Count; i++)
                {
                    CommPortProxy c = cpps[i];
                    if (c.RemoteHostIP == remoteIP)
                    {
                        c.Close();
                        cpps.RemoveAt(i);
                        removed = true;
                        break;
                    }
                }
            }
        }
コード例 #22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="grStName"></param>
        /// <param name="rd"></param>
        public void AddGrAlarmData(string grStName, string remoteIP, int address, GRAlarmData ad)
        {
            //假定上报报警数据中不包含报警
            //
            this._isIncludeAlarm = false;

            ArgumentChecker.CheckNotNull(ad);
            _grStName = grStName;
            _remoteIP = remoteIP;
            _address  = address;

            if (ad.cycPump1)
            {
                AddLvi(CYCLE_PUMP_1, ALARM_FAULT);
            }
            if (ad.cycPump2)
            {
                AddLvi(CYCLE_PUMP_2, ALARM_FAULT);
            }
            if (ad.cycPump3)
            {
                AddLvi(CYCLE_PUMP_3, ALARM_FAULT);
            }
            if (ad.oneGivePress_lo)
            {
                AddLvi(ONE_GIVE_PRESS, ALARM_LO_PRESS);
            }
            if (ad.oneGiveTemp_lo)
            {
                AddLvi(ONE_GIVE_TEMP, ALARM_LO_TEMP);
            }
            if (ad.powerOff)
            {
                AddLvi(POWER, ALARM_POWEROFF);
            }
            if (ad.recruitPump1)
            {
                AddLvi(RECRUIT_PUMP_1, ALARM_FAULT);
            }
            if (ad.recruitPump2)
            {
                AddLvi(RECRUIT_PUMP_2, ALARM_FAULT);
            }
            if (ad.twoBackPress_hi)
            {
                AddLvi(TWO_BACK_PRESS, ALARM_HI_PRESS);
            }
            if (ad.twoBackPress_lo)
            {
                AddLvi(TWO_BACK_PRESS, ALARM_LO_PRESS);
            }
            if (ad.twoGivePress_hi)
            {
                AddLvi(TWO_GIVE_PRESS, ALARM_HI_PRESS);
            }
            if (ad.twoGiveTemp_hi)
            {
                AddLvi(TWO_GIVE_TEMP, ALARM_HI_TEMP);
            }
            if (ad.watLevel_hi)
            {
                AddLvi(WATER_BOX_WL, ALARM_HI_WL);
            }
            if (ad.watLevel_lo)
            {
                AddLvi(WATER_BOX_WL, ALARM_LO_WL);
            }


            if (!_isIncludeAlarm)
            {
                AddLviNoAlarm("无", "报警解除");
            }

            if (!this.Visible)
            {
                this.Show();
            }

            if (_activeWhenAlarm)
            {
                this.Activate();
            }

            if (_isIncludeAlarm)
            {
                PlaySound();
            }
        }
コード例 #23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="task"></param>
//        private void Process( string remoteIP, Task task )
        private void Process(Task task)
        {
            ArgumentChecker.CheckNotNull(task);

            string      remoteIP = task.CommCmd.Station.DestinationIP;
            CommCmdBase cmd      = task.CommCmd;
            Station     st       = cmd.Station;

            CommResultState commResultState = task.LastCommResultState;
            string          s = null;

            if (XGConfig.Default.LogCommIO)
            {
                if (s == null)
                {
                    //s = GetLogString( commPort, task );
                    s = GetLogString(remoteIP, task);
                }

                FileLog.CommIO.Add(s);
                if (XGConfig.Default.ShowLogForm)
                {
                    frmLogs.Default.AddLog(s);
                }
            }

            // log fail comm
            // 所有通讯失败情况在此处理
            //
            if (commResultState != CommResultState.Correct)
            {
                if (XGConfig.Default.LogCommFail)
                {
                    if (s == null)
                    {
                        s = GetLogString(remoteIP, task);
                    }

                    if (XGConfig.Default.LogCommFail)
                    {
                        FileLog.CommFail.Add(s);
                    }

                    if (XGConfig.Default.ShowLogForm)
                    {
                        //frmLogs.FailForm.AddLog( s );
                        frmLogs.Default.AddLogCommFail(s);
                    }
                }

                ProcessFreeData(task.CommCmd.Station.DestinationIP, task.LastReceived);  //, task);
                return;
            }

            // 以下只是处理通讯成功的情况
            //

            // 4. XG real total count command
            //
            if (cmd is ReadTotalCountCommand)
            {
                ReadTotalCountCommand readCountCmd = cmd as ReadTotalCountCommand;
                ProcessReadTotalCountCmd(readCountCmd, task);
            }

            // 5. XG real record
            //
            if (cmd is ReadRecordCommand)
            {
                ReadRecordCommand readRecordCmd = cmd as ReadRecordCommand;
                ProcessReadRecordCmd(readRecordCmd);
            }

            // 6. XG clear record command
            //

            // 读取供热控制器实时数据
            // 1. GR real data command
            //
            if (cmd is GRRealDataCommand)
            {
                GRRealDataCommand realDataCmd = ( GRRealDataCommand )cmd;
                //ProcessGRRealDataCmd( commPort, realDataCmd );
                ProcessGRRealDataCmd(remoteIP, realDataCmd);
            }

            // 2. GR set out side temperature command
            //
            if (cmd is GRSetOutSideTempCommand)
            {
                GRSetOutSideTempCommand c = (GRSetOutSideTempCommand)cmd;
                ProcessGRSetOutSideTempCmd(c);
            }

            // 3. GR remote set control params
            //
        }
コード例 #24
0
ファイル: CollStateDisplay.cs プロジェクト: wwkkww1983/bt
 public CollStateDisplay(StatusBarPanel sbp)
 {
     ArgumentChecker.CheckNotNull(sbp);
     _sbp = sbp;
 }
コード例 #25
0
 public void Add(GRStationLastRealData grStRd)
 {
     ArgumentChecker.CheckNotNull(grStRd);
     InternalAdd(grStRd);
 }
コード例 #26
0
 public GRStationLastRealData(GRStation grSt, GRRealData grRd)
 {
     ArgumentChecker.CheckNotNull(grSt);
     _grSt = grSt;
     _grRd = grRd;
 }
コード例 #27
0
ファイル: frmControlProcess.cs プロジェクト: wwkkww1983/bt
 /// <summary>
 ///
 /// </summary>
 /// <param name="t"></param>
 private void RegisterTaskEvent(Task t)
 {
     ArgumentChecker.CheckNotNull(t);
     t.BeforeExecuteTask    += new EventHandler(t_BeforeExecuteTask);
     t.AfterProcessReceived += new EventHandler(t_AfterProcessReceived);
 }