RawDataDAT1::RawDataDAT1(VFS* vfs, const std::string& datfile, const s_info& info) : RawDataMemSource(info.unpackedLength) { boost::scoped_ptr<RawData> input (vfs->open(datfile)); input->setIndex(info.offset); if (info.type == 0x40) { // compressed LZSSDecoder decoder; decoder.decode(input.get(), getRawData(), getSize()); } else input->readInto(getRawData(), getSize()); }
bool MidiMessage::isNoteOff (const bool returnTrueForNoteOnVelocity0) const noexcept { auto data = getRawData(); return ((data[0] & 0xf0) == 0x80) || (returnTrueForNoteOnVelocity0 && (data[2] == 0) && ((data[0] & 0xf0) == 0x90)); }
bool MidiMessage::isNoteOn (const bool returnTrueForVelocity0) const noexcept { auto data = getRawData(); return ((data[0] & 0xf0) == 0x90) && (returnTrueForVelocity0 || data[2] != 0); }
uint8 MidiMessage::getVelocity() const noexcept { if (isNoteOnOrOff()) return getRawData()[2]; return 0; }
/* * Set the offset values (zero voltage values) * WARNING: the platform should be leveled first * using body mounted bubble level * Read 10 samples from sensor and average * Place offsets in offset registers */ void ADXL345::setOffset() { if(accelStatus == ON) { int32_t sumX = 0; int32_t sumY = 0; int32_t sumZ = 0; for(uint8_t i = 0; i < 10; i++) { getRawData(); // read raw data sumX = sumX + (int32_t) data[X]; sumY = sumY + (int32_t) data[Y]; sumZ = sumZ + (int32_t) data[Z]; // delay long enough for another sample to be available // @ 100 Hz -> 0.01 seconds delay(10); } offset[X] = (float) sumX / 10.0; offset[Y] = (float) sumY / 10.0; offset[Z] = (float) sumZ / 10.0 - (float) 256; vehicleStatus = vehicleStatus | ACCEL_READY; } else { Serial.println("WARNING: accel is not online -> cannot be zeroed"); } }
/* * Set the zero voltage values by averaging 10 samples */ void ITG3200::setOffset() { if(gyroStatus == ON) { int32_t sumX = 0; int32_t sumY = 0; int32_t sumZ = 0; for(uint8_t i = 0; i < 10; i++) { getRawData(); // read raw data sumX = sumX + (int32_t) data[X]; sumY = sumY + (int32_t) data[Y]; sumZ = sumZ + (int32_t) data[Z]; // delay long enough for another sample // to be available on the sensor // @ 100 Hz -> 0.01 sec delay(10); } offset[X] = (float) sumX / 10.0; offset[Y] = (float) sumY / 10.0; offset[Z] = (float) sumZ / 10.0; // set global gyro status vehicleStatus = vehicleStatus | GYRO_READY; } else { Serial.println("WARNING: gyro is not online -> cannot be zeroed"); } }
struct gyro* Gyroscope::getGyroData(){ getRawData(); prev_gyro->gyro_x = (float)raw_gyro->gyro_x * GYRO_SENSITIVITY_250DPS * SENSORS_DPS_TO_RADS; prev_gyro->gyro_y = (float)raw_gyro->gyro_y * GYRO_SENSITIVITY_250DPS * SENSORS_DPS_TO_RADS; prev_gyro->gyro_z = (float)raw_gyro->gyro_z * GYRO_SENSITIVITY_250DPS * SENSORS_DPS_TO_RADS; return raw_gyro; }
void RawFormat::serialize(boost::property_tree::ptree& parentNode) { boost::property_tree::ptree node; node.put("<xmlattr>.type", getType()); node.put("RawData", BufferHelper::getHex(getRawData())); parentNode.add_child(getDefaultXmlNodeName(), node); }
bool MidiMessage::isForChannel (const int channel) const noexcept { jassert (channel > 0 && channel <= 16); // valid channels are numbered 1 to 16 auto data = getRawData(); return ((data[0] & 0xf) == channel - 1) && ((data[0] & 0xf0) != 0xf0); }
int MidiMessage::getChannel() const noexcept { auto data = getRawData(); if ((data[0] & 0xf0) != 0xf0) return (data[0] & 0xf) + 1; return 0; }
const uint8* MidiMessage::getMetaEventData() const noexcept { jassert (isMetaEvent()); int n; auto d = getRawData() + 2; readVariableLengthVal (d, n); return d + n; }
void RawFormat::getLinearData(void* data, size_t dataLengthBytes) const { string ret; std::vector<unsigned char> buf = getRawData(); if (dataLengthBytes >= buf.size()) { memcpy(data, &buf[0], buf.size()); } }
void Linux3AxisEventInterface::workProc(void) { while(_bRunning == true) { getRawData(); if(_uiNapTime > 0) osgSleep(_uiNapTime); } }
int MidiMessage::getMetaEventLength() const noexcept { auto data = getRawData(); if (*data == 0xff) { int n; return jmin (size - 2, readVariableLengthVal (data + 2, n)); } return 0; }
void createInferenceOlmoAutomataData(vector<InferenceClassInterface*> *models,SimpleDataSet trainDataSet){ vector<SimpleDataSet> dataSplit = splitActions(trainDataSet); for (int i = 1; i <= Num_Actions; i++) { vector<vector<int> > rawData = getRawData(dataSplit[i - 1]); cout << "DAta for action:" << i << ", " << rawData.size() << endl; OlmoAutomata* inference = new OlmoAutomata(rawData); inference->setIdAction(i); inference->save(); models->push_back(inference); } }
/* * Return accelerations in g's */ void ADXL345::getValue(float *value) { getRawData(); // TODO - calibration work value[X] = -((float)data[X] - offset[X]) / (float) ADXL345_8GSENSITIVITY; value[Y] = ((float)data[Y] - offset[Y]) / (float) ADXL345_8GSENSITIVITY; value[Z] = ((float)data[Z] - offset[Z]) / (float) 263; //Serial.print(value[X]); //Serial.print(", "); //Serial.print(value[Y]); //Serial.print(", "); //Serial.print(value[Z]); //Serial.print("\n"); }
uint8_t *TR::X86DataSnippet::emitSnippetBody() { uint8_t *cursor = cg()->getBinaryBufferCursor(); // align to 16 bytes if (getDataSize() % 16 == 0) { cursor = (uint8_t*)(((intptrj_t)(cursor + 15)) & ((-1)<<4)); } getSnippetLabel()->setCodeLocation(cursor); memcpy(cursor, getRawData(), getDataSize()); addMetaDataForCodeAddress(cursor); cursor += getDataSize(); return cursor; }
/* * Convert raw data to rate in degrees/second */ void ITG3200::getRate(float rate[]) { getRawData(); rate[X] = ((float)data[X] - offset[X]) / (float) ITG3200_SENSITIVITY; rate[Y] = ((float)data[Y] - offset[Y]) / (float) ITG3200_SENSITIVITY; rate[Z] = ((float)data[Z] - offset[Z]) / (float) ITG3200_SENSITIVITY; /* if(rate[X] >= 0) Serial.print(" "); Serial.print(rate[X]); Serial.print("\t\t"); if(rate[Y] >= 0) Serial.print(" "); Serial.print(rate[Y]); Serial.print("\t\t"); if(rate[Z] >= 0) Serial.print(" "); Serial.print(rate[Z]); Serial.print("\n"); */ }
int main(int argc, char **argv) { // #if TEST_MODE // // Initialize test data // int data[MAXSIZE] = { 2, 20, 37, 22, 6, 3 }; // #else // // Receive input from user or open file // int data[MAXSIZE]; // int cnt = getData(data); // printf("Inputted data count = %d\n", cnt); // #endif // Handle data and processing RESULT set = { 0, 0, 0, 0, 0, 0, 0 }; /*Initialize results to zero*/ INT_NODE top; top.next = NULL; printf("Address of top = [%p]\n", &top); printf("Address of top.next = [%p]\n", top.next); getRawData(&top); updateResult(&set, top.next); printRawData(top.next); printResult(&set); // updateResult(&set, top.next); // printResult(&set); // updateResult(&set, top.next); // printResult(&set); // Output to screen print_h1st0gram(top.next); return 0; }
bool IDnsResource::setName(const std::string& newName) { char encodedName[256]; size_t encodedNameLen = 0; encodeName(newName, encodedName, encodedNameLen); if (m_DnsLayer != NULL) { if (encodedNameLen > m_NameLength) { if (!m_DnsLayer->extendLayer(m_OffsetInLayer, encodedNameLen-m_NameLength, this)) { LOG_ERROR("Couldn't set name for DNS query, unable to extend layer"); return false; } } else if (encodedNameLen < m_NameLength) { if (!m_DnsLayer->shortenLayer(m_OffsetInLayer, m_NameLength-encodedNameLen, this)) { LOG_ERROR("Couldn't set name for DNS query, unable to shorten layer"); return false; } } } else { char tempData[getSize()]; memcpy(tempData, m_ExternalRawData, getSize()); memcpy(m_ExternalRawData + encodedNameLen, tempData, getSize()); } memcpy(getRawData(), encodedName, encodedNameLen); m_NameLength = encodedNameLen; m_DecodedName = newName; return true; }
int8_t filterSensorData(int16_t* avgSensorData, float* filteredSensorData, uint32_t averagedDataDelatT){ float deltaT = averagedDataDelatT / 1000.0; //update deltaT for all functions and calculate from millisecond to second //convert raw data into angles etc getRawData(angle, omega, mag, avgSensorData, deltaT); //filter and merge sensor data getFilteredData(angle_p, omega_p, angle, omega, deltaT); //accl_x predicted filteredSensorData[0] = angle_p[0]; //accl_y predicted filteredSensorData[1] = angle_p[1]; //accl_z predicted filteredSensorData[2] = angle_p[2]; //gyro_x predicted filteredSensorData[3] = omega_p[0]; //gyro_y predicted filteredSensorData[4] = omega_p[1]; //gyro_z predicted filteredSensorData[5] = omega_p[2]; //compass_x filteredSensorData[6] = mag[0]; //compass_y filteredSensorData[7] = mag[1]; //compass_z filteredSensorData[8] = mag[2]; return NO_ERR; }
String MidiMessage::getDescription() const { if (isNoteOn()) return "Note on " + MidiMessage::getMidiNoteName (getNoteNumber(), true, true, 3) + " Velocity " + String (getVelocity()) + " Channel " + String (getChannel()); if (isNoteOff()) return "Note off " + MidiMessage::getMidiNoteName (getNoteNumber(), true, true, 3) + " Velocity " + String (getVelocity()) + " Channel " + String (getChannel()); if (isProgramChange()) return "Program change " + String (getProgramChangeNumber()) + " Channel " + String (getChannel()); if (isPitchWheel()) return "Pitch wheel " + String (getPitchWheelValue()) + " Channel " + String (getChannel()); if (isAftertouch()) return "Aftertouch " + MidiMessage::getMidiNoteName (getNoteNumber(), true, true, 3) + ": " + String (getAfterTouchValue()) + " Channel " + String (getChannel()); if (isChannelPressure()) return "Channel pressure " + String (getChannelPressureValue()) + " Channel " + String (getChannel()); if (isAllNotesOff()) return "All notes off Channel " + String (getChannel()); if (isAllSoundOff()) return "All sound off Channel " + String (getChannel()); if (isMetaEvent()) return "Meta event"; if (isController()) { String name (MidiMessage::getControllerName (getControllerNumber())); if (name.isEmpty()) name = String (getControllerNumber()); return "Controller " + name + ": " + String (getControllerValue()) + " Channel " + String (getChannel()); } return String::toHexString (getRawData(), getRawDataSize()); }
int MidiMessage::getControllerValue() const noexcept { jassert (isController()); return getRawData()[2]; }
int MidiMessage::getMetaEventType() const noexcept { auto data = getRawData(); return *data != 0xff ? -1 : data[1]; }
bool MidiMessage::isAllNotesOff() const noexcept { auto data = getRawData(); return (data[0] & 0xf0) == 0xb0 && data[1] == 123; }
bool MidiMessage::isActiveSense() const noexcept { return *getRawData() == 0xfe; }
//============================================================================== bool MidiMessage::isMetaEvent() const noexcept { return *getRawData() == 0xff; }
const uint8* MidiMessage::getSysExData() const noexcept { return isSysEx() ? getRawData() + 1 : nullptr; }
//============================================================================== bool MidiMessage::isSysEx() const noexcept { return *getRawData() == 0xf0; }
bool MidiMessage::isAllSoundOff() const noexcept { auto data = getRawData(); return data[1] == 120 && (data[0] & 0xf0) == 0xb0; }