import sys
from PyQt5.QtWidgets import QApplication
from PyQt5.uic import loadUi
from PyQt5.QtGui import QPixmap, QImage

from initializeCommunications import *
import signalplot

MOBILE_NUMBER = 20
listMobile=[]
def comboboxListener():
    mobile_id = int(ui.ComboBoxNumber.currentText())
    ui.LabelTextOVSF.setText(bin(listMobile[mobile_id].ovsfCode))
    ui.LabelTextDecodeMessage.setText(str(demodulateSignal(signal,listMobile[mobile_id])))
    ui.LabelTextDesiredMessage.setText(str(listMobile[mobile_id].message))

def buttonNewSimulationListener():
    #ui.LineEditInterferencesAmplitude.setText(ui.LineEditNbPhone.displayText())
    listMobileGenerator(int(ui.LineEditNbPhone.displayText()))
    #printSignal(signal)

def comboBoxGenerate():
    ui.ComboBoxNumber.clear()
    for mobile in listMobile:
        print(mobile)
        ui.ComboBoxNumber.insertItem(0, mobile.identifier)


if __name__ == "__main__":
    app = QApplication(sys.argv)
    listMobile = listMobileGenerator(MOBILE_NUMBER)
    ui = loadUi('gui.ui')
    ui.show()
    comboBoxGenerate()
    signal = generateGlobalSignal(listMobile)
    comboboxListener()

    ui.ComboBoxNumber.activated.connect(comboboxListener)
    ui.ButtonNewSimulation.clicked.connect(buttonNewSimulationListener)
    signalplot.plot(signal)
    qimg = QImage("plot.png")
    pixmap = QPixmap(qimg)
    ui.plotLabel.setPixmap(pixmap)

    sys.exit(app.exec_())

@@ -114,17 +114,16 @@
  QImage%0A
-%0A
 from ini
@@ -172,16 +172,79 @@
 alplot%0A%0A
+global MOBILE_NUMBER%0Aglobal listMobile%0Aglobal signal%0Aglobal ui%0A
 MOBILE_N
@@ -255,10 +255,9 @@
 R = 
-20
+5
 %0Alis
@@ -267,16 +267,26 @@
 bile=%5B%5D%0A
+signal=%5B%5D%0A
 def comb
@@ -297,24 +297,64 @@
 Listener():%0A
+    global signal%0A    global listMobile%0A
     mobile_i
@@ -460,16 +460,34 @@
 fCode))%0A
+    print(signal)%0A
     ui.L
@@ -765,35 +765,26 @@
 ())%0A    
-listMobileGenerator
+simulation
 (int(ui.
@@ -818,33 +818,8 @@
 ()))
-%0A    #printSignal(signal)
 %0A%0Ade
@@ -836,24 +836,46 @@
 Generate():%0A
+    global listMobile%0A
     ui.Combo
@@ -1008,228 +1008,308 @@
 r)%0A%0A
-%0Aif __name__ == %22__main__%22:%0A    app = QApplication(sys.argv)%0A    listMobile = listMobileGenerator(MOBILE_NUMBER)%0A    ui = loadUi('gui.ui')%0A    ui.show()%0A    comboBoxGenerate()%0A    signal = generateGlobalSignal(listMobile
+def simulation(mobileNumber):%0A    global MOBILE_NUMBER%0A    global listMobile%0A    global signal%0A    MOBILE_NUMBER=mobileNumber%0A    listMobile = listMobileGenerator(MOBILE_NUMBER)%0A    signal = generateGlobalSignal(listMobile)%0A    ui.LabelSignal.setText(%22Signal : %22 + str(signal) )%0A    comboBoxGenerate(
 )%0A  
@@ -1329,17 +1329,16 @@
 tener()%0A
-%0A
     ui.C
@@ -1580,16 +1580,137 @@
 ixmap)%0A%0A
+if __name__ == %22__main__%22:%0A    app = QApplication(sys.argv)%0A    ui = loadUi('gui.ui')%0A    simulation(10)%0A%0A    ui.show()%0A%0A
     sys.

add ability to relauch the bit simulation and displaying signal