{"id":20229021,"url":"https://github.com/contemporaries/example_ai_driver_ioc","last_synced_at":"2026-03-19T14:43:43.479Z","repository":{"id":240942567,"uuid":"767954320","full_name":"Contemporaries/example_ai_driver_ioc","owner":"Contemporaries","description":"EPICS IOC Eample for ai device driver","archived":false,"fork":false,"pushed_at":"2024-05-21T14:10:37.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T13:22:37.575Z","etag":null,"topics":["epics","epics-ioc"],"latest_commit_sha":null,"homepage":"","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Contemporaries.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-03-06T07:49:45.000Z","updated_at":"2024-08-02T08:50:46.000Z","dependencies_parsed_at":"2024-05-21T15:44:02.453Z","dependency_job_id":null,"html_url":"https://github.com/Contemporaries/example_ai_driver_ioc","commit_stats":null,"previous_names":["contemporaries/example_ai_driver_ioc"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Contemporaries/example_ai_driver_ioc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Contemporaries%2Fexample_ai_driver_ioc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Contemporaries%2Fexample_ai_driver_ioc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Contemporaries%2Fexample_ai_driver_ioc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Contemporaries%2Fexample_ai_driver_ioc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Contemporaries","download_url":"https://codeload.github.com/Contemporaries/example_ai_driver_ioc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Contemporaries%2Fexample_ai_driver_ioc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30205201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"ssl_error","status_checked_at":"2026-03-06T18:57:34.882Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["epics","epics-ioc"],"created_at":"2024-11-14T07:33:56.874Z","updated_at":"2026-03-07T01:35:01.907Z","avatar_url":"https://github.com/Contemporaries.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **IOC Dev Notes**\n\n\u003e IOC name: example\n\n## **Create IOC by EPICS tool**\n\n```shell\nmkdir example_ioc\ncd example_ioc\nmakeBaseApp.pl -t ioc example\nmakeBaseApp.pl -i -t ioc example\n```\n\n## **Create DB file**\n\n\u003e example.db\n\n```shell\nrecord(ai, \"example:ai\") {\n    field(DESC, \"this is a example of ai record\")\n    field(DTYP, \"EXAMPLE_AI\")\n    field(SCAN, \".1 second\")\n}\n```\n\n### **Makefile**\n\n```makefile\nTOP=../..\ninclude $(TOP)/configure/CONFIG\n#----------------------------------------\n#  ADD MACRO DEFINITIONS AFTER THIS LINE\n​\n#----------------------------------------------------\n# Create and install (or just install) into \u003ctop\u003e/db\n# databases, templates, substitutions like this\n#DB += xxx.db\nDB += example.db\n​\n#----------------------------------------------------\n# If \u003canyname\u003e.db template is not named \u003canyname\u003e*.template add\n# \u003canyname\u003e_template = \u003ctemplatename\u003e\n​\ninclude $(TOP)/configure/RULES\n#----------------------------------------\n#  ADD RULES AFTER THIS LINE\n​\n​\n```\n\n## **Source code**\n\n### **exampleMain.cpp**\n\n```cpp\n/*\n * @Author HuangLi\n * @Email lihuang@ihep.ac.cn\n * @Date 3/5/24\n * @Version 1.0.0\n */\n#include \u003cstddef.h\u003e\n#include \u003cstdlib.h\u003e\n#include \u003cstddef.h\u003e\n#include \u003cstring.h\u003e\n#include \u003cstdio.h\u003e\n​\n#include \"epicsExit.h\"\n#include \"epicsThread.h\"\n#include \"iocsh.h\"\n​\nint main(int argc,char *argv[])\n{\n    if(argc\u003e=2) {\n        iocsh(argv[1]);\n        epicsThreadSleep(.2);\n    }\n    iocsh(NULL);\n    epicsExit(0);\n    return(0);\n}\n​\n```\n\n### **DBD**\n\n\u003e example.dbd define device type\n\n```\n# Devices\ndevice(ai, INST_IO, EXAMPLE_AI, \"EXAMPLE_AI\")\n```\n\n### **ExampleAI.cpp**\n\n```cpp\n/*\n * @Author HuangLi\n * @Email lihuang@ihep.ac.cn\n * @Date 3/5/24\n * @Version 1.0.0\n */\n​\n#include \u003cstddef.h\u003e\n#include \u003cstdlib.h\u003e\n#include \u003ccstdlib\u003e\n#include \u003cctime\u003e\n#include \"limits\"\n​\n#include \"recGbl.h\"\n#include \"dbAccess.h\"\n​\n#include \"recSup.h\"\n#include \"devSup.h\"\n#include \"aiRecord.h\"\n#include \"epicsExport.h\"\n#include \u003ciostream\u003e\n​\nusing namespace std;\n​\nstatic long init(int *);\n​\nstatic long initRecord(aiRecord *pv);\n​\nstatic long readAI(aiRecord *pv);\n​\nstruct\n{\n    long number;\n    DEVSUPFUN report;\n    long (*init)(int *);\n    long (*initRecord)(aiRecord *);\n    DEVSUPFUN getIOIntInfo;\n    long (*readAI)(aiRecord *);\n    DEVSUPFUN specialLinConv;\n} EXAMPLE_AI = {\n    6,\n    NULL,\n    init,\n    initRecord,\n    NULL,\n    readAI,\n    NULL};\n​\nepicsExportAddress(dset, EXAMPLE_AI);\n​\nstatic long init(int *after)\n{\n    std::cout \u003c\u003c \"init\" \u003c\u003c std::endl;\n    return 0;\n}\n​\nstatic long initRecord(aiRecord *pv)\n{\n    std::cout \u003c\u003c \"initRecord\" \u003c\u003c std::endl;\n    pv-\u003eudf = FALSE;\n    return 0;\n}\n​\nstatic long readAI(aiRecord *pv)\n{\n    if (pv-\u003epact)\n    {\n        epicsFloat64 val = 0;\n        srand(time(nullptr));\n        int min = 1;\n        int max = 100;\n        val = min + (max - min) * (rand() / (double)RAND_MAX);\n        std::cout \u003c\u003c \"val: \" \u003c\u003c val \u003c\u003c std::endl;\n        pv-\u003eval = val;\n        pv-\u003eudf = FALSE;\n    }\n    else\n    {\n        pv-\u003epact = TRUE;\n        CALLBACK *pCallback = (CALLBACK *)(calloc(1, sizeof(CALLBACK)));\n        callbackRequestProcessCallbackDelayed(pCallback, priorityMedium, pv, 0.1);\n    }\n    return 2;\n}\n```\n\n### **Makefile**\n\n```makefile\nTOP=../..\n​\ninclude $(TOP)/configure/CONFIG\nUSR_CXXFLAGS += -std=c++11\nPROD_IOC = example\nDBD += example.dbd\nexample_DBD += base.dbd ../DBD/example.dbd\nSRC_DIRS += ../AI\n​\nexample_SRCS += example_registerRecordDeviceDriver.cpp\nexample_SRCS += ExampleAI.cpp\nexample_SRCS_DEFAULT += exampleMain.cpp\nexample_SRCS_vxWorks += -nil-\nexample_LIBS += $(EPICS_BASE_IOC_LIBS)\n​\n​\ninclude $(TOP)/configure/RULES\n```\n\n## **Run**\n\n```shell\ninit\ninitRecord\ninit\niocRun: All initialization complete\nval: 21.263\nepics\u003e val: 21.263\nval: 21.263\nval: 21.263\nval: 21.263\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontemporaries%2Fexample_ai_driver_ioc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcontemporaries%2Fexample_ai_driver_ioc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontemporaries%2Fexample_ai_driver_ioc/lists"}