Skip to content

Commit

Permalink
#13 Factor of 0.01 not considered for DC-String current
Browse files Browse the repository at this point in the history
40099 DC-Strom an String 1 in Ampere (Faktor 0.01) 1 Uint16 R
40100 DC-Strom an String 2 in Ampere (Faktor 0.01) 1 Uint16 R
40101 DC-Strom an String 3 in Ampere (Faktor 0.01) 1 Uint16 R
  • Loading branch information
Brovning committed Jan 12, 2022
1 parent fc1d541 commit 5a4eb62
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions e3dc/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
define("IMR_TYPE", 4);
define("IMR_UNITS", 5);
define("IMR_DESCRIPTION", 6);
define("IMR_SF", 7);
}

// E3DC settings
Expand Down Expand Up @@ -1195,9 +1196,9 @@ public function ApplyChanges()
array(40096, 1, 3, "DC_STRING_1_Voltage", "UInt16", "V", "DC_STRING_1_Voltage"),
array(40097, 1, 3, "DC_STRING_2_Voltage", "UInt16", "V", "DC_STRING_2_Voltage"),
array(40098, 1, 3, "DC_STRING_3_Voltage", "UInt16", "V", "DC_STRING_3_Voltage"),
array(40099, 1, 3, "DC_STRING_1_Current", "UInt16", "A", "DC_STRING_1_Current"),
array(40100, 1, 3, "DC_STRING_2_Current", "UInt16", "A", "DC_STRING_2_Current"),
array(40101, 1, 3, "DC_STRING_3_Current", "UInt16", "A", "DC_STRING_3_Current"),
array(40099, 1, 3, "DC_STRING_1_Current", "UInt16", "A", "DC_STRING_1_Current", 0.01),
array(40100, 1, 3, "DC_STRING_2_Current", "UInt16", "A", "DC_STRING_2_Current", 0.01),
array(40101, 1, 3, "DC_STRING_3_Current", "UInt16", "A", "DC_STRING_3_Current", 0.01),
array(40102, 1, 3, "DC_STRING_1_Power", "UInt16", "W", "DC_STRING_1_Power"),
array(40103, 1, 3, "DC_STRING_2_Power", "UInt16", "W", "DC_STRING_2_Power"),
array(40104, 1, 3, "DC_STRING_3_Power", "UInt16", "W", "DC_STRING_3_Power"),
Expand Down Expand Up @@ -1363,14 +1364,26 @@ private function createModbusInstances($modelRegister_array, $parentId, $gateway
// Erstelle Modbus Instancen
foreach ($modelRegister_array as $inverterModelRegister)
{
// get datatype
$datenTyp = $this->getModbusDatatype($inverterModelRegister[IMR_TYPE]);
if("continue" == $datenTyp)
{
continue;
}

// if scale factor is given, variable will be of type float
if(isset($inverterModelRegister[IMR_SF]) && 10000 >= $inverterModelRegister[IMR_SF])
{
$varDataType = MODBUSDATATYPE_REAL;
}
else
{
$varDataType = $datenTyp;
}

// get profile
if (isset($inverterModelRegister[IMR_UNITS])) {
$profile = $this->getProfile($inverterModelRegister[IMR_UNITS], $datenTyp);
$profile = $this->getProfile($inverterModelRegister[IMR_UNITS], $varDataType);
}
else
{
Expand All @@ -1383,7 +1396,7 @@ private function createModbusInstances($modelRegister_array, $parentId, $gateway
// Modbus-Instanz erstellen, sofern noch nicht vorhanden
if (false === $instanceId)
{
$this->SendDebug("create Modbus address", "REG_".$inverterModelRegister[IMR_START_REGISTER]." - ".$inverterModelRegister[IMR_NAME]." (datatype=".$datenTyp.", profile=".$profile.")", 0);
$this->SendDebug("create Modbus address", "REG_".$inverterModelRegister[IMR_START_REGISTER]." - ".$inverterModelRegister[IMR_NAME]." (modbusDataType=".$datenTyp.", varDataType=".$varDataType.", profile=".$profile.")", 0);

$instanceId = IPS_CreateInstance(MODBUS_ADDRESSES);

Expand Down Expand Up @@ -1411,15 +1424,20 @@ private function createModbusInstances($modelRegister_array, $parentId, $gateway
}


// Modbus-Instanz konfigurieren
// ************************
// config Modbus-Instance
// ************************
// set data type
if ($datenTyp != IPS_GetProperty($instanceId, "DataType"))
{
IPS_SetProperty($instanceId, "DataType", $datenTyp);
}
// set emulation state
if (false != IPS_GetProperty($instanceId, "EmulateStatus"))
{
IPS_SetProperty($instanceId, "EmulateStatus", false);
}
// set poll cycle
if ($pollCycle != IPS_GetProperty($instanceId, "Poller"))
{
IPS_SetProperty($instanceId, "Poller", $pollCycle);
Expand All @@ -1429,12 +1447,11 @@ private function createModbusInstances($modelRegister_array, $parentId, $gateway
{
IPS_SetProperty($instanceId, "Length", $inverterModelRegister[IMR_SIZE]);
}
/*
if(0 != IPS_GetProperty($instanceId, "Factor"))
// set scale factor
if(isset($inverterModelRegister[IMR_SF]) && 10000 >= $inverterModelRegister[IMR_SF] && $inverterModelRegister[IMR_SF] != IPS_GetProperty($instanceId, "Factor"))
{
IPS_SetProperty($instanceId, "Factor", 0);
IPS_SetProperty($instanceId, "Factor", $inverterModelRegister[IMR_SF]);
}
*/

// Read-Settings
if ($inverterModelRegister[IMR_START_REGISTER] + MODBUS_REGISTER_TO_ADDRESS_OFFSET != IPS_GetProperty($instanceId, "ReadAddress"))
Expand Down

0 comments on commit 5a4eb62

Please sign in to comment.