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
{
///
///
///
/// 55555 is a broadcast address.
///
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();
}
}
}