private void ImageSource_OnImage(Object theImage) { if (watchOn != null) { watchOn.Abort(); } if (Sr_status == SensorStatus.Aborting) { SmartRayImageSource.SoftTrigger(); NotifierHelper.Notify("ImageSource.SoftTriger"); } else { NotifierHelper.Notify("Sensor.OnImage", "获得图像。"); object[] imgs = theImage as object[]; this.LiveDisplay.Image = imgs[0] as ICogImage; LiveDisplay.Fit(); visionProAlg.Inputs["ZMap"].Value = imgs[0]; visionProAlg.Inputs["Intensity"].Value = imgs[1]; visionProAlg.Run(); //this.VisionProject.VisionAlgorithm.Inputs["ZMap"] = imgs[0]; //this.VisionProject.VisionAlgorithm.Inputs["Intensity"] = imgs[1]; //this.VisionProject.VisionAlgorithm.Run(); } Sr_status = SensorStatus.Idle; }
private void SensorWatchOn() { NotifierHelper.Notify("Sensor.SensorWatchOn", "扫描监视"); while (true) { TimeSpan x = DateTime.Now - lastScanTime; if (x.TotalMilliseconds > 6000) { if (Sr_status == SensorStatus.Scaning) { NotifierHelper.Notify("Sensor.ScanTimeOut", "扫描超时。"); { SmartRayImageSource.Stop(); Sr_status = SensorStatus.Aborting; Thread.Sleep(500); SmartRayImageSource.ImageSource srIs = SmartRayImageSource as SmartRayImageSource.ImageSource; srIs.ClearDatas(); SmartRayImageSource.SoftTrigger(); objScanState = ScanState.OVERTIME; //Connection2.Send("OverTime"); NotifierHelper.Notify("ImageSource.SoftTriger"); } } break; } Thread.Sleep(100); } //watchOn.Abort(); NotifierHelper.Notify("Sensor.SensorWatchOnStop", "扫描监视结束"); }
private void SaveChanges(object sender, System.Windows.RoutedEventArgs e) { var client = new RestClient("http://localhost:62140/Token"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.AddParameter("grant_type", "password"); request.AddParameter("username", textBoxEmail.Text); request.AddParameter("password", textBoxPassword.Password); IRestResponse response = client.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { Dictionary <string, string> tokenDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(response.Content); string accessToken = tokenDictionary["access_token"]; var clientAddNobreakToAccount = new RestClient("http://localhost:62140/api/"); var requestAddNobreakToAccount = new RestRequest("Nobreaks/PostAddNobreakToAccount", Method.POST); requestAddNobreakToAccount.AddHeader("content-type", "application/x-www-form-urlencoded"); requestAddNobreakToAccount.AddHeader("Authorization", "Bearer " + accessToken); requestAddNobreakToAccount.AddHeader("token_type", "bearer"); INobreakServiceChannel ch = App.Channel; //var informacoesNobreak = ch.InformationInquiry(); var nobreak = new Nobreak() { Serial = textBoxSerial.Text, Label = textBoxNobreakNickname.Text, //nobreak.UPSModel = informacoesNobreak.Modelo; //nobreak.Version = informacoesNobreak.Versao; CompanyName = "TS Shara" }; var nbJson = JsonConvert.SerializeObject(nobreak); requestAddNobreakToAccount.AddParameter("text/json", nbJson, ParameterType.RequestBody); requestAddNobreakToAccount.RequestFormat = RestSharp.DataFormat.Json; response = clientAddNobreakToAccount.Execute(requestAddNobreakToAccount); var settingsWorkQuery = new SettingsWorkQuery(); var currentSettings = settingsWorkQuery.FindFirstData(); currentSettings.UserEmail = textBoxEmail.Text; currentSettings.UserToken = accessToken; settingsWorkQuery.UpdateData(currentSettings); //MessageBox.Show(response.Content); NotifierHelper.ShowInformation(response.Content, 1); } else { Dictionary <string, string> responseError = JsonConvert.DeserializeObject <Dictionary <string, string> >(response.Content); NotifierHelper.ShowInformation(responseError["error_description"], 2); } }
private void Connection2_OnConnect(TcpServerConnection connection) { client_count++; NotifierHelper.Notify("Connection.ClientIn"); //if (client_count > 0) { UpdateClientStatus(); } }
public ActionResult Delete(int id) { #region Check Rights bool hasRights = false; hasRights = AdminHelper.CheckUserAction(ScreenEnum.Notifier, ActionEnum.Delete); if (!hasRights) { return(Json("You are UnAuthorized to do this action")); } #endregion string isDeleted = NotifierHelper.Delete(id); return(Json(isDeleted)); }
/// <summary> /// 通知相关组 /// </summary> /// <param name="notifyInfo"></param> /// <param name="group"></param> public void Notify(object notifyInfo, string group) { if (NotifierHelper.OnClientNotify != null && notifyInfo != null) { var notify = NotifierHelper.OnClientNotify(notifyInfo.ToString(), group, Context, Groups); if (string.IsNullOrEmpty(group)) { Clients.All.Notify(notify); } else { Clients.Group(group).Notify(notify); } } }
private void SrIs_OnPackageImage(object theImage) { if (Sr_status == SensorStatus.Idle) { NotifierHelper.Notify("Sensor.StartScan", "启动扫描。"); objScanState = ScanState.SCANNING; Sr_status = SensorStatus.Scaning; lastScanTime = DateTime.Now; watchOn = new Thread(SensorWatchOn); watchOn.Start(); //SR_timer.Interval = 8000; //SR_timer.Start(); } this.LiveDisplay.Image = theImage as ICogImage; LiveDisplay.Fit(); }
private void button1_Click(object sender, EventArgs e) { if (MyTCPServer == null) { MyTCPServer = new TcpServer(); this.MyTCPServer.Port = 2000; this.MyTCPServer.DataType = TcpServer.StreamType.Text; this.MyTCPServer.OnConnect += Connection2_OnConnect; this.MyTCPServer.OnLeaving += Connection2_OnLeaving; MyTCPServer.Open(); } else { } SmartRayImageSource.ImageSource srIs = new ImageSource(); if (srIs.Configure(Application.StartupPath + "/ScanSmartRay_2/SmartRayImageSource.xml")) { SmartRayImageSource = srIs; SmartRayImageSource.OnImage += ImageSource_OnImage; } if (srIs != null) { srIs.OnPackageImage += SrIs_OnPackageImage; } // this.MainDisplay.ColorMapLoad(Application.StartupPath + "/ColorMap.map"); NotifierHelper.Notify("App.Init.Sucess", "完成初始化。"); //} { visionProAlg = (CogSerializer.LoadObjectFromFile(Application.StartupPath + "/XXX.vpp") as CogToolBlock); visionProAlg.Ran += VisionAlgorithm_OnRan; } MessageBox.Show("完成初始化"); }
public ActionResult Add(int id = 0) { #region Check Rights bool hasRights; if (id == 0) //Check export rights { hasRights = AdminHelper.CheckUserAction(ScreenEnum.Notifier, ActionEnum.Add); } else { hasRights = AdminHelper.CheckUserAction(ScreenEnum.Notifier, ActionEnum.Edit); } if (!hasRights) { return(RedirectToAction("UnAuthorized", "Home", new { area = "" })); } #endregion // ViewBag.ConsigneeList = ListCommonHelper.GetConsigneeList(); ViewData["CityList"] = ListCommonHelper.GetCityGrouped(); NotifierVm notifierObj = NotifierHelper.GetNotifierInfo(id); return(View(notifierObj)); }
public ActionResult GetNotifierContacts(int notifierId) { var contactList = NotifierHelper.GetContactsList(notifierId); return(PartialView("~/Views/Shared/_ViewContacts.cshtml", contactList)); }
public ActionResult AddEditNotifier(NotifierVm notifierVm) { string isSaved = NotifierHelper.AddEditNotifier(notifierVm); return(Json(isSaved)); }
public ActionResult Index() { List <NotifierVm> notifierList = NotifierHelper.GetNotifierList(); return(View(notifierList)); }
/// <summary> /// Remove os registros do banco de dados /// </summary> private void ClearReport() { Query.DeleteNobreakDemandData(Query.FindAll()); ClearDatagrid(); NotifierHelper.ShowInformation(new TranslateToCurrentLanguage().GetCurrentLanguageDictionary("TipCleanEventReport"), AppConstant.TIP_SUCCESS_MESSAGE); }
private void btn3_Click(object sender, EventArgs e) { SmartRayImageSource.SoftTrigger(); NotifierHelper.Notify("ImageSource.SoftTriger"); }
private void Connection2_OnLeaving(TcpServerConnection connection) { client_count--; NotifierHelper.Notify("Connection.ClientLeave", "客户端断开。"); UpdateClientStatus(); }