But if i try to run it by my customer everythink runs well till the "itemId" is added to the access object.
From this moment nothing else happen (no errorcode, no exception). I implemented an counter to see if the procedure is working but without any success.
I can reproduce this behavior if i write the wrong "itemId" in my testscenario but the "itemId's" should be ok couse i use the same like in the Matrikon Explorere.
Please have you any idea, i am working on this problem since days without any success.
public void doConnect() {
try {
final ConnectionInformation ci = new ConnectionInformation();
ci.setHost(this.utut.txt_host.getText());
ci.setDomain(this.utut.txt_domain.getText());
ci.setUser(this.utut.txt_user.getText());
ci.setPassword(this.utut.txt_password.getText());
if(utut.chb_useId.isSelected()){
ci.setClsid(this.utut.txt_clsId.getText());
}else{
ci.setProgId(this.utut.txt_progId.getText());
}
final String itemId = this.utut.txt_itemId.getText();
// create a new server
final Server server = new Server(ci, Executors.newSingleThreadScheduledExecutor());
// connect to server
output.append("try to connect");
output.append("\n");
utut.txt_Output.setText(output.toString());
server.connect();
output.append("connected succesfully \n");
utut.txt_Output.setText(output.toString());
// add sync access, poll every 500 ms
AccessBase access;
access = new SyncAccess(server, 1000);
output.append("new access created \n");
utut.txt_Output.setText(output.toString());
output.append("new DataCallback will be created now \n");
utut.txt_Output.setText(output.toString());
access.addItem(itemId, new DataCallback() {
int counter = 0;
@Override
public void changed(Item item, ItemState state) {
output.append(state.toString());
output.append("\n");
output.append(String.valueOf(counter));
output.append("\n");
utut.txt_Output.setText(output.toString());
counter++;
}
});
// start reading
output.append("Start reading \n");
utut.txt_Output.setText(output.toString());
access.bind();
// wait a little bit
Thread.sleep(30 * 1000);
output.append("Stop reading \n");
utut.txt_Output.setText(output.toString());
// stop reading
access.unbind();
output.append("Connection closed \n");
utut.txt_Output.setText(output.toString());
} catch ( Exception e) {
// System.out.println(String.format("%08X: %s", ((JIException) e).getErrorCode(), server.getErrorMessage(((JIException) e).getErrorCode())));
// output.append(e.getMessage());
Writer writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
e.printStackTrace(printWriter);
String s = writer.toString();
utut.txt_Error.setText(s);
}