pnnl / tesp

Other
39 stars 37 forks source link

ns-3-helics (optimized build) garbling message in loadshed example #53

Closed temcdrm closed 2 years ago

temcdrm commented 3 years ago

The loadshed example runhpy.sh produced incorrect results because the switch did not open or close in GridLAB-D. The log said keyword 'OPENᄍU' is not valid for property phase_A_state. A temporary workaround was made by appending a null character in helicshed.py as shown below. However, this wasn't required for the 6-character CLOSED message just above it.

        if val == 1:
          logger.info('Switching ' + end_name + ' to CLOSED at second ' + str(t))
          h.helicsEndpointSendMessageRaw(swStatusEp, '', 'CLOSED'.encode())
        elif val == 0:
          logger.info('Switching ' + end_name + ' to OPEN at second ' + str(t))
#          h.helicsEndpointSendMessageRaw(swStatusEp, '', 'OPEN'.encode())
          h.helicsEndpointSendMessageRaw(swStatusEp, '', 'OPEN\0'.encode())

This looks like a memory bug in ns-3-helics that manifests in the optimized build but not in the debug build. When fixed properly, it may also fix issue #32