/** * <summary> * Returns the temperature at the time when the latest calibration was performed. * <para> * This function can be used to determine if a new calibration for ambient temperature * is required. * </para> * </summary> * <returns> * a temperature, as a floating point number. * On failure, throws an exception or return YAPI.INVALID_DOUBLE. * </returns> */ public virtual async Task <double> get_hardwareCalibrationTemperature() { string hwcal; hwcal = await this.get_hardwareCalibration(); if (!((hwcal).Substring(0, 1) == "@")) { return(YAPI.INVALID_DOUBLE); } return(YAPIContext.imm_atoi((hwcal).Substring(1, (hwcal).Length))); }
/** * <summary> * Switch the relay to the opposite state. * <para> * </para> * </summary> * <returns> * <c>YAPI.SUCCESS</c> if the call succeeds. * </returns> * <para> * On failure, throws an exception or returns a negative error code. * </para> */ public virtual async Task <int> toggle() { int sta; string fw; YModule mo; if (_firm == 0) { mo = await this.get_module(); fw = await mo.get_firmwareRelease(); if (fw == YModule.FIRMWARERELEASE_INVALID) { return(STATE_INVALID); } _firm = YAPIContext.imm_atoi(fw); } if (_firm < 34921) { sta = await this.get_state(); if (sta == STATE_INVALID) { return(STATE_INVALID); } if (sta == STATE_B) { await this.set_state(STATE_A); } else { await this.set_state(STATE_B); } return(YAPI.SUCCESS); } else { return(await this._setAttr("state", "X")); } }
public virtual async Task <int> loadCompensationTable(int tableIndex, List <double> tempValues, List <double> compValues) { string id; byte[] bin_json; List <string> paramlist = new List <string>(); int siz; int idx; double temp; double comp; id = await this.get_functionId(); id = (id).Substring(10, (id).Length - 10); bin_json = await this._download("extra.json?page=" + Convert.ToString((4 * YAPIContext.imm_atoi(id)) + tableIndex)); paramlist = this.imm_json_get_array(bin_json); // convert all values to float and append records siz = ((paramlist.Count) >> (1)); tempValues.Clear(); compValues.Clear(); idx = 0; while (idx < siz) { temp = Double.Parse(paramlist[2 * idx]) / 1000.0; comp = Double.Parse(paramlist[2 * idx + 1]) / 1000.0; tempValues.Add(temp); compValues.Add(comp); idx = idx + 1; } return(YAPI.SUCCESS); }
public virtual async Task <byte[]> encodeTimeStamp(string exp) { int explen; int i; byte[] res; int n; byte[] expasc; int v1; int v2; explen = (exp).Length; if (explen == 0) { res = new byte[0]; return(res); } if ((exp).Substring(0, 1) == "+") { n = YAPIContext.imm_atoi((exp).Substring(1, explen - 1)); res = new byte[1]; if (n > 30 * 86400) { n = 192 + (((n + 6 * 86400)) / ((7 * 86400))); } else { if (n > 86400) { n = 166 + (((n + 86399)) / (86400)); } else { if (n > 43200) { n = 143 + (((n - 43200 + 1799)) / (1800)); } else { n = -1 + (((n + 299)) / (300)); } } } if (n < 0) { n = 0; } res[0] = (byte)(n & 0xff); return(res); } if ((exp).Substring(4, 1) == "-" || (exp).Substring(4, 1) == "/") { // ignore century exp = (exp).Substring(2, explen - 2); explen = (exp).Length; } expasc = YAPI.DefaultEncoding.GetBytes(exp); res = new byte[7]; n = 0; i = 0; while ((i + 1 < explen) && (n < 7)) { v1 = expasc[i]; if ((v1 >= 48) && (v1 < 58)) { v2 = expasc[i + 1]; if ((v2 >= 48) && (v2 < 58)) { v1 = v1 - 48; v2 = v2 - 48; res[n] = (byte)((((v2) << (4))) + v1 & 0xff); n = n + 1; i = i + 1; } } i = i + 1; } while (n < 7) { res[n] = (byte)(0 & 0xff); n = n + 1; } if (i + 2 < explen) { // convert for timezone in cleartext ISO format +/-nn:nn v1 = expasc[i - 3]; v2 = expasc[i]; if (((v1 == 43) || (v1 == 45)) && (v2 == 58)) { v1 = expasc[i + 1]; v2 = expasc[i + 2]; if ((v1 >= 48) && (v1 < 58) && (v1 >= 48) && (v1 < 58)) { v1 = (((10 * (v1 - 48) + (v2 - 48))) / (15)); n = n - 1; v2 = 4 * res[n] + v1; if (expasc[i - 3] == 45) { v2 += 128; } res[n] = (byte)(v2 & 0xff); } } } return(res); }