/* * DeviceHandler.cpp * * Created on: 02/06/2021 * Author: Marco Modè * */ #include #include #include #include #include //#include #include ArduinoDH::ArduinoDH(object_id_t objectId, object_id_t comIF, CookieIF *cookie) : DeviceHandlerBase(objectId, comIF, cookie)/*, foundId(&bufferId), foundLen(&bufferLen)*/ { mode = _MODE_START_UP; } ArduinoDH::~ArduinoDH() { } /*void ArduinoDH::performOperationHook() { }*/ void ArduinoDH::doStartUp() { std::cout<<"Arduino device -> Switching-ON"< Switching-OFF"< Transition to Normal mode"< "); printf("\nStart: %7s", vecAcc[3 * k].start_string); printf("\nTyp: %u", vecAcc[3 * k].Typ); printf("\nSPCChNumber: %u", vecAcc[3 * k].SPCChNumber); printf("\nValue_Cnt: %u", vecAcc[3 * k].Value_Cnt); for (int i = 0; i < 9; i++) { printf("\nMeasurement number: %d", i); printf("\nValue: %f", vecAcc[3 * k].Value[i]); printf("\nTimestamp: %u", vecAcc[3 * k].Timestamp[i]); } printf("\nEnd: %7s", vecAcc[3 * k].end_string); printf("\n\nY ==> "); printf("\nStart: %7s", vecAcc[3 * k + 1].start_string); printf("\nTyp: %u", vecAcc[3 * k + 1].Typ); printf("\nSPCChNumber: %u", vecAcc[3 * k + 1].SPCChNumber); printf("\nValue_Cnt: %u", vecAcc[3 * k + 1].Value_Cnt); for (int i = 0; i < 9; i++) { printf("\nMeasurement number: %d", i); printf("\nValue: %f", vecAcc[3 * k + 1].Value[i]); printf("\nTimestamp: %u", vecAcc[3 * k + 1].Timestamp[i]); } printf("\nEnd: %7s", vecAcc[3 * k + 1].end_string); printf("\n\nZ ==> "); printf("\nStart: %7s", vecAcc[3 * k + 2].start_string); printf("\nTyp: %u", vecAcc[3 * k + 2].Typ); printf("\nSPCChNumber: %u", vecAcc[3 * k + 2].SPCChNumber); printf("\nValue_Cnt: %u", vecAcc[3 * k + 2].Value_Cnt); for (int i = 0; i < 9; i++) { printf("\nMeasurement number: %d", i); printf("\nValue: %f", vecAcc[3 * k + 2].Value[i]); printf("\nTimestamp: %u", vecAcc[3 * k + 2].Timestamp[i]); } printf("\nEnd: %7s", vecAcc[3 * k + 2].end_string); } std::cout << "\n\nEnd reading data.\n" << std::endl;*/ // The data are here written to the data pool where they would be available to be used for other objects DataSet ArduinoDataSet; PoolVector TempValueVec(datapool::Temperature_value, &ArduinoDataSet, PoolVariableIF::VAR_WRITE); for (int i = 0; i < 36; i++) { memcpy(&TempValueVec[i], &vecTemp[i].temperature, 4); } ArduinoDataSet.commit(PoolVariableIF::VALID); /*PoolVector TempTimeVec(datapool::Temperature_Timestamp, &ArduinoDataSet, PoolVariableIF::VAR_WRITE); for (int i = 0; i < 36; i++) { memcpy(&TempTimeVec[i], &vecTemp[i].Timestamp, 4); } ArduinoDataSet.commit(PoolVariableIF::VALID); sif::debug<<"\nDEBUG_DHi: End of copy to datapool"< EnvValueVec(datapool::Environmental_value, &ArduinoDataSet, PoolVariableIF::VAR_WRITE); for (int j = 0; j < 9; j++) { memcpy(&EnvValueVec[j], &vecEnv[j].Value, 4); } ArduinoDataSet.commit(PoolVariableIF::VALID); PoolVector EnvTimeVec(datapool::Environmental_Timestamp, &ArduinoDataSet, PoolVariableIF::VAR_WRITE); for (int j = 0; j < 9; j++) { memcpy(&EnvTimeVec[j], &vecEnv[j].Timestamp, 4); } ArduinoDataSet.commit(PoolVariableIF::VALID); sif::debug<<"\nDEBUG_DHj: End of copy to datapool"< AccValueVec(datapool::Accelerometer_value, &ArduinoDataSet, PoolVariableIF::VAR_WRITE); for (int k = 0; k < 15; k++) { memcpy(&AccValueVec[k], &vecAcc[k].Value, 36); } ArduinoDataSet.commit(PoolVariableIF::VALID); sif::debug<<"\nDEBUG_DHk1: End of copy to datapool"< AccTimeVec(datapool::Accelerometer_Timestamp, &ArduinoDataSet, PoolVariableIF::VAR_WRITE); for (int k = 0; k < 15; k++) { memcpy(&AccTimeVec[k], &vecAcc[k].Timestamp, 36); } ArduinoDataSet.commit(PoolVariableIF::VALID); sif::debug<<"\nDEBUG_DHk2: End of copy to datapool"<fullInfoPrintout = enable; }*/ /*ReturnValue_t ArduinoDH::initializeLocalDataPool( localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { return RETURN_OK; }*/ /*ReturnValue_t ArduinoDH::getParameter(uint8_t domainId, uint8_t uniqueId, ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, uint16_t startAtIndex) { return RETURN_OK; }*/ /*LocalPoolObjectBase* ArduinoDH::getPoolObjectHandle(lp_id_t localPoolId) { return RETURN_OK; }*/