Re JAVA MACROS
Hi all
I am designing a adaptive controller which takes input from 2 reports(at two points in flow) and then apply the FIR algorithm in order to get minimum error to adapt for system changes. For this I need to write a java macro . I have written a macro for this as shown below but it is showing the message Run Time Error Plz help. package macro; import java.util.*; import star.common.*; import star.base.neo.*; import star.base.report.*; import star.common.ImplicitUnsteadySolver; import star.common.PhysicalTimeStoppingCriterion; public class Testing extends StarMacro { public void execute() { execute0(); } private void execute0() { Simulation simulation_0 = getActiveSimulation(); MaxReport maxReport_1 = ((MaxReport) simulation_0.getReportManager().getReport("Maximum 3")); // Reads data of error microphone to file MaxReport maxReport_2 = ((MaxReport) simulation_0.getReportManager().getReport("Maximum 1")); PhysicalTimeStoppingCriterion maxTimeStoppingCriterion = (PhysicalTimeStoppingCriterion) simulation_0.getSolverStoppingCriterionManager().g etSolverStoppingCriterion("Maximum Physical Time"); maxTimeStoppingCriterion.getMaximumTime().setValue (80.0); // Change maximum physical time here double X[]={0,0,0,0,0,0,0,0,0,0}; double err=0; double mu=0.01; double w[]={0,0,0,0,0,0,0,0,0,0}; double d[]={0,0,0,0,0,0,0,0,0,0}; double timeStep = ((ImplicitUnsteadySolver) simulation_0.getSolverManager().getSolver(Implicit UnsteadySolver.class)).getTimeStep().getValue(); do { if (simulation_0.getSolution().getPhysicalTime() > 0) // Change Solution time after which macro is to be executed { X=d; double currentNoise=maxReport_1.getReportMonitorValue(); double inputNoise=maxReport_2.getReportMonitorValue(); d[1]=inputNoise; double op1=currentNoise; double op2=0; for (int j=1;j<11;j++) { op2 = op2 + w[j]*d[j]; } err=op1-op2; for (int j=1;j<11;j++) { w[j] = w[j] + 2.0*mu*err*X[j]; } for(int j=10;j>1;j--) { d[j] = d[j-1]; } } simulation_0.getSimulationIterator().step(1); } while (!maxTimeStoppingCriterion.getIsSatisfied()); } } |
Can you please post the error message that you get.
Did you make sure, that all reports have the correct input parts to deliver reasonable values? Do the reports have the correct Representation applied? |
All times are GMT -4. The time now is 16:55. |