Professional Documents
Culture Documents
Xcos-On-Web
Under the Guidance of Dr. D. B. Phatak
Contributors Mentors
Dattatreya Sarma G.V.S Dipti Ghosalkar
Jayaprakash Akula Inderpreet Arora
Ritveeka Vashistha
Ruhi Taj
Shashank Bhalotia
Shivendra Pratap Singh
Xcos-On-Web 4 July 2017
Acknowledgement
By doing this project, we would like to thank all those who have been instrumental in
helping us in achieving the desired outcome. We would like to thank Prof. D.B. Phatak and
IITB for providing us with this opportunity and having faith in our abilities. We would like to
thank our mentors Ms. Dipti Ghosalkar and Ms. Inderpreet Arora for being a constant support
and giving us a broader picture of the whole scenario. Their constant endeavor and guidance
has helped us to complete the project within the stipulated deadline. We would like to thank
Mr. Bikas Chhatri and Mr. Rahul Kharat for providing us the administrative help and making
our working environment comfortable. Last but not the least, we would like to thank our fellow
interns for helping us out with all the problems that we faced and making our internship
experience an enjoyable one.
____________________ _________________
Prof. D.B. Phatak Miss. Dipti Ghosalkar
Dept. Of CSE, IITB Project Mentor
Principal Investigator
Table of Contents
1. INTRODUCTION ............................................................................................................................... 6
1.1. AIM ....................................................................................................................................................... 6
1.2. MOTIVATION ........................................................................................................................................... 6
2. USING XCOS ON WEB ....................................................................................................................... 7
2.1 BUILDING SCILAB FROM SOURCE ON LINUX : .................................................................................................. 7
2.2 INSTALLING OTHER REQUIREMENTS :............................................................................................................ 8
3. LIMITATIONS WITH EARLIER VERSION .............................................................................................. 9
4. TWO WAY COMMUNICATION FOR TKSCALE BLOCK ........................................................................ 10
4.1 INTRODUCTION ...................................................................................................................................... 10
4.2 METHODOLOGY ..................................................................................................................................... 10
4.2.1 Creating the sliders for TKSCALE block .......................................................................................... 10
4.2.2 Logging the values of TKSCALE to file ........................................................................................... 15
4.2.3 Generating graph from values of TKSCALE. ................................................................................... 18
4.3 RESULTS ............................................................................................................................................... 20
4.3.1 Experimental setup having a single TKSCALE block ....................................................................... 20
4.3.2 Experimental setup having two TKSCALE blocks ........................................................................... 21
5. XCOS FOR TEXTBOOK COMPANION ................................................................................................ 22
5.1 INTRODUCTION ...................................................................................................................................... 22
5.2 FEATURES / REQUIREMENTS ..................................................................................................................... 22
5.3 THE DIAGRAM GENERATION ..................................................................................................................... 22
5.4 REPLACING THE INNERHTML...................................................................................................................... 24
5.5 FURTHER DEVELOPMENT ......................................................................................................................... 24
6. IMPLEMENTATION OF FUNCTIONALITY OF SINK BLOCKS : .............................................................. 25
6.1. CHANGE IN SOURCE FILES OF SCILAB : ........................................................................................................ 25
6.2. GENERATION OF OUTPUT ON THE WEB : ..................................................................................................... 34
6.2.1. Enabling 2D and 3D graphs :...................................................................................................... 34
6.2.2. Enabling Exporting feature in graphs : ...................................................................................... 34
6.2.3. Adding routes to control output ................................................................................................ 34
6.2.4. Creating 2D-charts for blocks giving 2D results ......................................................................... 35
6.2.5 Creating 3D-charts for blocks giving 3D results : ....................................................................... 36
6.2.6 Processing 2D-data .................................................................................................................... 36
6.2.7 Processing 3D-data .................................................................................................................... 37
6.2.8 Generation of Output .................................................................................................................. 37
6.2.9 Adding Event Listeners for Manipulation of Output Size : ......................................................... 38
6.2.10 Giving download of binary and audio files for blocks WRITEC_f and WRITEAU_f: .................. 39
6.2.11. Changes for implementation of sinks block TOWS_c and source block FROMWSB : .............. 39
6.2.12 Block Identification state and corresponding block event: ....................................................... 41
6.2.13 Results ....................................................................................................................................... 42
7 PARSER .......................................................................................................................................... 45
Indian Institute Of Technology, Bombay 4
Xcos-On-Web 4 July 2017
7.1 INTRODUCTION...................................................................................................................................... 45
7.2 IMPLEMENTATION .................................................................................................................................. 45
7.2.1 Parsing DEFINE : .......................................................................................................................... 45
7.2.2 Parsing GET : ................................................................................................................................ 47
7.2.3 Parsing SET : ................................................................................................................................. 47
7.3 IMPLEMENTED FUNCTIONS :..................................................................................................................... 48
7.4 RESULT : .............................................................................................................................................. 49
7.4.1 Response by get() function: ......................................................................................................... 49
7.4.2 Response by set function: Change in number of input ports from 2 to 3 ..................................... 49
8. MODIFICATION AND IMPLEMENTATION OF FUNCTION .................................................................. 51
8.1 INTRODUCTION ..................................................................................................................................... 51
8.2 ERRORS IN THE PREVIOUS BLOCKSS ........................................................................................................... 51
8.3. MODIFICATION OF ERRORS ..................................................................................................................... 55
8.3.1 Image lost on submission: ....................................................................................................... 55
8.3.2 Wrong display to the blocks having dynamic display: ............................................................. 56
8.3.3 Implementation of set function to CMSCOPE:.......................................................................... 56
8.3.4 Modifications in code for drag-drop......................................................................................... 57
9. REFERENCES.................................................................................................................................. 58
1. Introduction
Xcos is a Scilab tool dedicated to the modelling and simulation of hybrid dynamic systems
including both continuous and discrete models. It also allows simulating systems governed by
explicit equations (causal simulation) and implicit equations (a causal simulation). Xcos
includes a graphical editor which allows to easily represent models as block diagrams by
connecting the blocks to each other. Each block represents a predefined basic function or a
user-defined one. This blocks can be selected from a window called palette browser.[1]
1.1. Aim
1.2. Motivation
Scilab is free and open source software for numerical computation providing a
powerful computing environment for engineering and scientific applications. The current
scilab version is a desktop version, which requires several installations. The current project is
to build a web version, which carries all the functionalities of the original version and
requires no installations. This would allow the user to use the scilab with more ease.
Make sure you change the path of scilab call ie. SCI variable in sendlog.py to your build
scilab path before running any simulation.
4.1 Introduction
Out of the blocks present in Xcos application, TKSCALE is the only block
which has a real time interaction with the user for input. The earlier version of Xcos on web
has no module which enables the server to interact with user.
4.2 Methodology
Slider is used to change the input value by the user. User can change the input
range and output of the slider by changing the parameters of TK Scale and all the obtained
data should update in periodically with the specified ‘PERIOD’ parameter of CLOCK_c. So
to create the slider and update the data we will follow the steps mentioned in the Flow Chart.
Xml Code:
We will get the count of TK Scales used in experiment with their parameters
stored in an array. Also we have to update the data (input) periodically, so we should also
find ‘which TK Scale is connected to which CLOCK’ and get the clock parameters.
To find the TK Scale and Clock relation we used the following steps:
(i) Find all the clocks with its parameters (clock details)
(ii)
Find the ports of TK Scale and CLOCK_c to find their links. The details of the ports are
under mxcell tags in xmlcode.Also find all split id’s.
We used 2-D array, 1st column represents split id value, 2nd column indicates to which
group split belongs to.
-1 indicates split does not grouped with any other group.
Grouping Method:
(iii) Grouping Method:
Technique which iterates all the links in the experiment and grouping all the TK
Scale and CLOCK_c blocks to find their relation so that we can update the input data
periodically with the specified ‘PERIOD’ parameter.
- Iterating all the links -
--> find the source and target of the present link
(2). If source is not grouped and target is grouped to another split then add source to the
group where target belongs to.
(3). If target is not grouped and source is grouped to another split then add target to the group
where source belongs to.
Indian Institute Of Technology, Bombay 13
Xcos-On-Web 4 July 2017
(4). If source, target both are grouped with some other splits then merge one group into
another with minimum index number.
---> If source does not belong to splits then it belong to one of the CLOCK_c id's then find
the source and add source a new group.
---> If target does not belong to splits then it belong to one of the TK Scale id's then find the
target and add target to a new group.
We got two connections by the above steps :
. ‘which TK Scale connected to which split’ and
. ‘which CLOCK_c connected to which split’
Using these two connections we will find the RELATION between the TK Scale and
CLOCK_c
- iterate total clock group and finally obtain the detail ‘which split contains the ith clock’ -
From the obtained connection between CLOCK_c and Splits find the
connection between CLOCK_C and TK Scale. Finally we found the required connection. We
have to add the ‘Period’ parameter to the tkclk array
Create Sliders with Obtained Data:
Now we should create the sliders with obtained TK Scale details using slider.html
Whenever user slides the pointer in any one of the slider we will update values
of each slider which will be stored in the paragraph (‘p’) id basing on the slider number. The
ten id’s tk1 to tk10 take the updated value from the slider. Whenever any one of the id value
(innerhtml) is changed we will call ‘getcurval’ function using the below method tkclk has the
clock parameter ‘PERIOD’ for every TK Scale and tk1 to tk10 have the updated slider
Indian Institute Of Technology, Bombay 15
Xcos-On-Web 4 July 2017
values. Together we are store them in value Array (valuearr) and we will make an ‘Ajax’
request with that data. It will invoke a function in python named as “updatetkfile” in
sendlog.py
The following flowchart shows the process of updating data to the tk files
Note that when user changes the slider value, updated data will be written to the
file else present value will be written to the file continuously until new value appears. As we
are writing the updated values (input values) to a file. These may overlap when there are
multiple users. To overcome this situation we will creates files with uid (user id) generated
by uuid to every user. Using uuid1() we will not get any duplicate uid’s. If there are more
than 2^14 requests to uuid1 in less than ten nanoseconds then there might may appear few
cases to get duplicates which is impossible in our case due to less time span (10 ns).
Initialize the Process:
This function takes the updated data and store it in the val.txt file in values folder.
Findfile function checks the val.txt file content.If it contains “Start” it initializes thread and
creates required files,If it contains “Stop” it stop the thread, Else data updation will be done.
Getdetails functions takes the val.txt file and makes the data to be appended at the file end.
Getdetails from Val.txt:
We have to update the data periodically with the time. Val.txt contains only
‘PERIOD’ parameter so in order to update the time as well as data (input value) we pass the
data in val.txt to another function “appendtotkfile” which appends data and time to the file.
Append Data and Time to TK Files:
Indian Institute Of Technology, Bombay 17
Xcos-On-Web 4 July 2017
We created a file time.txt which updates time with the ‘PERIOD’ parameter
initialized to 0’s in findfile function. For every iteration we add the time in time.txt file with
the ‘PERIOD’ parameter and append it to the file with the data in the val.txt. Change Format
will change the time floating value to scientific format and the input value is received in
scientific format.
This process continues until user stops the simulation by closing the simulation window.
Terminate:
For closing sliders and to stop the thread we use the event closing of simulation
window. Stoptk function will close all slider windows as well as the thread by sending
“Stop” data in ajax request in index.html. By receiving the request in sendlog.py file we will
delete all the related files created. We will also call the stoptk function even if user closes the
main window without closing the simulation window.
The TKSCALE block, now has to read the values from the log file and process
it to generate appropriate graphs. The exact method by which TKSCALE block transmits its
value to the corresponding sink block is unknown. Only the method by which sink block
obtains the resulting value is known. So, the first approach for this problem was to modify
the latter method. But, this method too has its own limitations. For this approach to work
correctly the source code of around 25-30 blocks had to be modified and it is not practically
feasible and not an efficient method.
So, a different approach was adopted. This approach would replace TKSCALE
block by a RFILE_f block. RFILE_f block allows user to read data in a file with the name
defined with the input file name parameter, in text formatted mode or in binary mode. The
file is a sequence of records.. RFILE_f block updates its value from the file periodically
based on the time period set for the CLOCK block it is connected to. This block might
encounter an end of file argument during the reading process. In such cases the block repeats
the last value it read and hence obtained output might not tally with the expected output.
The problem now is how to change the diagram at the backend without the user
actually realizing it. The actual procedure of changing the diagram with TKSCALE to
RFILE_f block is done only when the user runs the simulation. At that time the current xcos
diagram (basically an xml file) is passed as an argument (.xcos file) to upload function. The
entire manipulation of block is done here at the backend without reflecting these changes to
the front end user.
Fig 4.2.3.1 : A sample example of the block diagram and its corresponding diagram at the
backend after altering it.
The question that arises now is “How do we create a new block in the xml file?”
Code has been written to add the entire BASIC BLOCK xml part of RFILE_f in the .xcos
file that gets uploaded to server. For every TKSCALE block a new RFILE_f basic block xml
has been added. The actual basic block xml for RFILE_f block can be obtained by exporting
the xml for diagram containing only that block. As the xml part of the block is very big. It
has been copied to a file and later read from it and written to the .xcos upload file.
The real task is to replace all the connections that a TKSCALE block had
with the new RFILE_f block. A module has been written in python to modify the xcos that
retains the connections of the TKSCALE and make RFILE_f to read the file containing the
slider values. The connections is set in the desired way by just changing ID of RFILE_f with
that of a TKSCALE block. Later the ID of TKSCALE block is altered with a negative
number and henceforth virtually removing it. The parameters of RFILE_f block are changed
to the read the required file by providing it with its location on the disk. Also the exact
format in which the numbers are present in the file have been provided to the RFILE_f block
[2]. Furthermore, the real time scaling value for experiments containing TKSCALE has been
hard coded to 1.0 to give user a live experience.
Usually for the other blocks scilab process communication (continues till the
end of simulation time) and graph generation go hand in hand. But for diagrams with
TKSCALE the same procedure is not applicable as writing values and reading values need to
happen parallel. For this purpose simulation diagrams are checked for non-empty canvas and
then scilab communication is terminated. As scilab communication would restrict any
parallel reading of file necessary for generation of graph. The code is made to sleep for a
small duration of time during the log file reading procedure as some time is required for
updating the log file with new value of TKSCALE.
4.3 Results
The following images will reflect the changes made and show the results of a few
experimental setups containing TKSCALE block.
5.1 Introduction
The Textbook Companion Project (TBC) aims to port solved examples from
standard textbooks using an open source software system, such as Scilab. Any standard
textbook can be used for this purpose.We can implement our Xcos for Textbook Companion
in ‘TBC code search’ section and improve its functionality thereby any user can see and
simulate any example of xcos.
For this idea, we created a generic method which will generate the diagram for the given
.xcos file contents.
At present we are storing and fetching the files from our client side system.
Url Format : http://127.0.0.1:8001/importxcos?Eid=fileuniqueid
We use Details.uid and names (dictionary) as variable names to support functionality to
access Xcos TBC for multiple users.
First we will check the innerhtml value and if it contains the file contents, we
will replace the unnecessary characters to import (generate) the diagram. Xcostodiagram
function will take the file contents and generates the diagram.
H) we have to open our xcos page to run the simulation.
Meanwhile we should replace the innerhtml file contents back to the “xcosnull”
.So we kept a ajax request which will change the innerhtml back to “xcosnull”.
The source files of Scilab were modified to write the output data to a file with unique
id per user. The following basic steps were followed to store the data:
I. Using a filename with unique id :
This was implemented by concatenating Scilab’s process-id with the filename.
Fig.6.1.1 shows the process of giving unique id in a source C file(cscope.c).
Fig.6.1.1: Using process-id of scilab to generate unique filenames for data files
II. Opening the file in append mode so that data of one block does not overwrite
data of other block.
III. Giving unique block-id to differentiate the data of different blocks.
IV. Defining of the initializing step of the block’s output. Fig.5.1.2 shows the
initialization step for a CSCOPE block. Process-id of Scilab and block-id of
block were used to differentiate the initialization step of different output blocks.
1) CSCOPE.c :
This file was modified to write data outputted by a CSCOPE block to a data file.
CSCOPE gives a single graph as output. Fig.6.1.5 shows the data stored for this block.
Fig.6.1.5: Recording each set of data for a CSCOPE block
2) CMSCOPE.c :
This file was modified to write data outputted by a CMSCOPE block to a data
file. CMSCOPE can give multiple output graphs. Fig.6.1.6 shows the data stored for this block.
3) CSCOPXY.c :
This file was modified to write data outputted by a CSCOPXY block to a data
file. CSCOPXY gives a single 2D-graph as output. Fig.6.1.7 shows the data stored for this
block.
Fig.6.1.7: Recording output data for a CSCOPXY block
4) CSCOPXY3D.c :
This file was modified to write data outputted by a CSCOPXY3D block to a data
file. CSCOPXY3D gives a single 3D-graph as output. Fig.6.1.8 shows the data stored for this
block. As it gives a 3D-graph, values of z-axis is also important as well as the angle of rotation
of the axes.
Fig.6.1.8: Recording output data for a CSCOPXY3D block
5) CANIMXY3D :
This file was modified to write data outputted by a CANIMXY3D block to a data
file. CANIMXY3D gives a single 3D-graph as output. Fig.6.1.9 shows the data stored for this
block. As it gives a 3D-graph, values of z-axis is also important as well as the angle of rotation
of the axes. It gives an animated output depending on the buffer size, so that needs to recorded
as well.
Fig.6.1.9: Recording output data for a CANIMXY3D block
6) BARXY_sim.sci :
This file was modified to write data outputted by a BARXY block to a data file.
BARXY gives output as an animated 2D-rotating line. It does so by using sequence of pairs
of points to generate lines while deleting the previous pairs from the output screen. Fig.6.1.10
shows the Initialization phase of BARXY. As BARXY gives output of a different type, a
different format is used for storing its data, as shown in Fig.6.1.11.
7) AFFICHEBLOCK.java :
This file was modified to write data outputted by a AFFICH_m block to a data
file. AFFICH_m displays its output on the block itself. Fig.6.1.12 shows the process of
retrieving Scilab’s process-id in java. Fig.6.1.13 shows the step of recording the output data.
8)CFSCOPE:
This file was modified to write data outputted by a CFSCOPE block to a data
file.It has only one graph for a particular block.The writing to log file part changes in
the file are in fig 6.1.14
Fig.6.1.14: Recording output data for CFSCOPE block
9)CANIMXY:
This file was modified to write data outputted by a CANIMXYblock to a data file.This
block gives a animation as a a output.The animation output depends on buffer so that is also
written in the log file.The changes for data writing to the block file are as follows in figure
6.1.15.
10)WRITEC_f:
This block actually writes binary data in a binary file so in the web version it was needed
that we return a binary file.As this file should be unique to be sent to the client,so we use pid
its name.For uniqueness with several similar blocks we have used timestamp in microsecond
also in the name of file generated.The timestamp generating part is as follows-
Then we name the file on the basis of pid ,timestamp and specified name .Here we name the
file on the basis of above specified factors and write the name of the generated file in the log
file along with initialization by the following change in code given in figure 6.1.17
Fig.6.1.17: Initialization ,naming and writing to the log file for WRITEC_f block
We write the ending part in the case when the binary file writing ends as follows-
Fig.6.1.18: Specifying of ending state and closing the log file for WRITEC_f
11)WRITEAU_f:
This block actually writes audio data in a audio file so in the web version it was needed
that we return a audio file.As this file should be unique to be sent to the client,so we use pid
its name.For uniqueness with several similar blocks we have used timestamp in microsecond
also in the name of file generated.The timestamp generating function of writec.c is directly
used.Then we name the file on the basis of pid ,timestamp and audio tag. Here we write the
name of the generated file in the log file along with initialization by the following change in
code:
Fig.6.1.19: Initialization ,naming and writing to the log file for WRITEAU_f block
We write the ending part in the case when the audio file writing ends as follows:
Fig.6.1.18: Specifying of ending state and closing the log file for WRITEAU_f
The output data recorded through Scilab source files would be used as input to the
web version to generate result for the user.
highcharts-3d.js.
Fig.6.2.5a: Create 3D-graphs
To give the functionality for maximizing the output graph, event listeners were used
in chart.js. Fig.6.2.9a shows the different event listeners provided for the manipulations.
Fig.6.2.9a: Event listeners for window MAXIMIZE, NORMALIZE and CLOSE
Then the XMLHTTP receives the corresponding file as a blob object and then an object url
is generated for the file with which a download popup for the client is triggered. For this the
corresponding changes in chart.js are as in figure 6.2.10b
we could not directly use the blocks. So to use a workspace for a complete session of the
client we saved and loaded the workspace only when needed. We save the workspce by
modifying the command for running scilab. For that we needed to identify the blocks before
simulation. So we parsed the xml file using minidom library of python during the upload file
process only. We use a counter variable named workspace_counter and set it to 0 if no such
block and 1 corresponding to TOWS_c and 2 corresponding to a FROMWSB block and 3 if
both blocks are present and we assign this workspace_counter to a global list workspace_list
corresponding the the file. We also save the variable to be saved for TOWS_c in a global
dictionary WORKSPACE_dict corresponding to the particular xcos file uploaded.For this
the following changes are done in upload route of SendLog
Fig.6.2.11b: Saving and Loading workspace commands on the basis of existence of blocks
This is done for case where normal sending of points as in general could
not be used as in the case of BARXY so we defined a new event trigger in the chart.js as
follows:
6.2.13 Results :
A sample 2D result is shown in Fig.6.2.10a. Fig.6.2.10b shows a sample 3D result.
Fig.6.2.10c shows the result of a BARXY block.
7 PARSER
7.1 Introduction
In previous version of xcos-on-web neither can user see the current parameters nor can
he/she change parameters for the block. Hence getter and setter functions needed to be
implemented for all 230 blocks . But implementing these many getter and setter functions
would have taken a lot of time, So my mentor asked me to implement a parser which can
parse code of all the blocks written in sci language to javascript.
Sci code explanation : sci code for each block is divided into 2 parts for most of the
blocks, “set” and “define” . But, each block has “set”,”get” and “define” in javascript. So
parser divides the sci code into three parts (set is divided into get and set and then each part
is parsed differently.
7.2 Implementation
I extracted define part from “case define” of sci code. There are 3 types of
variables that are initialised in define.
a) LOCAL variables: These variables are initialised with constant values and are stored as
“this.[var] = [value]”. These variables are used to initialise other variables and are refrenced
in “get” functions. These variables are stored in exprvariables and their type
(“int”,”matrix”,”string”) is also stored. Derived variables are variables which uses local
variables in their initialisation these variables are stored in derivedvariables.
b) MODEL variables: For all blocks model is either initialised by function “scicos_model()”
or “scicos_diagram()”. Model stores 24 variables which are of different types.
Model : scilabstring
Sim : scilabstring
In : scilabdouble
In2 : scilabdouble
Intyp : scilabdouble
Out : scilabdouble
Out2 : scilabdouble
Outtyp : scilabdouble
Evtin : scilabdouble
Evtout : scilabdouble
State : scilabdouble
Indian Institute Of Technology, Bombay 45
Xcos-On-Web 4 July 2017
Dstate : scilabdouble
Odstate : list
Ipar : scilabdouble
Rpar : scilabdouble
Opar : list
Blocktype : scilabstring
Firing : scilabdouble
Dep_ut : scilabboolean
Label : scilabstring
Nzcross : scilabdouble
Nmode : scilabdouble
Equations : list
Uid : scilabstring
NOTE : This classification is different in scialb 6.0.0
C)VAR variables : Some variables are initialised as var as these are immediately stored in
one of the model variables. E.g “exprs” is stored in this.x.graphics
Since this type variable classification is not followed in scilab code. I identified a pattern, all
variables which are initialised before declaration of model are “local” variables, all variables
that are stored as “model.[var] = [value]” are “model” variables while others are var variable.
Bool isinitfinished stores the above discussed information.
Use of this Classification : Local variables are stored as simple data types already present
in javascript. Model and var variables are stored as scialbdouble, scialbstring, scilabboolean
or list. Hence, value is parsed differently for each type of variable.
For parsing I used regex to classify lines ( each line of the code ) on the basis of [value] i.e.
Everything that is present after “=” in a line
Each line is identified as [var] = [value]
Regex used:
1. Initlist = value is an array/matrix/complete/incomplete
2. Initnum = value is a number
3. Initfuncn = value is a function call
4. Initstring = value is not identified by previous regex expression but line is an
assignment
Depending on the classification under which each line falls it will be processed by different
functions. E.g. Updatefunction, updatenum, updatelist, updatestring.
1. Pattern - integers are parsed into [this.value], arrays are parsed into ...this.value
and matrix are parsed into colon_operator(this.value). Other regex expressions
are used to classify each element of value of type list/array.
B) FuncnCall(): this function parses values which are function calls. For each function
parameters need to be parsed into different forms.For e.g. Jetcolormap(n) ->
jetcolormap(this.n)
“exprs” : All parameters that can be changed by user are stored in exprs. Hence all variables
that are present in array assigned to “exprs” are stored as exprvariables and the form in
which these variables are stored in array is stored in getlist.
Important Functions:
A) Set_io() : This function sets variables which are related to ports.
B) check_io() : It first check if given number of ports agree with block connection and then
changes block structure.
However in the javascript code of check_io I have not implemented the validation part of the
sci code.
2. Linspace() :
a. Purpose : to get a vector of linearly spaced numbers from a to b of size n.
b. Parameters:
1. a : first value
2. b : second value
3. n : size of vector
4. Set_io : This function is same as set_io() function of scilab except that validation has not
been implemented.
a. Purpose - Change the structure of model depending on the on parameters passed.
b. Parameters -
i.Model : initial and resulting block model structure
ii.Graphics: initial and resulting block graphics structure
iii.Inp : new input ports sizes
iv.Out : new output ports sizes
v.Clkin : new event input ports sizes
vi.Clkout : new event output ports sizes
vii.In_implicit : index of implicit input ports, the other ports are supposed to be explicit
viii.Out_implicit : index of implicit output ports, the other ports are supposed to be explicit
5. Check_io : It is implementation of check_io function of scilab in javascript.
Purpose : check_io first check if given number of ports agree
With block connection and then changes block structure
Parameters : same as that of set_io
Correction in Functions :
While testing I found that some functions have some error in the implementation.
1. Standard_define() - variables like pin, pout, pein, peout were assigned incorrect values
inside if() blocks.
2. Inverse() - Argument “[]” was parsed incorrectly
3. Size() - Cases 1 and 2 were not implemented.
7.4 Result :
Define, Set and Get are implemented for all blocks except 22 blocks.
8.1 Introduction
The implementation of some functions and changes were needed in the previous block in
order to allow the complete functioning of the functions being implemented. The errors of
the previous blocks are mentioned in the following section. All of these are now completely
functioning.
Underfunction_ commonlyusedblocks(){
CMSCOPE: Error After submission, image is getting lost;
DEMUX: Error Seems to have no image:But no submit button
MUX: Error Seems to have no image:But no submit button
NRMSOM_f: Error Seems to have no image:But no submit button
PRODUCT: Error Not except replica of the image shown
RELATIONALOP: Error The image displayed is different from the image supposed to be
there
SWITCH2_m: Error No image being displayed.Must have an error!
}
Underfunction_ continoustime(){
CLR: Error in the image being displayed
PDE: Error No image being displayed.
}
Underfunction_ discretetimesystems(){
DLR : Error in image that is being displayed
DLSS: Error in the size being displayed
}
Underfunction_ eventhandling(){
CLOCK_c: Error in losing the image on submission
Indian Institute Of Technology, Bombay 51
Xcos-On-Web 4 July 2017
Underfunction_ Electrical(){
Capacitor: Error-Image size not as expected
Diode: Error-Image size not as expected
Sinevoltage: Error- Wrong image being displayed
Vvsourceac: Error- Wrong image being displayed
Vsourceac: Error- Wrong image being displayed
}
Underfunction_ Integer(){
BITCLEAR: Error- Wrong image being displayed
BITSET: Error- Wrong image being displayed
DFLIPFLOP: Error- Improper way of image being displayed
DLATCH: Error- Unable to drop the image
EXTRACTBITS: Error- Wrong image being displayed
JKFLIPFLOP: Error- Unable to drop the image
SHIFT: Error- Wrong image being displayed
}
Underfunction_ Port&Subsystem(){
CLKINV_f: Error- No image being displayed
CLKOUTV_f: Error- No image being displayed
INIMPL_f: Error- wrong image being displayed
OUT_f: Error- No image being displayed
}
Underfunction_ signalrouting(){
DEMUX: Error-Image size not as expected
DEMUX_f: Error-Image size not as expected
FROM: Error- wrong image being displayed
FROMMO: Error- wrong image being displayed
GOTO: Error- wrong image being displayed
GOTOMO: Error- wrong image being displayed
The error observed above was modified by changing the code for submit onclick function by
re-loading the image and calling it.
The code for the on-click submit is as follows:
Even after submission to three ports, changes were not shown. Hence modified to a new set
function.
The blocks which weren’t draggable/droppable were modified by changing the syntax and
logical errors in the previous block implementations as well as the display -html function.
9. References
[1] https://www.scilab.org/content/download/390/2810/file/scilabtec_Xcos.pdf
[2] https://www.cs.mtu.edu/~shene/COURSES/cs201/NOTES/chap05/format.html
[3] https://www.highcharts.com