Skip to content

Commit

Permalink
Integration with Hop V2.X.X in progress. Action and Transform Read, W…
Browse files Browse the repository at this point in the history
…rite and Events are working, Subscription is missing due to S7 driver problems. The resources for modification are added to the portal.
  • Loading branch information
ceos01 committed Apr 28, 2023
1 parent 9ddf709 commit fd4bf09
Show file tree
Hide file tree
Showing 41 changed files with 1,355 additions and 211 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ atlassian-ide-plugin.xml
*.tar.gz
*.rar


# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1615,8 +1615,6 @@ public enum BACnetVendorId {
THING_WAREHOUSELLC((int) 1404, (int) 1404, (String) "Thing Warehouse LLC"),
INNOFRIENDS_GMBH((int) 1405, (int) 1405, (String) "Innofriends GmbH"),
METRONICAKP_SPJ((int) 1406, (int) 1406, (String) "Metronic AKP Sp. J."),
<<<<<<< HEAD

TECHKNAVE((int) 1407, (int) 1407, (String) "Techknave"),
ELSNER_ELEKTRONIK((int) 1408, (int) 1408, (String) "Elsner Elektronik"),
LEFOO_INDUSTRIAL_HANGZHOU_CO_LTD(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
* @author cgarcia
*/
@HopMetadata(
key = "Xplc4xconnection",
name = "PLC4x Connection",
key = "Xplc4xaction",
name = "PLC4x Action",
description = "A shared PLC4x connection to a PLC",
image = "plc4x_toddy.svg",
documentationUrl = "/metadata-types/neo4j/neo4j-connection.html")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,32 @@


import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.hop.core.Const;
import org.apache.hop.core.exception.HopException;
import org.apache.plc4x.hop.metadata.Plc4xConnection;
import org.apache.plc4x.java.DefaultPlcDriverManager;
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
import org.w3c.dom.Node;


@Action(
id = "CHECK_PLC4X_CONNECTIONS",
name = "i18n::Plc4xAction.Name",
description = "i18n::Plc4xAction.Description",
name = "i18n::Plc4xActionConnections.Name",
description = "i18n::Plc4xActionConnections.Description",
image = "plc4x_toddy.svg",
categoryDescription = "i18n:org.apache.hop.workflow:ActionCategory.Category.Conditions",
keywords = "i18n::Plc4xAction.keyword",
documentationUrl = "/workflow/actions/checkdbconnection.html")
keywords = "i18n::Plc4xActionConnections.keyword",
documentationUrl = "/workflow/actions/plc4x.html")
public class Plc4xCheckConnections extends ActionBase implements Cloneable, IAction {
private static final Class<?> PKG = Plc4xCheckConnections.class; // Needed by Translator


private Plc4xConnection[] connections;
private boolean connected = false;
private PlcConnection plcconn = null;

protected static final String[] unitTimeDesc =
new String[] {
Expand Down Expand Up @@ -241,17 +248,41 @@ public void loadXml( Node entrynode, IHopMetadataProvider metadataProvider, IVar
}

/**
* Execute this action and return the result. In this case it means, just set the result boolean in the Result
* Execute this action and return the result.
* In this case it means, just set the result boolean in the Result
* class.
*
* @param result The result of the previous execution
* Check all conections metadata from the dialog.
* @param prevResult The result of the previous execution
* @return The Result of the execution.
*/
@Override
public Result execute( Result result, int nr ) {
result.setResult(true);
System.out.println("NR: " + nr);

public Result execute( Result prevResult, int nr ) {
Result result = prevResult;
result.setNrErrors(0);
connected = true;
for (Plc4xConnection connmeta:connections) {
try {
plcconn = new DefaultPlcDriverManager().getConnection(connmeta.getUrl()); //(01)
if (!plcconn.isConnected()) {
logBasic("Cant connect to: " + connmeta.getUrl());
connected = false;
plcconn = null;
//break;
}
plcconn.close();
plcconn = null;
} catch (Exception ex) {
Logger.getLogger(Plc4xCheckConnections.class.getName()).log(Level.SEVERE, null, ex);
connected = false;
plcconn = null;
//break;
} finally {

}

}

result.setResult(connected);
return result;
}

Expand All @@ -268,4 +299,23 @@ public Result execute( Result result, int nr ) {
public void check( List<ICheckResult> remarks, WorkflowMeta workflowMeta, IVariables variables,
IHopMetadataProvider metadataProvider ) {
}

@Override
public boolean resetErrorsBeforeExecution() {
return false;
}

@Override
public boolean isEvaluation() {
return true;
}

@Override
public boolean isUnconditional() {
return false;
}




}
Loading

0 comments on commit fd4bf09

Please sign in to comment.