########################################################################### # # Copyright (c) 2021-2024 Diality Inc. - All Rights Reserved. # # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # @file test_hd_fluid_leak.py # # @author (last) Peter Lucia # @date (last) 21-May-2021 # @author (original) Peter Lucia # @date (original) 03-May-2021 # ############################################################################ import numpy as np import sys from time import sleep sys.path.append("../../") from dialin import HDSimulator from dialin.protocols.CAN import DenaliMessage, DenaliChannels from dialin.common import MsgIds from dialin.utils.conversions import integer_to_bytearray, float_to_bytearray def run(): hd_sim = HDSimulator(log_level="DEBUG") dg_sim = HDSimulator(log_level="DEBUG") while True: state = np.random.randint(0, 2) payload = integer_to_bytearray(state) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_DG_FLUID_LEAK_STATE.value, payload=payload) hd_sim.can_interface.send(message, 0) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_HD_FLUID_LEAK_STATE.value, payload=payload) dg_sim.can_interface.send(message, 0) sleep(1) if __name__ == '__main__': run()