Commit 3ba801ae authored by Claes Sjofors's avatar Claes Sjofors

Xtt commands 'wait' and 'close graph/classgraph' added

parent 49e52a1d
......@@ -54,6 +54,6 @@ queuefull <Queue is full> /error
waveformat <Unsupported wavefile format> /error
filecorrupt <File is corrupt> /error
notcollectw <Not collect window> /error
noclassgraph <No classgraph found> /error
......@@ -165,4 +165,6 @@
100201 cs xtt Commands 'open graph /class/parent' and 'check isattribute' added button in object graphs to open parent object graph.
100209 cs xtt Error message for invalid local attributes in Ge graphs.
100209 cs ge Command 'set attr/bypass' replaced by action SetValue in object graphs.
100209 cs ge PID object graph, indicator for Inverse didn't work.
\ No newline at end of file
100209 cs ge PID object graph, indicator for Inverse didn't work.
100216 cs xtt Command 'close graph', qualifier /classgraph added.
100216 cs xtt Command 'wait' added.
\ No newline at end of file
......@@ -44,6 +44,13 @@ typedef struct {
} wow_sSelection;
CoWowGtk::~CoWowGtk()
{
if ( m_wait_timerid)
g_source_remove( m_wait_timerid);
}
void CoWowGtk::question_ok_cb( GtkWidget *w, gpointer data)
{
wow_t_question_cb *cbdata = (wow_t_question_cb *) data;
......@@ -735,6 +742,7 @@ CoWowTimerGtk::~CoWowTimerGtk()
{
if ( m_timerid)
g_source_remove( m_timerid);
}
void CoWowTimerGtk::add( int time, void (* callback)(void *data), void *data)
......@@ -1315,6 +1323,23 @@ pwr_tStatus CoWowGtk::DeleteMenuItem( const char *name, void *menu)
}
gboolean CoWowGtk::wait_cb( void *data)
{
((CoWowGtk *)data)->m_wait_timerid = 0;
gtk_main_quit();
return FALSE;
}
void CoWowGtk::Wait( float time)
{
m_wait_timerid = g_timeout_add( int(time * 1000), wait_cb, this);
gtk_main();
}
......
......@@ -87,9 +87,10 @@ class CoWowTimerGtk : public CoWowTimer {
class CoWowGtk : public CoWow {
public:
GtkWidget *m_parent;
gint m_wait_timerid;
CoWowGtk( GtkWidget *parent) : m_parent(parent) {}
~CoWowGtk() {}
CoWowGtk( GtkWidget *parent) : m_parent(parent), m_wait_timerid(0) {}
~CoWowGtk();
void DisplayQuestion( void *ctx, const char *title, const char *text,
void (* questionbox_ok) ( void *, void *),
void (* questionbox_cancel) ( void *, void *),
......@@ -116,6 +117,7 @@ class CoWowGtk : public CoWow {
pwr_tStatus DeleteMenuItem( const char *name, void *menu);
CoWowTimer *timer_new();
void SetParent( GtkWidget *parent) { m_parent = parent;}
void Wait( float time);
static void PopupPosition( GtkWidget *parent, int x_event, int y_event, int *x, int *y);
static void GetAtoms( GdkAtom *graph_atom, GdkAtom *objid_atom, GdkAtom *attrref_atom);
......@@ -140,6 +142,8 @@ class CoWowGtk : public CoWow {
static void list_apply_cb( GtkWidget *w, gpointer data);
static void list_ok_cb( GtkWidget *w, gpointer data);
static void list_cancel_cb( GtkWidget *w, gpointer data);
static gboolean wait_cb( void *data);
};
#endif
......
......@@ -106,13 +106,14 @@ class CoWow {
const char *button1, const char *button2,
const char *button3, const char *image,
int input_length) { return 0;}
virtual void Wait( float time) {}
static int HideWarranty();
virtual int DisplayWarranty() { return 0;}
virtual void DisplayLicense() {}
virtual CoWowTimer *timer_new() { return 0;}
virtual pwr_tStatus CreateMenuItem( const char *name, void *menu, int pixmap, int append, void *w) { return 0;}
virtual pwr_tStatus DeleteMenuItem( const char *name, void *menu) { return 0;}
};
#endif
......
......@@ -501,6 +501,7 @@ class XNav {
int create_object( char *classname, char *name);
int delete_object( char *name);
void print_methods();
static pwr_tStatus get_instance_classgraph( char *instance_str, pwr_tFileName filename);
// Table module member functions
int show_plcthreads();
......
......@@ -211,6 +211,8 @@ static int xnav_write_func( void *client_data,
void *client_flag);
static int xnav_read_func( void *client_data,
void *client_flag);
static int xnav_wait_func( void *client_data,
void *client_flag);
dcli_tCmdTable xnav_command_table[] = {
{
......@@ -226,25 +228,25 @@ dcli_tCmdTable xnav_command_table[] = {
"OPEN",
&xnav_open_func,
{ "dcli_arg1", "dcli_arg2", "/NAME", "/FILE",
"/SCROLLBAR", "/WIDTH", "/HEIGHT", "/MENU",
"/NAVIGATOR", "/CENTER", "/OBJECT", "/NEW",
"/INSTANCE", "/COLLECT", "/FOCUS", "/INPUTEMPTY",
"/ENTRY", "/TITLE", "/ACCESS", "/CLASSGRAPH", "/PARENT", "/BYPASS",
"/CLOSEBUTTON", "/TARGET", "/TRIGGER", "/TYPE", "/FTYPE", ""}
"/SCROLLBAR", "/WIDTH", "/HEIGHT", "/MENU",
"/NAVIGATOR", "/CENTER", "/OBJECT", "/NEW",
"/INSTANCE", "/COLLECT", "/FOCUS", "/INPUTEMPTY",
"/ENTRY", "/TITLE", "/ACCESS", "/CLASSGRAPH", "/PARENT", "/BYPASS",
"/CLOSEBUTTON", "/TARGET", "/TRIGGER", "/TYPE", "/FTYPE", ""}
},
{
"CLOSE",
&xnav_close_func,
{ "dcli_arg1", "dcli_arg2", "/NAME", "/OBJECT",
"/INSTANCE", "/ALL", "/EXCEPT", ""}
"/INSTANCE", "/CLASSGRAPH", "/ALL", "/EXCEPT", ""}
},
{
"CREATE",
&xnav_create_func,
{ "dcli_arg1", "/TEXT", "/MENU", "/DESTINATION",
"/COMMAND", "/AFTER", "/BEFORE", "/FIRSTCHILD",
"/COMMAND", "/AFTER", "/BEFORE", "/FIRSTCHILD",
"/LASTCHILD", "/CLASS", "/NAME", "/PIXMAP",
""}
""}
},
{
"DELETE",
......@@ -282,9 +284,9 @@ dcli_tCmdTable xnav_command_table[] = {
"HELP",
&xnav_help_func,
{ "dcli_arg1", "dcli_arg2", "dcli_arg3", "dcli_arg4",
"/HELPFILE", "/POPNAVIGATOR", "/BOOKMARK",
"/INDEX", "/BASE", "/RETURNCOMMAND", "/WIDTH",
"/HEIGHT", "/VERSION", ""}
"/HELPFILE", "/POPNAVIGATOR", "/BOOKMARK",
"/INDEX", "/BASE", "/RETURNCOMMAND", "/WIDTH",
"/HEIGHT", "/VERSION", ""}
},
{
"LOGOUT",
......@@ -305,13 +307,13 @@ dcli_tCmdTable xnav_command_table[] = {
"CROSSREFERENCE",
&xnav_crossref_func,
{ "dcli_arg1", "/NAME", "/FILE", "/STRING", "/BRIEF",
"/FUNCTION", "/CASE_SENSITIVE", "/WINDOW", ""}
"/FUNCTION", "/CASE_SENSITIVE", "/WINDOW", ""}
},
{
"SET",
&xnav_set_func,
{ "dcli_arg1", "dcli_arg2", "/NAME", "/VALUE",
"/BYPASS", "/INDEX", "/SOURCE", ""}
"/BYPASS", "/INDEX", "/SOURCE", ""}
},
{
"SETUP",
......@@ -337,10 +339,10 @@ dcli_tCmdTable xnav_command_table[] = {
"LOGGING",
&xnav_logging_func,
{ "dcli_arg1", "dcli_arg2", "/FILE", "/TIME", "/ENTRY",
"/TYPE", "/PARAMETER", "/CONDITION", "/INSERT",
"/BUFFER_SIZE", "/PRIORITY", "/STOP", "/NOSTOP",
"/CREATE", "/ALL", "/LINE_SIZE", "/SHORTNAME",
"/NOSHORTNAME", ""}
"/TYPE", "/PARAMETER", "/CONDITION", "/INSERT",
"/BUFFER_SIZE", "/PRIORITY", "/STOP", "/NOSTOP",
"/CREATE", "/ALL", "/LINE_SIZE", "/SHORTNAME",
"/NOSHORTNAME", ""}
},
{
"CALL",
......@@ -374,6 +376,11 @@ dcli_tCmdTable xnav_command_table[] = {
&xnav_read_func,
{ "dcli_arg1", "/OBJECT", "/FILE", ""}
},
{
"WAIT",
&xnav_wait_func,
{ "dcli_arg1", "/TIME", ""}
},
{"",}};
......@@ -2570,8 +2577,6 @@ static int xnav_open_func( void *client_data,
pwr_tFileName fname;
int use_default_access;
unsigned int access;
pwr_tAName aname;
pwr_tEnum graph_conf;
// Command is "OPEN GRAPH" without graph object
scrollbar = ODD( dcli_get_qualifier( "/SCROLLBAR", 0, 0));
......@@ -2615,77 +2620,16 @@ static int xnav_open_func( void *client_data,
else {
if ( classgraph) {
// Get file from class of instance object
pwr_sAttrRef aref;
pwr_tObjName cname;
pwr_tCid cid;
pwr_tFileName found_file;
if ( !instance_p) {
xnav->message('E',"Enter instance object");
return XNAV__HOLDCOMMAND;
}
sts = gdh_NameToAttrref( pwr_cNObjid, instance_p, &aref);
sts = XNav::get_instance_classgraph( instance_p, file_str);
if ( EVEN(sts)) {
xnav->message('E',"Instance object not found");
return XNAV__HOLDCOMMAND;
}
sts = gdh_GetAttrRefTid( &aref, &cid);
while ( ODD(sts)) {
// Try all superclasses
sts = gdh_ObjidToName( cdh_ClassIdToObjid( cid), cname, sizeof(cname),
cdh_mName_object);
if ( EVEN(sts)) return sts;
cdh_ToLower( cname, cname);
if ( cdh_CidToVid(cid) < cdh_cUserClassVolMin ||
(cdh_CidToVid(cid) >= cdh_cManufactClassVolMin &&
cdh_CidToVid(cid) <= cdh_cManufactClassVolMax)) {
if ( cname[0] == '$')
sprintf( file_str, "pwr_c_%s", &cname[1]);
else
sprintf( file_str, "pwr_c_%s", cname);
}
else
strcpy( file_str, cname);
// Get base class graphs on $pwr_exe
cdh_ToLower( fname, file_str);
if ( instance_p &&
(cdh_NoCaseStrncmp( fname, "pwr_c_", 6) == 0 ||
cdh_NoCaseStrncmp( fname, "pwr_c_", 6) == 0)) {
strcpy( fname, "$pwr_exe/");
strcat( fname, file_str);
strcpy( file_str, fname);
}
else {
strcpy( fname, "$pwrp_exe/");
strcat( fname, file_str);
strcpy( file_str, fname);
}
// Add any GraphConfiguration to filename
strcpy( aname, instance_p);
strcat( aname, ".GraphConfiguration");
sts = gdh_GetObjectInfo( aname, &graph_conf, sizeof(graph_conf));
if ( ODD(sts)) {
if ( graph_conf != 0) {
char gc[12];
sprintf( gc, "%d", graph_conf);
strcat( fname, gc);
}
strcpy( file_str, fname);
}
strcat( fname, ".pwg");
sts = dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_INIT);
dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_END);
if ( ODD(sts)) break;
sts = gdh_GetSuperClass( cid, &cid, aref.Objid);
}
if ( EVEN(sts)) {
xnav->message('E',"No classgraph found");
xnav->message('E', XNav::get_message(sts));
return XNAV__HOLDCOMMAND;
}
......@@ -3583,12 +3527,23 @@ static int xnav_close_func( void *client_data,
pwr_tAName object_str;
pwr_tAName instance_str;
char *instance_p;
int classgraph;
if ( ODD( dcli_get_qualifier( "/INSTANCE", instance_str, sizeof(instance_str))))
instance_p = instance_str;
else
instance_p = 0;
if ( ODD( dcli_get_qualifier( "/CLASSGRAPH", 0, 0))) {
classgraph = 1;
if ( !instance_p) {
xnav->message('E', "Instance is missing");
return XNAV__HOLDCOMMAND;
}
}
else
classgraph = 0;
if ( ODD( dcli_get_qualifier( "/OBJECT", object_str, sizeof(object_str))))
{
pwr_tObjid objid;
......@@ -3635,29 +3590,42 @@ static int xnav_close_func( void *client_data,
char fname[80];
// Command is "CLOSE GRAPH"
if ( ODD( dcli_get_qualifier( "dcli_arg2", file_str, sizeof(file_str))))
{
if ( file_str[0] == '/')
{
if ( ODD( dcli_get_qualifier( "dcli_arg2", file_str, sizeof(file_str)))) {
if ( file_str[0] == '/') {
xnav->message('E', "Syntax error");
return XNAV__HOLDCOMMAND;
}
}
else if ( EVEN( dcli_get_qualifier( "/FILE", file_str, sizeof(file_str))))
{
else if ( classgraph) {
// Get file from class of instance object
pwr_tStatus sts;
if ( !instance_p) {
xnav->message('E',"Enter instance object");
return XNAV__HOLDCOMMAND;
}
sts = XNav::get_instance_classgraph( instance_p, file_str);
if ( EVEN(sts)) {
xnav->message('E', XNav::get_message(sts));
return XNAV__HOLDCOMMAND;
}
}
else if ( ODD( dcli_get_qualifier( "/FILE", file_str, sizeof(file_str)))) {
// Get base class graphs on $pwr_exe
if ( instance_p &&
(cdh_NoCaseStrncmp( fname, "pwr_c_", 6) == 0 ||
cdh_NoCaseStrncmp( fname, "pwr_t_", 6) == 0)) {
strcpy( fname, "$pwr_exe/");
strcat( fname, file_str);
strcpy( file_str, fname);
}
}
else {
xnav->message('E',"Enter file");
return XNAV__HOLDCOMMAND;
}
// Get base class graphs on $pwr_exe
// cdh_ToUpper( fname, file_str);
if ( instance_p &&
(cdh_NoCaseStrncmp( fname, "pwr_c_", 6) == 0 ||
cdh_NoCaseStrncmp( fname, "pwr_t_", 6) == 0)) {
strcpy( fname, "$pwr_exe/");
strcat( fname, file_str);
strcpy( file_str, fname);
}
xnav->close_graph( file_str, instance_p);
return XNAV__SUCCESS;
......@@ -5317,6 +5285,33 @@ static int xnav_read_func(void *client_data,
return XNAV__SUCCESS;
}
static int xnav_wait_func(void *client_data,
void *client_flag)
{
XNav *xnav = (XNav *)client_data;
char time_str[80];
float ftime;
int sts;
if ( EVEN( dcli_get_qualifier( "/TIME", time_str, sizeof(time_str)))) {
if ( EVEN( dcli_get_qualifier( "dcli_arg1", time_str, sizeof(time_str)))) {
xnav->message('E', "Time is missing");
return XNAV__HOLDCOMMAND;
}
}
sts = sscanf( time_str, "%f", &ftime);
if ( sts != 1) {
xnav->message('E', "Time syntax error");
return XNAV__HOLDCOMMAND;
}
xnav->wow->Wait( ftime);
return XNAV__SUCCESS;
}
int XNav::show_database()
{
int sts;
......@@ -7311,3 +7306,76 @@ static void xnav_show_objectlist_cancel_cb( void *ctx)
}
pwr_tStatus XNav::get_instance_classgraph( char *instance_str, pwr_tFileName filename)
{
// Get file from class of instance object
pwr_tStatus sts;
pwr_sAttrRef aref;
pwr_tObjName cname;
pwr_tCid cid;
pwr_tFileName found_file, fname, file_str;
pwr_tAName aname;
pwr_tEnum graph_conf;
sts = gdh_NameToAttrref( pwr_cNObjid, instance_str, &aref);
if ( EVEN(sts)) return sts;
sts = gdh_GetAttrRefTid( &aref, &cid);
while ( ODD(sts)) {
// Try all superclasses
sts = gdh_ObjidToName( cdh_ClassIdToObjid( cid), cname, sizeof(cname),
cdh_mName_object);
if ( EVEN(sts)) return sts;
cdh_ToLower( cname, cname);
if ( cdh_CidToVid(cid) < cdh_cUserClassVolMin ||
(cdh_CidToVid(cid) >= cdh_cManufactClassVolMin &&
cdh_CidToVid(cid) <= cdh_cManufactClassVolMax)) {
if ( cname[0] == '$')
sprintf( file_str, "pwr_c_%s", &cname[1]);
else
sprintf( file_str, "pwr_c_%s", cname);
}
else
strcpy( file_str, cname);
// Get base class graphs on $pwr_exe
cdh_ToLower( fname, file_str);
if ( (cdh_NoCaseStrncmp( fname, "pwr_c_", 6) == 0 ||
cdh_NoCaseStrncmp( fname, "pwr_c_", 6) == 0)) {
strcpy( fname, "$pwr_exe/");
strcat( fname, file_str);
strcpy( file_str, fname);
}
else {
strcpy( fname, "$pwrp_exe/");
strcat( fname, file_str);
strcpy( file_str, fname);
}
// Add any GraphConfiguration to filename
strcpy( aname, instance_str);
strcat( aname, ".GraphConfiguration");
sts = gdh_GetObjectInfo( aname, &graph_conf, sizeof(graph_conf));
if ( ODD(sts)) {
if ( graph_conf != 0) {
char gc[12];
sprintf( gc, "%d", graph_conf);
strcat( fname, gc);
}
strcpy( file_str, fname);
}
strcat( fname, ".pwg");
sts = dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_INIT);
dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_END);
if ( ODD(sts)) break;
sts = gdh_GetSuperClass( cid, &cid, aref.Objid);
}
if ( EVEN(sts))
return XNAV__NOCLASSGRAPH;
strcpy( filename, fname);
return XNAV__SUCCESS;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment