""" ########################################################################### # # Copyright (c) 2020-2025 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 run.py # # @author (last) Behrouz NematiPour # @date (last) 24-Feb-2021 # @author (original) Behrouz NematiPour # @date (original) 19-Aug-2020 # ############################################################################ the main function to load the main simulator loader widget """ import sys from dialin.ui import utils from PySide2 import QtCore, QtWidgets from simulator.loader import Simulator from dialin.ui.hd_simulator import HDSimulator from dialin.ui.hd_simulator_alarms import HDAlarmsSimulator, HIGH def main(): """ the main function which initializes the Simulator and starts it. :return: none """ utils.tstStart(__file__) # create qt application app = QtWidgets.QApplication(sys.argv) simulator = Simulator() simulator.show() hd_simulator_instance_counter_check() utils.tstDone() # start qt application main loop sys.exit(app.exec_()) def hd_simulator_instance_counter_check(): """ Checks to make sure only one instance of the HDSimulator has been created. this code shall be part of the HDSimulator __init__ but other codes are not ready for this. so only the simulator is checking it now. """ if HDSimulator.instanceCount > 1: raise Exception("more than one instance of HDSimulator shall not be created.") else: if HDAlarmsSimulator.instanceCount > 1: raise Exception("more than one instance of HDAlarmsSimulator shall not be created.") else: print("HDAlarmsSimulator number of instances is ", HDAlarmsSimulator.instanceCount) print("HDSimulator number of instances is ", HDSimulator.instanceCount) if __name__ == "__main__": QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_ShareOpenGLContexts) main()