Пример #1
0
 def send_simulation(self):
     if self.simulation_extraction == 0:
         extraction = pms.get_extraction_my(self.current_instant)
     elif self.simulation_extraction == 1:
         extraction = pms.get_extraction_os(self.current_instant)
     elif self.simulation_extraction == 2:
         extraction = pms.get_extraction_feed(self.current_instant)
     else:
         extraction = pms.get_extraction_aleatoire(self.current_instant)
     logger.info(u"{} Send {}".format(self._le2mclt.uid, extraction))
     yield (self.server_part.callRemote("new_extraction", extraction))
Пример #2
0
 def remote_set_initial_extraction(self):
     if self.le2mclt.simulation:
         if self.simulation_extraction == 0:
             extraction = pms.get_extraction_my(self.current_instant)
         elif self.simulation_extraction == 1:
             extraction = pms.get_extraction_os(self.current_instant)
         elif self.simulation_extraction == 2:
             extraction = pms.get_extraction_feed(self.current_instant)
         else:
             extraction = pms.get_extraction_aleatoire(self.current_instant)
         logger.info(u"{} Send {}".format(self.le2mclt, extraction))
         return extraction
     else:
         defered = defer.Deferred()
         screen = GuiInitialExtraction(self, defered)
         screen.show()
         return defered
Пример #3
0
    def __init__(self, remote, defered):
        QDialog.__init__(self, remote.le2mclt.screen)

        self.remote = remote
        self.defered = defered

        layout = QVBoxLayout()
        self.setLayout(layout)

        explanation_area = WExplication(parent=self,
                                        text=texts_CO.INITIAL_EXTRACTION)
        layout.addWidget(explanation_area)

        self.slider_area = MySlider()
        layout.addWidget(self.slider_area)

        buttons = QDialogButtonBox(QDialogButtonBox.Ok)
        buttons.accepted.connect(self._accept)
        layout.addWidget(buttons)

        self.setWindowTitle("Decision")
        self.adjustSize()
        self.setFixedSize(self.size())

        if self.remote.le2mclt.automatique:
            if self.remote.simulation_extraction == 0:
                self.slider_area.setValue(
                    pms.get_extraction_my(self.remote.current_instant))
            elif self.remote.simulation_extraction == 1:
                self.slider_area.setValue(
                    pms.get_extraction_os(self.remote.current_instant))
            elif self.remote.simulation_extraction == 2:
                self.slider_area.setValue(
                    pms.get_extraction_feed(self.remote.current_instant))
            else:
                self.slider_area.setValue(
                    pms.get_extraction_aleatoire(self.remote.current_instant))
            self.timer_automatique = QTimer()
            self.timer_automatique.timeout.connect(
                buttons.button(QDialogButtonBox.Ok).click)
            self.timer_automatique.start(3000)
Пример #4
0
    def remote_display_decision(self, the_n):
        self.current_instant = the_n
        # simulation ---------------------------------------------------------------------------------------------------
        if self._le2mclt.simulation:
            # continuous
            if pms.DYNAMIC_TYPE == pms.CONTINUOUS:
                self.continuous_simulation_defered = defer.Deferred()
                self.continuous_simulation_timer = QTimer()
                self.continuous_simulation_timer.setInterval(1000)
                self.continuous_simulation_timer.timeout.connect(
                    self.send_simulation)
                self.continuous_simulation_timer.start()
                return self.continuous_simulation_defered

            # discrete
            elif pms.DYNAMIC_TYPE == pms.DISCRETE:
                if self.simulation_extraction == 0:
                    extraction = pms.get_extraction_my(self.current_instant)
                elif self.simulation_extraction == 1:
                    extraction = pms.get_extraction_os(self.current_instant)
                elif self.simulation_extraction == 2:
                    extraction = pms.get_extraction_feed(self.current_instant)
                else:
                    extraction = pms.get_extraction_aleatoire(
                        self.current_instant)
                logger.info(u"{} Send {}".format(self.le2mclt, extraction))
                return extraction

        # manual or auto -----------------------------------------------------------------------------------------------
        else:
            defered = defer.Deferred()
            if self.decision_screen is None:
                self.decision_screen = GuiDecision(self, defered)
                self.decision_screen.showFullScreen()
            else:
                self.decision_screen.defered = defered
                self.decision_screen.update_data_and_graphs()
            return defered
Пример #5
0
 def update_data_and_graphs(self):
     if self.remote.le2mclt.automatique:
         if self.remote.extractions.ydata[-1] == 0:
             self.extract_dec.setValue(0)
         if self.remote.simulation_extraction == 0:
             self.extract_dec.setValue(
                 pms.get_extraction_my(self.remote.current_instant))
         elif self.remote.simulation_extraction == 1:
             self.extract_dec.setValue(
                 pms.get_extraction_os(self.remote.current_instant))
         elif self.remote.simulation_extraction == 2:
             self.extract_dec.setValue(
                 pms.get_extraction_feed(self.remote.current_instant))
         else:
             self.extract_dec.setValue(
                 pms.get_extraction_aleatoire(self.remote.current_instant))
     self.plot_extraction.canvas.draw()
     self.plot_resource.canvas.draw()
     self.plot_payoff.canvas.draw()
     self.textEdit_infos.setHtml(self.remote.text_infos)
     if pms.DYNAMIC_TYPE == pms.DISCRETE:
         self.label_period.setText(u"Période {}".format(
             self.remote.current_instant))
         self.compte_rebours.restart()
Пример #6
0
    def __init__(self, remote, defered):
        super(GuiDecision, self).__init__(remote.le2mclt.screen)
        # main attributes
        self.remote = remote
        self.defered = defered

        layout = QVBoxLayout(self)

        # ----------------------------------------------------------------------
        # HEAD AREA
        # ----------------------------------------------------------------------
        layout_head = QHBoxLayout()
        layout.addLayout(layout_head, 0)

        if pms.DYNAMIC_TYPE == pms.DISCRETE:
            self.label_period = QLabel(
                le2mtrans(u"Period") +
                u" {}".format(self.remote.current_instant))
            layout_head.addWidget(self.label_period, 0, Qt.AlignLeft)

        self.compte_rebours = None
        if pms.DYNAMIC_TYPE == pms.CONTINUOUS:
            self.compte_rebours = WCompterebours(self,
                                                 pms.CONTINUOUS_TIME_DURATION,
                                                 lambda: None)
        elif pms.DYNAMIC_TYPE == pms.DISCRETE:
            self.compte_rebours = WCompterebours(self,
                                                 pms.DISCRETE_DECISION_TIME,
                                                 self.send_extrac)
        layout_head.addWidget(self.compte_rebours, 0, Qt.AlignLeft)
        layout_head.addStretch()

        # ----------------------------------------------------------------------
        # GRAPHICAL AREA
        # ----------------------------------------------------------------------

        self.plot_layout = QGridLayout()
        layout.addLayout(self.plot_layout)
        # extraction
        self.plot_extraction = PlotExtraction(self.remote.extractions,
                                              self.remote.extractions_group)
        self.plot_layout.addWidget(self.plot_extraction, 0, 0)
        # part payoff
        self.plot_payoff = PlotPayoff(self.remote.payoff_part)
        self.plot_layout.addWidget(self.plot_payoff, 0, 1)
        # available resource
        self.plot_resource = PlotResource(self.remote.resource)
        self.plot_layout.addWidget(self.plot_resource, 1, 0)
        # value in text mode
        widget_infos = QWidget()
        widget_infos.setLayout(QVBoxLayout())
        self.textEdit_infos = QTextEdit()
        self.textEdit_infos.setReadOnly(True)
        self.textEdit_infos.setHtml(self.remote.text_infos)
        widget_infos.layout().addWidget(self.textEdit_infos)
        self.plot_layout.addWidget(widget_infos, 1, 1)
        self.plot_layout.setColumnStretch(0, 1)
        self.plot_layout.setColumnStretch(1, 1)

        # ----------------------------------------------------------------------
        # DECISION AREA
        # ----------------------------------------------------------------------

        self.extract_dec = MySlider()
        player_extrac = self.remote.extractions.ydata[-1]
        self.extract_dec.setValue(player_extrac)
        self.extract_dec.lcd.display(player_extrac)
        layout.addWidget(self.extract_dec)

        # ----------------------------------------------------------------------
        # FOOT AREA
        # ----------------------------------------------------------------------

        self.setWindowTitle(trans_GA(u"Decision"))

        if pms.DYNAMIC_TYPE == pms.CONTINUOUS:
            self.extract_dec.slider.sliderReleased.connect(self.send_extrac)
            if self.remote.le2mclt.automatique:
                self.extract_dec.slider.valueChanged.connect(self.send_extrac)
            self.timer_continuous = QTimer()
            self.timer_continuous.timeout.connect(self.update_data_and_graphs)
            self.timer_continuous.start(
                int(pms.TIMER_UPDATE.total_seconds()) * 1000)

        if pms.DYNAMIC_TYPE == pms.DISCRETE and self.remote.le2mclt.automatique:
            if self.remote.simulation_extraction == 0:
                self.extract_dec.setValue(
                    pms.get_extraction_my(self.remote.current_instant))
            elif self.remote.simulation_extraction == 1:
                self.extract_dec.setValue(
                    pms.get_extraction_os(self.remote.current_instant))
            elif self.remote.simulation_extraction == 2:
                self.extract_dec.setValue(
                    pms.get_extraction_feed(self.remote.current_instant))
            else:
                self.extract_dec.setValue(
                    pms.get_extraction_aleatoire(self.remote.current_instant))

        self.remote.end_of_time.connect(self.end_of_time)