Index: HD/RTC.py =================================================================== diff -u -rc5826238ca4b80671231a9c564af3ea01b9be06f -r0da0106eca868b9144298c60911710b3414a5837 --- HD/RTC.py (.../RTC.py) (revision c5826238ca4b80671231a9c564af3ea01b9be06f) +++ HD/RTC.py (.../RTC.py) (revision 0da0106eca868b9144298c60911710b3414a5837) @@ -5,7 +5,7 @@ # 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 RTC.py +# @file rtc.py # # @date 31-Mar-2020 # @author P. Lucia @@ -16,14 +16,15 @@ ############################################################################ from DialIn.CoreCANProtocol import (DenaliMessage, DenaliChannels) -from .utils import integer2ByteArray, float2ByteArray +from utils import integer_to_byte_array, float_to_byte_array import ctypes + class HDRTC: """ - \class HDRTC + \class HDRTC - \brief Hemodialysis Device (HD) Dialin API sub-class for RTC commands. + \brief Hemodialysis Device (HD) Dialin API sub-class for rtc commands. """ MSG_ID_SET_RTC_DATE_TIME = 0x801D @@ -46,24 +47,24 @@ channel_id = DenaliChannels.hd_sync_broadcast_ch_id msg_id = self.MSG_ID_RTC_EPOCH self.can_interface.register_receiving_publication_function(channel_id, msg_id, - self.handlerRTCEpoch) - self.RTCEpoch = 0 + self.handler_rtc_epoch) + self.rtc_epoch = 0 - def handlerRTCEpoch(self, message): + def handler_rtc_epoch(self, message): """ - Publishes the RTC time in epoch + Publishes the rtc time in epoch - \param message: published RTC epoch message + \param message: published rtc epoch message \returns none """ epoch = int.from_bytes(bytearray( message['message'][self.START_POS_SET_PT:self.END_POS_SET_PT]), byteorder=DenaliMessage.BYTE_ORDER) - self.RTCEpoch = ctypes.c_uint32(epoch) + self.rtc_epoch = ctypes.c_uint32(epoch) - def CmdSetRTCTimeAndDate(self, secs, mins, hours, days, months, years): + def cmd_set_rtc_time_and_date(self, secs, mins, hours, days, months, years): """ - Constructs and sends the time and date to be written to RTC + Constructs and sends the time and date to be written to rtc \returns 1 if successful, zero otherwise """ @@ -72,14 +73,14 @@ hour = bytes([hours]) day = bytes([days]) month = bytes([months]) - year = integer2ByteArray(years) + year = integer_to_byte_array(years) payload = sec + min + hour + day + month + year message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, message_id=self.MSG_ID_SET_RTC_DATE_TIME, payload=payload) - print("Setting time and date to RTC") + print("Setting time and date to rtc") # Send message received_message = self.can_interface.send(message) @@ -88,7 +89,7 @@ if received_message is not None: print(received_message) # str_res = str(flow) - print("Time and Date in RTC set to seconds: " + str(sec) + " minutes: " + str(min) + " hours: " + + print("Time and Date in rtc set to seconds: " + str(sec) + " minutes: " + str(min) + " hours: " + str(hour) + " days: " + str(day) + " months: " + str(month) + " years: " + str(year) + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) # response payload is OK or not OK