These functions are located in the lib/common.g file. |
/*-------------------------------------------------------------------- * Function: send_hs_command * Returns: The return from the Cascade Historian, or nil * Description: Sends commands to the Cascade Historian. *------------------------------------------------------------------*/ function send_hs_command(widget, purpose, pt, args) { local tsk, arg0, arg1, arg2, arg3, ret1, ret2; /* Choose the correct history, based on the point name. */ local pt1 = parse_string(string(substr(string(pt), 0, 3), "DB")); local pt2 = parse_string(string(substr(string(pt), 0, 3), "DBP")); if ((tsk = locate_task("demohistdb", nil)) != nil) { switch (purpose) { case "enable": if (widget.switched_on()) ret1 = send(tsk, `enable()); else ret1 = send(tsk, `disable()); case "deadband": arg0 = string("\(absolute ", args[0], "\)"); arg1 = string("\(percent ", args[1], "\)"); arg2 = string("\(timelimit ", args[2], "\)"); arg3 = string("\(countlimit ", args[3], "\)"); ret1 = send(tsk, `deadband(@pt1, @arg0, @arg1, @arg2, @arg3)); ret2 = send(tsk, `deadband(@pt2, @arg0, @arg1, @arg2, @arg3)); /* Print the return values. */ princ("Deadband status for ", pt1, ":\n", ret1, "\n"); princ("Deadband status for ", pt2, ":\n", ret2, "\n"); case "version": ret1 = send(tsk, `version()); ret1; } close_task(tsk); } ret1; }
/*-------------------------------------------------------------------- * Function: assign_history * Returns: A string * Description: Changes the point-name suffix (_001) of a history to match * the corresponding deadbanded history. Called by the * .assign_values() function, which selects the proper * history based on the Y history and X history drop-down * boxes in the GUI. *------------------------------------------------------------------*/ function assign_history(dbset, history, entry) { switch (dbset) { case "NONE": history = entry; case "DB": history = string(substr(entry, 0, 3), "DB"); case "DBP": history = string(substr(entry, 0, 3), "DBP"); } history; }
/*-------------------------------------------------------------------- * Function: display_hs_info * Returns: An integer (50) * Description: Puts the Cascade Historian version number and instructions * into the text widget. Used only at start-up. *------------------------------------------------------------------*/ function display_hs_info(txt_wgt) { local version_string; for(i=0; i<=50; i++) { if ((version_string = string(send_hs_command(nil, "version", nil, nil))) != "nil") { anygui_show_text(txt_wgt, string("Now running ", substr(version_string, 9, 17), "\n", substr(version_string, 27, strstr(version_string, "at") - 27), "\n\nTo start the demo, ensure that\nthe PID Emulator ", "is running,\nthen press the Record button."), 3); i = 50; } else usleep(10000); } }
Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.