// GET: ControlBlock public ActionResult Index() { IniFileControl inifileControl = IniFileControl.GetInstance(); CdioControl cdioControl = CdioControl.GetInstance(); DealControl dealControl = DealControl.GetInstance(); ViewData["FileTimerState"] = inifileControl.TimerState() == false?"关闭":"开启"; ViewData["TimerTimerState"] = inifileControl.Timer2State() == false ? "关闭" : "开启"; ViewData["DealState"] = dealControl.getConnectState() == false ? "断开" : "连接"; if (cdioControl.InitMoto().Equals("Success")) { ViewData["CdioInitState"] = "连接"; } else { CdioCloseTimer(); ViewData["CdioInitState"] = cdioControl.InitMoto(); } ViewData["CdioTimerState"] = cdioControl.TimerState() == false ? "关闭" : "开启"; ControlBlockViewModel controlblockviewModel = new ControlBlockViewModel { readiniModel = inifileControl.ReadInifile() }; return(View(controlblockviewModel)); }
public JsonResult StateLoad() { try { string runState = ""; string cdioconnectState = ""; if (cdioControl.InitMotoState().Equals("Success")) { cdioconnectState = "连接"; } else { cdioconnectState = cdioControl.InitMotoState(); } if (cdioControl.getMotoState().IsMotoRunning == false) { runState = "停止"; } else if (cdioControl.getMotoState().MotoREV == 0) { runState = "正转"; } else if (cdioControl.getMotoState().MotoREV == 1) { runState = "反转"; } var state = new { filestate = inifileControl.TimerState() == false ? "关闭" : "开启", cdiostate = cdioControl.TimerState() == false ? "关闭" : "开启", timestate = inifileControl.Timer2State() == false ? "关闭" : "开启", runstate = runState, cdioconnectstate = cdioconnectState, dealstate = dealControl.getConnectState() == false ? "断开" : "连接" }; return(Json(state, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { var state = new { filestate = "错误", cdiostate = "错误", timestate = "错误", runstate = "错误", cdioconnectstate = "错误", dealstate = "错误" }; LogHelper.WriteLog(this.GetType(), ex); return(Json(state, JsonRequestBehavior.AllowGet)); } }