def findPDFViewer(self): # list of programs to look for. each item is of the form (name, # args). if name is an absolute path only that exact location is # looked at, otherwise PATH is searched for the program (on # Windows, all paths are interpreted as absolute). args is the # list of arguments for the program. progs = [] if misc.isUnix: progs = [ (u"/usr/local/Adobe/Acrobat7.0/bin/acroread", "-tempFile"), (u"acroread", "-tempFile"), (u"evince", ""), (u"okular", ""), ] elif misc.isWindows: # get value via registry if possible, or fallback to old method. viewer = util.getWindowsPDFViewer() if viewer: self.pdfViewerPath = viewer self.pdfViewerArgs = "" return progs = [ (ur"C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Adobe\Reader 10.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe", ""), ] else: pass success = False for name, args in progs: if misc.isWindows or (name[0] == u"/"): if util.fileExists(name): success = True break else: name = util.findFileInPath(name) if name: success = True break if success: self.pdfViewerPath = name self.pdfViewerArgs = args
def findPDFViewer(self): # list of programs to look for. each item is of the form (name, # args). if name is an absolute path only that exact location is # looked at, otherwise PATH is searched for the program (on # Windows, all paths are interpreted as absolute). args is the # list of arguments for the program. progs = [] if misc.isUnix: progs = [ (u"/usr/local/Adobe/Acrobat7.0/bin/acroread", "-tempFile"), (u"acroread", "-tempFile"), (u"xpdf", ""), (u"evince", ""), (u"gpdf", ""), (u"kpdf", ""), ] elif misc.isWindows: progs = [ (ur"C:\Program Files\Adobe\Reader 10.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Adobe\Acrobat 4.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Foxit Software\Foxit Reader\Foxit Reader.exe", ""), ] else: pass success = False for name, args in progs: if misc.isWindows or (name[0] == u"/"): if util.fileExists(name): success = True break else: name = util.findFileInPath(name) if name: success = True break if success: self.pdfViewerPath = name self.pdfViewerArgs = args
def startSimulation(self): # load results if already available, perform the simulation otherwise if util.fileExists(self.resultsFilePath): util.logger.info( f"Results for this simulation are already available: {self.resultsFilePath}" ) self.results = util.loadDataset(self.resultsFilePath) else: symbolDataFilePath = self.mainDataFolder + self.bot.symbol + '_prices.csv' symbolData = util.getSymbolData(symbolDataFilePath) util.logger.info("Simulation started") self.bot.createInitialGrid(startPrice=symbolData['Price'][0]) self.market.startSimulation(symbolData) self.results = self.market.getResults() self.results.to_csv(self.resultsFilePath) util.logger.info(f"Results saved in {self.mainDataFolder}")
def mainLoop(): log.log(log.ALWAYS, "poolPi running main loop...") lastSecs = 0 # main loop while(gv.loop): secs = int(time.mktime(time.localtime())) # fast loop (millisecs) # respond to button presses quickly menu.mainLoopButtons() if (gv.webUpdate == True): ipc.update() # 1 second loop if (secs != lastSecs): timer.checkEvents() power.checkPowerStatus() menu.statusDisplay() equipment.toggleLED() redispy.setStatus() # 5 second loop if (secs % 5 == 0): redispy.setInfo() # 10 second loop (move to 60 ?) if (secs % 10 == 0): if (gv.systemMode == cfg.SPA_ON): ow.thermostat() # 60 second loop if (secs % 60 == 0): util.checkCPUtemp() ow.checkForFreeze() # dim lcd at night if (checkTime(21, 0)): lcd.setBrightness(64) elif (checkTime(6, 0)): lcd.setBrightness(255) # at midnight, reset 1-wire errors if (checkTime(0, 0)): ow.resetErrors() # dev use - allows shutdown from console # by creating the file 'sdpp' in pi home if (util.fileExists()): log.log(log.CRITICAL, "*** Exit Loop Detected ***") gv.loop = False lastSecs = secs # make sure processor gets to rest (cpu goes to 100% otherwise ??) time.sleep(0.25) # end of main loop log.log(log.CRITICAL, "exiting loop") return
def findPDFViewer(self): # list of programs to look for. each item is of the form (name, # args). if name is an absolute path only that exact location is # looked at, otherwise PATH is searched for the program (on # Windows, all paths are interpreted as absolute). args is the # list of arguments for the program. progs = [] if misc.isUnix: progs = [ (u"/usr/local/Adobe/Acrobat7.0/bin/acroread", "-tempFile"), (u"acroread", "-tempFile"), (u"xpdf", ""), (u"evince", ""), (u"gpdf", ""), (u"kpdf", ""), ] elif misc.isWindows: # get value via registry if possible, or fallback to old method. viewer = util.getWindowsPDFViewer() if viewer: self.pdfViewerPath = viewer self.pdfViewerArgs = "" return progs = [ (ur"C:\Program Files\Adobe\Reader 10.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Adobe\Acrobat 4.0\Reader\AcroRd32.exe", ""), (ur"C:\Program Files\Foxit Software\Foxit Reader\Foxit Reader.exe", ""), ] else: pass success = False for name, args in progs: if misc.isWindows or (name[0] == u"/"): if util.fileExists(name): success = True break else: name = util.findFileInPath(name) if name: success = True break if success: self.pdfViewerPath = name self.pdfViewerArgs = args
import numpy as np from datetime import datetime import util, datapreprocess import build.pysim as pysim ''' Used to compare how a trained LSTM model handels against various variations. ''' # Deterministic output np.random.seed(1000) # Generate or load 128 randomly positioned locations sequences = 128 if util.fileExists('randomPositionsSplines_Leg_%d_New' % sequences, '', util.comparisonDir): allArmPositions, allSplines = util.loadFile('randomPositionsSplines_Leg_%d_New' % sequences, '', util.comparisonDir) print 'Loaded arm positions and spline trajectories' else: allArmPositions = [[np.random.uniform(-0.05, 0.05), np.random.uniform(-0.2, -0.05), np.random.uniform(-0.05, 0.05)] for i in xrange(sequences)] # sides = [np.random.randint(1, 2) for j in xrange(sequences)] allSplines = [[[np.random.uniform(-0.03, 0.03), -0.1 + np.random.uniform(-0.02, 0.02), (-1)**i * np.random.uniform(0, 0.05), 0, 1, 0, 0] for i in xrange(1, 25)] for j in xrange(sequences)] util.saveData('randomPositionsSplines_Leg_%d_New' % sequences, [allArmPositions, allSplines], '', util.comparisonDir) print 'Saved arm positions for later reference' # Use velocities of Decrease: 50%, 10%, 5%, and Increase: 5%, 10%, 50% velocities = [1.5, 1.75, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.75, 3.0] rotateX = [0.0, -np.radians(1), -np.radians(5), -np.radians(10), -np.radians(15), np.radians(1), np.radians(5), np.radians(10), np.radians(15)] # y axis variation (left and right, negative is right (wrt human)) rotateY = [0.0, -np.radians(1), -np.radians(5), -np.radians(10), -np.radians(15), np.radians(1), np.radians(5), np.radians(10), np.radians(15)] # z axis variation (up and down, negative is down (wrt human)) rotateZ = [0.0, -np.radians(1), -np.radians(5), -np.radians(10), -np.radians(15), np.radians(1), np.radians(5), np.radians(10), np.radians(15)]