Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Set the message interval (timedelta) for federate. Note th#
# HELICS minimum message time interval is 1 ns and by default
# it uses a time delta of 1 second. What is provided to the
# setTimedelta routine is a multiplier for the default timedelta.
# Set one second message interval #
h.helicsFederateInfoSetTimeProperty(fedinfo, h.helics_property_time_delta, deltat)
h.helicsFederateInfoSetIntegerProperty(fedinfo, h.helics_property_int_log_level, 1)
mFed = h.helicsCreateMessageFederate("TestA Federate", fedinfo)
yield mFed
h.helicsFederateFinalize(mFed)
state = h.helicsFederateGetState(mFed)
assert state == 3
while (h.helicsBrokerIsConnected(broker)):
time.sleep(1)
h.helicsFederateInfoFree(fedinfo)
h.helicsFederateFree(mFed)
h.helicsCloseLibrary()
testValue = "String2"
pubid = h.helicsFederateRegisterGlobalPublication (vFed, "pub1", h.helics_data_type_string, "")
subid = h.helicsFederateRegisterSubscription (vFed, "pub1", "")
h.helicsInputSetDefaultString(subid, defaultValue)
h.helicsFederateEnterExecutingMode(vFed)
counter = 60
while counter > 0:
counter -= 1
time.sleep(1)
# Broker should be connected at this point
assert h.helicsBrokerIsConnected(helicsBroker) == 1, "Broker should still be connected"
h.helicsFederateFinalize(vFed)
state = h.helicsFederateGetState(vFed)
assert state == 3
while (h.helicsBrokerIsConnected(helicsBroker)):
time.sleep(1)
h.helicsFederateInfoFree(fedinfo)
h.helicsFederateFree(vFed)
def destroy_value_federate(fed, broker):
status = h.helicsFederateFinalize(fed)
assert status == 0
status, state = h.helicsFederateGetState(fed)
assert status == 0
assert state == 3
while (h.helicsBrokerIsConnected(broker)):
time.sleep(1)
h.helicsFederateFree(fed)
h.helicsCloseLibrary()
def destroy_federate(fed):
h.helicsFederateFinalize(fed)
h.helicsFederateFree(fed)
h.helicsCloseLibrary()
def destroy_federate(fed):
h.helicsFederateFinalize(fed)
h.helicsFederateFree(fed)
h.helicsCloseLibrary()
def destroy_federate(fed):
h.helicsFederateFinalize(fed)
# status, state = h.helicsFederateGetState(fed)
# assert state == 3
# while (h.helicsBrokerIsConnected(broker)):
# time.sleep(1)
h.helicsFederateFree(fed)
h.helicsCloseLibrary()
def destroy_federate(fed):
h.helicsFederateFinalize(fed)
# status, state = h.helicsFederateGetState(fed)
# assert state == 3
while (h.helicsBrokerIsConnected(broker)):
time.sleep(1)
h.helicsFederateFree(fed)
h.helicsCloseLibrary()