VirtualLabBuilder.src.VLabModel

Classes to describe the virtual-lab view and to set-up the virtual-lab

Information


 
 
VLabModel package  includes the PartialView, Root and VirtualLab classes. 
PartialView and VirtualLab classes are inhereted from the classes with the same name contained in the 
VLabModel package included in the VirtualLabBuilder library. 


Package Content

NameDescription
VirtualLabBuilder.src.VLabModel.PartialView PartialView Partial model required as base class for the view description model
VirtualLabBuilder.src.VLabModel.Root Root Root element of the view description
VirtualLab Class describing the complete virtual-lab
NULL Null class


VirtualLabBuilder.src.VLabModel.PartialView VirtualLabBuilder.src.VLabModel.PartialView

Partial model required as base class for the view description model

Information


 

PartialView class includes an instance of the Root component. The Root component is the root element for the view description. The following tasks are performed by the PartialView class:


Parameters

TypeNameDefaultDescription
RealTcom0.1Communication interval
IntegerserverPort4242Server Port number
StringsourceCodePath"C:/Program Files/Dymola/Sou...Path where the C-functions, graphics.jar and delayrun.exe are located
StringfileName"gui.java"Java file name

Modelica definition

partial model PartialView 
  "Partial model required as base class for the view description model" 
  import Modelica.Utilities.*;
  parameter Real Tcom = 0.1 "Communication interval";
  parameter Integer serverPort=4242 "Server Port number";
  parameter String sourceCodePath = "C:/Program Files/Dymola/Source/VirtualLabBuilder/" 
    "Path where the C-functions, graphics.jar and delayrun.exe are located";
  Root root( serverPort = serverPort) "Root component";
//Global variables************************************
  inner Real CK[sizeMax] 
    "CK[i] = true if the component identified by the number i has changed its value due to a user action";
  inner Real Inew[sizeMax] 
    "Vector containing the new values of the interactive variables";
  inner Boolean refreshView( start= false) 
    "True only when the model-view communication is established";
  inner Integer p "Socket number";
  inner parameter String fileName = "gui.java" "Java file name";
protected 
  inner parameter Integer sizeMax = 500 
    "Maximum number of interactive variables";
  inner parameter String fInteractive = "InteractiveVars.txt" 
    "Name of the file used by the InteractiveControl elements";
  inner parameter String fComponent = "Components.txt" 
    "Name of the file used by the graphic elments";
  
//**************************************************  
  
  Boolean startServer(start=true, fixed=true);
  
equation 
  when pre(startServer) and   initial() then
   Functions.bodyGUI(fileName=  fileName); //Last lines of the code of the java file
   Files.removeFile("Manifest.txt");
   Files.copy(sourceCodePath + "graphics.jar", "./graphics.jar",replace=  true);
   Files.copy(sourceCodePath + "delayrun.exe", "./delayrun.exe",replace=  true);
    
   //Compilation and execution of the java file      
   Streams.print("Manifest-Version: 1.0","Manifest.txt");
   Streams.print("Class-Path: graphics.jar","Manifest.txt");
    
   Streams.print("Main-Class: "+ Strings.substring(    fileName,    1,    Strings.length(fileName) - 5),"Manifest.txt");
   Streams.close("Manifest.txt");
   System.command("javac " + fileName + " -classpath graphics.jar");
   System.command("jar cvfm " + Strings.substring(    fileName,    1,    Strings.length(fileName) - 5) + ".jar Manifest.txt "+Strings.substring(    fileName,    1,    Strings.length(fileName) - 5)+".class");
    
   p = CServer.startCServer(serverPort);
   startServer = false;
   Files.removeFile("delayrun.ini");
   Streams.print("0","delayrun.ini");
   Streams.print(Strings.substring(    fileName,    1,    Strings.length(fileName) - 5) + ".jar","delayrun.ini");
    
  System.command("delayrun");
end when;
  
//Obtaining the value of the data sent by the graphic interface to the model
  when sample(0, Tcom) then
    
  refreshView =  not (pre(refreshView));
(CK, Inew) = CServer.getVarValues(
  p,   sizeMax);
    
  end when;
  
  
end PartialView;

VirtualLabBuilder.src.VLabModel.Root VirtualLabBuilder.src.VLabModel.Root

Root element of the view description

VirtualLabBuilder.src.VLabModel.Root

Information


 
The Root component is the root element for the view description.   
 

Parameters

TypeNameDefaultDescription
IntegerserverPort Server Port number

Connectors

TypeNameDescription
ChildLcLLeftConnector

Modelica definition

model Root "Root element of the view description" 
  import Modelica.Utilities.*;
outer String fileName "Name of the java file";
parameter Integer serverPort "Server Port number";
Interfaces.ChildL cLLeft "Connector";
protected 
Integer num "Number identifying the component";
outer parameter String fInteractive 
    "File used by the InteractiveControls elements";
outer parameter String fComponent "File used by the graphic elements";
  
initial algorithm 
//Remove files used by the InteractiveControls elements and the graphic elements
Files.removeFile(fInteractive);
Files.removeFile(fComponent);
  
num := 0; //Number identifying the root component
Functions.signalFile( fileName=fileName, serverPort=serverPort); //First lines of the Java code
  
initial algorithm 
 cLLeft.nodeReference :=num;
 cLLeft.borderLayout :=false;
equation 
when false then
  num = pre(num);
  cLLeft.nodeReference = pre(cLLeft.nodeReference);
  cLLeft.borderLayout = pre(cLLeft.borderLayout);
end when;
end Root;

VirtualLabBuilder.src.VLabModel.VirtualLab

Class describing the complete virtual-lab

VirtualLabBuilder.src.VLabModel.VirtualLab

Information


                        

The class describing the complete virtual-lab has to contain an instance of VirtualLab class. The virtual-lab designer has to set the name of the model and the view classes.


Parameters

TypeNameDefaultDescription
RealTcom0.1Communication interval
StringfileName"gui.java"Name of the java file
replaceable model ViewINULLClass describing the virtual-lab view
replaceable model ModelINULLClass describing the virtual-lab model
StringsourceCodePath"C:/Dymola60/Source/VirtualL...Path where the C-functions, graphics.jar and delayrun.exe are located

Modelica definition

model VirtualLab "Class describing the complete virtual-lab" 
  parameter Real Tcom = 0.1 "Communication interval";
 parameter String fileName = "gui.java" "Name of the java file";
 replaceable model ViewI =  NULL "Class describing the virtual-lab view";
 replaceable model ModelI = NULL "Class describing the virtual-lab model";
 ViewI View( Tcom = Tcom, fileName = fileName, sourceCodePath = sourceCodePath) 
    "View description";
 ModelI Model "Interactive model description";
parameter String sourceCodePath = "C:/Dymola60/Source/VirtualLabBuilder/" 
    "Path where the C-functions, graphics.jar and delayrun.exe are located";
  
end VirtualLab;

VirtualLabBuilder.src.VLabModel.NULL

Null class

Modelica definition

model NULL "Null class" 
  
end NULL;

VirtualLabBuilder.src.VLabModel.VirtualLab.ViewI

Class describing the virtual-lab view

Modelica definition

replaceable model ViewI =  NULL "Class describing the virtual-lab view";

VirtualLabBuilder.src.VLabModel.VirtualLab.ModelI

Class describing the virtual-lab model

Modelica definition

replaceable model ModelI = NULL "Class describing the virtual-lab model";

HTML-documentation generated by Dymola Tue Jul 24 18:58:13 2007.