Showing results for 
Search instead for 
Do you mean 
Reply

Plant Simulation DDE connect with Java as Client

It is my first post, I hope it is so right. I would like to establish a connection between Java and Plant Simulation wie Dynamic Data Exchange. Java as server works, unfortunately Java as client does not work. I have tired with Excel as a client to see what happens, as I  Plant Simulation as a server return a message (see photo). 

 

 

 

Screen.jpg

 

 

 

My question is how can I get it to switch System,Data or Info. 

I've tried it like this:


final DDEClientConversation conversation = new DDEClientConversation();

conversation.connect("eM-Plant", "data");


conversation.execute("XXXXXXXXXX");

 

 

Unfortunately, I do not know what I should enter into the brackets. l have tried many variants, but without success. I hope you can help me.

 

 

Greeting Özcan M.

6 REPLIES

Re: Plant Simulation DDE connect with Java as Client

[ Edited ]

Hello Oezcan,

In your Excel example you have to specify the second argument to DDEInitiate as string:

DDEInitiate("em-plant", "data")

In your Java code just also use the request method instead of execute. Here you can then pass the path to a variable in Plant Simulation:

conversation.request("InformationFlow.Variable")

 

Regards,

Ralf

Re: Plant Simulation DDE connect with Java as Client

[ Edited ]
Hello,
 
thank you for the fast answer.
I use the command
System.out.println(conversation.request(".Netzwerk.Variable"));
but without success, because it can not be run since no connection to the server (Plant Simulation) is established.
 
I think that the error is the plant simulation a request sends as with Excel (see photo from the last post).
How is it possible to confirm the request e.g. EM-Plant | Data?
 
I tried it with her command, without succes.
conversation.execute("eM-Plant|data");
The completly command.
package dde;

import com.pretty_tools.dde.DDEException;
import com.pretty_tools.dde.DDEMLException;
import com.pretty_tools.dde.client.DDEClientConversation;

public class JClient
{
public static void main(String[] args)
{
try
{

final DDEClientConversation conversation = new DDEClientConversation();

conversation.setTimeout(3000);

conversation.connect("eM-Plant", "data");

conversation.execute("eM-Plant|data");



try
{
System.out.println(conversation.request(".Netzwerk.Variable"));


}
finally
{
conversation.disconnect();
}
}
catch (DDEMLException e)
{
System.out.println("DDEMLException: 0x" + Integer.toHexString(e.getErrorCode()) + " " + e.getMessage());
}
catch (DDEException e)
{
System.out.println("DDEClientException: " + e.getMessage());
}
catch (Exception e)
{
System.out.println("Exception: " + e);
}
}
}

  Thanke you! Best regards

 

Özcan M.

 

Re: Plant Simulation DDE connect with Java as Client

The following code works fine in Excel:

Sub Macro1()
    Dim Kanal As Long
    Dim Wert As Variant
    
    Kanal = DDEInitiate("em-plant", "data")
    Wert = DDERequest(Kanal, ".InformationFlow.Variable")
    ActiveCell.FormulaR1C1 = Wert(1)
    DDETerminate (Kanal)
End Sub

So I guess the problem is in the Java code. Since I'm not a Java expert, I cannot help you here.

 

Regards,

Ralf

Re: Plant Simulation DDE connect with Java as Client

Sorry for the late answer.

The code works fine with Excel, but the problem with Java is still, so I decided to use the com interface. 

 

 

 

 

Regards,

 

Özcan

Re: Plant Simulation DDE connect with Java as Client / COM-Port

[ Edited ]

Hello, I have looked at the help of Plant Simulation. There is described the Plant simulation can be controlled by COM interface via the name "Tecnomatix.PlantSimulationRemoteControl.13.0" and the ActiveX should enable it. But I did not understand how it could run. Can you give me a note?

 

Edit:

I have created a new method and have inserted the following lines :


var eMPlant = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.13.0")

eMPlant.setVisible(true);

 

I wanted to reach the Com port for other programs visible, but always comes a error message.

How is it possible that I can open the COM port?

 

 

 

Thanks

 

Regards

 

Özcan

Re: Plant Simulation DDE connect with Java as Client / COM-Port

Plant Simulation offers a COM interface which is not related to the Active/X interface of the interface package.

 

The code you posted is JavaScript code and should work if you execute it using cscript.exe.

Regards,

Ralf