public void recordValue(String name, long timeStamp, float value) throws IOException {
		SensorData sd = (SensorData)paramStorage.get(name);
		
		if (sd.list_bos != null && sd.list_bos.size() >= maxBulkSize){
			adapter.storeRecord(sd.list_bos.getBuffer(), sd.list_bos.size());
			sd.list_bos = null;
		}

		if (sd.list_bos == null){
			sd.list_bos = new DirectBOS(maxBulkSize);
			sd.list_dos = new DataOutputStream(sd.list_bos);
			// ID of the current trip
			sd.list_dos.writeLong(tripStamp);
			// Sensor parameter name
			sd.list_dos.writeUTF(name);
			// Initiate timestamp
			sd.list_dos.writeByte(0xFE);
			sd.list_dos.writeLong(timeStamp);
			// Initiate interval value
			sd.currentInterval = 1 + sd.updateInterval/10;
			if (sd.currentInterval > Short.MAX_VALUE)
				sd.currentInterval = Short.MAX_VALUE;
			sd.list_dos.writeByte(0xFF);
			sd.list_dos.writeShort(sd.currentInterval);
			// init data
			sd.last_ts = timeStamp;
			sd.currentAveraged = 0;
			sd.averagedNo = 0;
		}

		long ts_diff = timeStamp-sd.last_ts;
		
		// accumulate values
		if (sd.optionAverage){
			sd.currentAveraged = (sd.currentAveraged*sd.averagedNo + value)/(sd.averagedNo+1);
			sd.averagedNo++;
		}else{
			sd.currentAveraged = value;
		}

		if (ts_diff >= sd.updateInterval || ts_diff == 0)
		{
			int ts_diff_adopted = (int)(ts_diff / sd.currentInterval);
			/*
			 * May happen if sensor reading is delayed because of some issues
			 * and becomes outside of current coefficient 
			 */
			if (ts_diff_adopted >= 0xFE){
				sd.list_dos.writeByte(0xFE);
				sd.list_dos.writeLong(sd.last_ts);
				ts_diff_adopted = 0;
			}
			// Write sensor value
			sd.list_dos.writeByte(ts_diff_adopted);
			sd.list_dos.writeFloat(sd.currentAveraged);
			sd.last_ts = timeStamp;
			sd.currentAveraged = 0;
			sd.averagedNo = 0;
		}
	}