// Logiscope Instrumentation function // Copyright (c) Kalimetrix 2014 // This file is an example of Intrumentation function // used socket solution to communicate with the // TestChecker Gateway (See TestChecker on line help // and documentation (\doc) to have more // information about the TestChecker Gateway). package jv; import java.io.* ; import java.lang.*; import java.net.*; public class VlgInstrument { static int Delay = 1000; // Modify this attribute if your instrumented application // is too slow or too speed. static Socket socket; static OutputStream output; static PrintWriter pw = null; static VlgInstrument me = new VlgInstrument(); public VlgInstrument() { try { socket = new Socket("localhost", 6309); // Change Hostname by your computer // name. output = socket.getOutputStream(); pw = new PrintWriter(output); pw.print("N"); pw.print('\n'); pw.flush(); } catch (UnknownHostException ue) { System.out.println("Unable to connect to host"); socket = null; output = null; pw = null; } catch (IOException io) { socket = null; output = null; pw = null; System.out.println("Unable to initialize connection"); } } protected synchronized void finalize() throws Throwable { if (pw == null) return; pw.flush(); pw.close(); pw = null; try { output.close(); } catch ( IOException ie) { } output = null; } static protected synchronized void wait(int msec) { int i; for (i = 0; i < msec; i++); } static public synchronized void ddp1(String name, String date) { if (pw == null) return; wait(Delay); pw.print(1); pw.print('\n'); pw.print(name); pw.print('\n'); pw.print(date); pw.print('\n'); pw.flush(); } static public synchronized boolean cond(String name, boolean cond, int ddp_true, int ddp_false) { if (pw == null) return cond; wait(Delay); pw.print("X"); pw.print('\n'); pw.print(name); pw.print('\n'); if(cond) pw.print(ddp_true); else pw.print(ddp_false); pw.print('\n'); pw.flush(); return cond; } static public synchronized void ddp(String name, int ddp) { if (pw == null) return; wait(Delay); pw.print("X"); pw.print('\n'); pw.print(name); pw.print('\n'); pw.print(ddp); pw.print('\n'); pw.flush(); } }