-> Hier kostenlos registrieren
Hallo, ich bin ein neuer Benutzer, ich bin hier, um um Hilfe zu bitten, um mit einer Siemens S7-1200/1500-SPS über die ACCON AGLInk-Bibliothek zu kommunizieren, indem ich eine Anwendung in Java schreibe.
Ich habe keine echte SPS, ich simuliere eine S7-1500 über PCL SIM 3.0 Advanced, ich habe die Konfiguration über TIA V14 hochgeladen.
Mit dem geschriebenen Code kann ich eine Verbindung zur PCL herstellen und einige Informationen lesen, aber ich erhalte den Fehler „Timeout“, wenn ich versuche, symbolic_LoadAGLinkSymbolsFromPLC auszuführen.
Entschuldigung für das schlechte Deutsch, aber ich spreche/schreibe es nicht und ich habe einen Übersetzer benutzt
Danke
Ich habe keine echte SPS, ich simuliere eine S7-1500 über PCL SIM 3.0 Advanced, ich habe die Konfiguration über TIA V14 hochgeladen.
Mit dem geschriebenen Code kann ich eine Verbindung zur PCL herstellen und einige Informationen lesen, aber ich erhalte den Fehler „Timeout“, wenn ich versuche, symbolic_LoadAGLinkSymbolsFromPLC auszuführen.
Java:
package accon.aglink;
import java.io.File;
import de.deltalogic.accon.aglink4.AgLink;
import de.deltalogic.accon.aglink4.AglConnTypeEx;
import de.deltalogic.accon.aglink4.AglPlcClassEx;
import de.deltalogic.accon.aglink4.AglPlcConnection;
import de.deltalogic.accon.aglink4.AglS7_TcpIPTia_1;
import de.deltalogic.accon.aglink4.AglTiaProtectionLevel;
import de.deltalogic.accon.aglink4.Agl_S7_TCPIP_TIA;
public class Main {
public static void main(String[] args) {
try
{
// TODO: insert valid values
String resulting_agl_file = "C:\\temp\\saved_symbols.agl";
String plc_ip_address = "192.168.5.101";
connectToPlcAndDownLoadSymbols(plc_ip_address, resulting_agl_file);
}
catch (Exception e)
{
System.out.println("ERROR in main");
e.printStackTrace();
}
}
private static void connectToPlcAndDownLoadSymbols(String plc_ip_address, String agl_file) throws Exception {
// Activate your license
AgLink.activate("123456-12345-123456");
final int device = 0; // Used ACCON-AGLink device
final int plcNr = 2; // Used PlcNr (free Number for TCP/IP)
final int TIMEOUT_MS = 30000;
// Option 1:
// Load connection settings from AGLink40CfgDev0000.xml. Generate this
// file with AGLink40_Config.exe
// Set the path to your AGLink connection configuration files (xml) if
// necessary
// AgLink.setParaPath("PathToAGLink40CfgDev0000.xml");
// Option 2:
// Set connection settings in code:
Agl_S7_TCPIP_TIA lanSettings = new Agl_S7_TCPIP_TIA();
AglS7_TcpIPTia_1 tia_connection = new AglS7_TcpIPTia_1();
tia_connection.Address = plc_ip_address; // IP Address of the PLC
tia_connection.bConnTypeEx = AglConnTypeEx.CT_HMI;
tia_connection.bPLCClassEx = AglPlcClassEx.PLCEx_AUTO_TIA;
tia_connection.lTimeOut = TIMEOUT_MS;
tia_connection.wPlcNr = plcNr;// Used PlcNr
lanSettings.addPlcAddress(tia_connection);
// Prepare the device with settings above
AgLink.setParas(device, lanSettings);
// Create new AglPlcConnection instance using device 0 and PlcNr 2
AglPlcConnection plcConnection = new AglPlcConnection(device, plcNr);
// Connect to your desired PLC that contains the TIA project that you
// configured for access.
System.out.println("Establishing connection...");
plcConnection.connect();
System.out.println("Connected.");
// Optional: Get the MLFB to confirm that we established the connection
// to the right PLC.
String mlfb = plcConnection.readMLFBNr();
System.out.println(String.format("MLFB Nr of connected PLC: '%s'", mlfb));
// Download all symbols from the PLC, save the symbols in memory
System.out.println("GetCurrentProtectionLevel...");
AglTiaProtectionLevel protection = plcConnection.symbolic_GetCurrentProtectionLevel();
System.out.println(protection.toString());
System.out.println("Start download...");
long root_handle = plcConnection.symbolic_LoadAGLinkSymbolsFromPLC();
assert (root_handle != 0);
System.out.println("download done.");
// Disconnect from PLC
System.out.println("Disconnecting...");
plcConnection.disConnect();
System.out.println("Disconnected.");
// Save the symbols in a binary file.
System.out.println("Save symbols to file...");
AgLink.symbolic_SaveAGLinkSymbolsToFile(root_handle, agl_file);
System.out.println("Save symbols to file done");
if (new File(agl_file).exists()) {
System.out.println(String.format("AGL file '%s' created", agl_file));
System.out.println(
String.format("Downloaded file can be loaded back to memory with AgLink.symbolic_LoadAGLinkSymbolsFromFile(\"%s\"); ", agl_file));
} else {
System.out.println(String.format("AGL file '%s' not created", agl_file));
}
// Free the memory
AgLink.symbolic_FreeHandle(root_handle);
}
}
Kannst du mir helfen?Connected.
MLFB Nr of connected PLC: '6ES7 SIM-01500-APLC'
GetCurrentProtectionLevel...
PROTECTION_LEVEL_FULL_ACCESS_WITHOUT_FAILSAFE
Start download...
ERROR in main
de.deltalogic.accon.aglink4.AglIOException: Method: 'symbolic_LoadAGLinkSymbolsFromPLC', Error Code: 'AGL40_TIMEOUT', Error Nr: '0xFFF50004', Error Message: 'Timeout',
at de.deltalogic.accon.aglink4.AglPlcConnection.symbolic_LoadAGLinkSymbolsFromPLC(AglPlcConnection.java:1542)
at accon.aglink.Main.connectToPlcAndDownLoadSymbols(Main.java:89)
at accon.aglink.Main.main(Main.java:23)
Entschuldigung für das schlechte Deutsch, aber ich spreche/schreibe es nicht und ich habe einen Übersetzer benutzt
Danke