Name | Description |
---|---|
![]() | Partial model required as base class for the view description model |
![]() | Root element of the view description |
VirtualLab | Class describing the complete virtual-lab |
NULL | Null class |
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:
Type | Name | Default | Description |
---|---|---|---|
Real | Tcom | 0.1 | Communication interval |
Integer | serverPort | 4242 | Server Port number |
String | sourceCodePath | "C:/Program Files/Dymola/Sou... | Path where the C-functions, graphics.jar and delayrun.exe are located |
String | fileName | "gui.java" | Java file name |
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;
Type | Name | Default | Description |
---|---|---|---|
Integer | serverPort | Server Port number |
Type | Name | Description |
---|---|---|
ChildL | cLLeft | Connector |
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;
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.
Type | Name | Default | Description |
---|---|---|---|
Real | Tcom | 0.1 | Communication interval |
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 | |
String | sourceCodePath | "C:/Dymola60/Source/VirtualL... | Path where the C-functions, graphics.jar and delayrun.exe are located |
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;
model NULL "Null class" end NULL;
replaceable model ViewI = NULL "Class describing the virtual-lab view";
replaceable model ModelI = NULL "Class describing the virtual-lab model";