Skip to content

Commit f0eeaf6

Browse files
committed
obsolete code is removed
1 parent 313756e commit f0eeaf6

24 files changed

+46
-949
lines changed

README.md

+46-22
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
# SimDatabase
2-
A MySQL extension for Simulink.
2+
A MySQL/WebAPI(JSON) extension for Simulink.
33

4-
## sfun - CMEX S-Function
5-
More elegant and useable soultion with proper error handling.
4+
## MySQL block
65

7-
## extlib - External Library
8-
Dynamic Link Library. I wrote this to test the capabilities of this method. (obsolete)
6+
![sql_database](imgs/SQLDatabase.png)
7+
![sql_database_params](imgs/SQLDatabase_params.png)
8+
![sfun_simsql](imgs/sfun_simsql.png)
99

10-
## Online mode
11-
12-
![online](imgs/online.png)
13-
14-
The Online database block uses a MySQL server to generate the desired output data, this is achieved by a custom CMEX S-Function written in C using the **MySQL Connector C API version 6.1.11**.
10+
The MySQL database block connects to a MySQL server in order to request the desired output data, this is achieved by a custom CMEX S-Function written in C using the **MySQL Connector C API version 6.1.11**.
1511

1612
The block can interpret a predefined format of SQL entry:
1713

@@ -26,33 +22,61 @@ The precision required for the simulation is, currently, achieved by linear inte
2622

2723
The connection and the query take a long time compared to the other operations. To solve this problem the block saves the results in a unique file and only uses the database when this file does not exist, otherwise reads the data from the file, which takes significantly less time.
2824

29-
## Offline mode
25+
## WebAPI (JSON) block
3026

31-
![offline](imgs/offline.png)
27+
![webapi_json](imgs/JSONAPIDatabase.png)
28+
![webapi_json_params](imgs/JSONAPIDatabase_params.png)
29+
![sfun_webjson](imgs/sfun_simwebjson.png)
3230

33-
The Offline database block uses a file to output the measured data. The Simulink program has no easy built-in support for custom text file handling, so this is achieved by the same .dll file used in the Online database block.
31+
The WebAPI (JSON) block connects to a TCP/IP server in order to request the desired output data in the form of a JSON response. The block implements a TCP/IP client and uses [DaveGamble's cJSON library](https://github.com/DaveGamble/cJSON) to parse the response.
3432

35-
The block can interpret a predefined format of file entry:
33+
An example of a request:
34+
```
35+
http://127.0.0.1/api/api.php?startDate=2019-05-
36+
17&startTime=06:00:00&endDate=2019-05-
37+
17&endTime=20:30:00&sensors=TW,I
38+
```
39+
An example of a response (if the query was successful):
3640
```
37-
Date;Time;N1;N2;N3;N4...
38-
YYYY-MM-DD;hh:mm:ss;v1;v2;v3;v4...
41+
{
42+
"data":[
43+
{
44+
"date":"2018-04-17",
45+
"time":"06:00:00",
46+
"TW":20.98,
47+
"I":53.33
48+
},
49+
{
50+
"date":"2018-04-17",
51+
"time":"06:40:00",
52+
"TW":21.95,
53+
"I":103.33
54+
}
55+
]
56+
}
57+
```
58+
An example of a response (if the query was unsuccessful):
59+
```
60+
{
61+
"error": "startTime is needed"
62+
}
3963
```
40-
This format can be easily exported from an Excel table using CSV export.
4164

4265
The precision required for the simulation is, currently, achieved by linear interpolation, which can be turned off.
4366

67+
The connection and the query take a long time compared to the other operations. To solve this problem the block saves the results in a unique file and only uses the database when this file does not exist, otherwise reads the data from the file, which takes significantly less time.
68+
4469
## Requirements
45-
- MATLAB R2018b + Simulink (trial can do the trick)
70+
- MATLAB (>= R2018b) + Simulink (trial can do the trick)
4671
- Visual Studio 2017 Community Edition (free)
4772

4873
## Compilation
4974
Setup ```mex``` with the ```mex -setup``` command in MATLAB.
50-
- sfun : Run ```compile.m```.
51-
- extlib : Run ```compile_and_test.m```.
75+
Run ```sfun/sql/compile.m``` or ```sfun/webjson/compile.m```.
5276

5377
## Usage
54-
- sfun : Copy ```sfun_simdatabase.mexwXX``` to the **Working Directory** and see ```sim_test.slx```.
55-
- extlib : Copy ```simdatabase.dll``` and ```resolve_pointer.m``` to the **Working Directory** and follow the example ```.SLX``` files.
78+
Use the database example ```example/sql/sim_test.sql``` to setup the database.
79+
In order to use the JSON block, an example implementation of the API can be found in ```example/webjson```, it is called **api**. It uses the previously installed database scheme.
5680

5781
## Notes
5882
- Compiled with MS Visual Studio 2017 Community.

extlib/common.c

-55
This file was deleted.

extlib/common.h

-22
This file was deleted.

extlib/compile_and_test.m

-50
This file was deleted.

extlib/dconsole.c

-71
This file was deleted.

extlib/dconsole.h

-39
This file was deleted.

extlib/local.csv

-6
This file was deleted.

0 commit comments

Comments
 (0)