public void OnAfterFiveThenOffAfterFivePlusTwenty() { var detector = new SmokeDetector(); // 4 seconds at level of 0.6 accumulates detection for (int i = 0; i < 4; i++) { Assert.AreEqual(0, detector.Cycle(0.6)); } // the 5th second at level 0.6 triggers alarm Assert.AreEqual(1, detector.Cycle(0.6)); // alarm sounds while detection decays // through 5 seconds at level 0.1 for (int i = 0; i < 5; i++) { Assert.AreEqual(0, detector.Cycle(0.1)); } // alarm sounds for another 20 seconds for (int i = 0; i < 20; i++) { Assert.AreEqual(0, detector.Cycle(0.1)); } // 20 seconds without breaching level means // it is safe to turn off alarm Assert.AreEqual(-1, detector.Cycle(0.1)); }
/// <summary> /// 更新SmokeDetector信息 /// </summary> public static void UpdateSmokeDetector(SmokeDetector entity) { DataCommand cmd = new DataCommand("UpdateSmokeDetector"); cmd.SetParameter <SmokeDetector>(entity); cmd.ExecuteNonQuery(); }
public void OnAfterFiveThenOffAfterFivePlusTwenty () { var detector = new SmokeDetector(); // 4 seconds at level of 0.6 accumulates detection for (int i = 0; i < 4; i++) { Assert.AreEqual (0, detector.Cycle (0.6)); } // the 5th second at level 0.6 triggers alarm Assert.AreEqual (1, detector.Cycle (0.6)); // alarm sounds while detection decays // through 5 seconds at level 0.1 for (int i = 0; i < 5; i++) { Assert.AreEqual (0, detector.Cycle (0.1)); } // alarm sounds for another 20 seconds for (int i = 0; i < 20; i++) { Assert.AreEqual (0, detector.Cycle (0.1)); } // 20 seconds without breaching level means // it is safe to turn off alarm Assert.AreEqual (-1, detector.Cycle (0.1)); }
public Ambulance(SmokeDetector smokeDetector) { this.smokeDetector = smokeDetector; smokeDetector.evSmokeDetected += SmokeDetector_evSmokeDetected; //this delegate registration delete all previos subscibers smokeDetector.delSmokeDetected = SmokeDetector_delSmokeDetected; }
private void OnTriggerEnter(Collider other) { if (other.tag == "SmokeDetector") { m_CurrentSmokeDetector = other.GetComponent <SmokeDetector>(); m_CurrentSmokeDetector.DetectingSmoke(true); } }
private void OnDestroy() { if (m_CurrentSmokeDetector != null) { m_CurrentSmokeDetector.DetectingSmoke(false); m_CurrentSmokeDetector = null; } }
/// <summary> /// 创建SmokeDetector信息 /// </summary> public static int InsertSmokeDetector(SmokeDetector entity) { DataCommand cmd = new DataCommand("InsertSmokeDetector"); cmd.SetParameter <SmokeDetector>(entity); int result = cmd.ExecuteScalar <int>(); return(result); }
/// <summary> /// 获取单个SmokeDetector信息 /// </summary> public static SmokeDetector LoadSmokeDetector(int sysNo) { DataCommand cmd = new DataCommand("LoadSmokeDetector"); cmd.SetParameter("@SysNo", DbType.Int32, sysNo); SmokeDetector result = cmd.ExecuteEntity <SmokeDetector>(); return(result); }
public FireDepartment(SmokeDetector smokeDetector) { this.smokeDetector = smokeDetector; //Rigistra metodo de Respond como um cuidador de evento smokeDetector.FireAlarm += new SmokeDetector.FireAlarmEventHandler(Respond); Console.WriteLine("Smoke detector registered " + "at fire department"); }
/// <summary> /// 创建SmokeDetector信息 /// </summary> public static int InsertSmokeDetector(SmokeDetector entity) { var sysNo = SmokeDetectorDA.InsertSmokeDetector(entity); (new MapDataService(entity.CompanySysNo)).InitAsync(); //更新首页缓存数据 return(sysNo); }
/// <summary> /// 设备详情 /// </summary> /// <param name="code"></param> /// <returns></returns> public static SmokeDetector LoadSmokeDetail(string code) { SmokeDetector info = SmokeDetectorDA.LoadSmokeDetail(code); //if(info.Status== SmokeDetectorStatus.Delete) //{ // info = null; //} return(info); }
public ActionResult UpdateSmokeInfo(string code, string newDeviceID, string addressSysNo, string position) { if (addressSysNo == null) { throw new BusinessException("位置信息错误,请重新选择后再试。"); } int sysNo = int.Parse(addressSysNo); if (sysNo == 0) { throw new BusinessException("位置信息错误,请重新选择后再试。"); } Address address = AddressService.LoadAddress(sysNo); if (address == null) { throw new BusinessException("位置信息错误,请重新选择后再试。"); } if (string.IsNullOrWhiteSpace(newDeviceID)) { throw new BusinessException("请填写ONENET编号!。"); } SmokeDetector result = SmokeDetectorServices.LoadSmokeDetectorByDeviceID(newDeviceID); if (result != null && result.Code != code) { throw new BusinessException("已存在该ONENET编号!。"); } SmokeDetector smoke = SmokeDetectorServices.IsUniquenessCode(code); if (smoke != null) { //List<Address> addressList = AddressService.LoadSubsetAddressByAddressSysNo(smoke.CompanySysNo, sysNo); //if (addressList != null && addressList.Count > 0) //{ // throw new BusinessException("请选择详细地址!。"); //} smoke.DeviceId = newDeviceID; smoke.AddressCode = address.Code; smoke.AddressName = address.PathName; smoke.Position = position; SmokeDetectorServices.UpdateSmokeDetector(smoke); return(Json(new AjaxResult() { Success = true }, JsonRequestBehavior.AllowGet)); } else { return(Json(new AjaxResult() { Success = false }, JsonRequestBehavior.AllowGet)); } }
static void Main(string[] args) { //Cria um novo detector de fumaca SmokeDetector smokeDetector = new SmokeDetector("102 East Main St."); //Adiciona ao departamento de incendio FireDepartment fireDepartment = new FireDepartment(smokeDetector); smokeDetector.Alarm(); // chama evento Alarm Console.ReadLine(); // Atrasa saida do programa }
private void OnTriggerExit(Collider other) { if (other.tag == "SmokeDetector") { if (m_CurrentSmokeDetector != null) { m_CurrentSmokeDetector.DetectingSmoke(false); m_CurrentSmokeDetector = null; } } }
public void Test_ReadSegments_Ok() { Assert.Equal(5, TestLines.Length); var sut = new SmokeDetector(TestLines); int actual = sut.FindTotalRiskLevel(); Assert.Equal(15, actual); long lactual = sut.FindTop3BasinValues(); Assert.Equal(1134, lactual); }
public void Day09_Puzzle1_and_2_Ok() { var lines = Utils.ReadLinesFromFile("Day09.txt"); Assert.Equal(100, lines.Length); var sut = new SmokeDetector(lines); int actual = sut.FindTotalRiskLevel(); Assert.Equal(588, actual); long lactual = sut.FindTop3BasinValues(); Assert.Equal(964712, lactual); }
public void smoke_detector_IdleAtSafeLevels() { SmokeDetector.Reset(); int signal_on, signal_off; // 60 seconds at level of 0.1 should be peaceful for (int i = 0; i < 60; i++) { signal_off = 0; signal_on = 0; SmokeDetector.smoke_detector(0.1, ref signal_on, ref signal_off); Assert.AreEqual(0, signal_off, "Iteration #" + i); Assert.AreEqual(0, signal_on, "Iteration #" + i); } }
public ActionResult DeleteDetector(string code, bool isdelete) { SmokeDetector detector = SmokeDetectorServices.LoadSmokeDetail(code); if (detector == null) { throw new BusinessException(string.Format("编号为【{0}】的设备不存在", code)); } if (isdelete) { DeleteDeviceRequest send = new DeleteDeviceRequest() { DeviceID = detector.DeviceId }; DeleteDviceResponse sendRes = ONENETService.DeleteDevice(send); SmokeDetectorServices.DeleteSmokeDetector(detector, CurrUser); SmokeDetectorServices.DeleteClientSmokeDetectorBycode(code); return(Json(new AjaxResult() { Success = true }, JsonRequestBehavior.AllowGet)); } else { DeleteDeviceRequest send = new DeleteDeviceRequest() { DeviceID = detector.DeviceId }; DeleteDviceResponse sendRes = ONENETService.DeleteDevice(send); if (sendRes.IsSuccess) { //更新本地设备状态 SmokeDetectorServices.DeleteSmokeDetector(detector, CurrUser); SmokeDetectorServices.DeleteClientSmokeDetectorBycode(code); return(Json(new AjaxResult() { Success = true }, JsonRequestBehavior.AllowGet)); } else { return(Json(new AjaxResult() { Success = false, Message = "删除失败,ONENET平台返回消息:" + sendRes.msg }, JsonRequestBehavior.AllowGet)); } } }
public void AccumulateDetection() { int time = 0, offTime = 0, detected = 0; bool alarmOn = false, waiting = false; for (int i = 1; i <= 4; i++) { int actual = SmokeDetector.Cycle(0.6, ref time, ref offTime, ref detected, ref alarmOn, ref waiting); Assert.AreEqual(0, actual); Assert.AreEqual(i, time); Assert.AreEqual(i, detected); } }
public ActionResult DeviceDetails(string code) { DateTime now = DateTime.Now; QF_SmokeDetectorStatusLog filter = new QF_SmokeDetectorStatusLog() { DeviceCode = code, PageIndex = 0, PageSize = 9999 }; QueryResult <SmokeDetectorStatusLog> list = SmokeDetectorServices.QueryDeviceNoticeList(filter); SmokeDetector info = SmokeDetectorServices.LoadSmokeDetail(code); info.MessageList = list.data; ViewBag.UserType = curentUser.UserType; return(View(info)); }
public JsonResult DeleteDetector(string code) { //if (curentUser.UserType != UserType.Installer) //{ // throw new BusinessException("您不是安装人员,不能删除当前设备"); //} SmokeDetector detector = SmokeDetectorServices.LoadSmokeDetail(code); if (detector == null) { throw new BusinessException(string.Format("编号为【{0}】的设备不存在", code)); } if (curentUser.UserType == UserType.Installer) { if (detector.InstallerSysNo != curentUser.ManagerSysNo) { throw new BusinessException("您没有安装过当前设备,无权删除"); } } else { if (detector.InstallerSysNo != -curentUser.UserSysNo) { throw new BusinessException("您没有安装过当前设备,无权删除"); } } DeleteDeviceRequest send = new DeleteDeviceRequest() { DeviceID = detector.DeviceId }; DeleteDviceResponse sendRes = ONENETService.DeleteDevice(send); CurrentUser current = new CurrentUser { UserSysNo = curentUser.UserSysNo, UserDisplayName = curentUser.UserDisplayName }; SmokeDetectorServices.DeleteSmokeDetector(detector, current); SmokeDetectorServices.DeleteClientSmokeDetectorBycode(code); return(Json(new AjaxResult() { Success = true }, JsonRequestBehavior.AllowGet)); }
public void smoke_detector_OnAfterFiveThenOffAfterFivePlusTwenty() { SmokeDetector.Reset(); int signal_on = 0, signal_off = 0; // 4 seconds at level of 0.6 accumulates detection for (int i = 0; i < 4; i++) { signal_off = 0; signal_on = 0; SmokeDetector.smoke_detector(0.6, ref signal_on, ref signal_off); Assert.AreEqual(0, signal_off, "Iteration #" + i); Assert.AreEqual(0, signal_on, "Iteration #" + i); } // the 5th second at level 0.6 triggers alarm signal_off = 0; signal_on = 0; SmokeDetector.smoke_detector(0.6, ref signal_on, ref signal_off); Assert.AreEqual(0, signal_off); Assert.AreEqual(1, signal_on); // alarm sounds while detection decays through 5 seconds at level 0.1 for (int i = 0; i < 5; i++) { signal_off = 0; signal_on = 0; SmokeDetector.smoke_detector(0.1, ref signal_on, ref signal_off); Assert.AreEqual(0, signal_off, "Iteration #" + i); Assert.AreEqual(0, signal_on, "Iteration #" + i); } // alarm sounds for another 20 seconds for (int i = 0; i < 20; i++) { signal_off = 0; signal_on = 0; SmokeDetector.smoke_detector(0.1, ref signal_on, ref signal_off); Assert.AreEqual(0, signal_off, "Iteration #" + i); Assert.AreEqual(0, signal_on, "Iteration #" + i); } // 20 seconds without breaching level means it is safe to turn off alarm signal_off = 0; signal_on = 0; SmokeDetector.smoke_detector(0.1, ref signal_on, ref signal_off); Assert.AreEqual(1, signal_off); Assert.AreEqual(0, signal_on); }
public static Task DeleteSmokeCoordinate(SmokeDetector smokeDetector, CurrentUser currentUser) { return(Task.Run(() => { try { if (smokeDetector == null) { return; } var addressMaps = AddressMapService.GetSmokeDetectorAddressMap(smokeDetector.SysNo); if (addressMaps == null) { return; } foreach (var addressMap in addressMaps) { if (string.IsNullOrEmpty(addressMap.SmokeCoordinate)) { continue; } var markers = JsonConvert.DeserializeObject <List <AddressMapMarker> >(addressMap.SmokeCoordinate); var marker = markers.Where(a => a.Type == AddressMapMarkerType.SmokeDetector && a.SysNo == smokeDetector.SysNo).FirstOrDefault(); if (marker != null) { markers.Remove(marker); addressMap.SmokeCoordinate = JsonConvert.SerializeObject(markers); } } AddressMapService.UpdateAddressMapCoordinateBatch(addressMaps, smokeDetector.CompanySysNo, currentUser); } catch (Exception e) { Logger.WriteLog("删除烟感器时 删除地图点位失败:" + e.Message); } })); }
public ActionResult AddSmokeDetector(SmokeDetector entity) { long deviceCode = 0; long.TryParse(entity.Code, out deviceCode); if (deviceCode <= 0) { return(Json(new AjaxResult() { Success = false, Message = "请扫描正确的设备二维码。" })); } //if (curentUser.UserType != UserType.Installer) //{ // return Json(new AjaxResult() { Success = false, Message = "您不是管理员,请绑定管理员账号。" }); //} //if ((entity.AddressSysNo == null || entity.AddressSysNo <= 0) && (entity.Memo == "" || entity.Memo == null)) //{ // return Json(new AjaxResult() { Success = false, Message = "请选择详细地址或者填写备注。" }); //} if ((!entity.AddressSysNo.HasValue || entity.AddressSysNo <= 0) && string.IsNullOrWhiteSpace(entity.Position)) { return(Json(new AjaxResult() { Success = false, Message = "请选择地址或填写设备具体位置。" })); } Address address = AddressDA.LoadAddress(entity.AddressSysNo.GetValueOrDefault()); if (address == null) { return(Json(new AjaxResult() { Success = false, Message = "位置信息错误,请重新选择后再试。" })); } entity.AddressCode = address.Code; entity.AddressName = address.PathName; if ((address.ParentSysNo == 0 || address.ParentSysNo == null) && (address.PathName == "" || address.PathName == null)) { entity.AddressName = address.Name; } entity.Status = SmokeDetectorStatus.Offline; if (curentUser.UserType == UserType.Installer) { entity.InstallerSysNo = curentUser.ManagerSysNo; } else { entity.InstallerSysNo = -curentUser.UserSysNo; } entity.InstallerName = HttpUtility.UrlDecode(curentUser.UserID); entity.InUserSysNo = curentUser.UserSysNo; entity.InUserName = HttpUtility.UrlDecode(curentUser.UserID); SmokeDetector smoke = SmokeDetectorServices.IsUniquenessCode(entity.Code); SystemUserService service = new SystemUserService(); SystemUser systemuser = service.LoadSystemUser(curentUser.ManagerSysNo.GetValueOrDefault(), ConstValue.ApplicationID); if (systemuser == null) { UserMgr.Logout(); return(Json(new AjaxResult() { Success = false, Message = "登录超时,请退出公众号重新进入。" })); } //if (smoke != null && smoke.CompanySysNo != systemuser.MasterSysNo) //{ // return Json(new AjaxResult() { Success = false, Message = "设备已安装,不能再安装。" }); //} //else if (smoke != null) { if (smoke.Status == SmokeDetectorStatus.Delete) { entity.Status = SmokeDetectorStatus.Offline; } else { entity.Status = smoke.Status; if (smoke.InstallerSysNo <= 0) { if (smoke.InstallerSysNo != -curentUser.UserSysNo) { return(Json(new AjaxResult() { Success = false, Message = "设备已安装,不能再安装。" })); } } else { if (!(smoke.CompanySysNo == systemuser.MasterSysNo && curentUser.UserType == UserType.Installer)) { return(Json(new AjaxResult() { Success = false, Message = "设备已安装,不能再安装。" })); } } }; CreateDeviceRequest reques = new CreateDeviceRequest() { IMei = entity.Code, IMsi = entity.Code, Desc = "测试设备", IsOnLine = 1, Observe = 1, Protocol = "LWM2M", Title = entity.Code, Tags = entity.Code + "," + entity.Code }; CreateDeviceResponse result = ONENETService.CreateDevice(reques); if (result.IsSuccess) { entity.DeviceId = result.DeviceId; } else { entity.DeviceId = smoke.DeviceId; } entity.SysNo = smoke.SysNo; SmokeDetectorServices.UpdateSmokeDetector(entity); if (curentUser.UserType != UserType.Installer) { Logger.WriteLog("Code:" + entity.Code); BindingDevicesApi(entity.Code); } return(Json(new AjaxResult() { Success = true, Message = "修改成功!" })); //} //else //{ // return Json(new AjaxResult() { Success = false, Message = "系统异常!" }); //} } else { CreateDeviceRequest reques = new CreateDeviceRequest() { IMei = entity.Code, IMsi = entity.Code, Desc = "测试设备", IsOnLine = 1, Observe = 1, Protocol = "LWM2M", Title = entity.Code, Tags = entity.Code + "," + entity.Code }; CreateDeviceResponse result = ONENETService.CreateDevice(reques); if (result.IsSuccess) { entity.DeviceId = result.DeviceId; } int i = SmokeDetectorServices.InsertSmokeDetector(entity); SmokeDetectorStatusLog statusLog = new SmokeDetectorStatusLog() { Status = entity.Status, BeginTime = DateTimeHelper.GetTimeZoneNow(), ReceivedJsonData = "", SmokeDetectorCode = entity.Code }; if (curentUser.UserType != UserType.Installer) { Logger.WriteLog("Code:" + entity.Code); BindingDevicesApi(entity.Code); } return(Json(new AjaxResult() { Success = true, Message = "添加成功!" })); } }
public static void UpdateSmokeDetector(SmokeDetector entity) { SmokeDetectorDA.UpdateSmokeDetector(entity); }
public static void DeleteSmokeDetector(SmokeDetector smokeDetector, CurrentUser currentUser) { SmokeDetectorDA.DeleteSmokeDetector(smokeDetector.SysNo); DeleteSmokeCoordinate(smokeDetector, currentUser); }
public ActionResult CancelWarning(string code) { SmokeDetector detector = SmokeDetectorServices.LoadSmokeDetail(code); if (detector == null) { throw new BusinessException(string.Format("编号为【{0}】的设备不存在", code)); } if (detector.Status != SmokeDetectorStatus.Warning && detector.Status != SmokeDetectorStatus.TestWarning) { throw new BusinessException(string.Format("编号为【{0}】的设备不是报警状态", code)); } if (detector.Status == SmokeDetectorStatus.TestWarning) { //更新本地设备状态 SmokeDetectorStatusLog lastLog = SmokeDetectorServices.LoadSmokeDetectorStatusLogByDeviceCode(detector.Code); SmokeDetectorStatusLog statusLog = new SmokeDetectorStatusLog() { PreStatus = detector.Status.Value, Status = SmokeDetectorStatus.CancelWarning, BeginTime = DateTimeHelper.GetTimeZoneNow(), ReceivedJsonData = "", SmokeDetectorCode = detector.Code }; detector.Status = SmokeDetectorStatus.CancelWarning; if (lastLog != null && statusLog.BeginTime.HasValue && lastLog.BeginTime.HasValue) { statusLog.DurationSeconds = (int)(statusLog.BeginTime.Value - lastLog.BeginTime.Value).TotalSeconds; } //更新本地设备状态 SmokeDetectorServices.UpdateSmokeDetector(detector); //更新首页数据 (new MapDataService(detector.CompanySysNo)).DataChangeAsync(); //写设备状态更改日志 SmokeDetectorServices.InsertSmokeDetectorStatusLog(statusLog); return(Json(new AjaxResult() { Success = true }, JsonRequestBehavior.AllowGet)); } else { SendCmdRequest send = new SendCmdRequest() { Imei = detector.Code }; SendCmdResponse sendRes = ONENETService.SendCmd(send); if (sendRes.IsSuccess) { //更新本地设备状态 SmokeDetectorStatusLog lastLog = SmokeDetectorServices.LoadSmokeDetectorStatusLogByDeviceCode(detector.Code); SmokeDetectorStatusLog statusLog = new SmokeDetectorStatusLog() { PreStatus = detector.Status.Value, Status = SmokeDetectorStatus.CancelWarning, BeginTime = DateTimeHelper.GetTimeZoneNow(), ReceivedJsonData = "", SmokeDetectorCode = detector.Code }; detector.Status = SmokeDetectorStatus.CancelWarning; if (lastLog != null && statusLog.BeginTime.HasValue && lastLog.BeginTime.HasValue) { statusLog.DurationSeconds = (int)(statusLog.BeginTime.Value - lastLog.BeginTime.Value).TotalSeconds; } //更新本地设备状态 SmokeDetectorServices.UpdateSmokeDetector(detector); //更新首页数据 (new MapDataService(detector.CompanySysNo)).DataChangeAsync(); //写设备状态更改日志 SmokeDetectorServices.InsertSmokeDetectorStatusLog(statusLog); return(Json(new AjaxResult() { Success = true }, JsonRequestBehavior.AllowGet)); } else { return(Json(new AjaxResult() { Success = false, Message = "取消失败!" }, JsonRequestBehavior.AllowGet)); } } }
/// <summary> /// /// </summary> public static SmokeDetector IsUniquenessCode(string code) { SmokeDetector info = SmokeDetectorDA.LoadSmokeDetail(code); return(info); }
public HttpResponseMessage SyncDeviceStatus() { Stream reqstream = HttpContext.Current.Request.InputStream; reqstream.Seek(0, System.IO.SeekOrigin.Begin); string body = new StreamReader(reqstream).ReadToEnd(); Logger.WriteLog("API接收数据:" + body); List <SyncDeviceStatusRequest> list = JsonConvert.DeserializeObject <List <SyncDeviceStatusRequest> >(body); SyncDeviceStatusResponse response = new SyncDeviceStatusResponse(); if (list == null || list.Count <= 0) { response.IsSuccess = false; response.Message = "参数错误。"; } else { SyncDeviceStatusRequest request = null; foreach (var item in list) { if (SMOKE_STATUS_CODE.Contains(item.Status)) { request = item; break; } } if (request == null) { response.IsSuccess = false; response.Message = "参数错误。"; } else { SmokeDetector detecor = SmokeDetectorServices.LoadSmokeDetailByDeviceID(request.DeviceID); if (detecor == null) { response.Message = "设备不存在。"; } else { SmokeDetectorStatus status = MatchDeviceStatus(request.Status); if (detecor.Status != status)//两次设备状态不一致 { SmokeDetectorStatusLog lastLog = SmokeDetectorServices.LoadSmokeDetectorStatusLogByDeviceCode(detecor.Code); #region 更新设备状态,写状态变更日志 DateTime dt; DateTime.TryParse(request.CDatetime, out dt); SmokeDetectorStatusLog statusLog = new SmokeDetectorStatusLog() { PreStatus = detecor.Status.Value, Status = status, BeginTime = dt == DateTime.MinValue ? DateTimeHelper.GetTimeZoneNow() : dt, ReceivedJsonData = body, SmokeDetectorCode = detecor.Code }; detecor.Status = status; if (lastLog != null && statusLog.BeginTime.HasValue && lastLog.BeginTime.HasValue) { statusLog.DurationSeconds = (int)(statusLog.BeginTime.Value - lastLog.BeginTime.Value).TotalSeconds; } using (var trans = TransactionManager.Create()) { SmokeDetectorServices.InsertSmokeDetectorStatusLog(statusLog); SmokeDetectorServices.UpdateSmokeDetector(detecor); trans.Complete(); } #endregion #region 更新首页地图数据缓存 (new MapDataService(detecor.CompanySysNo)).DataChangeAsync(); #endregion #region 发送消息 if (detecor.Status == SmokeDetectorStatus.Warning || detecor.Status == SmokeDetectorStatus.TestWarning) { Task.Factory.StartNew(() =>//火灾报警 { DevicesWarningTemplateTemplate devicesWarningTemplate = new DevicesWarningTemplateTemplate { SerID = detecor.Code, DeviceName = "烟感设备报警", Type = "火灾报警", WarningTime = DateTimeHelper.GetTimeZoneNow().ToString("yyyy-MM-dd HH:mm:ss"), Memo = $"此设备地址为{detecor.AddressName}", MasterID = detecor.Code, DateStr = DateTimeHelper.GetTimeZoneNow().ToString("yyyy-MM-dd HH:mm:ss"),//短信通知时间 Address = detecor.AddressName }; if (detecor.InstallerSysNo.HasValue && detecor.InstallerSysNo < 0) { devicesWarningTemplate.Address = detecor.Position; devicesWarningTemplate.Memo = detecor.Position; } SendMessageService.SendMessage(devicesWarningTemplate, detecor.Code); }); } else if (detecor.Status == SmokeDetectorStatus.Lost || detecor.Status == SmokeDetectorStatus.Offline || detecor.Status == SmokeDetectorStatus.OutNet) { Task.Factory.StartNew(() =>//离线报警 { DevicesOfflineTemplateTemplate devicesOfflintTemplate = new DevicesOfflineTemplateTemplate { SerID = detecor.Code, DeviceName = "烟感设备离线", DeviceAddress = $"此设备地址为{detecor.AddressName}", OffLineTimeStr = DateTimeHelper.GetTimeZoneNow().ToString("yyyy-MM-dd HH:mm:ss"), Memo = "请尽快处理!", MasterID = detecor.Code, DateStr = DateTimeHelper.GetTimeZoneNow().ToString("yyyy-MM-dd HH:mm:ss"),//短信通知时间 Address = detecor.AddressName }; if (detecor.InstallerSysNo.HasValue && detecor.InstallerSysNo < 0) { devicesOfflintTemplate.Address = detecor.Position; devicesOfflintTemplate.Memo = detecor.Position; } SendMessageService.SendMessage(devicesOfflintTemplate, detecor.Code); }); } else if (detecor.Status == SmokeDetectorStatus.LowPower) { Task.Factory.StartNew(() =>//低电压报警 { DevicesWarningTemplateTemplate devicesWarningTemplate = new DevicesWarningTemplateTemplate { SerID = detecor.Code, DeviceName = "烟感设备电量过低", Type = "低电量报警", WarningTime = DateTimeHelper.GetTimeZoneNow().ToString("yyyy-MM-dd HH:mm:ss"), Memo = $"此设备地址为{detecor.AddressName}", MasterID = detecor.Code, DateStr = DateTimeHelper.GetTimeZoneNow().ToString("yyyy-MM-dd HH:mm:ss"),//短信通知时间 Address = detecor.AddressName }; if (detecor.InstallerSysNo.HasValue && detecor.InstallerSysNo < 0) { devicesWarningTemplate.Address = detecor.Position; devicesWarningTemplate.Memo = detecor.Position; } SendMessageService.SendMessage(devicesWarningTemplate, detecor.Code); }); } #endregion } response.IsSuccess = true; } } } string result = JsonConvert.SerializeObject(response); return(new HttpResponseMessage() { Content = new StringContent(result, Encoding.UTF8, "application/json") }); }
public FiremanSam(SmokeDetector smokeDetector) { this.smokeDetector = smokeDetector; smokeDetector.evSmokeDetected += SmokeDetector_evSmokeDetected;; smokeDetector.delSmokeDetected += SmokeDetector_delSmokeDetected; }
public ActionResult _Modify(string code) { SmokeDetector detector = SmokeDetectorServices.LoadSmokeDetail(code) ?? new SmokeDetector(); return(PartialView("_Modify", detector)); }