private void pviService_ServiceDisconnected(object sender, PviEventArgs e) { PviService pviService = PviService.PviServiceInstance; pviService.PVIEventArgs = e; FadeOut(ERROR_CONNECTING); }
private void Variable_Connected(object sender, PviEventArgs e) { var cpuName = String.Empty; var cpuIp = String.Empty; var v = sender as Variable; if (v != null) { var c = v.Parent as Cpu; if (c != null) { cpuName = c.Name; cpuIp = c.Connection.TcpIp.DestinationIpAddress; } } var pviEventMsg = Utils.FormatPviEventMessage($"ServiceWrapper.Variable_Connected Cpu Name={cpuName}, cpuIp={cpuIp} ", e); _eventNotifier.OnVariableConnected(sender, new PviApplicationEventArgs() { Message = pviEventMsg }); }
private void Variable_Connected(object sender, PviEventArgs e) { var v = sender as Variable; var text = e.Name; Variables = _cpu.Variables; }
private void _service_Connected(object sender, PviEventArgs e) { string serviceName = String.Empty; if (sender is Service service) { serviceName = service.FullName; } var cpuWrapper = new CpuWrapper(_service, _eventNotifier); var variableWrapper = new VariableWrapper(_service, _eventNotifier); var fw = new FileWrapper(); var cpuManager = new CpuManager(cpuWrapper); var variableInfo = new VariableInfoCollection(fw); var variableManager = new VariableManager(variableWrapper, variableInfo); var pviEventMsg = Utils.FormatPviEventMessage($"ServiceWrapper._service_Connected; ServiceName={serviceName}", e); _eventNotifier.OnPviServiceConnected(sender, new PviApplicationEventArgs() { Message = pviEventMsg, ServiceWrapper = this, CpuManager = cpuManager, CpuWrapper = cpuWrapper, VariableManager = variableManager, VariableWrapper = variableWrapper }); _pollingService = new PollingService(_service, cpuManager); _pollingService.Start(); }
private void OnServiceConnected(object sender, PviEventArgs e) { if (sender is BR.AN.PviServices.Service service) { ServiceConnected?.Invoke(sender, e); } }
private void Cpu_Removed(object sender, PviEventArgs e) { string name = String.Empty; try { var cpu = sender as Cpu; if (cpu != null) { name = cpu.Name; cpu.Removed -= Cpu_Removed; cpu.Connected -= Cpu_Connected; cpu.Error -= Cpu_Error; cpu.Disconnected -= Cpu_Disconnected; _service.Cpus.Remove(cpu); cpu.Dispose(); if (_cpuInfoLookup.ContainsKey(name)) { Connect(_cpuInfoLookup[name]); } } } catch (System.Exception ex) { var cpuName = String.IsNullOrEmpty(name) ? String.Empty : name; throw new System.Exception($"Cpu_Wrapper.Cpu_Removed. Error removing cpu {name}", ex); } }
private void PviService_Connected(object sender, PviEventArgs e) { var pviEventMsg = FormatPviEventMessage("PviService._service_Connected", e); log.Log(new LogEntry(LoggingEventType.Information, pviEventMsg)); OnServiceConnected(sender, e); }
private void PviService_Connected(object sender, PviEventArgs e) { var pviEventMsg = FormatPviEventMessage("PviService._service_Connected", e); _log.Error(pviEventMsg); OnServiceConnected(sender, e); }
private void cpu_Error(object sender, PviEventArgs e) { log.Info($"cpu_Error()... {e.Name}, {e.Action}, {e.ErrorCode}, {e.ErrorText}"); string msg = string.Format("PVI Error: {0} Addr: {1}", e.ErrorCode, e.Name); toolStripStatusLabel1.Text = msg; }
private void _service_Disconnected(object sender, PviEventArgs e) { var pviEventMsg = Utils.FormatPviEventMessage("ServiceWrapper._service_Disconnected", e); _eventNotifier.OnPviServiceDisconnected(sender, new PviApplicationEventArgs() { Message = pviEventMsg }); }
private void PviManager_ServiceConnected(object sender, PviEventArgs e) { PviService = sender as BR.AN.PviServices.Service; var cpuService = new CpuManager(PviService); cpuService.CpuConnect += CpuService_CpuConnect; cpuService.CreateCpu("Cpu1", "192.168.0.101"); }
private void cpu_Disconnected(object sender, PviEventArgs e) { log.Info($"cpu_Disconnected()... {e.Name}, {e.Action}, {e.ErrorCode}, {e.ErrorText}"); toolStripStatusLabel1.Text = "PLC odpojeno!"; statusLabelCpuState.Text = "Offline"; ClearCpuInfo(); log.Info("cpu_Disconnected()... OK"); }
private void Variable_Connected(object sender, PviEventArgs e) { var variable = sender as Variable; var cpu = variable.Parent as Cpu; if (variable != null && cpu != null) { _logger.Log(new LogEntry(LoggingEventType.Information, PviMessage.FormatMessage($"Variable Connected. Cpu={cpu.Name}; Variable={variable.Name}", e))); } }
private void cpu_Connected(object sender, PviEventArgs e) { Cpu cpu = sender as Cpu; if (cpu != null) { UpdateLoaded(e.Name); } _logger.Log(new LogEntry(LoggingEventType.Information, PviMessage.FormatMessage("Cpu Connected", e))); }
private void cpu_Connected(object sender, PviEventArgs e) { Cpu cpu = sender as Cpu; if (cpu != null) { _log.Info($"CpuManager.cpu_Connected Name={cpu.Name}"); var variableManager = new VariableManager(cpu); OnCpuConnect(variableManager); } }
private void variable_Disconnected(object sender, PviEventArgs e) { log.Info($"variable_Disconnected()... {e.Name}, {e.Action}, {e.ErrorCode}, {e.ErrorText}"); var variable = sender as Variable; if (variable.UserData is Control edit && edit is Label) { edit.Enabled = false; (edit.Tag as Label).ImageIndex = 1; } }
private void cpu_Error(object sender, PviEventArgs e) { _log.Error(PviMessage.FormatMessage("Cpu Error", e)); Cpu cpu = sender as Cpu; if (cpu != null) { cpu.Connected -= cpu_Connected; cpu.Error -= cpu_Error; cpu.Disconnected -= cpu_Disconnected; } }
private void variable_Connected(object sender, PviEventArgs e) { log.Info($"variable_Connected()... {e.Name}, {e.Action}, {e.ErrorCode}, {e.ErrorText}"); var variable = sender as Variable; variable.ReadValue(); if (variable.UserData is Control edit && edit is RegexTextBox) { edit.Text = "Online"; } }
private void OnServiceConnected(object sender, PviEventArgs e) { Service service = sender as Service; if (service != null) { EventHandler <PviEventArgs> temp = ServiceConnected; if (temp != null) { temp(sender, e); } } }
private void variable_ValueWritten(object sender, PviEventArgs e) { log.Info($"variable_ValueWritten()... {e.Name}, {e.Action}, {e.ErrorCode}, {e.ErrorText}"); var variable = sender as Variable; if (variable.UserData is Control edit) { if (edit.Tag is Label) { (edit.Tag as Label).ImageIndex = -1; } } }
private void Cpu_Connected(object sender, PviEventArgs e) { String ipAddress = String.Empty; Cpu cpu = sender as Cpu; if (sender != null) { ipAddress = cpu.Connection.TcpIp.DestinationIpAddress; } var pviEventMsg = Utils.FormatPviEventMessage($"ServiceWrapper.Cpu_Connected. IpAddress={ipAddress}", e); _eventNotifier.OnCpuConnected(sender, new CpuConnectionArgs(cpu, pviEventMsg)); }
private void cpu_Error(object sender, PviEventArgs e) { _logger.Log(new LogEntry(LoggingEventType.Information, PviMessage.FormatMessage("Cpu Error", e))); Cpu cpu = sender as Cpu; if (cpu != null) { cpu.Connected -= cpu_Connected; cpu.Error -= cpu_Error; cpu.Disconnected -= cpu_Disconnected; UpdateLoaded(e.Name); } }
private void Cpu_Error(object sender, PviEventArgs e) { String ipAddress = String.Empty; if (sender is Cpu cpu) { ipAddress = cpu.Connection.TcpIp.DestinationIpAddress; } var pviEventMsg = Utils.FormatPviEventMessage($"ServiceWrapper.Cpu_Error. IpAddress={ipAddress} ", e); _eventNotifier.OnCpuError(sender, new PviApplicationEventArgs() { Message = pviEventMsg }); }
private void variable_Error(object sender, PviEventArgs e) { log.Info($"variable_Error()... {e.Name}, {e.Action}, {e.ErrorCode}, {e.ErrorText}"); var variable = sender as Variable; if (variable.UserData is Control edit && edit is RegexTextBox) { edit.Enabled = false; edit.Text = "E" + e.ErrorCode.ToString(); if (edit.Tag is Label) { (edit.Tag as Label).ImageIndex = 0; } } }
private void PviManager_ServiceConnected(object sender, PviEventArgs e) { PviService = sender as Service; var settingFile = ConfigurationProvider.CpuSettingsFile; var collection = new CpuInfoCollection(); try { collection.Open(settingFile); CpuService = new CpuManager(PviService); CpuService.CpusLoaded += CpuService_CpusLoaded; CpuService.LoadCpuCollection(collection.GetAll()); } catch (System.Exception ex) { _logger.Log(new LogEntry(LoggingEventType.Error, "Error Loading Cpu Settings", ex)); } }
private void Cpu_Disconnected(object sender, PviEventArgs e) { String ipAddress = String.Empty; if (sender is Cpu cpu) { if (_service.Cpus.ContainsKey(cpu.Name)) { ipAddress = cpu.Connection.TcpIp.DestinationIpAddress; cpu.Dispose(); } } var pviEventMsg = Utils.FormatPviEventMessage($"ServiceWrapper.Cpu_Disconnected. IpAddress={ipAddress}", e); _eventNotifier.OnCpuDisconnected(sender, new PviApplicationEventArgs() { Message = pviEventMsg }); }
private void Service_Connected(object sender, PviEventArgs e) { log.Info($"Service_Connected()... {e.Name}, {e.Action}, {e.ErrorCode}, {e.ErrorText}"); cpu = new Cpu(service, "cpu"); cpu.Connection.DeviceType = DeviceType.TcpIp; cpu.Connection.TcpIp.DestinationIpAddress = Properties.Settings.Default.PVILocalIP; cpu.Connection.TcpIp.DestinationPort = Convert.ToInt16(Properties.Settings.Default.PVILocalPort); cpu.Connection.TcpIp.DestinationStation = Convert.ToByte(Properties.Settings.Default.PVIDestStation); cpu.Connection.TcpIp.SourceStation = Convert.ToByte(Properties.Settings.Default.PVISrcStation); cpu.Connected += cpu_Connected; cpu.Disconnected += cpu_Disconnected; cpu.Error += cpu_Error; cpu.Connect(); toolStripStatusLabel1.Text = "VytvářÃm spojenà s PLC..."; log.Info("Service_Connected()... OK"); }
private void cpu_Connected(object sender, PviEventArgs e) { log.Info($"cpu_Connected()... {e.Name}, {e.Action}, {e.ErrorCode}, {e.ErrorText}"); toolStripStatusLabel1.Text = "PLC připojeno."; statusLabelCpuState.Text = cpu.State.ToString(); statusLabelCpuRuntime.Text = cpu.RuntimeVersion; InitVariable(ref trigger1Value, "gTrigger1Value", tbTrigger1Value); InitVariable(ref trigger1Delay, "gTrigger1DeadTime", tbTrigger1Delay); InitVariable(ref trigger1MuteActive, "gTrigger1MuteActive", alarm1Ack, true); InitVariable(ref trigger1Alarm, "gTrigger1Alarm", tabPageLimit1, true); InitVariable(ref trigger2Value, "gTrigger2Value", tbTrigger2Value); InitVariable(ref trigger2Delay, "gTrigger2DeadTime", tbTrigger2Delay); InitVariable(ref trigger2MuteActive, "gTrigger2MuteActive", alarm2Ack, true); InitVariable(ref trigger2Alarm, "gTrigger2Alarm", tabPageLimit2, true); InitVariable(ref varPowerLimit, "gPowerLimit", rtbPowerLimit); InitVariable(ref varPowerFactor, "gPowerFactor", rtbPowerFactor); InitVariable(ref varActValue, "gActPower", label10, true); InitVariable(ref varPeakValue, "gPeakPower", label12, true); InitVariable(ref varPowerConsumed, "gPowerConsumed", label14, true); InitVariable(ref varPowerLimitTarif, "gPowerLimitInterval", label16, true); InitVariable(ref varTarifInterval, "gTarifInterval", rtbTarifInterval); InitVariable(ref varTarifTime, "gTarifTime", null, true); log.Info("cpu_Connected()... OK"); if (Properties.Settings.Default.AutoSetPlcTime) { cpu.WriteDateTime(DateTime.Now); } }
private void PviService_Disconnected(object sender, PviEventArgs e) { var pviEventMsg = FormatPviEventMessage("PviService_Disconnected", e); log.Log(new LogEntry(LoggingEventType.Error, pviEventMsg)); }
void variable_Disconnected(object sender, PviEventArgs e) { }
private string FormatPviEventMessage(string message, PviEventArgs e) { return(String.Format("{0}; Action={1}, Address={2}, Error Code={3}, Error Text={4}, Name={5} ", message, e.Action, e.Address, e.ErrorCode, e.ErrorText, e.Name)); }
public static void LogInfo(string message, PviEventArgs e) { Log.LogInfo(FormatMessage(message, e)); }
private static string FormatMessage(string message, PviEventArgs e) { return String.Format("{0}; Action={1}, Address={2}, Error Code={3}, Error Text={4}, Name={5} ", message, e.Action, e.Address, e.ErrorCode, e.ErrorText, e.Name); }
void v_Activated(object sender, PviEventArgs e) { }
void variable_Error(object sender, PviEventArgs e) { }
private void pviEngine_ServiceConnected(object sender, PviEventArgs e) { PviService pviService = PviService.PviServiceInstance; pviService.PVIEventArgs = e; FadeOut(CONNECTED); }
private void pviEngine_ServiceError(object sender, PviEventArgs e) { PviService pviService = PviService.PviServiceInstance; pviService.PVIEventArgs = new PviEventArgs("Test", "123456", 98765, "language", BR.AN.PviServices.Action.ErrorEvent); FadeOut(ERROR_CONNECTING); }
void v_Error(object sender, PviEventArgs e) { try { StringBuilder sb = new StringBuilder(); Variable v = sender as Variable; if (v != null) { sb.AppendFormat("Variable Name: {0}\n", v.Name); sb.AppendFormat("Action: {0}\n", e.Action); sb.AppendFormat("Address: {0}\n", e.Address); sb.AppendFormat("Error Code: {0}\n", e.ErrorCode); sb.AppendFormat("Error Text: {0}\n", e.ErrorText); sb.AppendFormat("Name: {0}\n", e.Name); sb.AppendLine("Exception:"); sb.AppendLine(e.ToString()); } Log.LogError(sb.ToString()); } catch (System.Exception ex) { Log.LogError("", ex); } }
private void service_ServiceError(object sender, PviEventArgs e) { string message = String.Format("service_ServiceError; Action={0}, Address={1}, Error Code={2}, Error Text={3}, Name={4} ", e.Action, e.Address, e.ErrorCode, e.ErrorText, e.Name); Log.LogError(message); string text = "PVI network error -- connection closed"; string caption = "PVI Error"; MessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Error); }
private void cpu_Error(object sender, PviEventArgs e) { lock (m_EventLock) { OnCpuError(sender, e); } }
void v2_ValueRead(object sender, PviEventArgs e) { Variable v = sender as Variable; }
private void OnCpuConnected(object sender, PviEventArgs e) { Cpu cpu = sender as Cpu; if (cpu != null) { EventHandler<PviEventArgs> temp = m_CpuConnected; if (temp != null) { temp(sender, e); } } }
private void OnMockCpuConnected(object sender, PviEventArgs e) { PviEventArgs eventArgs = new PviEventArgs(e.Name, e.Address, 0, "en-US", e.Action); Cpu cpu = sender as Cpu; if (cpu != null) { EventHandler<PviEventArgs> temp = m_CpuConnected; if (temp != null) { temp(sender, eventArgs); } } }
void SendProductionData_ValueChanged(object sender, PviEventArgs e) { try { Variable rpFileName = m_Cpu.Variables["runningPart.fileName"]; rpFileName.ReadValue(true); string fileName = rpFileName.Value.ToString(); Variable variable = sender as Variable; if (variable.Value) { variable.WriteValueAutomatic = false; variable.Value.Assign(false); variable.WriteValue(); foreach (RecipeVariable rv in m_RecipeVariables) { rv.Value = m_Cpu.Variables[rv.Name].Value; } string destinationFile = Path.Combine(m_ProductionFile, fileName) + ".xlsx"; string sourceFile = Path.Combine(MasterFile, MASTER_FILE); if (File.Exists(destinationFile)) { RecipeMasterServices.RenameExistingFile(destinationFile, true); } File.Copy(sourceFile, destinationFile, true); RecipeData.WriteExcelData(destinationFile, m_Templates, m_RecipeVariables); } } catch (System.Exception ex) { Log.LogError("", ex); } }
private void m_Service_Disconnected(object sender, PviEventArgs e) { lock (m_EventLock) { LogPviEvent.LogInfo("Pvi Service Disconnected", e); OnServiceDisconnected(sender, e); } }
void v_Connected(object sender, PviEventArgs e) { try { Variable v = sender as Variable; if (v.Name == "communicationsActive") { v.Value.Assign(1); v.WriteValue(); } if (this.m_VariableStack.Count > 0) { v = m_VariableStack.Pop(); v.Active = true; v.Connect(); } } catch (System.Exception ex) { Log.LogError("", ex); } }
public static string FormatMessage(string message, PviEventArgs e) { return($"{message}; Action={e.Action}, Address={e.Address}, Error Code={e.ErrorCode}, Error Text={e.ErrorText}, Name={e.Name}"); }
private void m_Service_Error(object sender, PviEventArgs e) { lock (m_EventLock) { LogPviEvent.LogError("Pvi Service Error", e); if (e.ErrorCode != 0) { OnServiceError(sender, e); } } }
private void cpu_Disconnected(object sender, PviEventArgs e) { lock (m_EventLock) { OnCpuDisconnected(sender, e); } }
private void OnServiceConnected(object sender, PviEventArgs e) { Service service = sender as Service; if (service != null) { EventHandler<PviEventArgs> temp = ServiceConnected; if (temp != null) { temp(sender, e); } } }
private void cpu_MockError(object sender, PviEventArgs e) { lock (m_EventLock) { OnMockCpuConnected(sender, e); } }
private void OnServiceDisconnected(object sender, PviEventArgs e) { Service service = sender as Service; if (service != null) { service.Dispose(); service = null; EventHandler<PviEventArgs> temp = ServiceDisconnected; if (temp != null) { temp(sender, e); } } }
private void OnCpuError(object sender, PviEventArgs e) { Cpu cpu = sender as Cpu; if (cpu != null) { UnregisterEvents(cpu); cpu.Disconnect(); EventHandler<PviEventArgs> temp = m_CpuError; if (temp != null) { temp(sender, e); } } }
private void OnServiceError(object sender, PviEventArgs e) { Service service = sender as Service; if (service != null) { UnregisterEvents(service); service.Disconnect(); EventHandler<PviEventArgs> temp = this.ServiceError; if (temp != null) { temp(sender, e); } } }
private void OnMockCpuError(object sender, PviEventArgs e) { //Cpu cpu = sender as Cpu; //PviEventArgs eventArgs = new PviEventArgs(e.Name, e.Address, 0, "en-US", e.Action); //if (cpu != null) //{ // UnregisterEvents(cpu); // cpu.Disconnect(); // EventHandler<PviEventArgs> temp = m_CpuError; // if (temp != null) // { // temp(sender, eventArgs); // } //} }
void rpFileName_ValueRead(object sender, PviEventArgs e) { Variable v = sender as Variable; }