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 = list() DBA_Collection = list() colors = list() Oscope_Data = list() Oscope_Data_2 = list() print("Beginning Scan") for i in range(Runs): print("Going to target value") if Oscope.lower() == 'true': DP1_Vals, DBA_Col, Oscope, O2 = M.Ramp_One_Way(Client, Dipole_Tag, End_Value, Max_Step = Step_Size, Return = "Y", \ Read_Tag = Read, count = count, Oscope = Oscope, os_address = os_address) DP1_Values += DP1_Vals #Adding the recorded data to the lists DBA_Collection += DBA_Col Oscope_Data += Oscope Oscope_Data_2 += O2 else: DP1_Vals, DBA_Col = M.Ramp_One_Way(Client, Dipole_Tag, End_Value, Max_Step=Step_Size, Return="Y", Read_Tag=Read, count=count) DP1_Values += DP1_Vals #Adding the recorded data to the lists DBA_Collection += DBA_Col
#Reading in the excel file as a dataframe for easier access (abbreviated as df) excel_as_df = pd.read_excel( '..\Magnet Saves\{}.xlsx'.format(Notebook) ) #Using windows command line controls to direct python to the directory Client = M.Make_Client( '192.168.1.2' ) #Establishing a connection with the PLC, see Master.Make_Client for i in range( len(Hnums)): #Iterate through the list of Horizontal window frames print("Window Frame {} H".format(i + 1), Hnums[i], excel_as_df['WF H'].iloc[i]) #Print which magnet it is ramping M.Ramp_One_Way(Client, Hnums[i], excel_as_df['WF H'].iloc[i], Max_Step=0.010) #Ramp that magnet, see Master.Ramp_One_Way #Repeat for all types of magnets for i in range(len(Vnums)): print("Window Frame {} V".format(i + 1), Vnums[i], excel_as_df['WF V'].iloc[i]) M.Ramp_One_Way(Client, Vnums[i], excel_as_df['WF V'].iloc[i], Max_Step=0.010) for i in range(len(Solnums)): print("Solenoid {}".format(i + 1), Solnums[i], excel_as_df['Sol'].iloc[i]) M.Ramp_One_Way(Client, Solnums[i], excel_as_df['Sol'].iloc[i],
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) #The above function walks the magnet to the endpoint ,and returns the data DP1_Values += DP1_Vals #Adding the recorded data to the lists DBA_Collection += DBA_Col colors += ['chocolate' for i in list(range(len(DP1_Vals))) ] #Appending 'chocolate' as the color for this data set DP1_Vals, DBA_Col = M.Ramp_One_Way(Client, Dipole_Tag, Start_Value, Max_Step=Step_size,
Solnum = 9 #Number of solenoids Solnums = [] for i in range(100): if i < WFHnum: Hnums.append(20203 + 4 * i) if i < WFVnum: Vnums.append(20201 + 4 * i) if i < DPnum: Dpnums.append(22201 + 2 * i) if i < Solnum: Solnums.append(21201 + 2 * i) Client = M.Make_Client('192.168.1.2') for i in range(len(Hnums)): print("Window Frame {} H".format(i + 1)) M.Ramp_One_Way(Client, Hnums[i], 0, Max_Step=0.010) for i in range(len(Vnums)): print("Window Frame {} V".format(i + 1)) M.Ramp_One_Way(Client, Vnums[i], 0, Max_Step=0.010) for i in range(len(Solnums)): print("Solenoid {}".format(i + 1)) M.Ramp_One_Way(Client, Solnums[i], 0, Max_Step=0.010) for i in range(len(Dpnums)): print("Dipole {}".format(i + 1)) M.Ramp_One_Way(Client, Dpnums[i], 0, Max_Step=0.005)