def mpm_config_path(): appdata = UserSettings.user_config_folder() path = os.path.join(appdata, 'mpm') if not os.path.exists(path): os.mkdir(path) return path
def killAll(self, event): print 'shutting down...' UserSettings.screenposition = self.GetScreenPosition() UserSettings.writecfg() if UserSettings.opsys == 'Windows': #this doesn't work in Linux... speeds up appearance of shutdown LicenseDlg.Hide() KMLControl.Hide() AboutDlg.Hide() MsgDialog.Hide() SettingsDialog.Hide() self.Hide() if services.gps is not False: print 'closing serial port' services.gps.close() print 'gps closed' print 'closing httpd' Kml.myserver.close() print 'stopping recording if it\'s active' SettingsDialog.stopRec() if services.myvs is not False: print 'closing VSPE-L' try: services.myvs.close() #try because this will not be included in 64bit except NameError: pass print 'number of running threads' print threading.activeCount() print 'destroying objects' try: LicenseDlg.Destroy() KMLControl.Destroy() AboutDlg.Destroy() MsgDialog.Destroy() SettingsDialog.Destroy() self.Destroy() except: print 'error... exiting' exit()
def __init__(self): super(UserSettingsForm, self).__init__() self.setupUi(self) self.user_settings = UserSettings() # Initialize fields with user settings values self._output_dir_line_edit.setText( osp.abspath(str(self.user_settings.output_dir))) self._working_dir_line_edit.setText( osp.abspath(str(self.user_settings.working_dir))) self._sim_duration_line_edit.setText( str(self.user_settings.sim_duration)) self._wfds_exec_line_edit.setText(str(self.user_settings.wfds_exec)) self._smv_exec_line_edit.setText(str(self.user_settings.smv_exec)) # Set line edits to read only self._output_dir_line_edit.setReadOnly(True) self._working_dir_line_edit.setReadOnly(True) self._wfds_exec_line_edit.setReadOnly(True) self._smv_exec_line_edit.setReadOnly(True) # Clicked signal emits a bool that is passed with the lambda, # Which is why the dummy variable checked is there. self.output_dir_button.clicked.connect( lambda checked, x=True, state=self: button_clicked((x, state))) self.working_dir_button.clicked.connect( lambda checked, x=False, state=self: button_clicked((x, state))) self.wfds_exec_bttn.clicked.connect(lambda checked, x=True, state=self: button_clicked_exec((x, state))) self.smv_exec_bttn.clicked.connect(lambda checked, x=False, state=self: button_clicked_exec((x, state))) self.button_box.accepted.connect(self.save_user_settings)
def jsonLoad(self, DB): GlobalUserData = UserSettings.Data() DataForSearch = GlobalUserData.GetUserData() if (DataForSearch['ShowData'] is None): result = self.__execute__(DataForSearch['tables'], DataForSearch['data'], DB) else: result = self.__execute__(DataForSearch['tables'], DataForSearch['data'], DB, DataForSearch['ShowData']) print("\n\nResultado\n") print(result) print('\n')
def update_user_settings(): start_time = UserSettings.get("DayStartDelay") / 15 day_start = convert_input(UserSettings.get("OpenTime")) num_chairs = UserSettings.get("MaxChairs") day_close = convert_input(UserSettings.get("CloseTime")) longest_time = (day_close[0] - day_start[0]) * 4 + day_close[1] - day_start[1]
# # Parameters: # # time - time in HH:MM format # # Returns: # # twople of hour,minute def convert_input(time): hour = int(time[0:2]) minute = int(time[3:5]) return hour, minute start_time = UserSettings.get("DayStartDelay")/15 day_start = convert_input(UserSettings.get("OpenTime")) num_chairs = UserSettings.get("MaxChairs") day_close = convert_input(UserSettings.get("CloseTime")) longest_time = (day_close[0]-day_start[0])*4+day_close[1]-day_start[1] # Function: convert_to_format # # Converts a time in the format HH:MM to the format used in the algorithm. # # # Parameters: # # time - time in HH:MM formats #
class UserSettingsForm(QDialog, Ui_UserSettingsForm): def __init__(self): super(UserSettingsForm, self).__init__() self.setupUi(self) self.user_settings = UserSettings() # Initialize fields with user settings values self._output_dir_line_edit.setText( osp.abspath(str(self.user_settings.output_dir))) self._working_dir_line_edit.setText( osp.abspath(str(self.user_settings.working_dir))) self._sim_duration_line_edit.setText( str(self.user_settings.sim_duration)) self._wfds_exec_line_edit.setText(str(self.user_settings.wfds_exec)) self._smv_exec_line_edit.setText(str(self.user_settings.smv_exec)) # Set line edits to read only self._output_dir_line_edit.setReadOnly(True) self._working_dir_line_edit.setReadOnly(True) self._wfds_exec_line_edit.setReadOnly(True) self._smv_exec_line_edit.setReadOnly(True) # Clicked signal emits a bool that is passed with the lambda, # Which is why the dummy variable checked is there. self.output_dir_button.clicked.connect( lambda checked, x=True, state=self: button_clicked((x, state))) self.working_dir_button.clicked.connect( lambda checked, x=False, state=self: button_clicked((x, state))) self.wfds_exec_bttn.clicked.connect(lambda checked, x=True, state=self: button_clicked_exec((x, state))) self.smv_exec_bttn.clicked.connect(lambda checked, x=False, state=self: button_clicked_exec((x, state))) self.button_box.accepted.connect(self.save_user_settings) @QtCore.pyqtSlot(name='save_user_settings') def save_user_settings(self): # Modify user settings to whatever the user has modified them to be self.user_settings.output_dir = self._output_dir_line_edit.text() self.user_settings.working_dir = self._working_dir_line_edit.text() self.user_settings.sim_duration = self._sim_duration_line_edit.text() self.user_settings.wfds_exec = self._wfds_exec_line_edit.text() self.user_settings.smv_exec = self._smv_exec_line_edit.text() self.user_settings.save_user_settings() def output_dir_line_edit(self): return self._output_dir_line_edit def working_dir_line_edit(self): return self._working_dir_line_edit def wfds_exec_line_edit(self): return self._wfds_exec_line_edit def smv_exec_line_edit(self): return self._smv_exec_line_edit
def settingsOK(self, event): UserSettings.writecfg() self.Hide() event.Skip()
def doOK(self, event): self.Hide() UserSettings.termsAgreed = True UserSettings.writecfg() MainWindow.Show()
def mmgRun(): global app app = wx.App(False) wx.SetDefaultPyEncoding('utf-8') wx.InitAllImageHandlers() global services services = Services() #Object to hold data services global KMLControl KMLControl = KML_Ctrl(None) #Object for KML Control dialog global MsgDialog MsgDialog = MsgDialogSub(None) #Object for message dialog MsgDialog.ok = False global AboutDlg AboutDlg = AboutDlgSub(None) global SettingsDialog SettingsDialog = SettingsDialogSub(None) #Object for settings dialog window global LicenseDlg LicenseDlg = LicenseDlgSub(None) #Object for license dialog global MainWindow MainWindow = MainWindowSub(None) #Object for main window MainWindow.SetDoubleBuffered(True) #Reduces flickering '''set the icons''' d = path.abspath(UserSettings.workdir + '/rc/mmg.ico') icon = wx.Icon(d, wx.BITMAP_TYPE_ICO) MainWindow.SetIcon(icon) MsgDialog.SetIcon(icon) AboutDlg.SetIcon(icon) SettingsDialog.SetIcon(icon) LicenseDlg.SetIcon(icon) '''about and license''' d = path.abspath(UserSettings.workdir + '/rc/mmg.png') AboutDlg.mmgpng = wx.Bitmap(d, wx.BITMAP_TYPE_ANY) AboutDlg.mmgLogo.SetBitmap(AboutDlg.mmgpng) AboutDlg.bSizer13.Fit(AboutDlg) AboutDlg.title.SetLabel('MatrixMariner GPS %s' %(UserSettings.version)) AboutDlg.Layout() if UserSettings.opsys == 'Windows': d = path.abspath(UserSettings.workdir + '/rc/windowslicense.txt') if UserSettings.opsys == 'Linux': d = path.abspath(UserSettings.workdir + '/rc/linuxlicense.txt') f = open(d, 'r') lic = f.read() LicenseDlg.licText.SetValue(lic) f.close() LicenseDlg.title.SetLabel('MatrixMariner GPS %s' %(UserSettings.version)) LicenseDlg.mmgLogo.SetBitmap(AboutDlg.mmgpng) LicenseDlg.bSizer16.Fit(LicenseDlg) LicenseDlg.Layout() '''virtual serial port emulation''' if UserSettings.opsys == 'Windows' and UserSettings.arch == 'x86': try: import VSPE services.myvs = VSPE.vspe() services.myvs.initialize() except: print 'VSPI driver not installed, installing...' msg = 'MMG needs to install a Virtual Serial Port Emulator Driver\r' + \ 'This will only install once.' title = 'Attention' MsgDialog.postMsg(msg, title) while MsgDialog.IsShown(): sleep(.1) if MsgDialog.ok: from subprocess import Popen, PIPE from os import chdir, getcwd chdir(getcwd()+'\\rc\\SetupVSPE\\') print getcwd() cmd = 'SetupVSPE.msi /qb' print cmd p = Popen(cmd, shell=True, stdout=PIPE) p.wait() lnk = UserSettings.homedir+'\\Desktop\\VSPE.lnk' while not path.isfile(lnk): print 'waiting to delete:', lnk sleep(1) remove(lnk) try: import VSPE services.myvs = VSPE.vspe() services.myvs.initialize() except: pass services.vspeflag = False if UserSettings.opsys == 'Linux': import VSPLin services.myvs = VSPLin.vsp(dir='/tmp/dev', pname='vgps') ''''fix some events ''' MainWindow.Bind(wx.EVT_SYS_COLOUR_CHANGED, MainWindow.blockSysColor) #bind system color change event to Block other apps from changing color MainWindow.Bind(wx.EVT_CLOSE, MainWindow.killAll) MainWindow.Unbind(wx.EVT_RIGHT_DOWN) #override wx.EVT_RIGHT_DOWN in GUI automatically created by wxFB MainWindow.Bind(wx.EVT_CONTEXT_MENU, MainWindow.MainWindowOnContextMenu) #replace EVT_RIGHT_DOWN with this... works better #MainWindow.Bind(wx.EVT_SIZING, MainWindow.onResize) MainWindow.bindEvents() #bind events to custom event handler LicenseDlg.Bind(wx.EVT_CLOSE, MainWindow.killAll) '''read config file and layout main window and settings dialog''' UserSettings.readcfg() MainWindow.SetPosition(UserSettings.screenposition) SettingsDialog.allAppear() #show hide gps information base on user settings (layout gets reset) SettingsDialog.setColors(UserSettings.daycolor) MainWindow.OptionsMenu.RemoveItem(MainWindow.kmlCtrl) #don't show this menu item yet '''change settings dialog to reflect user config''' ###gps input tab### SettingsDialog.replaySetup() #Fills recording listbox from recordings directory if directory is empty fill it with all files from \\rc\\recordings SettingsDialog.recSetup() #Fills the recording filename field #SettingsDialog.replaySpeed.SetSelection(UserSettings.replaySpeed - 1) SettingsDialog.replayLoop.SetValue(UserSettings.loopReplays) ###gps output tab### d = path.abspath(UserSettings.workdir + '/rc/greyLED.png') SettingsDialog.greyLED = wx.Bitmap(d, wx.BITMAP_TYPE_ANY) d = path.abspath(UserSettings.workdir + '/rc/redLED.png') SettingsDialog.redLED = wx.Bitmap(d, wx.BITMAP_TYPE_ANY) SettingsDialog.recLED.SetBitmap(SettingsDialog.greyLED) SettingsDialog.kmlLED.SetBitmap(SettingsDialog.greyLED) ###information tab### SettingsDialog.gpstimeCheckbox.SetValue(UserSettings.gpstime) #check/uncheck gps time checkbox from user settings i = SettingsDialog.gpstimeChoice.FindString(UserSettings.gpstime_fmt) SettingsDialog.gpstimeChoice.SetSelection(i) #select gps time format from user settings i = SettingsDialog.timezoneChoice.FindString(UserSettings.timezone) SettingsDialog.timezoneChoice.SetSelection(i) #select timezone format from user settings SettingsDialog.dateCheckbox.SetValue(UserSettings.gpsdate) #check/uncheck date checkbox from user settings i = SettingsDialog.dateChoice.FindString(str(UserSettings.gpsdate_fmt)) SettingsDialog.dateChoice.SetSelection(i) #select date format from user settings SettingsDialog.latitudeCheckbox.SetValue(UserSettings.latitude) #check/uncheck latitude checkbox from user settings i = SettingsDialog.lluChoice.FindString(UserSettings.llu_fmt) SettingsDialog.lluChoice.SetSelection(i) #select lat/long format from user settings SettingsDialog.longitudeCheckbox.SetValue(UserSettings.longitude) #check/uncheck longitude checkbox from user settings SettingsDialog.sogCheckbox.SetValue(UserSettings.sog) #check/uncheck speed over ground checkbox from user settings i = SettingsDialog.sogChoice.FindString(UserSettings.sog_fmt) SettingsDialog.sogChoice.SetSelection(i) #select sog format from user settings SettingsDialog.cogCheckbox.SetValue(UserSettings.cog) #check/uncheck course over ground checkbox from user settings SettingsDialog.altitudeCheckbox.SetValue(UserSettings.altitude) #check/uncheck altitude checkbox from user settings i = SettingsDialog.altitudeChoice.FindString(UserSettings.alt_fmt) SettingsDialog.altitudeChoice.SetSelection(i) #select altitide format from user settings SettingsDialog.hdopCheckbox.SetValue(UserSettings.hdop) #check/uncheck hdop checkbox from user settings ###appearance tab### SettingsDialog.dayColorPicker.SetColour(UserSettings.daycolor) SettingsDialog.nightColorPicker.SetColour(UserSettings.nightcolor) if UserSettings.opsys == 'Linux': efonts = wx.FontEnumerator() efonts.EnumerateFacenames() listfonts = efonts.GetFacenames() listfonts.sort() SettingsDialog.fontCombo.SetItems(listfonts) SettingsDialog.fontCombo.SetStringSelection(UserSettings.fontface) SettingsDialog.fontSizePicker.SetValue(UserSettings.mdfontsz) SettingsDialog.chooseFont(None) ###kick it off### Kml.myserver = Kml.KMLServer() if UserSettings.termsAgreed: MainWindow.Show() else: LicenseDlg.Show() '''autoconnect to last com imput port''' i = int(UserSettings.gpsCOM[3:UserSettings.gpsCOM.__len__()+1]) SettingsDialog.gps_source_spinCtrl.SetValue(i) i = SettingsDialog.gps_baud_combo.FindString(str(UserSettings.gpsBaud)) SettingsDialog.gps_baud_combo.SetSelection(i) SettingsDialog.autoconnect = wx.Timer(SettingsDialog) SettingsDialog.Bind(wx.EVT_TIMER, SettingsDialog.GPSInputApply(None, True), SettingsDialog.autoconnect) SettingsDialog.autoconnect.Start(milliseconds=2000, oneShot=True) '''auto-start tcpd, vspe, and/or kml if on last time''' # if services.myvs != False: # for vsp in UserSettings.vsps: # if not comlst.__contains__(vsp): #don't create a virtual com that exists as a real one # SettingsDialog.virtualAdd(None, vsp) # else: # UserSettings.vsps.remove(vsp) if UserSettings.tcpip != '' and UserSettings.tcpport > 0: SettingsDialog.tcpCheckbox.SetValue(True) SettingsDialog.tcpGetIP(None) #populate ips in tcpAddrChoice i = SettingsDialog.tcpAddrChoice.FindString(UserSettings.tcpip) SettingsDialog.tcpAddrChoice.SetSelection(i) SettingsDialog.tcpPortChoice.SetValue(str(UserSettings.tcpport)) SettingsDialog.tcpCheck(None) if UserSettings.kml: SettingsDialog.kmlToggle.SetValue(True) SettingsDialog.kmlOut(None) app.MainLoop()
s = stat.replace(current_path + '\\', '') s = s.replace('.C3D', '') d = dyn.replace(current_path + '\\', '') d = d.replace('.C3D', '') #1.1 Simplifie static and dynamic files Point_To_Keep=['LTOE','LHEE','LMET','LMED','LMIF','LANK','LTIB',\ 'RTOE','RHEE','RMET','RMED','RMIF','RANK','RTIB','RTTU','RKNE','RTHI',\ 'LTTU','LKNE','LTHI','LASI','RASI','LPSI','RPSI'] Simplify_acq.new_dyn(dyn, Point_To_Keep) # Simplify_acq.new_stat(stat,Point_To_Keep,100) Simplify_acq.clear_acq(dyn) Simplify_acq.clear_acq(stat) #1.2 pyCGM computation for original positions UserSettings.user_settings(dyn, current_path, s, d, 'pyCGM1') pyCGM2_CGM11_modelling.main(args) #1.3 Get initial pyCGM angles (reference) acq_dyn = File_Processing.reader(dyn) LPelvisAngles = acq_dyn.GetPoint("LPelvisAngles_pyCGM1").GetValues() LHipAngles = acq_dyn.GetPoint("LHipAngles_pyCGM1").GetValues() LKneeAngles = acq_dyn.GetPoint("LKneeAngles_pyCGM1").GetValues() LAnkleAngles = [] for frame in range(len(LKneeAngles[:, 0])): LAnkleAngles.append([ acq_dyn.GetPoint("LAnkleAngles_pyCGM1").GetValues()[frame, 0], acq_dyn.GetPoint("LAnkleAngles_pyCGM1").GetValues()[frame, 2] ]) LAnkleAngles = np.array(LAnkleAngles)