public virtual double imm_decodeVal(int w) { double val; val = w; if (_isScal32) { val = val / 1000.0; } else { if (_isScal) { val = (val - _offset) / _scale; } else { val = YAPIContext.imm_decimalToDouble(w); } } if (_caltyp != 0) { if (imm_calhdl != null) { val = imm_calhdl(val, _caltyp, _calpar, _calraw, _calref); } } return(val); }
//--- (generated code: YDataStream implementation) #pragma warning disable 1998 public virtual int imm_initFromDataSet(YDataSet dataset, List <int> encoded) { int val; int i; int maxpos; int iRaw; int iRef; double fRaw; double fRef; double duration_float; List <int> iCalib = new List <int>(); // decode sequence header to extract data _runNo = encoded[0] + (((encoded[1]) << (16))); _utcStamp = encoded[2] + (((encoded[3]) << (16))); val = encoded[4]; _isAvg = (((val) & (0x100)) == 0); _samplesPerHour = ((val) & (0xff)); if (((val) & (0x100)) != 0) { _samplesPerHour = _samplesPerHour * 3600; } else { if (((val) & (0x200)) != 0) { _samplesPerHour = _samplesPerHour * 60; } } val = encoded[5]; if (val > 32767) { val = val - 65536; } _decimals = val; _offset = val; _scale = encoded[6]; _isScal = (_scale != 0); _isScal32 = (encoded.Count >= 14); val = encoded[7]; _isClosed = (val != 0xffff); if (val == 0xffff) { val = 0; } _nRows = val; duration_float = _nRows * 3600 / _samplesPerHour; _duration = (int)Math.Round(duration_float); // precompute decoding parameters _decexp = 1.0; if (_scale == 0) { i = 0; while (i < _decimals) { _decexp = _decexp * 10.0; i = i + 1; } } iCalib = dataset.imm_get_calibration(); _caltyp = iCalib[0]; if (_caltyp != 0) { imm_calhdl = _parent._yapi.imm_getCalibrationHandler(_caltyp); maxpos = iCalib.Count; _calpar.Clear(); _calraw.Clear(); _calref.Clear(); if (_isScal32) { i = 1; while (i < maxpos) { _calpar.Add(iCalib[i]); i = i + 1; } i = 1; while (i + 1 < maxpos) { fRaw = iCalib[i]; fRaw = fRaw / 1000.0; fRef = iCalib[i + 1]; fRef = fRef / 1000.0; _calraw.Add(fRaw); _calref.Add(fRef); i = i + 2; } } else { i = 1; while (i + 1 < maxpos) { iRaw = iCalib[i]; iRef = iCalib[i + 1]; _calpar.Add(iRaw); _calpar.Add(iRef); if (_isScal) { fRaw = iRaw; fRaw = (fRaw - _offset) / _scale; fRef = iRef; fRef = (fRef - _offset) / _scale; _calraw.Add(fRaw); _calref.Add(fRef); } else { _calraw.Add(YAPIContext.imm_decimalToDouble(iRaw)); _calref.Add(YAPIContext.imm_decimalToDouble(iRef)); } i = i + 2; } } } // preload column names for backward-compatibility _functionId = dataset.imm_get_functionId(); if (_isAvg) { _columnNames.Clear(); _columnNames.Add("" + _functionId + "_min"); _columnNames.Add("" + _functionId + "_avg"); _columnNames.Add("" + _functionId + "_max"); _nCols = 3; } else { _columnNames.Clear(); _columnNames.Add(_functionId); _nCols = 1; } // decode min/avg/max values for the sequence if (_nRows > 0) { if (_isScal32) { _avgVal = this.imm_decodeAvg(encoded[8] + (((((encoded[9]) ^ (0x8000))) << (16))), 1); _minVal = this.imm_decodeVal(encoded[10] + (((encoded[11]) << (16)))); _maxVal = this.imm_decodeVal(encoded[12] + (((encoded[13]) << (16)))); } else { _minVal = this.imm_decodeVal(encoded[8]); _maxVal = this.imm_decodeVal(encoded[9]); _avgVal = this.imm_decodeAvg(encoded[10] + (((encoded[11]) << (16))), _nRows); } } return(0); }