示例#1
0
    except:
        print("Error grabbing data from {}".format(Amp_IP))
        print("Detected Names: {} Detected Values: {}".format(
            len(Values), len(Names)))

        continue

    #############################
    ## Write to the PLC
    #############################

    Values = np.array([float(Value) for Value in Values[1:]])

    try:

        M.Write_Multiple(Client, Tag_List[0],
                         Values)  #Writing all of the values to the PLC

    except:

        print("Write to PLC failed...")
        print("Waiting...")
        time.sleep(Sleep_Check_Time / 10)

        try:  #Try again with fresh connection
            M.Make_Client(PLC_IP)
            M.Write_Multiple(Client, Tag_List[0], Values)

        except:
            print("Write to PLC failed after {:.2f} second wait".format(
                Sleep_Check_Time / 10))
示例#2
0
    WFs = []  #Creating and emptying the list of WF values for the next write
    Sols = []  #Creating the list and the functionality just not using for now

    #Creating the correct sized list to input into the write_multiple function
    for _ in range(Dipole_Count):
        Dipoles.append(pre_scaled_value * Dipole_Amplitude)

    for _ in range(Window_Frame_Count * 2):  #Multiplied by two because we have
        #Horizontal and Vertical
        WFs.append(pre_scaled_value * WF_Amplitude)

    for _ in range(Solenoid_Count):
        Sols.append(pre_scaled_value * Sol_Amplitude)

    if testing == False:
        M.Write_Multiple(Client, Dipole_Start_Tag, Dipoles)
        M.Write_Multiple(Client, Window_Frame_Start_Tag, WFs)

        ##################################################
        #DO NOT UNCOMMENT UNTIL WE HAVE SOLENOID TOGGLING FUNCTIONALITY
        #M.Write_Multiple(Client, Solenoid_Start_Tag, Sols)
        ##################################################

        time.sleep(.05)

    else:
        continue

print("{0:.1f} Seconds to run".format(time.time() - Start_Time))

if plot == True: