Exemple #1
0
def Snapshot(Client, filename, start=8):
    import Tag_Database as Tags

    M.Read(Client, Tags.CU_V)

    variables = vars(Tags)
    variables = np.array(list(variables.items()))
    variables = variables[start:]
    #variables[:,1] = variables[:,1].astype(int)
    #variables = variables[variables[:,1].argsort()]
    Tag_List = []
    for item in variables:
        Tag_List.append([item[1], False])

    temp_list = []
    temp_list.append(M.Gather(Client, Tag_List, count=20, sleep_time=0.010))

    with open(filename,
              'w') as f:  #Opening a file with the current date and time
        for num, line in enumerate(temp_list[0]):
            f.write(variables[num, 0] + ": " + str(line).strip("([])") +
                    '\n')  #Writing each line in that file
        f.close()  #Closing the file to save it
End_Value = float(
    input(
        "What is the ending amperage that you want to ramp the magnet to? (Amps)   "
    ))

#Uncomment to make variable number of runs
#Runs = int(input("How many runs do you want the Dipole to make?   "))

Runs = 1  #Number of times you want to ramp to the input value and back to the start
Dipole_Tag = Tags.DP1  #Modbus address of the magnet we are writing to
Step_size = .001  #Step Size, in Amps, that we are taking to reach our goal
Read = Tags.DBA_Bypass  #Modbus address of the value we want to read while we scan the magnet
count = 20  #Number of times we want to average the Read Tag value

Start_Value = M.Read(Client,
                     Dipole_Tag)  #Recording the starting value of the Dipole
print("Started at {0:.3f} Amps".format(Start_Value))

DP1_Values = []
DBA_Collection = []
colors = []

for i in range(Runs):

    DP1_Vals, DBA_Col = M.Ramp_One_Way(Client,
                                       Dipole_Tag,
                                       End_Value,
                                       Max_Step=Step_size,
                                       Return="Y",
                                       Read_Tag=Read,
                                       count=count)
Exemple #3
0
    - Analyze the data and output the middle of the FWHM
    - Give the user the option to ramp to the optimal values
'''
#All necessary imports, Master must be 06/01/2020 version or greater
import Master as M
import time
import matplotlib.pyplot as plt
import numpy as np
from datetime import datetime
import Tag_Database as Tags

Client = M.Make_Client('10.50.0.10')  #Connect to PLC

start_time = time.time()  #Grabbing start time to take time of Dog Leg

Pulsing_Status = bool(M.Read(Client, Tags.Pulsing_Output,
                             Bool=True))  #Detects whether pulsing or not

Move_To_Optimum = False  #True or false, move to calculated center point after dog leg is finished?

# The tag list below is structured as multiple lists. Each of these lists contain the tag and whether or not that tag should be averaged
Tag_List = [[Tags.WF6H, False], [Tags.WF7H, False], [Tags.WF6V, False], [Tags.WF7V, False], \
            [Tags.Emitted_Current, True], [Tags.Recirculator_Halfway, True], \
            [Tags.Recirculator_Bypass, True], [Tags.CU_V, False], [Tags.SRF_Pt, False]]

Threshold_Percent = 0  #Float. The percentage of beam that we want to collect in order to turn the Dog Leg around

Zoom_In_Factor = 1  #This is how much we want to zoomn in if we are interested in an artifact at the center of the dog leg or want higher precision in the center

Scale_Factor = 0.91  #This is how much we want to scale off of the excel documents used prior to Dog Legs

Read_Steps = 40  #Integer. Number of steps to be taken in the Dog Leg. Must be an integer
print("\n\n\n")
print("-" * 60)
print("Beginning modulation")
print("-" * 60)
print("\n\n\n")

reset = False
regulation_setpoint_change = False
pulsing = False

#########################################
# Reset button loop
#########################################
while True:

    reset = M.Read(Client, Reset_Tag, Bool = True)
    running = M.Read(Client, Running_Tag, Bool = True)
    pulsing = M.Read(Client, Pulsing_Tag, Bool = True)
    regulation_setpoint_change = M.Read(Client, Regulation_Setpoint_Tag, Bool = True)
    Error_signal_offset = M.Read(Client, Regulation_Entry_Tag)
    #print(Error_signal_offset)
    i += 1
    
    if reset: #Checks the reset parameter and runs if True
        print("-"*60 + "\n\n\nResetting Oscilloscope\n\n\n" + "-"*60) #print visual break to indicate reset

        GPIB.measurement_setup(OS,IF_Channel, measurement = Measurement) #Same as beginning parameters above
        GPIB.channel_settings_check(OS, IF_Channel)
        GPIB.trigger_settings_set(OS, Trigger_Channel, Trigger_Level)
        GPIB.vertical_marker_pulsing(OS, IF_Channel)
        os.system('cls')
Exemple #5
0
#Adjust T scan Parameters
Horizontal_Delta = .1
Vertical_Delta = .1
Resolution = 40


#Adjust Grid Parameters
Grid_Resolution_Horizontal = 4
Grid_Resolution_Vertical = 5

#For the client
IP = '192.168.1.2'

Client = M.Make_Client(IP)

WFH_Start = M.Read(Client, WFH_Tag)
WFV_Start = M.Read(Client, WFV_Tag)

######
#Walking us to our starting point
######

for i in range(1, Grid_Resolution + 1):
    WFH_Write_Value = WFH_Start - i/2 * (Horizontal_Delta/Grid_Resolution)
    WFV_Write_Value = WFV_Start + i/2 * (Vertical_Delta/Grid_Resolution)
    
    M.Write(Client, WFH_Tag, WFH_Write_Value)
    M.Write(Client, WFV_Tag, WFV_Write_Value)
    
WFH_Corner = M.Read(Client, WFH_Tag)
WFV_Corner = M.Read(Client, WFV_Tag)
Exemple #6
0
    position of the cathode. This data is used to determine the strength 
    of our accelerating fields and to help determine running parameters.
    
Example of how to use it:
    - Run it
'''

import Master as M
import Tag_Database as Tags
import numpy as np
import matplotlib.pyplot as plt
import time

time_1 = time.time()
Client = M.Make_Client("10.50.0.10")
M.Read(Client, Tags.WF1H
       )  #Arbitrary read to establish trust (I think this part is weird to me)

################################################################
### Initialize #################################################
################################################################

V0_resolution = 50  #Resolution of steps taken in both cutoff measurements
Num_sawtooths_1 = 1  #number of points taken in the first cutoff
Num_sawtooths_2 = 1  #second cutoff

################################################################
### Grab the operator input of V0 ranges #######################
################################################################

##V0_1 = float(input("V0 Setpoint 1  "))
##V0_2 = float(input("V0 Setpoint 2  "))
Exemple #7
0
import Master as M
import numpy as np
import Tag_Database as Tags
import os
import time
os.system("Color 8a")
variables = vars(Tags)
variables = np.array(list(variables.items()))
variables = variables[117:]
while True:
    Client = M.Make_Client("10.50.0.10")
    for item in variables:
        print(item[0] + ": ",round(M.Read(Client, item[1]), 3))
    Client.close()
    time.sleep(30)
    os.system('cls') 
Exemple #8
0
WFH_Tag = 20203
WFV_Tag = 20201
Read_Tag = 11109

Horizontal_Delta = .4
Vertical_Delta = .4

Grid_Resolution = 10
Resolution = 40

IP = '192.168.1.2'

Client = M.Make_Client(IP)

WFH_Start = M.Read(Client, WFH_Tag)
WFV_Start = M.Read(Client, WFV_Tag)

######
#Walking us down to the start of our diagonal
######

for i in range(1, Grid_Resolution + 1):
    WFH_Write_Value = WFH_Start - i * (Horizontal_Delta / Grid_Resolution)
    WFV_Write_Value = WFV_Start - i * (Vertical_Delta / Grid_Resolution)

    M.Write(Client, WFH_Tag, WFH_Write_Value)
    M.Write(Client, WFV_Tag, WFV_Write_Value)

WFH_Mid = M.Read(Client, WFH_Tag)
WFV_Mid = M.Read(Client, WFV_Tag)
import Master as M
import time
import Tag_Database as Tags
import matplotlib.pyplot as plt

Client = M.Make_Client('10.50.0.10')

times = list()

for _ in range(1000):

    start_time = time.time()

    Tag1 = M.Read(Client, Tags.WF1H)

    M.Write(Client, Tags.WF1H, 0)

    times.append(1000 * (time.time() - start_time))

plt.hist(times)
plt.xlabel('time (ms)')
plt.ylabel('counts')

plt.show()
#Window Frames Horizontal

WF6H_Tag = Tags.WF6H  #The tag for Window Frame 6 Horizontal
WF7H_Tag = Tags.WF7H  #The tag for Window Frame 7 Horizontal

WF6V_Tag = Tags.WF6V  #Window Frame 6 Vertical Tag
WF7V_Tag = Tags.WF7V  #Window Frame 7 Vertical Tag

###################################################################################################

### End of User Defined Variables

###################################################################################################

WF6H_Start = M.Read(Client,
                    WF6H_Tag)  #Starting value for Window Frame 6 Horizontal
WF7H_Start = M.Read(Client,
                    WF7H_Tag)  #Starting value for Window Frame 7 Horizontal

WF6V_Start = M.Read(Client,
                    WF6V_Tag)  #Starting value for Window Frame 6 Horizontal
WF7V_Start = M.Read(Client,
                    WF7V_Tag)  #Starting value for Window Frame 7 Horizontal

start_time = time.time()

#Summing the start current of the two dumps
Start_Current = (
    M.Read(Client, Target_Tag, Average=True, count=count, sleep_time=sleep) +
    M.Read(Client, Target_Tag_2, Average=True, count=count, sleep_time=sleep))
Exemple #11
0
def Toggle(Client, Tag_Number):

    M.Write(Client, Tag_Number, (M.Read(Client, Tag_Number) == False))

    return
Exemple #12
0
import numpy as np
import Master as M
import Tag_Database as Tags

Client = M.Make_Client('192.168.1.2')

Status = (M.Read(Client, '00015') == True)


def Toggle(Client, Tag_Number):

    M.Write(Client, Tag_Number, (M.Read(Client, Tag_Number) == False))

    return
Exemple #13
0
******* Changes to Master File -- Gather() added inital_values for speed
******* Changes to Tag Database -- Added BH Pf slider bar params (bottom)

'''

import Master as M
import Tag_Database as Tags
import numpy as np
import matplotlib.pyplot as plt
import time
from datetime import datetime

time_1 = time.time()
Client = M.Make_Client("10.60.0.11")
M.Read(Client, Tags.WF1H
       )  #Arbitrary read to establish trust (I think this part is weird to me)

################################################################
### Initialize #################################################
################################################################

number_of_points = 50  #Resolution of steps taken in both cutoff measurements
Num_sawtooths_1 = 6  #number of points taken in the first cutoff
Num_sawtooths_2 = 6  #second cutoff
Ratio_From_Start = 0.8  #The amount to move the slider bar back up after running

################################################################
### Grab the operator input of V0 ranges #######################
################################################################

V0_1 = float(input("V0 Low Cutoff 2  "))
WF6H_Tag = Tags.WF6H #The tag for Window Frame 6 Horizontal
WF7H_Tag = Tags.WF7H #The tag for Window Frame 7 Horizontal

WF6V_Tag = Tags.WF6V #Window Frame 6 Vertical Tag
WF7V_Tag = Tags.WF7V #Window Frame 7 Vertical Tag

EC_Tag = Tags.Emitted_Current

###################################################################################################

### End of User Defined Variables

###################################################################################################

WF6H_Start = M.Read(Client,WF6H_Tag) #Starting value for Window Frame 6 Horizontal
WF7H_Start = M.Read(Client,WF7H_Tag) #Starting value for Window Frame 7 Horizontal

WF6V_Start = M.Read(Client,WF6V_Tag) #Starting value for Window Frame 6 Horizontal
WF7V_Start = M.Read(Client,WF7V_Tag) #Starting value for Window Frame 7 Horizontal

EC = M.Read(Client, EC_Tag)

start_time = time.time()

#Summing the start current of the two dumps
Start_Current = (M.Read(Client, Target_Tag, Average = True, count = count,sleep_time = sleep) + M.Read(Client, Target_Tag_2, Average = True, count = count,sleep_time = sleep))
    
H_Broken = False #Creating the check tag for the Horizontal dog leg, starting out as false as no errors could have been raised yet
V_Broken = False #Creating the check tag for the Vertical dog leg, starting out as false as no errors could have been raised yet
Exemple #15
0
    config_file_path, "Dog Leg")

print(Tunnel)
if Tunnel.lower() == 'west':
    import Tag_Database_West as Tags
elif Tunnel.lower() == 'east':
    import Tag_Database_East as Tags
else:
    import Tag_Database as Tags

#####################################################################
# Connect to PLC & gather start values
#####################################################################
Client = M.Make_Client(PLC_IP)

Pulsing_Status = bool(M.Read(Client, Tags.Pulsing_Output,
                             Bool=True))  #Detects whether pulsing or not

if Pulsing_Status:
    count = pulsing_count  #Integer. How many points will be recorded at each step and averaged over if pulsing
    sleep_time = 0.010  #Float.(S) time between averaged reads
else:
    count = count  #Non-pulsing count of avg
    sleep_time = 0.010  #Non-pulsing sleep

#WF6H_Tag, WF7H_Tag, WF6V_Tag, WF7V_Tag = Tags.WF6H, Tags.WF7H, Tags.WF6V, Tags.WF7V #6 and 7 dog leg
WF6H_Tag, WF7H_Tag, WF6V_Tag, WF7V_Tag = Tags.WF6H, Tags.WF7H, Tags.WF6V, Tags.WF7V  #16 and 17 dog leg

WF6H_Start = M.Read(Client, WF6H_Tag)
WF7H_Start = M.Read(Client, WF7H_Tag)
WF6V_Start = M.Read(Client, WF6V_Tag)
WF7V_Start = M.Read(Client, WF7V_Tag)
Exemple #16
0
#Window Frames Horizontal

WF12H_Tag = Tags.WF12H #The tag for Window Frame 12 Horizontal
WF13H_Tag = Tags.WF13H #The tag for Window Frame 13 Horizontal

WF12V_Tag = Tags.WF12V #Window Frame 12 Vertical Tag
WF13V_Tag = Tags.WF13V #Window Frame 13 Vertical Tag

###################################################################################################

### End of User Defined Variables

###################################################################################################

WF12H_Start = M.Read(Client,WF12H_Tag) #Starting value for Window Frame 12 Horizontal
WF13H_Start = M.Read(Client,WF13H_Tag) #Starting value for Window Frame 13 Horizontal

WF12V_Start = M.Read(Client,WF12V_Tag) #Starting value for Window Frame 12 Horizontal
WF13V_Start = M.Read(Client,WF13V_Tag) #Starting value for Window Frame 13 Horizontal

start_time = time.time()

#Summing the start current of the two dumps
Start_Power = M.Read(Client, Target_Tag, Average = True, count = count,sleep_time = sleep)
    
H_Broken = False #Creating the check tag for the Horizontal dog leg, starting out as false as no errors could have been raised yet
V_Broken = False #Creating the check tag for the Vertical dog leg, starting out as false as no errors could have been raised yet

###################################################################################################
import GPIB_FUNCS as GPIB #Importing our GPIB communication functions for easier comprehension and use
import pyvisa #import GPIB communication module
import time #imports time to sleep program temporarily
import Master as M
import Tag_Database as Tags

Client = M.Make_Client('10.50.0.10') #Connecting to PLC


print(M.Read(Client, Tags.Oscope_Reset, Bool = True))
print(M.Read(Client, Tags.Regulation_Setpoint_Reset, Bool = True))
print(M.Read(Client, Tags.Error_Signal_Regulation, Bool = True))
print(M.Read(Client, Tags.Pulsing_Output, Bool = True))
#for i in range(100):
#    M.Write(Client,55555, i)
#    print(i)
#    time.sleep(0.1)


#Pulsing_Tag = Tags.Pulsing_Output #Assign Modbus address here
Running_Tag = Tags.Error_Signal_Regulation #Assign Modbus address here
#Reset_Tag = Tags.Error_Signal_Reset #Assign Modbus address here
#Regulation_Setpoint_Tag = Tags.Regulation_Setpoint_Reset #Assign Modbus address here

RM = pyvisa.ResourceManager() #pyVISA device manager
Resources = RM.list_resources() #Printing out all detected device IDs
print(Resources)
SG = RM.open_resource("GPIB0::10::INSTR")
OS = RM.open_resource("GPIB0::16::INSTR")
time.sleep(2)
import Master as M
import numpy as np
import Tag_Database as Tags
import os
import time

Client = M.Make_Client("10.50.0.10")

M.Read(Client, Tags.CU_V)

start = 134

os.system("Color 8a")
variables = vars(Tags)
variables = np.array(list(variables.items()))
variables = variables[start:]
#variables[:,1] = variables[:,1].astype(int)
#variables = variables[variables[:,1].argsort()]
Tag_List = []
for item in variables:
    if "Emitted_Current" in item[0]:
        Tag_List.append([item[1], True])
    else:
        Tag_List.append([item[1], False])

while True:
    temp_list = []
    a = time.time()
    temp_list.append(M.Gather(Client, Tag_List, count=20, sleep_time=0.010))
    os.system('cls')
    print(time.time() - a)
Exemple #19
0
    Coupler_Shoulder, Solenoid_4_Temp, Solenoid_5_Temp
]

DST_Conversion = 3
if time.localtime().tm_isdst == 1:
    DST_Conversion = 4

Client = M.Make_Client("10.50.0.10")

while True:
    start_time = time.time()

    temp_list = [time.time() * 10**3 - DST_Conversion * 60 * 60 * 1000]

    for Tag in Vacuums:
        temp_list.append(M.Read(Client, Tag))

    file = open("Data.txt", 'a')
    file.write(str(temp_list).strip("[]") + "\n")
    file.close()
    with open("Data.txt", "r+") as file:
        contents = file.readlines()
        if np.shape(contents)[0] > txt_file_length:
            file.seek(0)
            for num, j in enumerate(contents):
                if num != 1:
                    file.write(j)
            file.truncate()
    file.close()
    elapsed_time = time.time() - start_time
    print(elapsed_time)
Exemple #20
0
sleep_time = 10 #Float.(ms)Sleep for 20 ms, this is tested to not overload PLC or give redundant data
sleep = sleep_time/1000 #Setting the sleep time to ms


Delta_6 = 0.384/Zoom_In_Factor #Change in Window Frame 6 Values throughout the test, standard is 0.384 from Dog Leg Excel sheets (01/01/2020)
Delta_7 = 0.228/Zoom_In_Factor #Change in Window Frame 7 Values throughout the test, standard is 0.228 from Dog Leg Excel sheets (01/01/2020)

collected_list_H = [] #Storing values for the magnets throughout the Horizontal Dog Leg
collected_list_V = [] #Storing values for the magnets throughout the Vertical Dog Leg

#Window Frames Horizontal

WF6H_Tag = 20223 #The tag for Window Frame 6 Horizontal
WF7H_Tag = 20227 #The tag for Window Frame 7 Horizontal

WF6H_Start = M.Read(Client,WF6H_Tag) #Starting value for Window Frame 6 Horizontal
WF7H_Start = M.Read(Client,WF7H_Tag) #Starting value for Window Frame 7 Horizontal

WF6H_list = [] #Storing the values for the horizontal run for Window Frame 6
WF7H_list = [] #Storing the values for the horizontal run for Window Frame 7

start_time = time.time()

#Summing the start current of the two dumps
Start_Current = (M.Read(Client, Target_Tag, Average = True, count = 20,sleep_time = .010) + M.Read(Client, Target_Tag_2, Average = True, count = 20,sleep_time = .010))
    
H_Broken = False #Creating the check tag for the Horizontal dog leg, starting out as false as no errors could have been raised yet
V_Broken = False #Creating the check tag for the Vertical dog leg, starting out as false as no errors could have been raised yet

#######################################################################################################################
import matplotlib.pyplot as plt
from datetime import datetime
import time
import numpy as np
import Master as M
import Tag_Database as Tags

Client = M.Make_Client('10.50.0.10')


End_Value = float(input("What is the ending amperage that you want to ramp the magnet to? (Amps)   "))

#Grabbing all of our data for the system snapshot
#################################################
Pulsing_Status = bool(M.Read(Client, Tags.Pulsing_Output, Bool = True))
Emission_Setpoint = M.Read(Client, Tags.Emission_Set)

if Pulsing_Status:
    Emission_Actual = M.Read(Client, Tags.Emitted_Current, Average = True, count = 50, sleep_time = 0.010)
else:
    Emission_Actual = M.Read(Client, Tags.Emitted_Current, Average = True, count = 20, sleep_time = 0.010)
    
IR_Temp = M.Read(Client, Tags.IR_Temp)
VA_Temp = M.Read(Client, Tags.VA_Temp)
V0_Setpoint = M.Read(Client, Tags.V0_SP)
V0_Read = M.Read(Client, Tags.V0_Read)
Cathode_V = M.Read(Client, Tags.Voltage_Read)
Cathode_I = M.Read(Client, Tags.Current_Read)
Cathode_Z = M.Read(Client, Tags.Impedance_Read)
Cathode_P = M.Read(Client, Tags.Power_Read)
Exemple #22
0
# print(type(Tunnel), type(PLC_IP), type(os_address), type(Runs), type(Step_Size), type(count), type(Oscope))

Client = M.Make_Client(PLC_IP)

End_Value = float(
    input(
        "What is the ending amperage that you want to ramp the magnet to? (Amps)   "
    ))

now = datetime.today().strftime(
    '%y%m%d_%H%M%S'
)  #Taking the current time in YYMMDD_HHmm format to save the plot and the txt file

#Grabbing all of our data for the system snapshot
#################################################
Pulsing_Status = bool(M.Read(Client, Tags.Pulsing_Output, Bool=True))

Emission_Setpoint = M.Read(Client, Tags.Emission_Set)

if Pulsing_Status:
    Emission_Actual = M.Read(Client,
                             Tags.Emitted_Current,
                             Average=True,
                             count=pulsing_count,
                             sleep_time=0.010)
else:
    Emission_Actual = M.Read(Client,
                             Tags.Emitted_Current,
                             Average=True,
                             count=count,
                             sleep_time=0.010)
import Master as M
import Tag_Database as Tags
import time

Client = M.Make_Client('10.50.0.10')

print(M.Read(Client, Tags.RF_Beam_Mon))

time.sleep(0.01)

print(M.Read(Client, Tags.RF_Beam_Mon))

time.sleep(15)