Unfortunately we do not have the device here to test it.
But looking into your library, I can see that the default i²c address (that is used if you do not set the address in the device configuration (parameters)) is 0x41 (see body of Adafruit_CurrentSense, line 6). Did you verify this with i2cdetect?
What I saw in the Adafruit example code is that the registers are 16bit long:
uint16_t config = INA219_CONFIG_BVOLTAGERANGE_32V |
In your lib you used the write8 method.
Currently, there is no ready-to-use write16 method, but it is easy to program in your own lib:
METHOD write16 : BOOL
usiRegister: USINT; (* register to write *)
uiValue: UINT; (* value *)
Buffer: ARRAY[0..2] OF BYTE;
Buffer := usiRegister;
Buffer := UINT_TO_USINT(SHR(uiValue, 8));
Buffer := UINT_TO_USINT(uiValue AND 16#FF);
Write16 := DINT_TO_BOOL(Write(ADR(Buffer), 3));
I guess that this should solve the problem!
Instead of the BeforeWriteOutputs method you should use the AfterReadInputs method, as this device is an input device. You can compare to the SRF02, which is also a pure sensor which is similar to yours
"c:\Users\<Username>\CODESYS Control for Raspberry PI\188.8.131.52\I2C_SRF02.library"