-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
15,592 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#Large interdelay which shall be in days usually | ||
|
||
# largevar = StringVar(value=self.largedelaydefault) | ||
# self.largeentry=TK.Entry(textvariable=largevar) | ||
# self.largeentry.grid(row=5,column=1) | ||
|
||
#label for largedelay | ||
# self.labellargeentry=TK.Label(text="LARGE DELAY (mins)", fg='red') | ||
# self.labellargeentry.grid(row=4,column=1) | ||
from selenium import webdriver | ||
from selenium.webdriver.common.keys import Keys | ||
import time | ||
import sys | ||
#import http.client | ||
#import pprint | ||
# | ||
#connection = http.client.HTTPSConnection("file:///D:/day2/allitems/friday_data/WebServerPort_again.json") | ||
#connection.request("GET", "/") | ||
#response = connection.getresponse() | ||
#headers = response.getheaders() | ||
#pp = pprint.PrettyPrinter(indent=4) | ||
#pp.pprint("Headers: {}".format(headers)) | ||
|
||
|
||
|
||
|
||
driver=webdriver.Chrome("C:\\Users\\sairamtvv\\Videos\\chromedriver_win32\\chromedriver.exe") | ||
|
||
#Get the html of the site, basically ip address here. | ||
|
||
baseUrl = "file:///D:/day2/allitems/friday_data/After_typing_rapid_X_0.54200.htm" | ||
|
||
driver.get(baseUrl) | ||
time.sleep(0.5) | ||
|
||
|
||
#Clicking two balls on the screen | ||
balls_Element=driver.find_element_by_id("enableDisableAxis0") | ||
|
||
if balls_Element is None: | ||
print("The position controller is not connecting...") | ||
sys.exit() | ||
else: | ||
balls_Element.click() | ||
time.sleep(1) | ||
driver.implicitly_wait(1) | ||
|
||
|
||
#Clicking home button | ||
driver.find_element_by_id("homeAxis0").click() | ||
driver.implicitly_wait(1) | ||
|
||
|
||
|
||
#sending ENABLE X and pressing enter | ||
imme_comm=driver.find_element_by_id("immediate-command-text") | ||
imme_comm.send_keys("ENABLE X") | ||
time.sleep(1) | ||
imme_comm.send_keys(Keys.RETURN) | ||
time.sleep(0.2) | ||
|
||
|
||
#checking for NO ERROR in the bottom status bar | ||
#bottombar_Element=driver.find_element_by_id("status-bar") | ||
#if bottombar_Element is not None: | ||
# print("bottombar_Element found") | ||
#bottombar_value=bottombar_Element.get_attribute("value") | ||
#print("The bottombar value is " +bottombar_value) | ||
|
||
|
||
check_enable_Element = driver.find_element_by_id('axis0Status') | ||
check_enable_Text = check_enable_Element.text | ||
|
||
if check_enable_Text=='Enabled': | ||
print("Enabled and lets continue") | ||
time.sleep(0.5) | ||
|
||
#clearing the immediate-command text for next command and then Absolute command | ||
imme_comm=driver.find_element_by_id("immediate-command-text") | ||
time.sleep(0.5) | ||
imme_comm.clear() | ||
imme_comm.send_keys("ABSOLUTE") | ||
time.sleep(1) | ||
imme_comm.send_keys(Keys.RETURN) | ||
time.sleep(0.2) | ||
|
||
|
||
#clearing the immediate-command text for next command and then POSITION 1 | ||
imme_comm=driver.find_element_by_id("immediate-command-text") | ||
time.sleep(0.5) | ||
imme_comm.clear() | ||
imme_comm.send_keys("RAPID X -0.542000 F5") | ||
time.sleep(1) | ||
imme_comm.send_keys(Keys.RETURN) | ||
time.sleep(0.2) | ||
driver.implicitly_wait(1) | ||
|
||
#Checking if the position feedback has reached the desired value | ||
pos_feedback_Text=0 | ||
desired_pos=-0.542000 | ||
while abs(desired_pos-float(pos_feedback_Text))>10**-3: | ||
pos_feedback_Element=driver.find_element_by_id('axis0PosFbk') | ||
time.sleep(0.5) | ||
pos_feedback_Text = pos_feedback_Element.text | ||
print("Reached the desired position") | ||
|
||
|
||
print("First test completed") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
"# arci_graphic" | ||
"# arci_graphic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Python SCPI socket functions | ||
|
||
|
||
|
||
import socket | ||
|
||
def SCPI_sock_connect(ipaddress,port=57732): | ||
""" Opens up a socket connection between an instrument and your PC | ||
Returns the socket session | ||
Arguments: | ||
ipaddress -> ip address of the instrument | ||
port -> optional -> socket port of the instrument (default 5025)""" | ||
|
||
try: | ||
session=socket.socket(socket.AF_INET,socket.SOCK_STREAM) | ||
session.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 0) | ||
session.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, 0) | ||
session.connect((ipaddress,port)) | ||
except IOError: | ||
print ("Failed to connect to the instrument, pleace check your IP address") | ||
#return | ||
return session | ||
|
||
def SCPI_sock_send(session,command,error_check=False): | ||
"""Sends a command to an instrument | ||
Arguments: | ||
session -> TCPIP socket connection | ||
command -> text containing an instrument command | ||
error_check -> optional -> Check for instrument errors (default False)""" | ||
|
||
resp = " " | ||
message=command + "\r\n" | ||
message=message.encode('ascii', 'ignore') | ||
session.sendall(message) | ||
|
||
if error_check==True: | ||
err = get_error(session, command) | ||
|
||
#def SCPI_sock_query(session,command,error_check=False): | ||
# """Sends a query to an instrument | ||
# Returns the query response | ||
# | ||
# Arguments: | ||
# session -> TCPIP socket connection | ||
# command -> text containing an instrument command | ||
# error_check -> optional -> Check for instrument errors (default False)""" | ||
# | ||
# session.settimeout(2.0) | ||
# try: | ||
# session.sendall(command + "\n") | ||
# response = getDataFromSocket(session) | ||
# if error_check==True: | ||
# err = get_error(session, command) | ||
# if err: | ||
# response = "<ERROR>" | ||
# return response | ||
# | ||
# except socket.timeout: | ||
# print "Query error:" | ||
# get_error(session, command) | ||
# response = "<ERROR>" | ||
# return response | ||
# | ||
def SCPI_sock_close(session): | ||
"""Closes the socket connection | ||
Argument: | ||
session -> TCPIP socket connection""" | ||
|
||
session.close() | ||
# | ||
def getDataFromSocket(session): | ||
"""Reads from a socket until a newline is read | ||
Returns the data read | ||
Argument: | ||
session -> TCPIP socket""" | ||
|
||
dat = "" | ||
while 1: | ||
message = session.recv(4096) | ||
last=len(message) | ||
if message[last-1] == "\n": | ||
dat=dat+message[:-1] | ||
return dat | ||
else: | ||
dat=dat+message | ||
# | ||
#def get_error(session, command): | ||
# """Checks an instrument for errors and print them out | ||
# Returns True if any errors are encountered | ||
# | ||
# Arguments: | ||
# session -> TCPIP socket connection | ||
# command -> text containing an instrument command""" | ||
# | ||
# has_err=False | ||
# resp = SCPI_sock_query(session,"SYST:ERR?") | ||
# | ||
# if int(resp[:2]) != 0: | ||
# print "Your command: " + command + " has errors:" | ||
# print resp | ||
# has_err = True | ||
# while int(resp[:2]) != 0: | ||
# resp=SCPI_sock_query(session,"SYST:ERR?") | ||
# if int(resp[:2]) != 0: | ||
# print resp | ||
# | ||
# return has_err |
Oops, something went wrong.