/// <summary> /// Computes a CRC 16 checksum of the specified bytes using the given algorithm /// </summary> /// <param name="algorithm">The CRC 16 Algorithm to use</param> /// <param name="bytes">The buffer to compute the CRC upon</param> /// <param name="start">The start index upon which to compute the CRC</param> /// <param name="length">The length of the buffer upon which to compute the CRC</param> /// <returns>The specified CRC</returns> public static ushort ComputeChecksum(Crc16Algorithm algorithm, byte[] bytes, int start, int length) { switch (algorithm) { case Crc16Algorithm.Standard: return(Standard.ComputeChecksum(bytes, start, length)); case Crc16Algorithm.Ccitt: return(CcittInitialZero.ComputeChecksum(bytes, start, length)); case Crc16Algorithm.CcittKermit: return(CcittKermit.ComputeChecksum(bytes, start, length)); case Crc16Algorithm.CcittInitialValue0xFFFF: return(CcittInitial0xFFFF.ComputeChecksum(bytes, start, length)); case Crc16Algorithm.CcittInitialValue0x1D0F: return(CcittInitial0x1D0F.ComputeChecksum(bytes, start, length)); case Crc16Algorithm.Dnp: return(Dnp.ComputeChecksum(bytes, start, length)); case Crc16Algorithm.Modbus: return(Standard.ComputeChecksum(bytes, start, length, ushort.MaxValue)); } throw new UnknownAlgorithmException("Unknown Algorithm"); }
public ScriptSettings(IZeusInput input, MyMeta.dbRoot database, Dnp.Utils.Utils dnp, string version) { this._input = input; this._database = database; this._version = version; this._dnpUtils = dnp; }
public ProgressDialogWrapper(Dnp.Utils.ProgressDialog progressDialog) { _progressDialog = progressDialog; script = ScriptSettings.GetInstance(); }
public static ScriptSettings InitInstance(IZeusInput input, MyMeta.dbRoot database, Dnp.Utils.Utils dnp, string version) { if (_instance == null) { if (input == null) throw new ApplicationException("InitInstance input"); if (database == null) throw new ApplicationException("InitInstance database"); if (dnp == null) throw new ApplicationException("InitInstance dnp"); if (string.IsNullOrEmpty(version)) throw new ApplicationException("InitInstance version"); _instance = new ScriptSettings(input, database, dnp, version); } return _instance; }