public void Parse(string[] strArray)
 {
     if (strArray != null)
     {
         foreach (var str in strArray)
         {
             if (!str.Equals(GTCommandFactory.ModbusInvalidString) && str.StartsWith("GET"))
             {
                 GTGetModbusDevice device = new GTGetModbusDevice(TerminalId);
                 var arr = str.Replace("GET[", "").TrimEnd(']').Split(',');
                 device.Parse(arr);
                 Devices.Add(device);
             }
         }
     }
 }
        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);
        }