public static void SetValueToOutGoingMassage(byte[] array, int index, string filterName) { ResetByteMessages(array); ByteMessageBuilderRepository.SetByteArrayByIndex(ByteMessages.Instance.ServiceModeOutgoing, 0, XmlFilterServiceMode.Instance.GetDefaultValueByName(SRVMODON)); ByteMessageBuilderRepository.SetByteArrayByIndex(ByteMessages.Instance.ServiceModeOutgoing, index, XmlFilterServiceMode.Instance.GetDefaultValueByName(filterName)); ByteMessageBuilderRepository.SetByteArrayByIndex(ByteMessages.Instance.ServiceModeOutgoing, 11, XmlFilterServiceMode.Instance.GetEOF()); }
public static void UdpUartTransmitStop(string cardType, string measureType) { ResetByteMessages(); ByteMessageBuilderRepository.SetByteArrayByIndex(ByteMessages.Instance.MeasureModeOutgoing, 0, XmlFilter.Instance.GetUdpUartTransmitStop()); ByteMessageBuilderRepository.SetByteArrayByIndex(ByteMessages.Instance.MeasureModeOutgoing, 1, XmlFilter.Instance.GetSelectedCardTypeValue(cardType)); ByteMessageBuilderRepository.SetByteArrayByIndex(ByteMessages.Instance.MeasureModeOutgoing, 2, XmlFilter.Instance.GetSelectedMeasurementValue(cardType, measureType)); ByteMessageBuilderRepository.SetByteArrayByIndex(ByteMessages.Instance.MeasureModeOutgoing, 4, XmlFilter.Instance.GetEOF()); }
private void LoopMessagesArrayToSend() { ByteMessageBuilderRepository.ClearArray(ByteMessages.Instance.ServiceModeIncoming); for (int i = 0; i < ByteMessages.Instance.ServiceModeOutgoing.Length; i++) { SendData(ByteMessages.Instance.ServiceModeOutgoing[i]); } }
private static void ResetByteMessages(byte[] array) { ByteMessageBuilderRepository.ClearArray(array); }
private void DataRecieved(object sender, SerialDataReceivedEventArgs e) { if (SerialPortManager.Instance.IsOpen) { try { byte received_byte = Convert.ToByte(SerialPortManager.Instance.ReadByte()); _receivedBytes[this.countBytes] = received_byte; string incomingByte = received_byte.ToString(); ByteMessageBuilderRepository.SetStrArrayByIndex(ByteMessages.Instance.MeasureModeIncoming, countBytes, incomingByte); //all bytes arrived if (countBytes == 2) { countBytes = 0; if (WasItRun) { IsRunningNow = GeneralMessageCollection.IsRunningStateChecker(true); TimeOutValidator(TimeOutValidatorStates.Reset); if (ValidatorIncomingMessage.ValidationEOF()) { if (XmlFilter.Instance.IsCommonIncluded(SelectedCardType) == true) { _commonMeasures = XmlFilter.Instance.GetNumberOfExpectedMeasureState(XmlFilter.Instance.GetDefaultName()); } else { _commonMeasures = 0; } if (XmlFilter.Instance.GetResponseCommand(this._receivedBytes[0].ToString()) == "VOIP_UDP_Start") { this._udp = new Udp(); this._udp.IsEnabled = true; this._udp.SendBytes.Add(_receivedBytes[1]); } else if (XmlFilter.Instance.GetResponseCommand(this._receivedBytes[0].ToString()) == "VOIP_UDP_Cont") { this._udp.IsEnabled = true; this._udp.SendBytes.Add(this._receivedBytes[1]); } else if (XmlFilter.Instance.GetResponseCommand(_receivedBytes[0].ToString()) == "VOIP_UDP_Stop") { this._udp.IsEnabled = true; CTRL_udpClient.Send(this._udp.SendBytes.ToArray(), this._udp.SendBytes.Count, this._udp.IPADDRESS, this._udp.PORT); this._udp.IsFinished = true; } if (!this._udp.IsEnabled) { //if the incoming messages's number is equle with the required number from XML file if (_incomingMeasureCounter == (XmlFilter.Instance.GetNumberOfExpectedMeasureState(SelectedCardType)) + _commonMeasures) { TimeOutValidator(TimeOutValidatorStates.Stop); MessageRecievedText = GeneralMessageCollection.GeneralMessageRecivedTranslation(" -> Validate OK", true) + MessageRecievedText; _validateFinished = true; GeneralMessageCollection.LoopCounter = 0; } else { if (SelectedMeasureType != "AutoMeasure") { IEnumerable <String> _measureList = XmlFilter.Instance.GetMeasureListByCardTypeWithoutAuto(SelectedCardType); var index = _measureList.ToList().IndexOf(SelectedMeasureType); GeneralMessageCollection.LoopCounter = index; TimeOutValidator(TimeOutValidatorStates.Stop); MessageRecievedText = GeneralMessageCollection.GeneralMessageRecivedTranslation("") + MessageRecievedText; GeneralMessageCollection.LoopCounter = 0; _validateFinished = false; } else { //when it is not validated yet and AutoMeasure. TimeOutValidator(TimeOutValidatorStates.Reset); _incomingMeasureCounter++; MessageRecievedText = GeneralMessageCollection.GeneralMessageRecivedTranslation("", true) + MessageRecievedText; GeneralMessageCollection.LoopCounter++; _validateFinished = false; } } } //if incoming message returns with measure ok or not-> negative logic if (IsMeasureModeIncomingReseted && ValidatorIncomingMessage.ErrorMessageBack(ByteMessages.Instance.MeasureModeIncoming[1]) && !this._udp.IsEnabled) { TimeOutValidator(TimeOutValidatorStates.Stop); _validateFinished = true; GeneralMessageCollection.LoopCounter = 0; } if (ReportFieldState && !this._udp.IsEnabled) { _savedMeasureCounter++; string reportInsertData = IsMeasureModeIncomingReseted ? XmlFilter.Instance.GetResponseData( ConverterRepository.ConvertDecimalStringToHexString(ByteMessages.Instance.MeasureModeIncoming[1].ToString())) : ""; ReportDataCollector.AddToVertical(reportInsertData); if (ReportFieldState && _validateFinished) { ReportDataCollector.AddToVerticalAtIndex(0, SchauerNumber.ToString()); ReportDataCollector.AddVerticalToHorizontal(); ReportDataCollector.CleanerVertical(); PopUpQuestionbox(); } } } else { TimeOutValidator(TimeOutValidatorStates.Stop); _validateFinished = true; GeneralMessageCollection.LoopCounter = 0; MessageRecievedText = GeneralMessageCollection.GeneralMessageRecived("Validate Error -> Wrong EoF") + MessageRecievedText; } } else { MessageRecievedText = "Info: " + DateTime.Now.ToString("HH:mm:ss").ToString() + " -> " + XmlFilter.Instance.GetResponseTranslate (ByteMessages.Instance.MeasureModeIncoming[0].ToString(), ByteMessages.Instance.MeasureModeIncoming[1].ToString(), ByteMessages.Instance.MeasureModeIncoming[2].ToString()) + "\n" + MessageRecievedText + "\n"; } WasItDisconnect(); ByteMessageBuilderRepository.ClearArray(ByteMessages.Instance.MeasureModeIncoming); } else { countBytes++; } if (_validateFinished) { _incomingMeasureCounter = 1; _validateFinished = false; IsRunningNow = GeneralMessageCollection.IsRunningStateChecker(false); } if (this._udp.IsFinished) { this._udp.Reset(); } } catch (Exception ex) { //throw; MessageBox.Show(GeneralMessageCollection.LogIntoFile(ex)); } } }
private static void ResetByteMessages() { ByteMessageBuilderRepository.ClearArray(ByteMessages.Instance.MeasureModeOutgoing); }
public static void ResetNok() { ResetByteMessages(); ByteMessageBuilderRepository.SetByteArrayByIndex(ByteMessages.Instance.MeasureModeOutgoing, 0, XmlFilter.Instance.GetResetNok()); ByteMessageBuilderRepository.SetByteArrayByIndex(ByteMessages.Instance.MeasureModeOutgoing, 4, XmlFilter.Instance.GetEOF()); }
public static void DisConfigureDevice() { ResetByteMessages(); ByteMessageBuilderRepository.SetByteArrayByIndex(ByteMessages.Instance.MeasureModeOutgoing, 0, XmlFilter.Instance.GetDisConnect()); ByteMessageBuilderRepository.SetByteArrayByIndex(ByteMessages.Instance.MeasureModeOutgoing, 4, XmlFilter.Instance.GetEOF()); }