https://daq00.triumf.ca/MidasWiki/index.php?title=Hotlink_note&feed=atom&action=historyHotlink note - Revision history2024-03-28T19:38:36ZRevision history for this page on the wikiMediaWiki 1.39.6https://daq00.triumf.ca/MidasWiki/index.php?title=Hotlink_note&diff=1744&oldid=prevSuz at 22:00, 7 July 20152015-07-07T22:00:25Z<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 15:00, 7 July 2015</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l99">Line 99:</td>
<td colspan="2" class="diff-lineno">Line 99:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>https://ladd00.triumf.ca/elog/Midas/546</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>https://ladd00.triumf.ca/elog/Midas/546</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Hotlink]]</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Hotlink<ins style="font-weight: bold; text-decoration: none;">]] [[Category:Event</ins>]]</div></td></tr>
</table>Suzhttps://daq00.triumf.ca/MidasWiki/index.php?title=Hotlink_note&diff=1742&oldid=prevSuz at 21:58, 7 July 20152015-07-07T21:58:06Z<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 14:58, 7 July 2015</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l98">Line 98:</td>
<td colspan="2" class="diff-lineno">Line 98:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>K.O.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>K.O.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>https://ladd00.triumf.ca/elog/Midas/546</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>https://ladd00.triumf.ca/elog/Midas/546</div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">[[Category:Hotlink]]</ins></div></td></tr>
</table>Suzhttps://daq00.triumf.ca/MidasWiki/index.php?title=Hotlink_note&diff=44&oldid=prevOlchansk: Created page with "Here are my notes on the MIDAS ODB "hot link" function. Perhaps others can find them useful. Using db_open_record(key,function), the user can tell MIDAS to call the specified..."2013-07-22T17:44:14Z<p>Created page with "Here are my notes on the MIDAS ODB "hot link" function. Perhaps others can find them useful. Using db_open_record(key,function), the user can tell MIDAS to call the specified..."</p>
<p><b>New page</b></p><div>Here are my notes on the MIDAS ODB "hot link" function. Perhaps others can find them useful.<br />
<br />
Using db_open_record(key,function), the user can tell MIDAS to call the specified user function when <br />
the specified ODB key is modified by any other MIDAS program. This function works both locally <br />
(shared memory odb access) and remotely (odb access through mserver tcp rpc). For example, the <br />
MIDAS "history" mechanism is implemented in the mlogger by "hot-linking" ODB <br />
"/equipment/xxx/Variables".<br />
<br />
First, the relevant data structures defined in midas.h and msystem.h (ODB database headers, etc)<br />
<br />
(in midas.h)<br />
#define NAME_LENGTH 32 /**< length of names, mult.of 8! */<br />
#define MAX_CLIENTS 64 /**< client processes per buf/db */<br />
#define MAX_OPEN_RECORDS 256 /**< number of open DB records */<br />
<br />
(in msystem.h)<br />
DATABASE buf <--- local, private to each client)<br />
DATABASE_HEADER* database_header <--- odb in shared memory<br />
char name[NAME_LENGTH]<br />
DATABASE_CLIENT client[MAX_CLIENTS]<br />
char name[NAME_LENGTH]<br />
OPEN_RECORD open_record[MAX_OPEN_RECORDS]<br />
handle<br />
access_mode<br />
flags<br />
<br />
(the above means that each midas client has access to the list of all open records through<br />
buf->database_header.client[i].open_record[j])<br />
<br />
Second, the data path through db_set_data & co: (other odb "write" functions work the same way)<br />
<br />
db_set_data(key)<br />
lock db<br />
update odb <--- memcpy(), really<br />
db_notify_clients(key)<br />
unlock db<br />
return<br />
<br />
db_notify_clients(key)<br />
loop: <--- data for this key changed and so data for all keys containing it<br />
also changed, and we need to notify anybody who has an open record<br />
on the parents of this key. need to loop over parents of this key (follow "..")<br />
if (key->notify_count)<br />
foreach client<br />
foreach open_record<br />
if (open_record.handle == key)<br />
ss_resume(client->port, "O hDB hKey")<br />
key = key.parent<br />
goto loop;<br />
<br />
ss_resume(port, message)<br />
idx = ss_suspend_get_index() <--- magic here<br />
send udp message ("O hDB hKey") to localhost:port <-- notifications sent only to local host!<br />
<br />
note 1: I do not completely understand the ss_suspend_xxx() stuff. The best I can tell<br />
is it creates a number of udp sockets bound to the local host and at least one udp rpc<br />
receive socket ultimately connected to the cm_dispatch_rpc() function.<br />
<br />
note 2: More magic here: database_header->client[i].port appears to be the udp rpc server<br />
port of the mserver, while ODB /Clients/xxx/Port is the tcp rpc server port<br />
of the client itself, on the remote host<br />
<br />
note 3: the following is for remote odb clients connected through the mserver. For local<br />
clients, cm_dispatch_rpc() calls the local db_update_record() as shown at the very end.<br />
<br />
note 4: this uses udp rpc. If the udp datagram is lost inside the os kernel (it looks like these udp/rpc <br />
datagrams never go out to the network), "hot-link" silently fails: code below is not executed. Some <br />
OSes (namely, Linux) are known to lose udp datagrams with high probability under certain<br />
not very well understood conditions.<br />
<br />
local mserver receives the udp datagram<br />
...<br />
cm_dispatch_ipc()<br />
if (message=="O hDB hKey")<br />
decode message (hDB, hKey)<br />
db_update_record(hDB, hKey)<br />
send tcp rpc with args(MSG_ODB, hDB, hKey)<br />
<br />
(note- unlike udp rpc, tcp rpc are never "lost")<br />
<br />
remote client receives tcp rpc:<br />
rpc_client_dispatch()<br />
recv_tcp(net_buffer)<br />
if (net_buffer.routine_id == MSG_ODB)<br />
db_update_record(hDB, hKey)<br />
<br />
db_update_record(hDB, hKey)<br />
if remote delivery, see cm_dispatch_ipc() above<br />
<--- local delivery<br />
foreach (_recordlist)<br />
if (recordlist.handle == hKey)<br />
if (!recordlist.access_mode&MODE_WRITE)<br />
db_get_record(hDB,hKey,recordlist.data,recordlist.size)<br />
recordlist.dispatcher(hDB,hKey,recordlist.info); <-- user-supplied handler<br />
<br />
Note: the dispatcher() above is the function supplied by the user in db_open_record().<br />
<br />
K.O.<br />
https://ladd00.triumf.ca/elog/Midas/546</div>Olchansk