コード例 #1
0
ファイル: MDRFCommon.cs プロジェクト: mosaicsys/MosaicLibCS
        /// <summary>
        /// Used to enforce specific range limits on values in this object:
        /// <para/>MaxDataBlockSize must be between 65536 and 1048576, rounded up to the next multiple of 16384,
        /// NominalMaxFileSize must be between 524288 and 2147483647 (Int32.MaxValue),
        /// MaxFileRecordingPeriod must be between 5 minutes and 7 days,
        /// FileIndexNumRows must be between 256 and 65536,
        /// MinInterFileCreateHoldoffPeriod must be between 15 seconds and 1 hour,
        /// If I8Offset/I4Offset/I2Offset is -1 it will be set to zero.
        /// </summary>
        public SetupInfo ClipValues()
        {
            // clip and round the maxDataBlockSize up to the next multiple of 4096 that is not larger than i4OneMillion
            MaxDataBlockSize = (MaxDataBlockSize.Clip(65536, i4OneMillion) + 0xfff) & 0x7ffff000;

            NominalMaxFileSize = NominalMaxFileSize.Clip(i4HalfMillion, Int32.MaxValue);

            MaxFileRecordingPeriod = MaxFileRecordingPeriod.Clip(TimeSpan.FromMinutes(5.0), TimeSpan.FromDays(7.0));

            FileIndexNumRows = FileIndexNumRows.Clip(256, 65536);

            MinInterFileCreateHoldoffPeriod = MinInterFileCreateHoldoffPeriod.Clip(TimeSpan.FromSeconds(15.0), TimeSpan.FromHours(1.0));

            if (I8Offset == -1)
            {
                I8Offset = 0;
            }
            if (I4Offset == -1)
            {
                I4Offset = 0;
            }
            if (I2Offset == -1)
            {
                I2Offset = 0;
            }

            return(this);
        }
コード例 #2
0
ファイル: MDRFCommon.cs プロジェクト: mosaicsys/MosaicLibCS
        /// <summary>This method is used to replace default (0) values for most property/field here with the value from the given <paramref name="other"/> instance.</summary>
        public SetupInfo MapDefaultsTo(SetupInfo other)
        {
            if (ClientNVS.IsNullOrEmpty())
            {
                ClientNVS = other.ClientNVS.ConvertToReadOnly();
            }

            DirPath        = DirPath.MapNullOrEmptyTo(other.DirPath);
            ClientName     = ClientName.MapNullOrEmptyTo(other.ClientName);
            FileNamePrefix = FileNamePrefix.MapNullOrEmptyTo(other.FileNamePrefix);

            CreateDirectoryIfNeeded          = CreateDirectoryIfNeeded.MapDefaultTo(other.CreateDirectoryIfNeeded);
            MaxDataBlockSize                 = MaxDataBlockSize.MapDefaultTo(other.MaxDataBlockSize);
            NominalMaxFileSize               = NominalMaxFileSize.MapDefaultTo(other.NominalMaxFileSize);
            FileIndexNumRows                 = FileIndexNumRows.MapDefaultTo(other.FileIndexNumRows);
            MaxFileRecordingPeriod           = MaxFileRecordingPeriod.MapDefaultTo(other.MaxFileRecordingPeriod);
            MinInterFileCreateHoldoffPeriod  = MinInterFileCreateHoldoffPeriod.MapDefaultTo(other.MinInterFileCreateHoldoffPeriod);
            MinNominalFileIndexWriteInterval = MinNominalFileIndexWriteInterval.MapDefaultTo(other.MinNominalFileIndexWriteInterval);
            MinNominalWriteAllInterval       = MinNominalWriteAllInterval.MapDefaultTo(other.MinNominalWriteAllInterval);
            I8Offset = I8Offset.MapDefaultTo(other.I8Offset);
            I4Offset = I4Offset.MapDefaultTo(other.I4Offset);
            I2Offset = I2Offset.MapDefaultTo(other.I2Offset);

            return(this);
        }