Commit 42c0305b authored by Claes Sjofors's avatar Claes Sjofors

rt_xtt_cmd, program for xtt commands added

parent d7adc79d
......@@ -774,7 +774,7 @@ int dcli_qio_assign( char *s, dcli_sChannel *chn)
return 0;
}
}
sts = dcli_qio_set_attr( &chan);
sts = dcli_qio_set_attr( &chan, 10);
*chn = (dcli_sChannel) chan;
return 1;
}
......@@ -785,7 +785,7 @@ int dcli_qio_assign( char *s, dcli_sChannel *chn)
/************************************************************************
*
* Name: dcli_qio_set_attr( dcli_sChannel *chn)
* Name: dcli_qio_set_attr( dcli_sChannel *chn, int tmo)
*
* Type: int
*
......@@ -795,7 +795,7 @@ int dcli_qio_assign( char *s, dcli_sChannel *chn)
*
* Description: Set attributes to a tty
*************************************************************************/
int dcli_qio_set_attr( dcli_sChannel *chn)
int dcli_qio_set_attr( dcli_sChannel *chn, int tmo)
#if defined(OS_VMS) || defined(OS_ELN)
{
return DCLI__SUCCESS;
......@@ -812,7 +812,7 @@ int dcli_qio_set_attr( dcli_sChannel *chn)
if ( sts != 0) return 0;
t.c_cc[VMIN] = 0;
t.c_cc[VTIME] = 10;
t.c_cc[VTIME] = tmo;
t.c_lflag &= ~ICANON;
t.c_lflag &= ~ECHO;
/* t.c_iflag ...*/
......
......@@ -81,7 +81,7 @@ int dcli_get_input_string( dcli_sChannel *chn,
const char *prompt);
int dcli_qio_assign( char *s, dcli_sChannel *chn);
int dcli_qio_set_attr( dcli_sChannel *chn);
int dcli_qio_set_attr( dcli_sChannel *chn, int tmo);
int dcli_qio_reset( dcli_sChannel *chn);
int dcli_qio_readw( dcli_sChannel *chn, char *buf, int len);
int dcli_qio_read( dcli_sChannel *chn, int tmo, char *buf, int len);
......
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include ../../special.mk
-include ../special.mk
-include special.mk
ifndef link_rule_mk
link_rule_mk := 1
ifeq ($(export_type),exp)
link = $(ldxx) $(explinkflags) $(domap) -o $(pwr_exe)/rt_xtt_cmd_gtk \
$(bld_dir)/rt_xtt_cmd_gtk.o $(bld_dir)/xtt_cmd_main.o $(rt_msg_eobjs) \
$(pwr_eobj)/rt_io_user.o \
$(pwre_conf_libdir) $(pwre_conf_libpwrxttgtk) $(pwre_conf_libpwrxtt) \
$(pwre_conf_libpwrxttgtk) $(pwre_conf_libpwrxtt) \
$(pwre_conf_libgtk) \
$(pwre_conf_libpwrrt) $(pwre_conf_lib)
else
link = $(ldxx) $(elinkflags) $(domap) -o $(pwr_exe)/rt_xtt_cmd_gtk \
$(bld_dir)/rt_xtt_cmd_gtk.o $(bld_dir)/xtt_cmd_main.o $(rt_msg_eobjs) \
$(pwr_eobj)/rt_io_user.o \
$(pwre_conf_libdir) $(pwre_conf_libpwrxttgtk) $(pwre_conf_libpwrxtt) \
$(pwre_conf_libpwrxttgtk) $(pwre_conf_libpwrxtt) \
$(pwre_conf_libgtk) \
$(pwre_conf_libpwrrt) $(pwre_conf_lib)
endif
endif
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/* wb_cmd_gtk.c -- command file processing
The main program of pwrc. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include "pwr.h"
#include "pwr_class.h"
#include "co_dcli.h"
#include "rt_load.h"
#include "co_dcli_input.h"
#include "co_lng.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "rt_xtt_gtk.h"
#include "xtt_xnav_gtk.h"
#include "xtt_item.h"
#include "xtt_url.h"
#include "xtt_xcolwind.h"
#include "co_lng.h"
#include "cow_xhelp_gtk.h"
#include "cow_wow_gtk.h"
#include "rt_xnav_msg.h"
#include "co_syi.h"
#include "rt_xtt_cmd_gtk.h"
XttCmdGtk::XttCmdGtk( GtkWidget *w)
{
pwr_tStatus sts;
pwr_tOName opplace = "";
xnav = new XNavGtk( this, (GtkWidget *)w, "Plant",
&brow_widget, (xnav_sStartMenu *)root_menu,
opplace, 0, &sts);
xnav->message_cb = &message_cb;
xnav->close_cb = XttCmd::close_cb;
xnav->login();
}
static int timeout_func()
{
while ( gtk_events_pending())
gtk_main_iteration();
return 1;
}
int main(int argc, char *argv[])
{
pwr_tStatus sts;
int i;
char str[256] ;
XttCmdGtk *cmd;
int quiet = 0;
int hide = 0;
const int window_width = 400;
const int window_height = 700;
GtkWidget *toplevel;
char title[80];
/* If arguments, treat them as a command and then exit */
// Open directory volume as default
str[0] = 0;
for ( i = 1; i < argc; i++) {
if ( argv[i][0] == '-') {
switch ( argv[i][1]) {
case 'h':
XttCmd::usage();
exit(0);
case 'q':
// Quiet
quiet = 1;
break;
case 'i':
// Hide
hide = 1;
break;
default:
cout << "Unknown argument: " << argv[i] << endl;
}
}
else {
if ( str[0] != 0)
strcat( str, " ");
strcat( str, argv[i]);
}
}
sts = gdh_Init("rt_xtt_cmd");
if (EVEN(sts)) {
printf( "Unable to connect to database\n");
exit(0);
}
gtk_init( &argc, &argv);
setlocale( LC_TIME, "en_US");
setlocale( LC_NUMERIC, "POSIX");
strcat( title, "Xtt Cmd");
// Gtk
toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", window_height,
"default-width", window_width,
"title", title,
NULL);
cmd = new XttCmdGtk( toplevel);
gtk_container_add( GTK_CONTAINER(toplevel), cmd->brow_widget);
gtk_widget_show_all( toplevel);
if ( hide)
g_object_set( toplevel, "visible", FALSE, NULL);
if ( !quiet)
cout << "\n\
Proview is free software; covered by the GNU General Public License.\n\
You can redistribute it and/or modify it under the terms of this license.\n\
\n\
Proview is distributed in the hope that it will be useful \n\
but WITHOUT ANY WARRANTY; without even the implied warranty of \n\
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \n\
GNU General Public License for more details.\n\n";
if ( str[0] != 0) {
dcli_remove_blank( str, str);
sts = cmd->xnav->command(str);
if ( ODD(sts))
return 0;
exit(sts);
}
sts = dcli_input_init( &cmd->chn, &cmd->recall_buf);
if ( EVEN(sts)) exit(sts);
// Init input
while ( 1 )
{
unsigned long terminator;
unsigned long option = DCLI_OPT_TIMEOUT;
/* get and parse the command */
/* get input */
dcli_qio_set_attr( &cmd->chn, 1);
sts = dcli_get_input_string( &cmd->chn, str, &terminator, sizeof(str), cmd->recall_buf, option,
1, timeout_func, 0, "xttc> ");
dcli_qio_reset( &cmd->chn);
// sts = scanf( "%s", str);
if ( strcmp( str, "") == 0)
continue;
dcli_remove_blank( str, str);
sts = cmd->xnav->command(str);
while ( gtk_events_pending())
gtk_main_iteration();
}
dcli_input_end( &cmd->chn, cmd->recall_buf);
}
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#ifndef rt_xtt_cmd_gtk_h
#define rt_xtt_cmd_gtk_h
#ifndef rt_xtt_cmd_h
# include "rt_xtt_cmd.h"
#endif
class XttCmdGtk : public XttCmd {
public:
XttCmdGtk( GtkWidget *w);
GtkWidget *toplevel;
GtkWidget *brow_widget;
};
#endif
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include ../../special.mk
-include ../special.mk
-include special.mk
ifndef link_rule_mk
link_rule_mk := 1
link = $(ldxx) $(elinkflags) $(domap) -o $(export_exe) \
$(export_obj) \
$(pwre_conf_libdir) $(pwre_conf_libpwrrt) $(pwre_conf_lib)
endif
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/* wb.cpp -- graphical editor */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include "pwr.h"
#include "co_dcli.h"
int main( int argc, char *argv[])
{
int i;
int found = 0;
char wmg[80];
pwr_tFileName file;
if ( argc > 1) {
for ( i = 1; i < argc; i++) {
if ( strcmp( argv[i], "-f") == 0) {
if ( i+1 >= argc) {
printf( "rt_xtt_cmd: Syntax error\n");
exit(0);
}
found = 1;
strcpy( wmg, argv[i+1]);
i++;
}
}
}
if ( !found) {
struct stat st;
strcpy( file, "$pwr_exe/rt_xtt_cmd_gtk");
dcli_translate_filename( file, file);
if ( stat( file, &st) == 0)
strcpy( wmg, "gtk");
else
strcpy( wmg, "motif");
}
strcpy( file, argv[0]);
strcat( file, "_");
strcat( file, wmg);
execvp( file, argv);
}
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#ifndef rt_xtt_cmd_h
#define rt_xtt_cmd_h
#ifndef pwr_h
# include "pwr.h"
#endif
#ifndef xtt_xnav_h
# include "xtt_xnav.h"
#endif
#ifndef co_dcli_input_h
# include "co_dcli_input.h"
#endif
class XttCmd {
public:
XttCmd();
XNav *xnav;
dcli_sChannel chn;
dcli_sRecall *recall_buf;
static void usage();
static void message_cb( void *ctx, char severity, const char *msg);
static void close_cb( void *ctx, int terminate);
static xnav_sStartMenu alarm_menu[];
static xnav_sStartMenu nethandler_menu[];
static xnav_sStartMenu communication_menu[];
static xnav_sStartMenu logging_menu[];
static xnav_sStartMenu system_menu[];
static xnav_sStartMenu root_menu[];
};
#endif
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/* xtt_cmd.c -- command file processing */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "pwr.h"
#include "pwr_class.h"
#include "co_dcli.h"
#include "rt_load.h"
#include "wb_foe_msg.h"
#include "co_dcli_input.h"
#include "flow.h"
#include "flow_ctx.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "xtt_xnav.h"
#include "xtt_item.h"
#include "rt_xtt_cmd.h"
xnav_sStartMenu XttCmd::alarm_menu[] = {
{ "Alarm List", xnav_eItemType_Command, menu_ePixmap_List, (void *) "show alarm"},
{ "Event List", xnav_eItemType_Command, menu_ePixmap_List, (void *) "show event"},
{ "Blocked Alarms", xnav_eItemType_Command, menu_ePixmap_List, (void *) "show block"},
{ "Historical List", xnav_eItemType_Command, menu_ePixmap_List, (void *) "show hist"},
{ "", 0, 0, NULL}};
xnav_sStartMenu XttCmd::nethandler_menu[] = {
{ "Link", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show link"},
{ "Subscription Client", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show subcli"},
{ "Subscription Server", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show subsrv"},
{ "", 0, 0, NULL}};
xnav_sStartMenu XttCmd::communication_menu[] = {
{ "RemNode", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show remnode"},
{ "RemTrans", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show remtrans"},
{ "", 0, 0, NULL}};
xnav_sStartMenu XttCmd::logging_menu[] = {
{ "Logging entry 1", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show logging/entry=1"},
{ "Logging entry 2", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show logging/entry=2"},
{ "Logging entry 3", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show logging/entry=3"},
{ "Logging entry 4", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show logging/entry=4"},
{ "Logging entry 5", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show logging/entry=5"},
{ "Logging entry 6", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show logging/entry=6"},
{ "Logging entry 7", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show logging/entry=7"},
{ "Logging entry 8", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show logging/entry=8"},
{ "Logging entry 9", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show logging/entry=9"},
{ "Logging entry 10", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show logging/entry=10"},
{ "", 0, 0, NULL}};
xnav_sStartMenu XttCmd::system_menu[] = {
{ "Nethandler", xnav_eItemType_Menu, menu_ePixmap_Map, (void *)&XttCmd::nethandler_menu},
{ "Communication", xnav_eItemType_Menu, menu_ePixmap_Map, (void *)&XttCmd::communication_menu},
{ "Device", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show device"},
{ "PlcThread", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show plcthread"},
{ "PlcPgm", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show plcpgm"},
{ "Logging", xnav_eItemType_Menu, menu_ePixmap_Map, (void *)&XttCmd::logging_menu},
{ "System Messages", xnav_eItemType_Command, menu_ePixmap_List, (void *) "open consolelog"},
{ "System Status", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show nodeinfo"},
{ "Nodes", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show nodeobjects"},
{ "Volumes", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show volumes"},
{ "", 0, 0, NULL}};
xnav_sStartMenu XttCmd::root_menu[] = {
{ "Database", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show database"},
{ "Alarm", xnav_eItemType_Menu, menu_ePixmap_Map, (void *)&XttCmd::alarm_menu},
{ "Store", xnav_eItemType_Command, menu_ePixmap_Map, (void *) "show file"},
{ "System", xnav_eItemType_Menu, menu_ePixmap_Map, (void *)&XttCmd::system_menu},
{ "Close", xnav_eItemType_Command, menu_ePixmap_Leaf, (void *) "exit"},
{ "", 0, 0, NULL}};
void XttCmd::usage()
{
cout << endl << endl <<
"xttc Proview Runtime Commands" << endl << endl <<
"Arguments:" << endl <<
" -h Print usage." << endl <<
" -q Quiet. Don't print license information." << endl <<
" -i Hide navigator." << endl << endl <<
" Other arguments are treated as a command and passed to the command parser" << endl <<
" If a command is given as an argument, the command will be executed and the" << endl <<
" program is then terminated." << endl <<
" If no command is given, xttc will prompt for a command." << endl << endl <<
"Examples:" << endl <<
" $ xttc" << endl <<
" xttc>" << endl << endl <<
" " << endl;
}
void XttCmd::message_cb( void *ctx, char severity, const char *msg)
{
if ( strcmp( msg, "") != 0)
printf( "XNAV-'%c'-MSG, %s\n", severity, msg);
}
void XttCmd::close_cb( void *ctx, int terminate)
{
XttCmd *cmd = (XttCmd *) ctx;
dcli_input_end( &cmd->chn, cmd->recall_buf);
exit(0);
}
XttCmd::XttCmd() :
xnav(0)
{
}
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