/// <summary> /// /// </summary> private void CreateSetTempCommand() { GRStation[] sts = GetSelectedGRStation(); if (sts == null || sts.Length == 0) { return; } // sts.Length * int times = sts.Length * 2 * (XGConfig.Default.XgCmdLatencyTime / 1000 + 1); foreach (GRStation st in sts) { if (st != null) { if (rdoSetByComputer.Checked) { GRSetOutSideTempCommand tempCmd = new GRSetOutSideTempCommand(st, this.OutsideTemperature); Task tempTask = new Task(tempCmd, new ImmediateTaskStrategy()); Singles.S.TaskScheduler.Tasks.Add(tempTask); GRSetOutSideTempModeCommand modeCmd = new GRSetOutSideTempModeCommand(st, OutSideTempWorkMode.SetByComputer); Task modeTask = new Task(modeCmd, new ImmediateTaskStrategy()); Singles.S.TaskScheduler.Tasks.Add(modeTask); } else if (rdoCollByGRCtrl.Checked) { GRSetOutSideTempModeCommand modecmd = new GRSetOutSideTempModeCommand(st, OutSideTempWorkMode.CollByControllor); Task modeTask = new Task(modecmd, new ImmediateTaskStrategy()); Singles.S.TaskScheduler.Tasks.Add(modeTask); times = times / 2; } } } MsgBox.Show("设置室外温度命令已提交, 执行完成需要大约 " + times + "秒"); }
private void ProcessGRSetOutSideTempCmd(GRSetOutSideTempCommand c) { // do nothing // }
/// <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 // }