{"id":21072314,"url":"https://github.com/g0mb4/simdatabase","last_synced_at":"2026-05-08T10:35:54.529Z","repository":{"id":148469625,"uuid":"142487610","full_name":"g0mb4/SimDatabase","owner":"g0mb4","description":"A MySQL/WebAPI(JSON) extension for Simulink.","archived":false,"fork":false,"pushed_at":"2020-12-30T09:59:24.000Z","size":503,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-14T03:11:10.090Z","etag":null,"topics":["cmex","json","mysql","s-function","sfun","simulink","webapi"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/g0mb4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-26T19:53:53.000Z","updated_at":"2020-12-30T09:59:27.000Z","dependencies_parsed_at":"2023-05-20T06:45:26.415Z","dependency_job_id":null,"html_url":"https://github.com/g0mb4/SimDatabase","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/g0mb4/SimDatabase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g0mb4%2FSimDatabase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g0mb4%2FSimDatabase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g0mb4%2FSimDatabase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g0mb4%2FSimDatabase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/g0mb4","download_url":"https://codeload.github.com/g0mb4/SimDatabase/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g0mb4%2FSimDatabase/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261199991,"owners_count":23123917,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cmex","json","mysql","s-function","sfun","simulink","webapi"],"created_at":"2024-11-19T18:56:08.944Z","updated_at":"2026-05-08T10:35:49.476Z","avatar_url":"https://github.com/g0mb4.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SimDatabase\nA MySQL/WebAPI(JSON) extension for Simulink.\n\n## MySQL block\n\n![sql_database](imgs/SQLDatabase.png)\n![sql_database_params](imgs/SQLDatabase_params.png)\n![sfun_simsql](imgs/sfun_simsql.png)\n\nThe 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**.\n\nThe block can interpret a predefined format of SQL entry:\n\n| date        | time     | data                 |\n|:-----------:|:--------:|:--------------------:|\n| YYYY-MM-DD  | hh:mm:ss | N1=v1;N2=v2;N3=v3; … |\n| ...  \t\t    |  ...     | ...                  |       \n\nThis way a specified number of *vs* can be extracted from the database for the given *Ns* based on the time interval.\n\nThe precision required for the simulation is, currently, achieved by linear interpolation, which can be turned off.\n\nThe 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.\n\n## WebAPI (JSON) block\n\n![webapi_json](imgs/JSONAPIDatabase.png)\n![webapi_json_params](imgs/JSONAPIDatabase_params.png)\n![sfun_webjson](imgs/sfun_simwebjson.png)\n\nThe 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.\n\nAn example of a request:\n```\nhttp://127.0.0.1/api/api.php?startDate=2019-05-\n17\u0026startTime=06:00:00\u0026endDate=2019-05-\n17\u0026endTime=20:30:00\u0026sensors=TW,I\n```\nAn example of a response (if the query was successful):\n```\n{\n    \"data\":[\n        {\n            \"date\":\"2018-04-17\",\n            \"time\":\"06:00:00\",\n            \"TW\":20.98,\n            \"I\":53.33\n        },\n        {\n            \"date\":\"2018-04-17\",\n            \"time\":\"06:40:00\",\n            \"TW\":21.95,\n            \"I\":103.33\n        }\n    ]\n}\n```\nAn example of a response (if the query was unsuccessful):\n```\n{\n    \"error\": \"startTime is needed\"\n}\n```\n\nThe precision required for the simulation is, currently, achieved by linear interpolation, which can be turned off.\n\nThe 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.\n\n## Requirements\n- MATLAB (\u003e= R2018b) + Simulink (trial can do the trick)\n- Visual Studio 2017 Community Edition (free)\n\n## Compilation\nSetup ```mex``` with the ```mex -setup``` command in MATLAB.\nRun ```sfun/sql/compile.m``` or ```sfun/webjson/compile.m```.\n\n## Usage\nUse the database example ```example/sql/sim_test.sql``` to setup the database.\nIn 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.\n\n## Notes\n- Compiled with MS Visual Studio 2017 Community.\n- Tested on Windows 10 x64.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg0mb4%2Fsimdatabase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fg0mb4%2Fsimdatabase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg0mb4%2Fsimdatabase/lists"}