Hi, hope you have a good day. I try to add current register in my DLMS Server:
// add current
CGXDLMSRegister *pRegister_curr = new CGXDLMSRegister("1.0.31.7.0.255");
pRegister_curr->SetAccess(2, DLMS_ACCESS_MODE_READ);
// set unit
unsigned char cr_unit = DLMS_UNIT_CURRENT;
pRegister_curr->SetUnit(cr_unit);
// set scaler
double curr_scaler;
curr_scaler = 0.01;
pRegister_curr->SetScaler(curr_scaler);
// set value
// query from db
std::cout << (db.connect() ? "Connected to database." : "Failed to connect to database.") << std::endl;
auto rows1 = db.rawQuery("SELECT * FROM `dt_meter1_register`");
CGXDLMSVariant curr_val;
curr_val = rows1[0]._0_0_1_0_0_255;
pRegister_curr->SetValue(curr_val);
std::cout << "Current value: " << curr_val.ToString() << std::endl;
// debug
double scaler_curr = pRegister_curr->GetScaler();
std::cout << "Scaling factor: " << scaler_curr << std::endl;
// double scaled_curr = curr_val.ToDouble() * scaler_curr;
// std::cout << "Scaled value: " << scaled_curr << std::endl;
GetItems().push_back(pRegister_curr);I set the scaler to 0.01, but the value doesn't get scaled properly. Let's say the value is 90, it would not be shown as 0.9 in Gurux GXDLMSDirector. I tried setting it as (-2), assuming the power of base10 of that is 0.01. What's the proper way to do this?
Thank you
jack
Hi Jack, The scaler is used…
Hi Jack,
The scaler is used when the value is read from the meter, and if the scaler is set.
pRegister_curr->SetValue only updates the value. Scaler is used when the value is write to the meter.
You also need to set the Force read or read the association view again if you change the scaler because it's static and read only once.
You can set the Force read by selecting "View" and "Force Read".
BR,
Mikko
Hi Mikko, thank you for the…
Hi Mikko, thank you for the response. I did re-associate by refreshing the device/pressing F5 each time I add/modify something to the server code, so the edit would take effect.
When tinkering with the server code, if I only do SetValue with no scaler, say 199, the value would show 199 in GXDLMSDirector. Then I try SetScaler and put it right after the SetValue
Regarding the value, i already put the value after i set the scaler, to my understanding If the scaler is used when the value gets written to the meter, that value should be updated with the scaler applied, isn't it?
Here's my updated code, this time i try another GetValue which takes two arguments. The value is still static:
The result i get is this:
Help me to understand this better
Regards
jack
Hi, Are you trying to make a…
Hi,
Are you trying to make a meter where you are adding the values from the database?
You don't need to call GetValue. The framework will handle that. You just need to set the correct value and scaler for the register object.
BR,
Mikko
Hi Mikko, yes I do. I don't…
Hi Mikko, yes I do. I don't have my sensors handy with me, but I have some data from my meter that i store in a database.
I think I get it now, but the scaled value only appears in profile generic where i have some registers as the capture object. when i read it from the "Register" list, it doesnt get multiplied. Is it some limitation when using static data instead of dynamic data gathered from sensor?
Regards,
jack
Hi, There are no limitations…
Hi,
There are no limitations. Ensure that you have only one instance of the register object that you share with profile generic capture objects.
Check your register scaler value.
BR,
Mikko