// Method used to cache DataStream objects (new DataLogger) internal virtual YDataStream imm_findDataStream(YDataSet dataset, string def) { string key = dataset.get_functionId() + ":" + def; if (_dataStreams.ContainsKey(key)) { return(_dataStreams[key]); } YDataStream newDataStream = new YDataStream(this, dataset, YAPIContext.imm_decodeWords(def)); _dataStreams[key] = newDataStream; return(newDataStream); }
public virtual async Task <List <YDataSet> > parse_dataSets(byte[] json) { List <string> dslist = new List <string>(); YDataSet dataset; List <YDataSet> res = new List <YDataSet>(); dslist = this.imm_json_get_array(json); res.Clear(); for (int ii = 0; ii < dslist.Count; ii++) { dataset = new YDataSet(this); await dataset._parse(dslist[ii]); res.Add(dataset); } return(res); }
// Method used to cache DataStream objects (new DataLogger) internal virtual YDataStream imm_findDataStream(YDataSet dataset, string def) { string key = dataset.get_functionId() + ":" + def; if (_dataStreams.ContainsKey(key)) { return(_dataStreams[key]); } List <int> words = YAPIContext.imm_decodeWords(def); if (words.Count < 14) { _throw(YAPI.VERSION_MISMATCH, "device firmware is too old"); return(null); } YDataStream newDataStream = new YDataStream(this, dataset, words); _dataStreams[key] = newDataStream; return(newDataStream); }
//--- (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); }
internal YDataStream(YFunction parent, YDataSet dataset, List <int> encoded) { _parent = parent; imm_initFromDataSet(dataset, encoded); }
//--- (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 ms_offset; int samplesPerHour; double fRaw; double fRef; 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; } } _dataSamplesInterval = 3600.0 / samplesPerHour; ms_offset = encoded[6]; if (ms_offset < 1000) { // new encoding -> add the ms to the UTC timestamp _startTime = _utcStamp + (ms_offset / 1000.0); } else { // legacy encoding subtract the measure interval form the UTC timestamp _startTime = _utcStamp - _dataSamplesInterval; } _firstMeasureDuration = encoded[5]; if (!(_isAvg)) { _firstMeasureDuration = _firstMeasureDuration / 1000.0; } val = encoded[7]; _isClosed = (val != 0xffff); if (val == 0xffff) { val = 0; } _nRows = val; if (_nRows > 0) { if (_firstMeasureDuration > 0) { _duration = _firstMeasureDuration + (_nRows - 1) * _dataSamplesInterval; } else { _duration = _nRows * _dataSamplesInterval; } } else { _duration = 0; } // precompute decoding parameters 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(); 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; } } // 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) { _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)))); } return(0); }