The examles in section 3. explain how to use the module in a php page.
2. Supported Versions / Platforms
PHP_EPICS has been tested with/on
Operating Systems
ca_get | varriant ca_get(string channel_name) | Get the value of the channel and return it with the correct variable type (double, int, string) |
ca_put | string ca_put(string channel_name,string channel_value) | Set the value of the specified channel to the new value. Returns either OK or an error message. |
ca_monitor | string ca_monitor(string channels,int timouout,string callback) | Setup a monitor on the channels (separated by commas) for the given "timeout" number of seconds. The function "callback" will be called each time some channel values change. The callback function need to receive 2 parameters, where the first is the channel modified, and the second is the new value. If 0 is specified for the timeout, the monitor will continue forever (not recommended). |
ca_type | string ca_type(string channel) | Return the type of data. |
ca_state | string ca_state(string channel) | Return the state of the channel. For example "Valid chid, connected to server" |
ca_info | array ca_info(string channel) | Return information about the channel, like the host serving it (returned in array). |
Example 1: test_ca_get_put.php
<?php #load external module dl("php_epics.so"); #call function ca_get implemented in the php_epics.so module and display #the result $rt = ca_get("TEST:ai1"); echo "Channel TEST:ai1 ".$rt; #in order to call ca_put function we want to pass a value as a parameter from #a text field echo "<FORM METHOD=GET ACTION=test_ca_get_put.php>\n"; echo "Channel TEST:ai2 <INPUT TYPE=TEXT NAME=CHANNEL VALUE=".$_GET["CHANNEL"].">"; echo "<INPUT TYPE=SUBMIT VALUE=Go>\n"; echo "</FORM>"; #call the function ca_put("TEST:ai2",$_GET["CHANNEL"]); #read and display the value echo "Channel TEST:ai2 ".ca_get("TEST:ai2"); #Note: Channels "TEST:ai1","TEST:ai2" are running as soft channels on a PC # on PSI network. ?>It looks like so:
Example 2: test_ca_monitor.php
You don't know and don't want to learn the php scripting language? Try to follow
the next section.
<?php
//load external module
dl("php_epics.so");
/* The function is called by ca_monitor imlemented in php_epics.so
* module any time when a value of one of EPICS channels changes
*Parameters:
* channel name
* value
*/
function test_monitor($a,$b) {
echo "test_monitor called: new value of $a is $b $<BR>\n";
//flush the output buffer to the browser
flush();
}
//flush the output buffer and turn off the output buffering
ob_end_flush() ;
//ca_monitor is implemented in php_epics.so module
$res=ca_monitor("TEST:ai1,TEST:ai2",40,"test_monitor");
echo "$res... Done.";
//Note: Channels "TEST:ai1","TEST:ai2" are running as soft channels on a PC
// on PSI network.
?>
It looks like so:
5. Things in progress
Currently a PHP parser/interpreter of adl files (MEDM) is under development. Once it will be finished,
it will allow to see/run (most if not all) MEDM pannel, directly from any recent web browser.
If you are interrested to see the current status of this development contact us.
Contacts:
Alain Bertrand, Renata Krempaska