summaryrefslogtreecommitdiffstats
path: root/htdocs/index.html
blob: 2fdccd4ea084d7ed7b728f234927f8af80ea9e55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<html>

<head>
    <title>XDS data collector binding Test</title>
    <link rel="stylesheet" href="iotbzh-Binding.css">
    <link rel="icon" type="image/x-icon" href="assets/favicon.ico">
    <script type="text/javascript" src="AFB-websock.js"></script>
    <script type="text/javascript" src="iotbzh-Binding.js"></script>

    <script type="text/javascript" src="assets/d3.v3.min.js"></script>
    <!-- <script type="text/javascript" src="assets/d3.v5.min.js"></script> -->

    <link rel="stylesheet" href="d3js-graph.css">
    <script type="text/javascript" src="d3js-graph.js"></script>
</head>

<body class="page-content" onload="init()">

    <img src="assets/iot-bzh-logo-small.png">

    <h1>XDS data collector prototype Test</h1>

    <button id="connected" onclick="init()">Binder WS Fail</button>
    <button id="monitoring" onclick="window.open('/monitoring/monitor.html','_monitor_ctl')">Debug/Monitoring</a>
    </button>

    <br>
    <br>

    <div>
        <button onclick="callbinder('xds','list' ,{});">List</button>
        </li>

        <button onclick="graphAGLBindings();">Graph AGL bindings</button>
        </li>

        <button onclick="callbinder('xds', 'trace', {'ws': 'can_emul'});">Trace ws can_emul</button>
        </li>

    </div>

    <br>

    <div id="graph">
    </div>

    <br>

    <div id="main" style="visibility:hidden">
        <ol>
            <li>Question
                <pre id="question"></pre>
            </li>
            <li>Response
                <pre id="output"></pre>
            </li>
            <li>Events:
                <pre id="outevt"></pre>
            </li>
        </ol>
    </div>
</body>
span class="p">, .info = "ping test for API"}, {.verb = "exit", .callback = ctrlapi_exit, .info = "Exit test"}, {.verb = NULL} /* marker for end of the array */ }; static int CtrlLoadStaticVerbs(afb_dynapi *apiHandle, AFB_ApiVerbs *verbs) { int errcount = 0; for (int idx = 0; verbs[idx].verb; idx++) { errcount += afb_dynapi_add_verb( apiHandle, CtrlApiVerbs[idx].verb, NULL, CtrlApiVerbs[idx].callback, (void *)&CtrlApiVerbs[idx], CtrlApiVerbs[idx].auth, 0); } return errcount; }; static int CtrlInitOneApi(AFB_ApiT apiHandle) { // Hugely hack to make all V2 AFB_DEBUG to work in fileutils AFB_default = apiHandle; CtlConfigT *ctrlConfig = afb_dynapi_get_userdata(apiHandle); return CtlConfigExec(apiHandle, ctrlConfig); } // next generation dynamic API-V3 mode #include <signal.h> static int CtrlLoadOneApi(void *cbdata, AFB_ApiT apiHandle) { CtlConfigT *ctrlConfig = (CtlConfigT *)cbdata; // save closure as api's data context afb_dynapi_set_userdata(apiHandle, ctrlConfig); // add static controls verbs int err = CtrlLoadStaticVerbs(apiHandle, CtrlApiVerbs); if (err) { AFB_ApiError(apiHandle, "CtrlLoadSection fail to register static V2 verbs"); return ERROR; } // load section for corresponding API err = CtlLoadSections(apiHandle, ctrlConfig, ctrlSections); // declare an event event manager for this API; afb_dynapi_on_event(apiHandle, CtrlDispatchApiEvent); // init API function (does not receive user closure ??? afb_dynapi_on_init(apiHandle, CtrlInitOneApi); afb_dynapi_seal(apiHandle); return err; } int afbBindingEntry(afb_dynapi *apiHandle) { int status, err = 0; size_t len = 0; char *dirList; const char *prefix = CONTROL_PREFIX, *envDirList = NULL, *configPath = NULL; json_object *resourcesJ = NULL, *eventsJ = NULL; CtlConfigT *ctrlConfig = NULL; AFB_default = apiHandle; AFB_ApiNotice(apiHandle, "Controller in afbBindingEntry"); envDirList = getEnvDirList(prefix, "CONFIG_PATH"); if(envDirList) { len = strlen(CONTROL_CONFIG_PATH) + strlen(envDirList); dirList = malloc(len + 1); snprintf(dirList, len + 1, "%s:%s", envDirList, CONTROL_CONFIG_PATH); } else { dirList = CONTROL_CONFIG_PATH; } configPath = CtlConfigSearch(apiHandle, dirList, prefix); if (!configPath) { AFB_ApiError(apiHandle, "CtlPreInit: No %s* config found in %s ", GetBinderName(), dirList); return ERROR; } // load config file and create API ctrlConfig = CtlLoadMetaDataUsingPrefix(apiHandle, configPath, prefix); if (!ctrlConfig) { AFB_ApiError(apiHandle, "CtrlBindingDyn No valid control config file in:\n-- %s", configPath); return ERROR; } if (!ctrlConfig->api) { AFB_ApiError(apiHandle, "CtrlBindingDyn API Missing from metadata in:\n-- %s", configPath); return ERROR; } AFB_ApiNotice(apiHandle, "Controller API='%s' info='%s'", ctrlConfig->api, ctrlConfig->info); err = wrap_json_pack(&resourcesJ, "{s[{ss, ss, ss}]}", "resources", "uid", "AFT", "info", "LUA Binder test framework", "libs", "aft.lua" ); err += wrap_json_pack(&eventsJ, "{s[{ss, ss}]}", "events", "uid", "monitor/trace", "action", "lua://AFT#_evt_catcher_" ); if(err) { AFB_ApiError(apiHandle, "Error at Controller configuration editing."); return err; } wrap_json_object_add(ctrlConfig->configJ, resourcesJ); wrap_json_object_add(ctrlConfig->configJ, eventsJ); // create one API per config file (Pre-V3 return code ToBeChanged) status = afb_dynapi_new_api(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, CtrlLoadOneApi, ctrlConfig); return status; }