public static Dictionary <string, ICGRC> GetConfiguration(ReceivedPacket packet) { Dictionary <string, ICGRC> list = new Dictionary <string, ICGRC>(); GTGeneralSettings cgrc00 = new GTGeneralSettings(packet.TerminalId); GTSimAndServerSettings cgrc01 = new GTSimAndServerSettings(packet.TerminalId); GTPollingAndGprsSettings cgrc02 = new GTPollingAndGprsSettings(packet.TerminalId); list.Add(nameof(GTGeneralSettings), cgrc00); list.Add(nameof(GTSimAndServerSettings), cgrc01); list.Add(nameof(GTPollingAndGprsSettings), cgrc02); //string raw = "SP333444<CGRC(ID(00,17/01/2021,07:51:07)N(+923333451191,+923468220229,+923333404763,,,,,,,,SR117R00BL01R00,13-Jan-16,16:27:21,+923,internet,,,+923,internet,,,333444,+923333451191,67.23.248.114,30004,SPMX00DT,SPMX01DT,,,,,,,1,15,2,4,30,9600,15,2)L(1000101101000000000001000000000000))\r>"; string[] strArray = SplitPacket(packet.Data); cgrc00.Parse(strArray); cgrc01.Parse(strArray); cgrc02.Parse(strArray); return(list); }
public static ICGRC GetConfiguration(ReceivedPacket packet, GTCommandType commandType) { ICGRC cgrc = null; string[] strArray = null; switch (commandType) { case GTCommandType.GeneralSettings: strArray = SplitPacket(packet.Data); cgrc = new GTGeneralSettings(packet.TerminalId); cgrc.Parse(strArray); break; case GTCommandType.SimAndServerSettings: strArray = SplitPacket(packet.Data); cgrc = new GTSimAndServerSettings(packet.TerminalId); cgrc.Parse(strArray); break; case GTCommandType.PollingAndGprsSettings: strArray = SplitPacket(packet.Data); cgrc = new GTPollingAndGprsSettings(packet.TerminalId); cgrc.Parse(strArray); break; case GTCommandType.WatchdogSettings: strArray = SplitPacket(packet.Data); cgrc = new GTWatchdogSettings(packet.TerminalId); cgrc.Parse(strArray); break; case GTCommandType.Reset: cgrc = new GTReset(packet.TerminalId); break; case GTCommandType.ResetRom: cgrc = new GTResetRom(packet.TerminalId); break; case GTCommandType.ExtendedConfigurationSettings: strArray = SplitPacket(packet.Data); cgrc = new GTExtendedConfigurationSettings(packet.TerminalId); cgrc.Parse(strArray); break; case GTCommandType.NetworkReadOnlyInformation: strArray = SplitPacket(packet.Data); cgrc = new GTNetworkReadOnlyInformation(packet.TerminalId); cgrc.Parse(strArray); break; case GTCommandType.GetModbusDevice: if (!packet.Data.Equals(GTCommandFactory.ModbusInvalidString)) { if (packet.Data.StartsWith("GET")) { strArray = SplitPacket(packet.Data.Replace("GET[", "").TrimEnd(']')); cgrc = new GTGetModbusDevice(packet.TerminalId); cgrc.Parse(strArray); } } break; case GTCommandType.GetMultipleModbusDevices: strArray = SplitPacket(packet.Data, ';'); cgrc = new GTGetModbusDeviceCollection(packet.TerminalId); cgrc.Parse(strArray); break; case GTCommandType.ClearAllModbusDevices: cgrc = new GTClearModbusDevices(packet.TerminalId); cgrc.Parse(new string[] { packet.Data }); break; case GTCommandType.AddModbusDevice: if (packet.Data.StartsWith("ADD")) { strArray = SplitPacket(packet.Data.Replace("ADD[", "").TrimEnd(']')); cgrc = new GTAddModbusDevice(packet.TerminalId); cgrc.Parse(strArray); } break; case GTCommandType.AddMultipleModbusDevices: strArray = SplitPacket(packet.Data, ';'); cgrc = new GTAddModbusDeviceCollection(packet.TerminalId); cgrc.Parse(strArray); break; default: break; } return(cgrc); }