private void itemValueReceive(ItemValueCallback obj) { string name = (string)obj.ClientHandle; string value = (string) obj.Value; if (Hardware.SegmentSummaryTagsList.Contains(name)) { try { int index = Hardware.SegmentSummaryTagsList.IndexOf(name); string propToUpdate = Hardware.SegmentSummaryPropertiesList[index]; this[propToUpdate] = value; } catch (Exception ex) { MessageBox.Show(Application.Current.MainWindow, "Failed to Update: " + name + "\n" + ex.ToString()); } } if ((name == "TC_Highest" || name == "TC_Lowest")) { if (TCLowest != null && TCLowest != null) { try { CalculatedTCAvg = ((Int32.Parse(TCHighest) + Int32.Parse(TCLowest)) / 2).ToString(); } catch (Exception) { MessageBox.Show(Application.Current.MainWindow, "Failed to Update: " + name); } } } if ((name == "TR_Highest" || name == "TR_Lowest")) { if (TRLowest != null && TRLowest != null) { try { CalculatedTRAvg = ((Int32.Parse(TRHighest) + Int32.Parse(TRLowest)) / 2).ToString(); } catch (Exception) { MessageBox.Show(Application.Current.MainWindow, "Failed to Update: " + name); } } } string RunningDisplayed = "RunningRamp" + RunningNb; RunningRampHrUI = this[RunningDisplayed].ToString(); try { RunningRampMinUI = (Int32.Parse(RunningRampHrUI) / 60).ToString(); } catch (Exception) { MessageBox.Show(Application.Current.MainWindow, "Unable to Update Ramp F/Min Value"); } }
private void CheckResponsibility(ItemValueCallback itemValue) { /************************************************************************************************************** * -> Method : CheckResponsibility * -> Param : ItemValueCallback itemValue * -> Event : This method is triggered by OPC_DataChanged Method * -> Description: This method publishes an event which updates the properties on UI **************************************************************************************************************/ _eventAggregator.GetEvent <UpdatedValueEvent>().Publish(itemValue); }
private void itemValueReceive(ItemValueCallback obj) { string name = (string)obj.ClientHandle; string value = (string)obj.Value; if (Hardware.OffsetTagsList.Contains(name)) { try { int index = Hardware.OffsetTagsList.IndexOf(name); string propToUpdate = Hardware.OffsetPropertiesList[index]; this[propToUpdate] = value; } catch (Exception ex) { MessageBox.Show("Failed to Update(SetPt): " + name + "\n" + ex.ToString()); } } }
private void itemValueReceive(ItemValueCallback obj) { string name = (string)obj.ClientHandle; string value = (string)obj.Value; if (Hardware.SegmentParameterTagsList.Contains(name)) { try { int index = Hardware.SegmentParameterTagsList.IndexOf(name); string propToUpdate = Hardware.SegmentParameterPropertiesList[index]; this[propToUpdate] = value; } catch (Exception ex) { MessageBox.Show(Application.Current.MainWindow, "Failed to Update" + name + "\n" + ex.ToString()); } } }
private void itemValueReceive(ItemValueCallback obj) { string name = (string)obj.ClientHandle; string value = (string)obj.Value; //if (Hardware.OffsetTagsList.Contains(name)) //{ // try // { // int index = Hardware.OffsetTagsList.IndexOf(name); // string propToUpdate = Hardware.OffsetPropertiesList[index]; // this[propToUpdate] = value; // } // catch (Exception Ex) // { // MessageBox.Show("Failed to Update(SetPt): " + name + "\n" + Ex.Message); // } //} }
public static void DataChanged(int clientSubscription, bool allQualitiesGood, bool noErrors, ItemValueCallback[] itemValues) { int idx; // Transaction Handle Is the PLC's Index 1 Based So Must Decrement By 1 idx = clientSubscription -1; try { //iterate through array of returned values foreach (ItemValueCallback itemValue in itemValues) { if (itemValue.ResultID.Succeeded) { //logger.Debug("PLC Name: {5}, Client Subscription: {0} Item: {1}, Value: {2}, Quality: {3}, Timestamp: {4}", clientSubscription, itemValue.ClientHandle, itemValue.Value, itemValue.Quality.Name, itemValue.TimeStamp); IDCService.IDCConfig.model.plcs[idx].opcliitems[(int)itemValue.ClientHandle - 1].value = itemValue.Value; IDCService.IDCConfig.model.plcs[idx].opcliitems[(int)itemValue.ClientHandle - 1].quality = itemValue.Quality.Quality; IDCService.IDCConfig.model.plcs[idx].opcliitems[(int)itemValue.ClientHandle - 1].timestamp = itemValue.TimeStamp; } else { logger.Info("ItemError In Item: {0}", IDCService.IDCConfig.model.plcs[idx].opcliitems[(int)itemValue.ClientHandle - 1].path); } // If Succeeded } // ForEach Item Value if (IDCService.IDCConfig.model.plcs[idx].initDataReceived != true) { logger.Info("DataChanged Initial Data Received For {0} ItemCount: {1}", IDCService.IDCConfig.model.plcs[idx].name, itemValues.Count()); } } catch (Exception ex) { logger.Error(ex, "DataChanged exception. Reason:" + ex.Message); } }
public static void ReadCompleted(int transactionHandle, bool allQualitiesGood, bool noErrors, ItemValueCallback[] itemValues) { int idx; // Transaction Handle Is the PLC's Index 1 Based So Must Decrement By 1 idx = transactionHandle - 1; try { //iterate through array of returned values foreach (ItemValueCallback itemValue in itemValues) { if (itemValue.ResultID.Succeeded) { IDCService.IDCConfig.model.plcs[idx].opcliitems[(int)itemValue.ClientHandle - 1].value = itemValue.Value; IDCService.IDCConfig.model.plcs[idx].opcliitems[(int)itemValue.ClientHandle - 1].quality = itemValue.Quality.Quality; IDCService.IDCConfig.model.plcs[idx].opcliitems[(int)itemValue.ClientHandle - 1].timestamp = itemValue.TimeStamp; } else { logger.Info("ReadCompleted ItemError In Item: {0}", IDCService.IDCConfig.model.plcs[idx].items[(int)itemValue.ClientHandle]._opccliitem.path); } // If Succeeded } // ForEach Item Value IDCService.IDCConfig.model.plcs[idx].initDataReceived = true; logger.Info("Initial Read Data Received For {0}", IDCService.IDCConfig.model.plcs[idx].name); } catch (Exception ex) { logger.Error(ex, "ReadCompleted exception. Reason:" + ex.Message); } }
private void checkResponsability(ItemValueCallback itemValue) { _eventAggregator.GetEvent <UpdatedValueEvent>().Publish(itemValue); }
private void GetItemValue(ItemValueCallback obj) { /************************************************************************************************************** * -> Method : PartsApply * -> Param : object obj * -> Event : This Method triggered by event called UpdatedValueEvent and is called whenever the PLC updates * a value of a property. The event is published by MainWindowViewModel * -> Description: This Method takes in an ItemValueCallBack obj contains a property called "ClientHandle", which * holds the property name and contains another property called "Value". This method then updates * the local context of the property to the new value using the "This" method, which uses reflection. * This method could also calculate the TC and TR average. **************************************************************************************************************/ string name = (string)obj.ClientHandle; string value = (string)obj.Value; if (Hardware.SegmentSummaryTagsList.Contains(name)) { try { int index = Hardware.SegmentSummaryTagsList.IndexOf(name); string propToUpdate = Hardware.SegmentSummaryPropertiesList[index]; this[propToUpdate] = value; } catch (Exception Ex) { MessageBox.Show(Application.Current.MainWindow, "Failed to Update: " + name + "\n" + Ex.Message); } } if ((name == "TC_Highest" || name == "TC_Lowest")) { if (TCLowest != null && TCHighest != null) { try { CalculatedTCAvg = ((Int32.Parse(TCHighest) + Int32.Parse(TCLowest)) / 2).ToString(); } catch (Exception) { ShowFailedToUpdateMessageBox(name); } } } if ((name == "TR_Highest" || name == "TR_Lowest")) { if (TRLowest != null && TRHighest != null) { try { CalculatedTRAvg = ((Int32.Parse(TRHighest) + Int32.Parse(TRLowest)) / 2).ToString(); } catch (Exception) { ShowFailedToUpdateMessageBox(name); //MessageBox.Show(Application.Current.MainWindow, "Failed to Update: " + name); } } } //string RunningDisplayed = "RunningRamp" + RunningNb; //RunningRampHrUI = this[RunningDisplayed].ToString(); //try //{ //RunningRampMinUI = (Int32.Parse(RunningRampHrUI) / 60).ToString(); //} //catch (Exception) //{ // MessageBox.Show(Application.Current.MainWindow, "Unable to Update Ramp F/Min Value"); // } }