private void ReadData() { FTD2XX.Read(handle, data); if (data[0] != STARTFLAG) { FTD2XX.FT_Purge(handle, FT_PURGE.FT_PURGE_RX); return; } if (data[1] == 255 || data[1] == 88) { // bigNG if (data[274] != protocolVersion) { return; } if (primaryData.Length == 0) { primaryData = new byte[data.Length]; } data.CopyTo(primaryData, 0); for (var i = 0; i < digitalTemperatures.Length; i++) { if (data[238 + i] > 0) { digitalTemperatures[i].Value = 0.5f * data[238 + i] + digitalTemperatures[i].Parameters[0].Value; ActivateSensor(digitalTemperatures[i]); } else { DeactivateSensor(digitalTemperatures[i]); } } for (var i = 0; i < analogTemperatures.Length; i++) { if (data[260 + i] > 0) { analogTemperatures[i].Value = 0.5f * data[260 + i] + analogTemperatures[i].Parameters[0].Value; ActivateSensor(analogTemperatures[i]); } else { DeactivateSensor(analogTemperatures[i]); } } for (var i = 0; i < sensorhubTemperatures.Length; i++) { if (data[246 + i] > 0) { sensorhubTemperatures[i].Value = 0.5f * data[246 + i] + sensorhubTemperatures[i].Parameters[0].Value; ActivateSensor(sensorhubTemperatures[i]); } else { DeactivateSensor(sensorhubTemperatures[i]); } } for (var i = 0; i < sensorhubFlows.Length; i++) { if (data[231 + i] > 0 && data[234] > 0) { var pulsesPerSecond = (data[231 + i] * 4.0f) / data[234]; var pulsesPerLiter = sensorhubFlows[i].Parameters[0].Value; sensorhubFlows[i].Value = pulsesPerSecond * 3600 / pulsesPerLiter; ActivateSensor(sensorhubFlows[i]); } else { DeactivateSensor(sensorhubFlows[i]); } } for (var i = 0; i < fans.Length; i++) { var maxRPM = 11.5f * ((data[149 + 2 * i] << 8) | data[148 + 2 * i]); if (fans[i] == null) { fans[i] = new Sensor("Fan Channel " + i, i, SensorType.Fan, this, new[] { new ParameterDescription("MaxRPM", "Maximum revolutions per minute (RPM) of the fan.", maxRPM) }, settings); } float value; if ((data[136] & (1 << i)) == 0) // pwm mode { value = 0.02f * data[137 + i]; } else // analog mode { value = 0.01f * data[141 + i]; } fans[i].Value = fans[i].Parameters[0].Value * value; ActivateSensor(fans[i]); controls[i].Value = 100 * value; ActivateSensor(controls[i]); } } else if (data[1] == 253) { // miniNG #1 if (alternativeData.Length == 0) { alternativeData = new byte[data.Length]; } data.CopyTo(alternativeData, 0); ReadminiNG(0); if (data[66] == 253) // miniNG #2 { ReadminiNG(1); } } }