示例#1
1
def main():

    USB1208LS=MCCDAQ()
    USB1208LS.FlashLED(0)
    
    USB1208LS.GetBoardName(0)
    i=USB1208LS.getStatus()
    print USB1208LS.GetErrMsg(i)

    print USB1208LS.GetConfig(BOARDINFO,0,0,BISERIALNUM)
    
    WConio.clrscr() 

    print "Demonstration of cbAOut() - chan0 pin13 - D/A 10bits"

    ExitFlag = False
    while (ExitFlag==False):

        WConio.gotoxy (0, 3)
        EngUnits = float ( raw_input('Enter a voltage between -5.0 and +5.0:  ') )

        DataValue=USB1208LS.FromEngUnits(0, BIP5VOLTS, EngUnits)
        USB1208LS.AOut (0, 0 , BIP5VOLTS, DataValue)
        
        print "%.2f volts has been sent to D/A 0.\n"\
               "Press Q to quit , any other key to continue: "  %EngUnits
        (ch,)=WConio.getch()
        
        if (ch=='q' or ch=='Q'): ExitFlag=True
示例#2
0
def writeout(s, o, c=True, replace_lines=0):
    '''Writes out a string to the stdout or appends it to a file'''
    if not o:

        if c:
            s = deutfize(s)

        if replace_lines and sys.platform in WINDOWS:
            try:
                import WConio
                pos = WConio.wherex(), WConio.wherey()
                for i in range(replace_lines):
                    sys.stdout.write(' '*(WConio.gettextinfo()[-3]-1) + '\n')
                WConio.gotoxy(pos[0], pos[1])
            except:
                replace_lines=0

        sys.stdout.write(s)

        if replace_lines and sys.platform in WINDOWS:
            WConio.gotoxy(pos[0], pos[1])

    else:
        with open(o, mode='a', encoding='utf-8') as o_file:
            o_file.write(s)
示例#3
0
    def run ( self ):
        tt = DrawGUI()
	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	host = ''
	port = 8888
	s.bind((host, port))
	s.listen(5)
	WConio.gotoxy(0,24)
	WConio.textcolor(WConio.YELLOW)
        print "Awaiting Connections"
	WConio.gotoxy(17,22)
	posy = 4
	count = 0
	while 1:
            conn, addr = s.accept()
            WConio.textcolor(WConio.YELLOW)
            c = 0
            for p in l:
                c = c + 1
                if addr[0] == p[1][0]:
                    cmd = enc('clean', key)
                    conn.send(cmd)
                else:
                    l.append([conn, addr])
            if c == 0:
                l.append([conn, addr])
示例#4
0
def main():

    USB1208LS=MCCDAQ()

    WConio.clrscr() 
    print "Demonstration of cbDIn()\n"\
           "Press any key to quit.\n\n"\
           "You may change a bit by applying a TTL high or\n"\
           "a TTL low to the corresponding pin# on port A.\n"

    print "The first 7 bits are: pin32 to pin 39\n"\
           "0  1  2  3  4  5  6  7\n "
    (a,a,a,a,a,a,a,a,a,a,row)=WConio.gettextinfo() 
    
    USB1208LS.DConfigPort (0, FIRSTPORTB, DIGITALIN)

    while (WConio.kbhit()==False):
        DataValue=USB1208LS.DIn(0, FIRSTPORTB)
        WConio.gotoxy(0,row)  
        print "Port Value: %d         " %DataValue

        # parse DataValue into bit values to indicate on/off status */
        for I in range (8):
            if (DataValue & 2**I):  BitValue = 1
            else:  BitValue = 0
            print "%d " %BitValue,
示例#5
0
def display_suggestion(msg):
    global old_matches
    matches = []
    if not msg or not msg.strip():
        if old_matches != matches:
            W.gotoxy(0, C.height - 2)
            W.clreol()
            old_matches = matches
        return
    msg = msg.split()[0]
    for command in commands:
        if command.command.startswith(msg) and not command.hide:
            matches.append(command)
    if matches:
        #limit our match count
        matches = matches[:5]
        if old_matches != matches:
            old_matches = matches
            W.gotoxy(0, C.height - 2)
            W.clreol()
        
            targetwidth = C.width / len(matches)
            W.textcolor(W.DARKGREY)
            for command in matches:
                W.cputs(('%s (%s)' % (command.command, format_time(command.time, command.time_variable))).center(targetwidth))
    return matches
示例#6
0
文件: otto.py 项目: marcgalang/otto
def selectDestination(gameArray,cursor,player,arrows):
	k=None
	oldCursor = cursor[:]
	while k<>"q":
		k = WConio.getkey()
		if k in arrows[0]:
			#WConio.gotoxy(cursor[0]*2+1+40-len(gameArray),cursor[1]*2+1) 
			printGrid(gameArray) #'erase' cursor icon
			d=arrows[0].index(k)		
			cursor[0]=(cursor[0]+arrows[1][d])
			if cursor[0]<0 or cursor[0]>len(gameArray) or abs(cursor[0]-oldCursor[0])>2:
				cursor[0]=(cursor[0]-arrows[1][d])
			cursor[1]=(cursor[1]+arrows[2][d])
			if cursor[1]<0 or cursor[1]>len(gameArray[0]) or abs(cursor[1]-oldCursor[1])>2:
				cursor[1]=(cursor[1]-arrows[2][d])
		printCursor(gameArray,oldCursor)
		printCursor2(gameArray,cursor)

		if k == " ":# when 'spacebar' entered
				if ord(gameArray[cursor[0]][cursor[1]])<>250:
					WConio.gotoxy(0,21)
					print "{0:^79}".format("Player {0}, you can only move to empty spaces".format(player))
				else:
					finalizeMove(gameArray,oldCursor,cursor,player)
					break
	return gameArray		
示例#7
0
文件: TestRCS.py 项目: philips/feusb
 def robust_write(self, command = ''):
     """Write to the RCS with robust exception handling."""
     try:
         self.write(command)
     except DisconnectError:
         global servo_mode
         servo_mode = IDLE
         # Blank screen due to device disconnect.
         WConio.textattr(0xb0)
         WConio.clrscr()
         WConio.gotoxy(10, 10)
         WConio.cputs('USB-RCS has been disconnected during write. '
                      'Trying to reconnect. ')
         self.robust_reconnect()
         usb = rcs.robust_read('U')
         firmware_version = usb[2]
         display_once(firmware_version)
     except Exception, e:
         WConio.textattr(0xc0)
         WConio.clrscr()
         WConio.gotoxy(0, 10)
         print "Unexpected exception in robust_write: ", type(e)
         print
         print e
         print
         raw_input("Press enter to exit ->")
         exit()
示例#8
0
文件: conio.py 项目: chyser/bin
def put(x, y, s, fgc=None, bgc=None):
#-------------------------------------------------------------------------------
    wc.gotoxy(x, y)
    if bgc:
        wc.textbackground(bgc)
    if fgc:
        wc.textcolor(fgc)
    wc.cputs(s)
示例#9
0
文件: conio.py 项目: chyser/bin
def put(x, y, s, fgc=None, bgc=None):
    #-------------------------------------------------------------------------------
    wc.gotoxy(x, y)
    if bgc:
        wc.textbackground(bgc)
    if fgc:
        wc.textcolor(fgc)
    wc.cputs(s)
示例#10
0
文件: conio.py 项目: chyser/bin
 def status(self, y, s):
     #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     wc.gotoxy(0, y)
     wc.movetext(0, y, self.ex, self.ey - 1, 0, y + 1)
     wc.gotoxy(0, y)
     wc.textbackground(7)
     wc.textcolor(15)
     wc.clreol()
     wc.cputs(s)
示例#11
0
文件: draw.py 项目: jtruscott/ld21
def put_at(x, y, msg, color=None):
    if color:
        W.textcolor(color)

    if len(msg) + x > C.width:
        log.debug('put_at: truncating %s by %i', msg, len(msg) + x - C.width)
        msg = msg[:C.width - x - 1]
    W.gotoxy(x, y)
    W.cputs(msg)
示例#12
0
文件: conio.py 项目: chyser/bin
 def status(self, y, s):
 #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     wc.gotoxy(0, y)
     wc.movetext(0, y, self.ex, self.ey -1, 0, y+1)
     wc.gotoxy(0, y)
     wc.textbackground(7)
     wc.textcolor(15)
     wc.clreol()
     wc.cputs(s)
示例#13
0
文件: draw.py 项目: jtruscott/ld21
def draw_box_text(box, text=None):
    if text is None:
        text = box.text
    W.textbackground(box.interior_background_color)
    for line in text:
        W.textcolor(line.color)
        if line.right_justify:
            W.gotoxy(box.left + box.width - line.x - len(line.text), box.top + line.y)
        else:
            W.gotoxy(box.left + line.x, box.top + line.y)
        W.cputs(line.text)
示例#14
0
    def run ( self ):
        time.sleep(3)
        oldLen = 0
        while 1:
            newLen = len(l)
            WConio.textcolor(WConio.LIGHTCYAN)
            posX = WConio.wherex()
            posY = WConio.wherey()
	    WConio.gotoxy(0,4)
	    if newLen < oldLen:
                for n in range(oldLen+1):
                    WConio.cputs("                                  \n\r")
            else:
                for n in range(len(l)+1):
                    WConio.cputs("                                  \n\r")
            WConio.gotoxy(0,4)
	    for i in range(len(l)):
                try:
                    print str(i) + ': ' + str(l[i][2])
                except:
                    print str(i) + ': ' + str(l[i][1][0])
            if posX > 16:
                WConio.gotoxy(posX,22)
            else:
                WConio.gotoxy(17,22)
            oldLen = len(l)
            time.sleep(3)
示例#15
0
文件: otto.py 项目: marcgalang/otto
def selectToken (gameArray,arrows,player):
	WConio.gotoxy(0,23)
	print "{0:^79}".format("Select one of your tokens to initiate a move.")
	k=None
	player=1
	while k<>"q":
		printCursor(gameArray,cursor)
		if k =="u":
			printUnicode()
		if k =="a":
			printAscii()
			
		k = WConio.getkey()
		if k in arrows[0]:
			WConio.gotoxy(cursor[0]*2+1+40-len(gameArray),cursor[1]*2+1) 
			printGrid(gameArray) #'erase' cursor icon
			d=arrows[0].index(k)		
			cursor[0]=(cursor[0]+arrows[1][d])%len(gameArray)
			cursor[1]=(cursor[1]+arrows[2][d])%len(gameArray[0])
		printCursor(gameArray,cursor)

		if k == " ":# when 'spacebar' entered
			if ord(gameArray[cursor[0]][cursor[1]])<>player:
				WConio.gotoxy(0,21)
				print "{0:^79}".format("Player {0}, you can only select a space that is already yours.".format(player))
			else:	
				clearLines()
				WConio.gotoxy(0,21)
				print "{0:^79}".format("Token selected.")
				#print " "*79
				gameArray = selectDestination(gameArray,cursor,player,arrows)
				break		
示例#16
0
文件: TestRCS.py 项目: philips/feusb
def display_bar(xcol, yrow, color, division, width):
    """Display a bar of 'color' and 'width', with two sections at 'division'."""
    full_cells, cell_frac = divmod(int(width * division * 3), 3)
    if division < 0:
        display_string = SPACE * width
    elif full_cells == width:
        display_string = FULL_BAR * width
    elif cell_frac == 0:
        display_string = FULL_BAR * full_cells + SPACE * (width - full_cells)
    elif cell_frac == 1:
        display_string = FULL_BAR * full_cells + HALF_BAR + SPACE * (width - full_cells - 1)
    else:
        display_string = FULL_BAR * (full_cells + 1) + SPACE * (width - full_cells - 1)
    WConio.gotoxy(xcol, yrow)
    WConio.textattr(color)
    WConio.cputs(display_string)
 def __draw(self):
    WConio.clrscr()
    
    # make walls
    for i in xrange(len(self.__walls)):
       self.__walls[i].draw()
       
    self.__worldInfo.player.draw((1,1))
    for z in self.__worldInfo.zombies:
       z.draw((1,1))
    for h in self.__worldInfo.healthPacks:
       h.draw((1,1))
    
    self.__drawHUD()
       
    WConio.gotoxy(0,self.__size[1] + 2)
示例#18
0
def main():
    USB1208LS=MCCDAQ()
    
    WConio.clrscr() 
    print "Demonstration of voltage conversions.\n"\
           "Press any key to quit.\n"

    # get the A/D channel to sample 
    Chan = int ( raw_input('Enter the channel to display: ') ) 

    print "\n\nNote: Please make certain that the board you are using supports\n"\
           "      the gain you are choosing and if it is not a programmable\n"\
           "      gain that the switches on the board are set correctly.\n\n"
    
    BoardNum = 0
    Gain = BIPPT625VOLTS
    
    # collect the sample with cbAIn() */
    while (Gain > 0):
        # select gain */
        WConio.gotoxy(0,10)
        while 1:
            Gain = int ( raw_input ("Please select one of the following ranges(1 to 4):\n"\
                                    "                           10 VOLTS UNIPOLAR --> 1\n"\
                                    "                           10 VOLTS BIPOLAR ---> 2\n"\
                                    "                            5 VOLTS UNIPOLAR --> 3\n"\
                                    "                            5 VOLTS BIPOLAR ---> 4\n"\
                                    "                                       Quit ---> 0\n\n"\
                                    "                                Your Choice ---> "))
            if  ( (Gain >= 0) and (Gain <= 4) ): break
        
        # Set Gain, MaxVal, and MinVal */
        if   (Gain==0): sys.exit(1)
        elif (Gain==1): Gain = UNI10VOLTS
        elif (Gain==2): Gain = BIP10VOLTS
        elif (Gain==3): Gain = UNI5VOLTS
        elif (Gain==4): Gain = BIP5VOLTS

        if (Gain >= 0):
            DataValue=USB1208LS.AIn (BoardNum, Chan, Gain)
            EngUnits =USB1208LS.ToEngUnits(BoardNum, Gain, DataValue)
            print "\nThe voltage on channel %d is %.2f " %(Chan, EngUnits)
            
        Gain = BIPPT625VOLTS
示例#19
0
文件: TestRCS.py 项目: philips/feusb
 def robust_read(self, command = None, count = 1):
     """Read from the RCS with robust exception handling."""
     global servo_mode
     while True:
         try:
             return self.read(command, count)
         except DisconnectError:
             servo_mode = IDLE
             # Blank screen due to device disconnect.
             WConio.textattr(0xb0)
             WConio.clrscr()
             WConio.gotoxy(10, 10)
             WConio.cputs('USB-RCS has been disconnected during read. '
                          'Trying to reconnect. ')
             self.robust_reconnect()
             usb = rcs.robust_read('U')
             firmware_version = usb[2]
             display_once(firmware_version)
         except ReadTimeoutError, e:
             servo_mode = IDLE
             # Blank screen due to device disconnect.
             WConio.textattr(0xc0)
             WConio.clrscr()
             WConio.gotoxy(10, 10)
             WConio.cputs('USB-RCS read timeout: '
                          'Communications is not responding as expected.')
             WConio.gotoxy(10, 12)
             raw_input("Unplug the USB-RCS.")
             while self.status() != DISCONNECTED:
                 time.sleep(0.500)
             WConio.gotoxy(10, 12)
             WConio.cputs("Now, plug-in the USB-RCS.")
             self.robust_reconnect()
             usb = rcs.robust_read('U')
             firmware_version = usb[2]
             display_once(firmware_version)
         except Exception, e:
             WConio.textattr(0xc0)
             WConio.clrscr()
             WConio.gotoxy(0, 10)
             print "Unexpected exception in robust_read: ", type(e)
             print e
             raw_input("Press enter to exit ->")
             exit()
 def __drawHUD(self):
    
    WConio.textattr(self.__HUDColor)
    
    WConio.gotoxy(self.__size[0]+4,1)
    print "--------HUD--------"
    WConio.gotoxy(self.__size[0]+4,3)
    print " Player Health:", self.__worldInfo.player.health
    WConio.gotoxy(self.__size[0]+4,4)
    print "         Kills:", self.__kills
    WConio.gotoxy(self.__size[0]+4,5)
    print "         Turns:", self.__turns
示例#21
0
文件: TestRCS.py 项目: philips/feusb
def display_update():
    """Display changing information, call repeatedly."""
    # Display the Disable Input Status.
    WConio.gotoxy(28, 0)
    if disabled:
        WConio.textattr(0xc0)
        WConio.cputs('   Enable Input Open -- All Servos Are Held Idle   ')
    else:
        WConio.textattr(0xa0)
        WConio.cputs('Enable Input Shorted -- Servo Positioning Permitted')
    # Display the servo command mode.
    WConio.gotoxy(28, 2)
    WConio.textattr(0x70)
    if command_mode is INIT:
        WConio.cputs('Servos held initialized:  AnyKey to run, Q to quit.')
    elif command_mode is RUN:
        WConio.cputs('Servos allowed to run:  AnyKey to brake, Q to quit.')
    elif command_mode is BRAKE:
        WConio.cputs('Servos braking:   AnyKey to idle servos, Q to quit.')
    elif command_mode is IDLE:
        WConio.cputs('Servos held idle:  AnyKey to initialize, Q to quit.')
    else:
        WConio.cputs('Error:  Unrecognized command mode!!!     Q to quit.')
    # Display servo cycle, speed, position in mS and position bar graph.
    for i, each_servo in enumerate(all_servos):
        WConio.gotoxy(4, 3 + i)
        WConio.textattr(0x70)
        # Cyc..Spd..Pos mS
        if accel_dif:
            accel = accel_list[i]
        else:
            accel = 1
        WConio.cputs('%3i %2i %3i %5i %01.4f'
                     %(accel, each_servo[3], each_servo[2], each_servo[1],
                       each_servo[0]/12000.0))
        color = 0x2b if i % 2 else 0x2a  #2a is green, 9b is blue
        display_bar(28, 3 + i, color,
                    float(each_servo[0] - SERVO_MIN) / SERVO_RANGE, 51)
    # Display analog measurement values.
    for i, each_channel in enumerate(analog_channels):
        color = 0x3b if i % 2 else 0x3a #a is green, b is blue
        volts = each_channel * 5.0 / ANALOG_MAX
        if i < 4:
            xoffset = 0
            yoffset = i
        else:
            xoffset = 40
            yoffset = i-4
        WConio.gotoxy(5 + xoffset, 21 + yoffset)
        WConio.textattr(0x70)
        WConio.cputs('%01.4fv'%volts)
        display_bar(13 + xoffset, 21 + yoffset, color, volts/5.0, 26)
示例#22
0
文件: TestRCS.py 项目: philips/feusb
 def robust_reconnect(self):
     """Reconnect with exception handling."""
     recon_count = 0
     while True:
         time.sleep(0.500)
         try:
             self.reconnect()
         except OpenError:
             recon_count += 1
             WConio.gotoxy(20, 14)
             WConio.cputs(' Reconnect retry attempts: %5i '%
                          recon_count)
         except Exception, e:
             WConio.gotoxy(5, 16)
             print "Unexpected exception during reconnect:", type(e)
             print e
             raw_input("Press enter to exit ->")
             exit()
         else:
             return
示例#23
0
文件: otto.py 项目: marcgalang/otto
def printGrid(array):	
	WConio.gotoxy(40-len(array),0)
	y=len(array[0])-1
	x=len(array)-1
	print chr(218)+(chr(196)+chr(194))*x+chr(196)+chr(191)
	for i in range(y):
		WConio.gotoxy(40-len(array),i*2+2)
		print chr(195)+(chr(196)+chr(197))*x+chr(196)+chr(180)
	WConio.gotoxy(40-len(array),y*2+2)
	print chr(192)+(chr(196)+chr(193))*x+chr(196)+chr(217)	
	for i in range(y+1):
		for j in range (x+2):
			WConio.gotoxy(j*2+40-len(array),i*2+1)
			print chr(179)
示例#24
0
文件: otto.py 项目: marcgalang/otto
def printCursor2(gameArray,cursor):
	WConio.gotoxy(cursor[0]*2+40-len(gameArray),cursor[1]*2)
	print chr(201)+chr(205)+chr(187)
	WConio.gotoxy(cursor[0]*2+40-len(gameArray),cursor[1]*2+1)
	print chr(186)+gameArray[cursor[0]][cursor[1]]+chr(186)
	WConio.gotoxy(cursor[0]*2+40-len(gameArray),cursor[1]*2+2)
	print chr(200)+chr(205)+chr(188)	
示例#25
0
文件: TestRCS.py 项目: philips/feusb
def display_once(firmware_version):
    """Display static information, call once."""
    WConio.textattr(0x70)
    WConio.clrscr()
    # Display Firmware Version or Firmware Status.
    WConio.gotoxy(2, 0)
    if firmware_version < 1.0:
        WConio.textattr(0xc0)
        WConio.cputs(' Firmware Unreliable!   ')
    else:
        WConio.textattr(0xa0)
        WConio.cputs(' Firmware Version %2.2f '%firmware_version)
    # Display servo static labels.
    WConio.gotoxy(0, 2)
    WConio.textattr(0x70)
    WConio.cputs(' S# Acc #Q Cyc Speed Pos mS\n')
    for i in range(1, 17):
        WConio.cputs(' %2i\n'%i)
    # Display analog channel labels.
    WConio.gotoxy(0, 20)
    WConio.textattr(0x70)
    WConio.cputs    (' C#  Voltage                             C#  Voltage')
    for i in range(1, 5):
        WConio.cputs('\n  %i                                       %i'%
                     (i, i+4))
示例#26
0
文件: otto.py 项目: marcgalang/otto
def finalizeMove(gameArray,oldCursor,cursor,player):
	WConio.gotoxy(0,21)
	if cursor==None:
		return gameArray
	print "{0:^79}".format("Token cloned.")
	gameArray[cursor[0]][cursor[1]]=chr(player)
	if abs(cursor[0]-oldCursor[0])==2 or abs(cursor[1]-oldCursor[1])==2:
		gameArray[oldCursor[0]][oldCursor[1]]=chr(250)
		WConio.gotoxy(0,21)
		print "{0:^79}".format("Token moved.")
	time.sleep(0)
	c=0
	for i in range (cursor[0]-1,cursor[0]+2):
		for j in range (cursor[1]-1,cursor[1]+2):
			try:
				if gameArray[i][j]==chr(player%2+1) and i>=0 and i<=len(gameArray) and j>=0 and j<= len(gameArray[0]):
					gameArray[i][j]=chr(player)
					c+=1
			except:
				pass
	print "{0:^79}".format("Assimilated {0} of the opponent's tokens.".format(c))	
	printGrid(gameArray)
	printBoard(gameArray)
	WConio.gotoxy(40-len(gameArray),21)
	return gameArray
示例#27
0
文件: otto.py 项目: marcgalang/otto
def intro():
	WConio.gotoxy(0,10)
	print "{0:^79}".format("  O     O  ")
	print "{0:^79}".format("  O     O  ")
	print "{0:^79}".format(" OOOOO OOOOO")
	print "{0:^79}".format("  O     O  ")
	print "{0:^79}".format("  O     O  ")
	print "{0:^79}".format("  O     O  ")
	print "{0:^79}".format("  O     O ")
	print "\n"*4
	print "{0:^79}".format("hit spacebar to continue")
	k=None
	speed = 20 #higher is slower
	inc=10
	r=12

	while 1:
		i=0
		while i<math.pi:
			ang=0
			while ang<math.pi/2:
				x=math.cos(ang)*r
				y=math.sin(ang)*r
				scale=math.cos(i)
				oldScale = math.cos(i-2*math.pi/speed)
				for j in range(-1,3,2):
					for k in range(-1,3,2):
						WConio.gotoxy(int(20+x*oldScale*j),int(12+y*k))
						print " "
						WConio.gotoxy(int(20+x*scale*j),int(12+y*k))
						print "O"
						WConio.gotoxy(int(60+x*oldScale*j),int(12+y*k))
						print " "
						WConio.gotoxy(int(60+x*scale*j),int(12+y*k))
						print "O"
				ang+=math.pi/4/inc		
			i+=math.pi/speed	
		if msvcrt.kbhit():
			if msvcrt.getch() ==" ":
				break		
示例#28
0
def main():
    USB1208LS=MCCDAQ()
    
    WConio.clrscr() 
    print "Demonstration of AIn()\n"\
           "Press any key to quit.\n"

    # get the A/D channel to sample 
    Chan = int ( raw_input('Enter the channel to display: ') )

    print "\nThe raw data value on Channel %u is: " %Chan,
    (a,a,a,a,a,a,a,a,a,col,row)=WConio.gettextinfo() 
    print "\nThe voltage on Channel %u        is: " %Chan,
    
    # collect the sample from the channel until a key is pressed 
    while (WConio.kbhit()==False):
        DataValue=USB1208LS.AIn (0, Chan, BIP5VOLTS)
        EngUnits =USB1208LS.ToEngUnits (0, BIP5VOLTS, DataValue)

        WConio.gotoxy(col,row)  
        print "%5d" %DataValue,
        WConio.gotoxy(col,row+1)  
        print "%.2fV" %EngUnits,
示例#29
0
 def run(self):
     WConio.textcolor(WConio.LIGHTGREEN)
     IPs = []
     time.sleep(1)
     while 1:
         r = open('C:\\PyBot\\connections.txt', 'r')
         str = r.read().split("\n")
         r.close()
         for i in str:
             if i != '':
                 try:
                     IPs.index(i)
                 except:
                     IPs.append(i)
         f = open('C:\\PyBot\\update.txt', 'w')
         x = WConio.wherex()
         y = WConio.wherey()
         for st in IPs:
             f.write(st + '\n')
             WConio.gotoxy(0, 4)
             WConio.cputs(st + '\n\r')
         f.close()
         WConio.gotoxy(x, y)
         time.sleep(2)
示例#30
0
    def run ( self ):
        WConio.textcolor(WConio.LIGHTGREEN)
        IPs = []
        time.sleep(1)
        while 1:
	    r = open('C:\\PyBot\\connections.txt', 'r')
	    str = r.read().split("\n")
	    r.close()
	    for i in str:
	    	if i != '':
                    try:
			IPs.index(i)
                    except:
			IPs.append(i)
            f = open('C:\\PyBot\\update.txt', 'w')
            x = WConio.wherex()
            y = WConio.wherey()
            for st in IPs:
                f.write(st + '\n')
		WConio.gotoxy(0,4)
		WConio.cputs(st + '\n\r')
            f.close()
            WConio.gotoxy(x, y)
            time.sleep(2)
示例#31
0
文件: otto.py 项目: marcgalang/otto
def selectBoard(arrows):
	WConio.clrscr()
	k=None
	comment = None
	size=[5,5]
	gameArray=makeArray(size)
	WConio.gotoxy(0,21)
	print "{0:^79}".format("Hit the spacebar to accept this board.")	
	while k<>" ":		
		k = WConio.getkey()
		if k in arrows[0]:
			d=arrows[0].index(k)
			size[0]=(size[0]+arrows[1][d]*2)
			size[1]=(size[1]+arrows[2][d]*2)
			if size[0]>21:
				size[0]=21
				comment = "That's as wide as you can go."
			elif size[0]<5:
				size[0]=5
				comment = "That's as narrow as you can go."
			elif size[1]>9:
				size[1]=9
				comment = "That's as tall as you can go."
			elif size[1]<5:
				size[1]=5
				comment = "That's as short as you can go."
			else:
				comment = ""
		gameArray=makeArray(size)
		WConio.gotoxy(0,21)
		print "{0:^79}".format("{} {}".format(size,comment))
		if size[0]*size[1]>50:
			print "{0:^79}".format("This size board will get some random tokens thrown on.")	
		print "{0:^79}".format(" Hit the spacebar to accept this board.")
	#init pieces
	gameArray[0][0]=chr(1)
	gameArray[0][len(gameArray[0])-1]=chr(2)
	gameArray[len(gameArray)-1][0]=chr(2)
	gameArray[len(gameArray)-1][len(gameArray[0])-1]=chr(1)
	if len(gameArray)*len(gameArray[0])>50:
		c=0
		WConio.gotoxy(0,21)
		
		while c< len(gameArray)*len(gameArray[0])-40:
			m=randint(0,len(gameArray)-1)
			n=randint(0,len(gameArray[0])-1)
			p=randint(0,len(gameArray)-1)
			q=randint(0,len(gameArray[0])-1)
			if gameArray[m][n]==chr(250) and gameArray[p][q]==chr(250) and m<>p:
				gameArray[m][n]=chr(1)
				gameArray[p][q]=chr(2)
				c=c+2
	clearLines()
	return (gameArray)
示例#32
0
    def run ( self ):
	WConio.textcolor(WConio.LIGHTRED)
	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	host = ''
	port = 8888
	s.bind((host, port))
	s.listen(1)
	IPs = []
	WConio.gotoxy(0,25)
	WConio.cputs("Awaiting Connections...")
	WConio.gotoxy(19,23)
	while 1:
            conn, addr = s.accept()
            WConio.gotoxy(0,25)
            WConio.cputs("Connection Recieved -- Adding to File")
	    WConio.gotoxy(19,23)
	    f = open('C:\\PyBot\\connections.txt', 'a')
	    f.write(addr[0] + '\n')
	    f.close()
示例#33
0
 def run(self):
     WConio.textcolor(WConio.LIGHTRED)
     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     host = ''
     port = 8888
     s.bind((host, port))
     s.listen(1)
     IPs = []
     WConio.gotoxy(0, 25)
     WConio.cputs("Awaiting Connections...")
     WConio.gotoxy(19, 23)
     while 1:
         conn, addr = s.accept()
         WConio.gotoxy(0, 25)
         WConio.cputs("Connection Recieved -- Adding to File")
         WConio.gotoxy(19, 23)
         f = open('C:\\PyBot\\connections.txt', 'a')
         f.write(addr[0] + '\n')
         f.close()
示例#34
0
文件: menu.py 项目: cheeriobus/idler
def menu(options, deletepreviouslines=0):
    _sel()
    _otr() # Initialize terminal conditions

    home = WConio.wherey() # Gets original y coordinate
    startup = home - deletepreviouslines - 2
    y = 0
    draw(options, y)
    multiple = []
    escolha = ''
    while escolha != '\r':  #\r = enter
        escolha = WConio.getkey()

        if escolha == 'up':
                if y != 0:
                    y-=1

        if escolha == 'down':
                if y != len(options)-1:
                    y+=1

        if escolha == '+':
            multiple.append(options[y])
            if options[y][-1] != '+':
                options[y] += '+'

        # To do: add option to remove from list

        WConio.gotoxy(0, home)
        draw(options,y)

    _otr()

    for i in range(WConio.wherey(), startup, -1):
        WConio.gotoxy(0, i)
        sys.stdout.write(' '*WConio.gettextinfo()[8])
    WConio.gotoxy(0, startup)

    if len(multiple)>0:
        return multiple
    else:
        return [options[y]]
示例#35
0
# Works with Microsoft Windows dos box
# Shows some use of WConio written by Chris Gonnerman

# Written by Priyend Somaroo
# Copyright (c) 2008 Vardaan Enterprises, www.vardaan.com

# Use and distribute freely.
# No liability for any use of this code will be accepted. Use is
# without any warranty whatsoever

# Requires the package WConio by Chris Gonnerman
# E-Mail : [email protected]
# Web : http://newcenturycomputers.net/projects/wconio.html

import WConio

old_setting = WConio.gettextinfo()[4] & 0x00FF
WConio.clrscr()
WConio.textcolor(WConio.LIGHTCYAN)
WConio.settitle("PyBot Control Center")
WConio.gotoxy(2, 2)
WConio.cputs("Welcome to the PyBot Control Center\n\r")
WConio.gotoxy(0, 4)
WConio.cputs("127.0.0.1\n\r")
WConio.cputs("192.168.1.1\n\r")
WConio.gotoxy(0, 25)
WConio.cputs("Random Output...")
WConio.gotoxy(2, 23)
WConio.cputs("Enter command: ")
WConio.getch()
WConio.gotoxy(0, 25)
示例#36
0
    return fs;
def dec(s,k) :
    fs = "";
    ka = 0;
    for i in range(0,len(s)) :
        fs += chr(int(ord(s[i])+10-(ord(k[ka])-35+(i%20-len(s)%20))))
        ka+=1;
        ka%=len(k);
    return fs;

#(2,24)
old_setting = WConio.gettextinfo()[4] & 0x00FF
WConio.clrscr()
WConio.textcolor(WConio.LIGHTRED)
WConio.settitle("PyBot Control Center")
WConio.gotoxy(2,2)
print "Welcome to the Pybot Control Center"

global l
global key
key = "this is the best key in the world, you'll never guess it :D 4&#*%:J"
l = []


WConio.cputs( "\n    username: "******"    password: "******""

try:
示例#37
0
文件: conio.py 项目: chyser/bin
 def goto(self, x, y):
     #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     wc.gotoxy(x + self.sx, y + self.sy)
# Set Control FVB Board I2C Address & DUT I2C Address
vFVB_Addr  = 0x88
vDUT_Addr  = 0xA2
DELAY_TIME = 1
TEST_PIN   = 'TXDIS'

# Set FVB Board I2C Memory
dictFVB_Mem = {                                       \
 'MOD_PWR' : 0x24,   # enable Module Power            \
 'TXDIS'   : 0x25,   # Set TxDisable Output.          \
 'AS0'     : 0x26,   # Set AS0 Output.                \
 'AS1'     : 0x27    # Set AS1 Output.                \
}

# backup the current Cursor position
vCursorX = WConio.wherex()
vCursorY = WConio.wherey()

vState = 0
while True:
    print 'Set %-7s to %d.' % (TEST_PIN, vState)
    I2C.WriteByte(vFVB_Addr, dictFVB_Mem[TEST_PIN], vState)
    
    time.sleep(DELAY_TIME)
    vState = not vState

    # restore the Cursor position
    WConio.gotoxy(vCursorX, vCursorY)

示例#39
0
 def _conio_gotoxy(self, x, y):
     import WConio  #pylint: disable = import-error
     WConio.gotoxy(x, y)
示例#40
0
import string
import os
import io
import time
import random
import urllib2
import re
import WConio
import threading
import sys

#(2,24)
old_setting = WConio.gettextinfo()[4] & 0x00FF
WConio.clrscr()
WConio.settitle("PyBot Control Center")
WConio.gotoxy(2, 2)
WConio.cputs("Welcome to the PyBot Control Center\n\r")
f = open('C:\\PyBot\\connections.txt', 'w')
j = open('C:\\PyBot\\update.txt', 'w')
p = open('C:\\PyBot\\cmd.txt', 'w')
f.write('')
j.write('')
p.write('')
f.close()
j.close()


class GetConnections(threading.Thread):
    def run(self):
        WConio.textcolor(WConio.LIGHTRED)
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
示例#41
0
文件: conio.py 项目: chyser/bin
 def goto(self, x, y):
     #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     wc.gotoxy(x, y)
示例#42
0
    def run(self):
        WConio.textcolor(WConio.LIGHTCYAN)
        while 1:
            WConio.gotoxy(79, 1)
            WConio.cputs(" ")
            WConio.gotoxy(78, 2)
            WConio.cputs(" ")
            WConio.gotoxy(77, 3)
            WConio.cputs(" ")
            WConio.gotoxy(76, 4)
            WConio.cputs(" ")
            WConio.gotoxy(2, 23)
            WConio.cputs("                                               ")
            WConio.gotoxy(2, 23)
            WConio.cputs("Enter command: ")
            cmd = raw_input()

            if cmd == 'Test' or cmd == 'test' or cmd == 'TEST':
                f = open('C:\\PyBot\\cmd.txt', 'w')
                f.write('test')
                f.close()
                WConio.gotoxy(0, 25)
                WConio.cputs(
                    "                                                        ")
                WConio.gotoxy(0, 25)
                WConio.cputs("'Test' command accepted.")
            elif cmd == 'exit' or cmd == 'Exit' or cmd == 'close' or cmd == 'Close' or cmd == 'Quit' or cmd == 'quit':
                f = open('C:\\PyBot\\cmd.txt', 'w')
                f.write('exit')
                f.close()
                WConio.gotoxy(0, 25)
                WConio.cputs(
                    "                                                        ")
                WConio.gotoxy(0, 25)
                WConio.cputs(
                    "Click the X button, this function isn't working.")
                WConio.gotoxy(79, 1)
                WConio.cputs("/")
                WConio.gotoxy(78, 2)
                WConio.cputs("/")
                WConio.gotoxy(77, 3)
                WConio.cputs("/")
                WConio.gotoxy(76, 4)
                WConio.cputs("/")
            else:
                WConio.gotoxy(0, 25)
                WConio.cputs(
                    "                                                        ")
                WConio.gotoxy(0, 25)
                WConio.cputs("Command not recognized.")