コード例 #1
0
 def doStartRecording(self, event):  # wxGlade: MainFrame.<event_handler>
     """
     Button handler for starting the recording of a patient
     TBD
     """
     # print "doStartRecording event handler"
     # self.depth_canvas.post_redraw_event()
     global recording
     self.SendSizeEvent()
     self.session = PreventionSession()
     self.session.patient_id = self.patient_id
     self.session.start_time = datetime.today()
     self.session.end_time = self.session.start_time
     self.session.depth_video_file_directory = ""
     (rc,msg) = self.sessionController.add(self.session)
     if rc != 0:
         self.SetStatusText(msg)
         return
     self.stop_button.Enable()
     self.start_button.Disable()
     self.director.SetSessionId(self.session.id)
     self.preventionDatabaseWriter.setSessionId(self.session.id)
     self.preventionDatabaseWriter.setExperimentId(self.experiment_id)
     self.session.depth_video_file_directory = self.director.GetDepthFileDirectory()
     try:
         os.makedirs(self.session.depth_video_file_directory)            
     except OSError as exc: # Python >2.5
         if exc.errno == errno.EEXIST and os.path.isdir(self.session.depth_video_file_directory):
             pass
         else: 
             # raise
             msg = "Unable to access directory: " + str(self.session.depth_video_file_directory) + ". Please insure that the drive is attached and unlocked."
             rc = util.showMessageDialog(msg, "Drive unavailable")
             self.start_button.Enable()
             self.stop_button.Disable()
             (rc,msg) = self.sessionController.deleteRecord(self.session.id)
             if rc != 0:
                 self.SetStatusText(msg)
             return
     freespace = util.GetFreeSpaceGB(self.director.GetDepthFileDirectory())
     if freespace < int(self.system_config['PREVENTION_FILE_SIZE_GB']):
         msg = "Not enough space to record patient. Need " + str(self.system_config['PREVENTION_FILE_SIZE_GB']) + " GB but found " + str(freespace) + " GB."
         rc = util.showMessageDialog(msg, "Out of space")
         (rc,msg) = self.sessionController.deleteRecord(self.session.id)
         if rc != 0:
             self.SetStatusText(msg)
         return
     self.depth_canvas.proc_.set_database_writer(self.preventionDatabaseWriter)
     self.depth_canvas.proc_.start_recording(str(self.session.depth_video_file_directory))
     recording = True
     # patientTurningController = PatientTurningController(db, PatientTurning, OlvPatientTurning, OlvPatientTurningCols)
     # self.results = patientTurningController.getByPatientBySessionByExperiment(patientId, sessionId, experimentId)
     # self.olv.SetObjects(self.results)
     self.CreateUpdatingList()
コード例 #2
0
 def onSelectRecord(self, event):
     """
     Button handler to select a record
     """
     selectedRow = self.resultsOlv.GetSelectedObject()
     if selectedRow == None:
         util.showMessageDialog("No row selected!", "Error")
         return
     key = selectedRow.getKey()
     self.selectedObject = self.controller.getRecordByKey(key)
     self.EndModal(0)
 def onEdit(self):
     """
     Modifies the record and shows a confirmation message dialog.
     """
     data = self.getData()
     (rc, msg) = self.controller.editRecord(self.selectedRow.getKey(), data)
     # Check return code from above and put up appropriate message dialog
     if rc == 0:
         util.showMessageDialog("Record Edited Successfully!", "Success!", wx.ICON_INFORMATION)
     else:
         util.showMessageDialog(msg, "Failure!", wx.ICON_INFORMATION)
     return rc
コード例 #4
0
 def onEditRecord(self, event):
     """
     Button handler to edit a record
     """
     selectedRow = self.resultsOlv.GetSelectedObject()
     if selectedRow == None:
         util.showMessageDialog("No row selected!", "Error")
         return
     dlg = AddModifyWoundDialog(self.controller, self.obj, self.db, row=selectedRow, title="Modify", addRecord=False)
     rc = dlg.ShowModal()
     if rc == 0:
         self.showAllRecords()
コード例 #5
0
 def onAddRecord(self, event):
     """
     Button handler to add a record to the database
     """
     selectedRow = self.resultsOlv.GetSelectedObject()
     if selectedRow == None:
         util.showMessageDialog("Need to select a patient in order to add a wound!", "Error")
         return
     dlg = AddModifyWoundDialog(self.controller, self.obj, self.db, row=selectedRow, title="Add", addRecord=True)
     rc = dlg.ShowModal()
     if rc == 0:
         self.showAllRecords()
コード例 #6
0
 def onAdd(self):
     """
     Adds the record to the database and shows a confirmation message dialog.
     """
     data = self.getData()
     (rc, msg) = self.controller.addRecord(data)
     
     # show dialog upon completion
     if rc == 0:
         util.showMessageDialog("Record Added", "Success!", wx.ICON_INFORMATION)
     else:
         util.showMessageDialog(msg, "Failure!", wx.ICON_INFORMATION)
     return rc
コード例 #7
0
 def onExperiments(self, event):
     """
     Button handler to show experiments for an algorithm
     """
     selectedRow = self.resultsOlv.GetSelectedObject()
     if selectedRow == None:
         util.showMessageDialog("No row selected!", "Error")
         return
     algorithmId = selectedRow.getKey()
     olvDialog = ExperimentDialog(None, self.db, algorithmId=algorithmId)
     rc = olvDialog.ShowModal()
     olvDialog.Destroy()
     self.Enable()
     self.showAllRecords()
コード例 #8
0
 def onConfiguration(self, event):
     """
     Button handler to show configuration parameters
     """
     selectedRow = self.resultsOlv.GetSelectedObject()
     if selectedRow == None:
         util.showMessageDialog("No row selected!", "Error")
         return
     algorithmId = selectedRow.getKey()
     olvDialog = AlgorithmDefaultsDialog(None, self.db, algorithmId)
     rc = olvDialog.ShowModal()
     olvDialog.Destroy()
     self.Enable()
     self.showAllRecords()
コード例 #9
0
 def onRecord(self, event):
     """
     Handler for the OK button. It will either call onAdd or onEdit as required.
     """
     rc = 0
     # Perform validation checks
     if self.descTextCtrl.GetValue() == "":
         util.showMessageDialog("Wound description cannot be empty!", "Failure!", wx.ICON_ERROR)
         return
     if self.addRecord:
         rc = self.onAdd()
     else:
         rc = self.onEdit()
     self.SetReturnCode(rc)
     if rc == 0:
         self.Destroy()
コード例 #10
0
 def onDelete(self, event):
     """
     Button handler to delete a record
     """
     selectedRow = self.resultsOlv.GetSelectedObject()
     if selectedRow == None:
         util.showMessageDialog("No row selected!", "Error")
         return
     (rc, msg) = self.controller.deleteRecord(selectedRow.getKey())
     # Check return code from above and put up appropriate message dialog
     if rc == 0:
         util.showMessageDialog("Record Deleted Successfully!", "Success!", wx.ICON_INFORMATION)
     else:
         util.showMessageDialog(msg, "Failure!", wx.ICON_INFORMATION)
     self.showAllRecords()
コード例 #11
0
 def OnInit(self):
     """
     Initializes the GUI and displays a modal login panel.
     """
     global db
     self.Init(cmd=False)  # initialize the inspection tool
     self.ReadConfiguration()
     # wx.InitAllImageHandlers()
     self.mainframe = MainFrame(None, -1, "Prevention", (0,0))
     self.SetTopWindow(self.mainframe)
     self.mainframe.Show(True)
     self.mainframe.panel_1.Disable()
     # Check if system is not on battery power
     if not util.GetPowerOnline():
         rc = util.showMessageDialog("Computer is running on battery power and not AC power. Please insure unit is plugged into wall outlet and the power strip is turned on.", "Power not connected")
         return 1
     logon = LogonDialog(None)
     logon.SetDb(db)
     rc = logon.ShowModal()
     # print "rc=%d" % rc
     if rc == 1:
         # get system configuration
         systemConfigurationController = SystemConfigurationController(db, SystemConfiguration, None, None)
         self.mainframe.system_config = {}
         config = systemConfigurationController.getAll()
         for conf in config:
             self.mainframe.system_config[conf.parameter_name] = conf.parameter_value
         pprint(self.mainframe.system_config)
         self.mainframe.InitCanvas()
         self.mainframe.InitMisc()
         self.mainframe.InitClinicalPane()
         self.mainframe.panel_1.Enable()
         self.mainframe.Show()
         self.mainframe.SetStatusText("Logon successful")
         logon.Destroy()
         return 1
     logon.Destroy()
     self.mainframe.Destroy()
     wx.GetApp().ProcessIdle()
     return 0