1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ProGauge_StartItaliana_Probe.MessageEntity.Outgoing
- {
- public enum RequestType
- {
- MeasureRequest,
- DiagnostiRequest,
- TemperatureRequest,
- VersionRequest,
- ResetSW,
- SetAlarmPointInDmm,
- }
- public abstract class RequestMessageBase : MessageBase
- {
- /// <summary>
- ///
- /// </summary>
- /// <param name="address">55555 is a broadcast address.</param>
- /// <param name="type"></param>
- public RequestMessageBase(string address, RequestType type)
- {
- if (string.IsNullOrEmpty(address)) throw new ArgumentException("address");
- if (address.Length > 5) throw new ArgumentException("address value length should <=5");
- address = address.PadLeft(5, '0');
- string requestMsg = "";
- switch (type)
- {
- case RequestType.MeasureRequest:
- requestMsg = "M";
- break;
- case RequestType.DiagnostiRequest:
- requestMsg = "D";
- break;
- case RequestType.TemperatureRequest:
- requestMsg = "T";
- break;
- case RequestType.VersionRequest:
- requestMsg = "V";
- break;
- case RequestType.ResetSW:
- requestMsg = "X";
- break;
- case RequestType.SetAlarmPointInDmm:
- requestMsg = "A";
- break;
- }
- requestMsg += address + "\r\n";
- base.RawContent = Encoding.ASCII.GetBytes(requestMsg).ToList();
- }
- }
- }
|