-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/506 set data buffer method in storage unit #507
Changes from 1 commit
111d0dc
7578479
672b908
9b5dc30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,8 +28,8 @@ | |
@return void; | ||
*/ | ||
PartitionedStorageUnit::PartitionedStorageUnit(){ | ||
this->storageCapacity = -1.0; | ||
this->storedDataSum = 0.0; | ||
this->storageCapacity = 0; | ||
this->storedDataSum = 0; | ||
return; | ||
} | ||
|
||
|
@@ -45,7 +45,7 @@ PartitionedStorageUnit::~PartitionedStorageUnit(){ | |
@return void | ||
*/ | ||
void PartitionedStorageUnit::customReset(uint64_t currentClock){ | ||
if (this->storageCapacity <= 0.0) { | ||
if (this->storageCapacity <= 0) { | ||
bskLogger.bskLog(BSK_INFORMATION, "The storageCapacity variable must be set to a positive value."); | ||
} | ||
return; | ||
|
@@ -58,7 +58,20 @@ void PartitionedStorageUnit::customReset(uint64_t currentClock){ | |
void PartitionedStorageUnit::addPartition(std::string dataName){ | ||
dataInstance tmpDataInstance; | ||
strncpy(tmpDataInstance.dataInstanceName, dataName.c_str(), sizeof(tmpDataInstance.dataInstanceName)); | ||
tmpDataInstance.dataInstanceSum = 0.0; | ||
tmpDataInstance.dataInstanceSum = 0; | ||
this->storedData.push_back(tmpDataInstance); | ||
return; | ||
} | ||
|
||
/*! Adds a specific amount of data to the specified partitions once | ||
@param partitionNames //Vector of partition names | ||
@param data //Vector of data to be added to each partition in partitionNames | ||
@return void | ||
*/ | ||
void PartitionedStorageUnit::setDataBuffer(std::vector<std::string> partitionNames, std::vector<long long int> data){ | ||
|
||
for (int i = 0; i < partitionNames.size(); i++) | ||
{ | ||
PartitionedStorageUnit::DataStorageUnitBase::setDataBuffer(partitionNames[i], data[i]); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New line here as well |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,8 +27,8 @@ | |
@return void | ||
*/ | ||
SimpleStorageUnit::SimpleStorageUnit(){ | ||
this->storageCapacity = -1.0; | ||
this->storedDataSum = 0.0; | ||
this->storageCapacity = 0; | ||
this->storedDataSum = 0; | ||
return; | ||
} | ||
|
||
|
@@ -43,7 +43,7 @@ SimpleStorageUnit::~SimpleStorageUnit(){ | |
@param currentClock | ||
*/ | ||
void SimpleStorageUnit::customReset(uint64_t currentClock){ | ||
if (this->storageCapacity <= 0.0) { | ||
if (this->storageCapacity <= 0) { | ||
bskLogger.bskLog(BSK_INFORMATION, "The storageCapacity variable must be set to a positive value."); | ||
} | ||
return; | ||
|
@@ -63,10 +63,10 @@ void SimpleStorageUnit::integrateDataStatus(double currentTime){ | |
if (storedData.size() == 0){ | ||
this->storedData.push_back({{'S','T','O','R','E','D',' ','D','A','T','A'}, 0}); | ||
} | ||
else if ((this->storedDataSum < this->storageCapacity) || (it->baudRate <= 0)){ | ||
else if ((this->storedDataSum + round(it->baudRate * this->currentTimestep) < this->storageCapacity) || (it->baudRate <= 0)){ | ||
//! - Only perform the operation if it will not result in less than 0 data | ||
if ((this->storedData[0].dataInstanceSum + it->baudRate * (this->currentTimestep)) >= 0){ | ||
this->storedData[0].dataInstanceSum += it->baudRate * (this->currentTimestep); | ||
this->storedData[0].dataInstanceSum += round(it->baudRate * (this->currentTimestep)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The braces around |
||
} | ||
} | ||
this->netBaud += it->baudRate; | ||
|
@@ -79,3 +79,12 @@ void SimpleStorageUnit::integrateDataStatus(double currentTime){ | |
this->previousTime = currentTime; | ||
return; | ||
} | ||
|
||
/*! Adds a specific amount of data to the storedData vector once | ||
@param data //Data to be added to the "STORED DATA" partition | ||
@return void | ||
*/ | ||
void SimpleStorageUnit::setDataBuffer(long long int data){ | ||
std::string partitionName = "STORED DATA"; | ||
SimpleStorageUnit::DataStorageUnitBase::setDataBuffer(partitionName, data); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is missing a new line at its end. You can see that github is alerting you of this fact with the little red circle containing a dash, just to the left above this comment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be
int64_t
also, (assuming I'm not missing something here...I could be :) )