//--- (generated code: YDataStream implementation) public virtual int _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 this._runNo = encoded[0] + (((encoded[1]) << (16))); this._utcStamp = encoded[2] + (((encoded[3]) << (16))); val = encoded[4]; this._isAvg = (((val) & (0x100)) == 0); this._samplesPerHour = ((val) & (0xff)); if (((val) & (0x100)) != 0) { this._samplesPerHour = this._samplesPerHour * 3600; } else { if (((val) & (0x200)) != 0) { this._samplesPerHour = this._samplesPerHour * 60; } } val = encoded[5]; if (val > 32767) { val = val - 65536; } this._decimals = val; this._offset = val; this._scale = encoded[6]; this._isScal = (this._scale != 0); this._isScal32 = (encoded.Count >= 14); val = encoded[7]; this._isClosed = (val != 0xffff); if (val == 0xffff) { val = 0; } this._nRows = val; duration_float = this._nRows * 3600 / this._samplesPerHour; this._duration = (int) Math.Round(duration_float); // precompute decoding parameters this._decexp = 1.0; if (this._scale == 0) { i = 0; while (i < this._decimals) { this._decexp = this._decexp * 10.0; i = i + 1; } } iCalib = dataset.get_calibration(); this._caltyp = iCalib[0]; if (this._caltyp != 0) { this._calhdl = YAPI._getCalibrationHandler(this._caltyp); maxpos = iCalib.Count; this._calpar.Clear(); this._calraw.Clear(); this._calref.Clear(); if (this._isScal32) { i = 1; while (i < maxpos) { this._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; this._calraw.Add(fRaw); this._calref.Add(fRef); i = i + 2; } } else { i = 1; while (i + 1 < maxpos) { iRaw = iCalib[i]; iRef = iCalib[i + 1]; this._calpar.Add(iRaw); this._calpar.Add(iRef); if (this._isScal) { fRaw = iRaw; fRaw = (fRaw - this._offset) / this._scale; fRef = iRef; fRef = (fRef - this._offset) / this._scale; this._calraw.Add(fRaw); this._calref.Add(fRef); } else { this._calraw.Add(YAPI._decimalToDouble(iRaw)); this._calref.Add(YAPI._decimalToDouble(iRef)); } i = i + 2; } } } // preload column names for backward-compatibility this._functionId = dataset.get_functionId(); if (this._isAvg) { this._columnNames.Clear(); this._columnNames.Add(""+this._functionId+"_min"); this._columnNames.Add(""+this._functionId+"_avg"); this._columnNames.Add(""+this._functionId+"_max"); this._nCols = 3; } else { this._columnNames.Clear(); this._columnNames.Add(this._functionId); this._nCols = 1; } // decode min/avg/max values for the sequence if (this._nRows > 0) { if (this._isScal32) { this._avgVal = this._decodeAvg(encoded[8] + (((((encoded[9]) ^ (0x8000))) << (16))), 1); this._minVal = this._decodeVal(encoded[10] + (((encoded[11]) << (16)))); this._maxVal = this._decodeVal(encoded[12] + (((encoded[13]) << (16)))); } else { this._minVal = this._decodeVal(encoded[8]); this._maxVal = this._decodeVal(encoded[9]); this._avgVal = this._decodeAvg(encoded[10] + (((encoded[11]) << (16))), this._nRows); } } return 0; }