Package fb.rt

Source Code of fb.rt.Debug_FBInstance

package fb.rt;

import fb.datatype.ANY;
import fb.rt.Device;
import fb.rt.FBInstance;
import fb.rt.FBRManagementException;
import fb.rt.Resource;
import fb.xml.mgt.FBMData;
import fb.xml.mgt.FBMECC;
import fb.xml.mgt.FBMEvent;
import fb.xml.mgt.FBMRequest;

public class Debug_FBInstance extends FBInstance {

  protected static int id;

  protected String FBtype;

  protected Debug_CLT remoteClient;

  protected static final String DEBUG = "DEBUG";

  public static String remoteDebugHost = "localhost:61502";

  public Debug_FBInstance(){
    super();

    initDebugClient(remoteDebugHost);
  }

  protected void initDebugClient(String debugHost) {
    if (debugHost != null)
      remoteClient = new Debug_CLT(debugHost, "");
    else
      remoteClient = new Debug_CLT(remoteDebugHost, "");
    System.out.println("Init debug client: " + remoteDebugHost);
  }
 
  public void updateEvent(String s) {
    try {
      FBMRequest text = new FBMRequest(String.valueOf(id++), "DEBUG",
          new FBMEvent(s, FBtype, "true"));
      System.out.println(text.toXMLString().toString());
      remoteClient.setXML(text.toXMLString().toString());
      remoteClient.setUpConnection();
      remoteClient.writeOut();
      remoteClient.tearDownConnection();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }

  public void updateData(String s, String value) {
    try {
      FBMRequest text = new FBMRequest(String.valueOf(id++), "DEBUG",
          new FBMData(s, FBtype, value));
      System.out.println(text.toXMLString().toString());
      remoteClient.setXML(text.toXMLString().toString());
      remoteClient.setUpConnection();
      remoteClient.writeOut();
      remoteClient.tearDownConnection();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }

  public void updateECC() {
    try {
      FBMRequest text = new FBMRequest(String.valueOf(id++), "DEBUG",
          new FBMECC(name, FBtype, String.valueOf(eccState)));
      System.out.println(text.toXMLString().toString());
      remoteClient.setXML(text.toXMLString().toString());
      remoteClient.setUpConnection();
      remoteClient.writeOut();
      remoteClient.tearDownConnection();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }

  public String getFBType() {
    return FBtype;
  }

  public void setType(String type) {
    if (FBtype != null)
      FBtype = (new StringBuilder(String.valueOf(type))).append(".")
          .append(FBtype).toString();
    else
      FBtype = type;
  }
}
TOP

Related Classes of fb.rt.Debug_FBInstance

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.