Hi all,
I am going to use the start_capture() and stop_capture() functions from the Typhoon HIL API 1.30.0 and Typhoon Control Center 2023.3. Based on the code examples from documentation I prepared a small test to verify if it works as expected and got the following error:
def recv_time_data(socket, flags=0, copy=False, track=True):
"""recv a numpy array or a dict with a numpy array and scalars"""
# first receive a metadata as json
md = socket.recv_json(flags=flags)
print(md)
# time data are sent as dictionary
> if md["time_data_type"] == "dict":
^^^^^^^^^^^^^^^^^^^^
E KeyError: 'time_data_type'
.venv\Lib\site-packages\typhoon\api\hil\stub.py:56: KeyError
I printed the md structure and it shows the following data:
[WARNING] [CAPTURE MESSAGE] stop_capture() will be ignored since desired number of samples are already captured!
{'dtype': 'float64', 'shape': [100000]}
so it is right that the key "time_data_type" does not exist.
Is this a bug in the HiL API or incompability issue?
After replacing the key: 'time_data_type' with 'dtype' it works as expected.
The code snipped I used for testing:
def test_typhoon_recorder():
import typhoon.api.hil as typhoon_hil
import time
trigger_settings = ["Forced"]
timeout = 2
capture_settings = [10, 2, 1e5]
channel_settings = [["TestOC.IaOCTest",
"TestOC.IcOCTest"], []]
buffer = []
typhoon_hil.set_text_mode(typhoon_hil.RM_SYSTEM)
typhoon_hil.load_model(MODEL_NAME)
typhoon_hil.load_settings_file(RUNX_SETTINGS)
typhoon_hil.start_simulation()
time.sleep(2)
typhoon_hil.start_capture(
capture_settings,
trigger_settings,
channel_settings,
dataBuffer=buffer,
timeout=timeout,
)
time.sleep(2)
typhoon_hil.stop_capture()
print(buffer)
typhoon_hil.stop_simulation()