def __init__(self, properties): Device.__init__(self) self.inputs = ["x", "y", "r", "phase"] self.port = properties['port'] #self.connection = pyvisa.ResourceManager().open_resource(self.port) #self.connection = mock_connection() #Mock connection for tests self.connection = GPIBDeviceConnection(self.port) self.outputs = [] self._properties = self._read_properties()
def setUp(self): self.pcb1 = Mock() self.pcb2 = Mock() self.interruptor = Mock() self.logger = Mock() self.printLine1 = InstIO("Impresion 1", 0) self.printLine2 = InstIO("Impresion 2", 0) self.queue = Queue() self.device = Device("Printer", self.interruptor, self.queue) # 0 equals to the device cod printer self.device.setLogger(self.logger)
def __init__(self, properties): Device.__init__(self) self.inputs = ["DCV", "DCC"] self.outputs = ["DCV", "DCC"] self.port = properties['port'] self.connection = pyvisa.ResourceManager().open_resource(self.port) self._set_constants_access() #self.connection = mock_connection() #Mock connection for tests try: self._properties = self._read_properties() except Exception as e: self.connection.close() raise (e)
class Kernel(object): ''' @summary: the abstraction of the operative system ''' def __init__(self, clock,programLoader,imanager,delivery,devices=[]): self.clock = clock self.programLoader = programLoader self.delivery = delivery self.imanager = imanager self.devices = devices def startUp(self): self.clock.start() for device in self.devices: device.start() def run(self,programName,priority=0,args=[]): self.pid = self.programLoader.loadProcess(programName,priority,args) return self.pid def ps(self): return self.programLoader.getPcbTable().getPS() def kill(self,pid): self.imanager.kill(pid) def installNewDevice(self,deviceName,deviceLogger): self.device = Device(deviceName,self.imanager) self.device.setLogger(deviceLogger) self.delivery.newDevice(self.device) self.devices.append(self.device) def manual(self,programName): return self.programLoader.manual(programName) def in_disk(self, programName): return self.programLoader.in_disk(programName)
class Test(unittest.TestCase): def setUp(self): self.pcb1 = Mock() self.pcb2 = Mock() self.interruptor = Mock() self.logger = Mock() self.printLine1 = InstIO("Impresion 1", 0) self.printLine2 = InstIO("Impresion 2", 0) self.queue = Queue() self.device = Device("Printer", self.interruptor, self.queue) # 0 equals to the device cod printer self.device.setLogger(self.logger) def test_when_process_is_called_the_instruccion_runs_and_ioDone_is_sent(self): self.packageOne = [self.pcb1, self.printLine1] self.device.proccess(self.packageOne) # arrange verify(self.interruptor).ioDone(self.pcb1) # assert
def setUp(self): # miscellaneous self.semaphore = Condition() self.disk = HardDisk() self.comparator = lambda pcb1, pcb2: pcb1.getPriority() > pcb2.getPriority() # the greater, the better self.readyQueue = OwnHeap(self.semaphore, self.comparator) # hardware self.memory = RAM(1000) self.mmu = MMU(1,self.memory) self.ioDelivery = IODelivery() self.progLoader = ProgramLoader(self.memory, self.disk, self.readyQueue,self.mmu) self.imanager = InterruptorManager() self.cpu = CPU(self.memory, self.imanager, self.semaphore,self.mmu) self.scheduler = Scheduler(self.cpu, self.readyQueue , 5, self.semaphore) # devices self.spooler = Device('printer', self.imanager) self.screen = Device('screen', self.imanager) self.ioDelivery.newDevice(self.spooler) self.ioDelivery.newDevice(self.screen) # im self.imanager.setScheduler(self.scheduler) self.imanager.setDisk(self.disk) self.imanager.setMmu(self.mmu) self.imanager.setIODelivery(self.ioDelivery) # loading programs self.ioInstruction = InstIO('directory', 0) self.cpuInstruction = InstCPU('1+1') self.prog1 = Program('ls') self.prog2 = Program('pwd') self.prog1.addInstruction(self.cpuInstruction) self.prog2.addInstruction(self.ioInstruction) self.disk.setProgram(self.prog1) self.disk.setProgram(self.prog2)
def __init__(self, properties): Device.__init__(self) self.port = properties['port'] self.has_adc = properties['has_adc'] self.frequency = properties['frequency'] self.points = properties['points'] self.ramp_time = properties['ramp_time'] #self.connection = mock_connection(self.port, 115200) self.connection = DuckConnection(self.port, 115200) self.connection.__enter__() self.outputs = [ " ".join([i, j]) for i, j in product( ['Port 0', 'Port 1', 'Port 2', 'Port 3'], ['AC', 'DC']) ] if self.has_adc: self.inputs = ['ADC 0', 'ADC 1', 'ADC 2', 'ADC 3'] else: self.inputs = [] self._properties = [ 'Frequency (Hz)', 'Points On Graph', 'Ramp Time (V/S)' ] self.ready = self._update_sine_function()
class Kernel(object): ''' @summary: the abstraction of the operative system ''' def __init__(self, clock, programLoader, imanager, delivery, devices=[]): self.clock = clock self.programLoader = programLoader self.delivery = delivery self.imanager = imanager self.devices = devices def startUp(self): self.clock.start() for device in self.devices: device.start() def run(self, programName, priority=0, args=[]): self.pid = self.programLoader.loadProcess(programName, priority, args) return self.pid def ps(self): return self.programLoader.getPcbTable().getPS() def kill(self, pid): self.imanager.kill(pid) def installNewDevice(self, deviceName, deviceLogger): self.device = Device(deviceName, self.imanager) self.device.setLogger(deviceLogger) self.delivery.newDevice(self.device) self.devices.append(self.device) def manual(self, programName): return self.programLoader.manual(programName) def in_disk(self, programName): return self.programLoader.in_disk(programName)
def installNewDevice(self, deviceName, deviceLogger): self.device = Device(deviceName, self.imanager) self.device.setLogger(deviceLogger) self.delivery.newDevice(self.device) self.devices.append(self.device)
if __name__ == "__main__": args = get_argparse() START = time.time() ALTITUDE = [float(e) for e in args.altitude] SPEED = [float(e) for e in args.speed] RADIUS_TOT, RADIUS_ME = float(args.radius_tot), float(args.radius_me) offset_N, offset_E = args.off_n, args.off_e with open(BOOKKEEPER_path, "a+") as f: f.write(",".join([FLIGHTLOG_NAME.format(START), DEVICE_LOG.format(START), args.info])) f.write("\n") #v = log = None d = Device(args.name, START, args.solo_edge, args.adaptive_fr, args.adaptive_pipes, is_nano=args.tegra, model=models[int(args.model)], ismac=False, verbose=args.verbose, input_type =args.input, conn_string=args.c, db_host=args.db) #v = d.drone #print("Flight Log Start") #log = FlightLog(v, logtime=0.1, start_time=START) #log.start() try: #v.arm_and_takeoff(ALTITUDE[0]) d.start() while True: time.sleep(1) print("d.state[img_out_q]", d.state["img_out_q"]) print("Active pipelines", d.state["active_pipelines"]) except ValueError as e: raise e
def __init__(self, properties): Device.__init__(self) self.connection = None
def installNewDevice(self,deviceName,deviceLogger): self.device = Device(deviceName,self.imanager) self.device.setLogger(deviceLogger) self.delivery.newDevice(self.device) self.devices.append(self.device)