
- •Опис застосування програми bluej
- •3 Настанова з інсталяції програми
- •4 Технологія розробки програмного додатку
- •4.1 Розробка класу для завантаження налаштувань
- •4.2 Розробка класу регулятора
- •4.3 Розробка головного класу додатку
- •4.4 Проектування графічного інтерфейсу
- •4.4.1 Розмітка інтерфейсу вікон програми
- •4.5 Розробка класу дляреалізації графічного інтерфейсу
- •Висновок
- •Список використаної літератури
- •Додаток а. Програмний код для обробки xml файлу з налаштуваннями програми
- •Додаток б. Програмний код класу Controller
- •Додаток в. Програмний код класу Application
- •Додаток г. Програмний код класу gui
- •Додаток г. Програмний код класу Graph
- •Додаток e. Вхідні дані
- •Додаток ж. Файл «Object»
Додаток б. Програмний код класу Controller
import java.util.TimerTask;
import java.util.Timer;
import java.lang.Math.*;
import org.math.array.DoubleArray.*;
import static org.math.array.LinearAlgebra.*;
import java.io.*;
public class Controller extends TimerTask
{
private static int inputs, outputs, xsize;
private static double[][] ad, bd, c, d;
private static double[][] ar, br, cr;
private static double[][] z, f, u, u1, y, e, x, x1, xr, xr1;
private static double[] unom, fmax;
private static boolean manual=false;
private static boolean work=true;
private final String OBJECT_FILE="data/object.xml";
public static boolean getManual() {return manual;}
public static void setManual(boolean newVal) {manual=newVal;}
public static boolean getWork() {return work;}
public static void setWork(boolean newVal) {work=newVal;}
public static double getY(int output) {return y[output][0];}
public static double getU(int input) {return u[input][0];}
public static void setU(double val,int input) {u[input][0]=val;}
public static double getZ(int output) {return z[output][0];}
public static void setZ(double val,int output) {z[output][0]=val;}
public Controller (int p_inputs, int p_outputs,int p_xsize, double[][] p_ad, double[][] p_bd,double[][] p_c, double[][] p_d, double[][] p_ar, double[][] p_br,double[][] p_cr,
double[] p_fmax,double[] p_unom)
{
this.inputs=p_inputs;
this.outputs=p_outputs;
this.xsize=p_xsize;
this.ar=p_ar;
this.ad=p_ad;
this.br=p_br;
this.bd=p_bd;
this.cr=p_cr;
this.c=p_c;
this.d=p_d;
this.fmax=p_fmax;
this.unom=p_unom;
/**
Код ініціалізує поля об'єктта таким чином, щоб
розмірності масивів полів збігалися з матрицями об'єкта і регулятора:
*/
this.z=new double [p_outputs][1];
this.f=new double [p_inputs][1];
this.u=new double [p_inputs][1];
this.u1=new double [p_inputs][1];
this.y=new double [p_outputs][1];
this.e=new double [p_outputs][1];
this.x=new double [this.c[0].length][1];
this.x1=new double [this.c[0].length][1];
this.xr=new double [this.ar[0].length][1];
this.xr1=new double [this.cr[0].length][1];
}
public void run()
{
if(work)
{
for(int i=0;i<inputs;i++)
f[i][0]=Math.random()*fmax[i];
if(!manual)
{
e=minus(y,z);
u=times(cr,xr);
xr=times (ar,xr);
xr1=times(br,e);
xr=plus(xr,xr1);
}
x=times(ad,x);
u1=plus(u,f);
x1=times(bd,u1);
x=plus(x,x1);
y=times(c,x);
}
}
}
Додаток в. Програмний код класу Application
public class Application
{
public static XMLInterface xml=new XMLInterface();
public static GUI gui=new GUI();
public static java.util.Timer controller=new java.util.Timer();
public Application()
{
try
{
int period=(int)(1000*xml.getDt());
controller.schedule (new Controller (xml.getInputs(),
xml.getOutputs(),xml.getXsize(),xml.getAd(),xml.getBd(),xml.getC(),
xml.getD(),xml.getAr(),xml.getBr(),xml.getCr(),xml.getFmax(),
xml.getUnom() ), 0,period);
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void main(String[]args)
{
new Application();
}
}