示例#1
0
        /// <summary>
        /// Can download the file content of the Settings Dump file (*.mepar), which is created using the TEC Service Software.
        /// See Maintenance tab.
        /// Please read the TEC User Manual for further information about this feature.
        /// </summary>
        /// <param name="address">Device Address. Use null to use the DefaultDeviceAddress defined on MeComQuerySet.</param>
        /// <param name="fileContent">Content of the .mepar file.</param>
        public void DownloadSettingsDumpFile(byte?address, string fileContent)
        {
            string[] settingsStrings = fileContent.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

            if (settingsStrings.Length == 0)
            {
                throw new FormatException("The fileContent does not contain any settings strings!");
            }

            try
            {
                foreach (string settingsString in settingsStrings)
                {
                    MeComPacket txFrame = new MeComPacket('#', address);
                    MeComVarConvert.AddString(txFrame.Payload, "?SD");
                    MeComVarConvert.AddString(txFrame.Payload, settingsString);
                    MeComPacket rxFrame = meQuerySet.Query(txFrame);
                    if (MeComVarConvert.ReadUint4(rxFrame.Payload) != 0)
                    {
                        throw new InvalidOperationException("The settings string has not been accepted (CRC error)!");
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ComCommandException(String.Format("Download Settings File failed: Address: {0}, Detail: {1}", address, ex.Message), ex);
            }
        }