import java.io.*; import java.util.*; import convert.*; import wrapper.*; public class TestModule2 extends CPAMMegamodule { public TestModule2(String p) {super(p);} protected void createParameters() { addParam("s1", new StringGentype("first text", "This is ")); addParam("s2", new StringGentype("second text", "a text!")); addParam("m1", new IntGentype("first operand",5)); addParam("m2", new IntGentype("second operand",7)); addParam("res", new IntGentype("result", 0)); } protected boolean makeEstimate(Estimates e, String methodname, ParamValueTableReader clientsettings) throws MethodNameException { if (methodname.equals("concat")) { e.feeValue = 50; e.feeProvided = true; e.timeValue = 50; e.timeAccuracy = 5; e.timeProvided = true; } else if (methodname.equals("mult")) { int m1=0, m2 =0; try{ m1=((IntGentype)clientsettings.get("m1")).getValue(); m2=((IntGentype)clientsettings.get("m2")).getValue(); } catch (Exception ex) {System.err.println(ex.getMessage()); ex.printStackTrace();} if (e.feeRequired) { e.feeProvided = true; e.feeValue = m1*m2; e.feeAccuracy = (float)e.feeValue / (float)10; } if (e.timeRequired) { e.timeProvided = true; e.timeValue = m1*40; e.timeAccuracy = (float)e.timeValue / (float)10;} if (e.datavolumeRequired) { e.datavolumeValue=m2; e.datavolumeProvided = true; e.datavolumeAccuracy = 0.5; } else if (methodname.equals("fast")) return false; } else throw new MethodNameException("Do not know this method."); return true; } protected boolean dispatchInvocation(CPAMWrapperCallbacks inv, String methodname) { try{ if (methodname.equals("concat")) { try{ String s1=((StringGentype)inv.getParam("s1")).getValue(); String s2=((StringGentype)inv.getParam("s2")).getValue(); Thread.sleep(30000); inv.updateInvocationProgress(49); Thread.sleep(30000); inv.updateParam("s1", new StringGentype("Concated string", s1+s2), true, 100); Thread.sleep(30000); return false; } catch (Exception e) {System.err.println(e.getMessage()); e.printStackTrace(); return false;} } else if (methodname.equals("mult")) { int m1=0, m2 =0; try{ m1=((IntGentype)inv.getParam("m1")).getValue(); m2=((IntGentype)inv.getParam("m2")).getValue(); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); return false; } inv.updateInvocationProgress(5); int res = 0; float acc=10; for (int i = 0; i