Index: simulator/run.py =================================================================== diff -u -r69b2aacf31c5fdc28e078f87dbdee5c3ab672dd1 -ra3c7851a7de7cbed6b06abef5033b35308c04c93 --- simulator/run.py (.../run.py) (revision 69b2aacf31c5fdc28e078f87dbdee5c3ab672dd1) +++ simulator/run.py (.../run.py) (revision a3c7851a7de7cbed6b06abef5033b35308c04c93) @@ -1,11 +1,28 @@ """ +########################################################################### +# +# Copyright (c) 2020-2026 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.squish import utils +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(): @@ -21,12 +38,30 @@ 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()