Commit ed36bc73 authored by Marcus Nordenberg's avatar Marcus Nordenberg

Merge branch 'profinet_et200sp_fix'

parents 96c3797c df3362a2
...@@ -20,7 +20,7 @@ AlwaysBreakBeforeMultilineStrings: false ...@@ -20,7 +20,7 @@ AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false AlwaysBreakTemplateDeclarations: false
BinPackArguments: true BinPackArguments: true
BinPackParameters: true BinPackParameters: true
BraceWrapping: BraceWrapping:
AfterClass: false AfterClass: false
AfterControlStatement: false AfterControlStatement: false
AfterEnum: false AfterEnum: false
...@@ -48,7 +48,7 @@ DerivePointerAlignment: false ...@@ -48,7 +48,7 @@ DerivePointerAlignment: false
DisableFormat: false DisableFormat: false
ExperimentalAutoDetectBinPacking: false ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories: IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/' - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2 Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)' - Regex: '^(<|"(gtest|isl|json)/)'
...@@ -77,7 +77,7 @@ PenaltyExcessCharacter: 1000000 ...@@ -77,7 +77,7 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60 PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left PointerAlignment: Left
ReflowComments: true ReflowComments: true
SortIncludes: true SortIncludes: false
SpaceAfterCStyleCast: false SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true SpaceBeforeAssignmentOperators: true
......
...@@ -57,7 +57,8 @@ int main(int argc, char* argv[]) ...@@ -57,7 +57,8 @@ int main(int argc, char* argv[])
pwr_tStatus sts; pwr_tStatus sts;
if (argc < 2 || streq(argv[1], "-h")) { if (argc < 2 || streq(argv[1], "-h"))
{
printf("\nUsage: pn_get_deviceid \"file-pattern\" > " printf("\nUsage: pn_get_deviceid \"file-pattern\" > "
"profinet_deviceid.dat\n\n"); "profinet_deviceid.dat\n\n");
exit(0); exit(0);
...@@ -66,7 +67,8 @@ int main(int argc, char* argv[]) ...@@ -66,7 +67,8 @@ int main(int argc, char* argv[])
dcli_translate_filename(file_spec, argv[1]); dcli_translate_filename(file_spec, argv[1]);
sts = dcli_search_file(file_spec, found_file, DCLI_DIR_SEARCH_INIT); sts = dcli_search_file(file_spec, found_file, DCLI_DIR_SEARCH_INIT);
while (ODD(sts)) { while (ODD(sts))
{
printf("# Processing file: %s\n", found_file); printf("# Processing file: %s\n", found_file);
parse_file(found_file); parse_file(found_file);
...@@ -89,8 +91,9 @@ void parse_file(char* filename) ...@@ -89,8 +91,9 @@ void parse_file(char* filename)
dcli_translate_filename(fname, filename); dcli_translate_filename(fname, filename);
fp.open(fname); fp.open(fname);
if (!fp) { if (!fp)
printf("# Unable to open file \"%s\"\n", fname); {
printf("# Unable to open file\n");
exit(0); exit(0);
} }
...@@ -102,19 +105,26 @@ void parse_file(char* filename) ...@@ -102,19 +105,26 @@ void parse_file(char* filename)
int vendorid_found = 0; int vendorid_found = 0;
int infotextid_found = 0; int infotextid_found = 0;
int infotext_found = 0; int infotext_found = 0;
while (fp.getline(line, sizeof(line))) { while (fp.getline(line, sizeof(line)))
{
char* s; char* s;
if (!in_deviceid) { if (!in_deviceid)
{
if ((s = strstr(line, "<DeviceIdentity"))) if ((s = strstr(line, "<DeviceIdentity")))
in_deviceid = 1; in_deviceid = 1;
} }
if (in_deviceid) { if (in_deviceid)
if (!deviceid_found) { {
if ((s = strstr(line, "DeviceID"))) { if (!deviceid_found)
for (s += 9; *s; s++) { {
if (*s == '\"') { if ((s = strstr(line, "DeviceID")))
{
for (s += 9; *s; s++)
{
if (*s == '\"')
{
sscanf(s + 3, "%x", &deviceid); sscanf(s + 3, "%x", &deviceid);
deviceid_found = 1; deviceid_found = 1;
break; break;
...@@ -122,10 +132,14 @@ void parse_file(char* filename) ...@@ -122,10 +132,14 @@ void parse_file(char* filename)
} }
} }
} }
if (!vendorid_found) { if (!vendorid_found)
if ((s = strstr(line, "VendorID"))) { {
for (s += 9; *s; s++) { if ((s = strstr(line, "VendorID")))
if (*s == '\"') { {
for (s += 9; *s; s++)
{
if (*s == '\"')
{
sscanf(s + 3, "%x", &vendorid); sscanf(s + 3, "%x", &vendorid);
vendorid_found = 1; vendorid_found = 1;
break; break;
...@@ -133,10 +147,14 @@ void parse_file(char* filename) ...@@ -133,10 +147,14 @@ void parse_file(char* filename)
} }
} }
} }
if (!infotextid_found) { if (!infotextid_found)
if ((s = strstr(line, "<InfoText"))) { {
for (s += 16; *s; s++) { if ((s = strstr(line, "<InfoText")))
if (*s == '\"') { {
for (s += 16; *s; s++)
{
if (*s == '\"')
{
strncpy(infotextid, s + 1, sizeof(infotextid)); strncpy(infotextid, s + 1, sizeof(infotextid));
if ((s = strchr(infotextid, '\"'))) if ((s = strchr(infotextid, '\"')))
*s = 0; *s = 0;
...@@ -146,7 +164,8 @@ void parse_file(char* filename) ...@@ -146,7 +164,8 @@ void parse_file(char* filename)
} }
} }
} }
if (strstr(line, "</DeviceIdentity>")) { if (strstr(line, "</DeviceIdentity>"))
{
in_deviceid = 0; in_deviceid = 0;
printf("%u %u\n", vendorid, deviceid); printf("%u %u\n", vendorid, deviceid);
...@@ -161,16 +180,22 @@ void parse_file(char* filename) ...@@ -161,16 +180,22 @@ void parse_file(char* filename)
} }
} }
if (!in_devicefunction) { if (!in_devicefunction)
{
if ((s = strstr(line, "<DeviceFunction"))) if ((s = strstr(line, "<DeviceFunction")))
in_devicefunction = 1; in_devicefunction = 1;
} }
if (in_devicefunction) { if (in_devicefunction)
if (!family_found) { {
if ((s = strstr(line, "ProductFamily"))) { if (!family_found)
for (s += 14; *s; s++) { {
if (*s == '\"') { if ((s = strstr(line, "ProductFamily")))
{
for (s += 14; *s; s++)
{
if (*s == '\"')
{
strncpy(family, s + 1, sizeof(family)); strncpy(family, s + 1, sizeof(family));
if ((s = strchr(family, '\"'))) if ((s = strchr(family, '\"')))
*s = 0; *s = 0;
...@@ -182,14 +207,19 @@ void parse_file(char* filename) ...@@ -182,14 +207,19 @@ void parse_file(char* filename)
} }
} }
} }
if (infotextid_found && !infotext_found) { if (infotextid_found && !infotext_found)
{
if (strstr(line, "<Text") && strstr(line, infotextid)) if (strstr(line, "<Text") && strstr(line, infotextid))
in_text = 1; in_text = 1;
if (in_text) { if (in_text)
if ((s = strstr(line, "Value"))) { {
for (s += 6; *s; s++) { if ((s = strstr(line, "Value")))
if (*s == '\"') { {
for (s += 6; *s; s++)
{
if (*s == '\"')
{
strncpy(infotext, s + 1, sizeof(infotext)); strncpy(infotext, s + 1, sizeof(infotext));
if ((s = strchr(infotext, '\"'))) if ((s = strchr(infotext, '\"')))
*s = 0; *s = 0;
......
...@@ -43,10 +43,11 @@ ...@@ -43,10 +43,11 @@
#include "../src/pn_viewer.h" #include "../src/pn_viewer.h"
class PnViewerGtk : public PnViewer { class PnViewerGtk : public PnViewer
{
public: public:
PnViewerGtk(void* v_parent_ctx, GtkWidget* v_parent_wid, const char* v_name, PnViewerGtk(void* v_parent_ctx, GtkWidget* v_parent_wid, const char* v_name,
const char* v_device, pwr_tStatus* status); const char* v_device, pwr_tStatus* status);
~PnViewerGtk(); ~PnViewerGtk();
GtkWidget* parent_wid; GtkWidget* parent_wid;
...@@ -66,8 +67,8 @@ public: ...@@ -66,8 +67,8 @@ public:
void set_prompt(const char* prompt); void set_prompt(const char* prompt);
void open_change_value(); void open_change_value();
static gboolean action_inputfocus( static gboolean action_inputfocus(GtkWidget* w, GdkEvent* event,
GtkWidget* w, GdkEvent* event, gpointer data); gpointer data);
static void valchanged_cmd_input(GtkWidget* w, gpointer data); static void valchanged_cmd_input(GtkWidget* w, gpointer data);
static void activate_exit(GtkWidget* w, gpointer data); static void activate_exit(GtkWidget* w, gpointer data);
static void activate_update(GtkWidget* w, gpointer data); static void activate_update(GtkWidget* w, gpointer data);
......
...@@ -50,11 +50,11 @@ extern "C" { ...@@ -50,11 +50,11 @@ extern "C" {
#include "pn_viewernav_gtk.h" #include "pn_viewernav_gtk.h"
PnViewerNavGtk::PnViewerNavGtk(void* l_parent_ctx, GtkWidget* l_parent_wid, PnViewerNavGtk::PnViewerNavGtk(void* l_parent_ctx, GtkWidget* l_parent_wid,
viewer_eType l_type, GtkWidget** w) viewer_eType l_type, GtkWidget** w)
: PnViewerNav(l_parent_ctx, l_type), parent_wid(l_parent_wid) : PnViewerNav(l_parent_ctx, l_type), parent_wid(l_parent_wid)
{ {
form_widget = scrolledbrowwidgetgtk_new( form_widget =
PnViewerNav::init_brow_cb, this, &brow_widget); scrolledbrowwidgetgtk_new(PnViewerNav::init_brow_cb, this, &brow_widget);
gtk_widget_show_all(brow_widget); gtk_widget_show_all(brow_widget);
...@@ -71,9 +71,6 @@ PnViewerNavGtk::~PnViewerNavGtk() ...@@ -71,9 +71,6 @@ PnViewerNavGtk::~PnViewerNavGtk()
gtk_widget_destroy(form_widget); gtk_widget_destroy(form_widget);
} }
void PnViewerNavGtk::set_input_focus() void PnViewerNavGtk::set_input_focus() { gtk_widget_grab_focus(brow_widget); }
{
gtk_widget_grab_focus(brow_widget);
}
#endif #endif
...@@ -41,10 +41,11 @@ ...@@ -41,10 +41,11 @@
#include "../src/pn_viewernav.h" #include "../src/pn_viewernav.h"
class PnViewerNavGtk : public PnViewerNav { class PnViewerNavGtk : public PnViewerNav
{
public: public:
PnViewerNavGtk(void* v_parent_ctx, GtkWidget* v_parent_wid, PnViewerNavGtk(void* v_parent_ctx, GtkWidget* v_parent_wid,
viewer_eType v_type, GtkWidget** w); viewer_eType v_type, GtkWidget** w);
~PnViewerNavGtk(); ~PnViewerNavGtk();
GtkWidget* parent_wid; GtkWidget* parent_wid;
......
...@@ -49,7 +49,8 @@ ...@@ -49,7 +49,8 @@
#include "pn_viewer_gtk.h" #include "pn_viewer_gtk.h"
typedef struct { typedef struct
{
GtkWidget* toplevel; GtkWidget* toplevel;
PnViewer* viewer; PnViewer* viewer;
} tViewer; } tViewer;
...@@ -80,35 +81,46 @@ int main(int argc, char* argv[]) ...@@ -80,35 +81,46 @@ int main(int argc, char* argv[])
setlocale(LC_TIME, "en_US"); setlocale(LC_TIME, "en_US");
ctx->toplevel = (GtkWidget*)g_object_new(GTK_TYPE_WINDOW, "default-height", ctx->toplevel = (GtkWidget*)g_object_new(GTK_TYPE_WINDOW, "default-height",
100, "default-width", 100, "title", "Profinet Viewer", NULL); 100, "default-width", 100, "title",
"Profinet Viewer", NULL);
// Create help window // Create help window
CoXHelpGtk* xhelp CoXHelpGtk* xhelp =
= new CoXHelpGtk(ctx->toplevel, 0, xhelp_eUtility_Wtt, (int*)&sts); new CoXHelpGtk(ctx->toplevel, 0, xhelp_eUtility_Wtt, (int*)&sts);
CoXHelpGtk::set_default(xhelp); CoXHelpGtk::set_default(xhelp);
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++)
if (streq(argv[i], "-h")) { {
if (streq(argv[i], "-h"))
{
usage(); usage();
exit(0); exit(0);
} else if (streq(argv[i], "-l")) { }
if (i + 1 >= argc) { else if (streq(argv[i], "-l"))
{
if (i + 1 >= argc)
{
usage(); usage();
exit(0); exit(0);
} }
Lng::set(argv[i + 1]); Lng::set(argv[i + 1]);
i++; i++;
} else if (str_StartsWith(argv[i], "eth")) { }
else if (str_StartsWith(argv[i], "eth"))
{
snprintf(dev_name, sizeof(dev_name), "%s", argv[i]); snprintf(dev_name, sizeof(dev_name), "%s", argv[i]);
} }
} }
// Open window // Open window
try { try
ctx->viewer = new PnViewerGtk( {
ctx, ctx->toplevel, "Profinet Viewer", dev_name, &sts); ctx->viewer =
new PnViewerGtk(ctx, ctx->toplevel, "Profinet Viewer", dev_name, &sts);
ctx->viewer->close_cb = viewer_close; ctx->viewer->close_cb = viewer_close;
} catch (co_error& e) { }
catch (co_error& e)
{
printf("** Exception: %s\n", e.what().c_str()); printf("** Exception: %s\n", e.what().c_str());
exit(0); exit(0);
} }
...@@ -117,9 +129,12 @@ int main(int argc, char* argv[]) ...@@ -117,9 +129,12 @@ int main(int argc, char* argv[])
g_object_set(ctx->toplevel, "visible", FALSE, NULL); g_object_set(ctx->toplevel, "visible", FALSE, NULL);
try { try
{
ctx->viewer->update_devices(); ctx->viewer->update_devices();
} catch (co_error& e) { }
catch (co_error& e)
{
printf("** Exception: %s\n", e.what().c_str()); printf("** Exception: %s\n", e.what().c_str());
} }
...@@ -130,8 +145,5 @@ int main(int argc, char* argv[]) ...@@ -130,8 +145,5 @@ int main(int argc, char* argv[])
#else #else
#include <stdio.h> #include <stdio.h>
int main() int main() { printf("Softing PNAK not built with this Proview release\n"); }
{
printf("Softing PNAK not built with this Proview release\n");
}
#endif #endif
...@@ -47,7 +47,8 @@ ...@@ -47,7 +47,8 @@
class PnViewerQtWidget; class PnViewerQtWidget;
class PnViewerQt : public PnViewer { class PnViewerQt : public PnViewer
{
public: public:
PnViewerQt(const char* v_name, const char* v_device, pwr_tStatus* status); PnViewerQt(const char* v_name, const char* v_device, pwr_tStatus* status);
~PnViewerQt(); ~PnViewerQt();
...@@ -67,11 +68,15 @@ public: ...@@ -67,11 +68,15 @@ public:
PnViewerQtWidget* toplevel; PnViewerQtWidget* toplevel;
}; };
class PnViewerQtWidget : public QWidget { class PnViewerQtWidget : public QWidget
{
Q_OBJECT Q_OBJECT
public: public:
PnViewerQtWidget(PnViewerQt* parent_ctx) : QWidget(), viewer(parent_ctx) {} PnViewerQtWidget(PnViewerQt* parent_ctx, QWidget* parent)
: QWidget(), viewer(parent_ctx)
{
}
protected: protected:
void focusInEvent(QFocusEvent* event); void focusInEvent(QFocusEvent* event);
...@@ -92,4 +97,4 @@ private: ...@@ -92,4 +97,4 @@ private:
PnViewerQt* viewer; PnViewerQt* viewer;
}; };
#endif #endif
\ No newline at end of file
...@@ -43,12 +43,12 @@ ...@@ -43,12 +43,12 @@
#include "pn_viewernav_qt.h" #include "pn_viewernav_qt.h"
PnViewerNavQt::PnViewerNavQt( PnViewerNavQt::PnViewerNavQt(void* l_parent_ctx, viewer_eType l_type,
void* l_parent_ctx, viewer_eType l_type, QWidget** w) QWidget** w)
: PnViewerNav(l_parent_ctx, l_type) : PnViewerNav(l_parent_ctx, l_type)
{ {
form_widget form_widget =
= scrolledbrowwidgetqt_new(PnViewerNav::init_brow_cb, this, &brow_widget); scrolledbrowwidgetqt_new(PnViewerNav::init_brow_cb, this, &brow_widget);
// Create the root item // Create the root item
*w = form_widget; *w = form_widget;
...@@ -60,9 +60,6 @@ PnViewerNavQt::~PnViewerNavQt() ...@@ -60,9 +60,6 @@ PnViewerNavQt::~PnViewerNavQt()
form_widget->close(); form_widget->close();
} }
void PnViewerNavQt::set_input_focus() void PnViewerNavQt::set_input_focus() { brow_widget->setFocus(); }
{
brow_widget->setFocus();
}
#endif #endif
\ No newline at end of file
...@@ -41,7 +41,8 @@ ...@@ -41,7 +41,8 @@
#include "../src/pn_viewernav.h" #include "../src/pn_viewernav.h"
class PnViewerNavQt : public PnViewerNav { class PnViewerNavQt : public PnViewerNav
{
public: public:
PnViewerNavQt(void* v_parent_ctx, viewer_eType v_type, QWidget** w); PnViewerNavQt(void* v_parent_ctx, viewer_eType v_type, QWidget** w);
~PnViewerNavQt(); ~PnViewerNavQt();
...@@ -52,4 +53,4 @@ public: ...@@ -52,4 +53,4 @@ public:
void set_input_focus(); void set_input_focus();
}; };
#endif #endif
\ No newline at end of file
...@@ -63,27 +63,37 @@ int main(int argc, char* argv[]) ...@@ -63,27 +63,37 @@ int main(int argc, char* argv[])
setlocale(LC_NUMERIC, "POSIX"); setlocale(LC_NUMERIC, "POSIX");
setlocale(LC_TIME, "en_US"); setlocale(LC_TIME, "en_US");
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++)
if (streq(argv[i], "-h")) { {
if (streq(argv[i], "-h"))
{
printf("\nUsage: profinet_viewer [-l language] [device]\n"); printf("\nUsage: profinet_viewer [-l language] [device]\n");
exit(0); exit(0);
} else if (streq(argv[i], "-l")) { }
if (i + 1 >= argc) { else if (streq(argv[i], "-l"))
{
if (i + 1 >= argc)
{
printf("\nUsage: profinet_viewer [-l language] [device]\n"); printf("\nUsage: profinet_viewer [-l language] [device]\n");
exit(0); exit(0);
} }
Lng::set(argv[i + 1]); Lng::set(argv[i + 1]);
i++; i++;
} else if (str_StartsWith(argv[i], "eth")) { }
else if (str_StartsWith(argv[i], "eth"))
{
snprintf(dev_name, sizeof(dev_name), "%s", argv[i]); snprintf(dev_name, sizeof(dev_name), "%s", argv[i]);
} }
} }
// Open window // Open window
PnViewerQt* viewer; PnViewerQt* viewer;
try { try
{
viewer = new PnViewerQt("Profinet Viewer", dev_name, &sts); viewer = new PnViewerQt("Profinet Viewer", dev_name, &sts);
} catch (co_error& e) { }
catch (co_error& e)
{
printf("** Exception: %s\n", e.what().c_str()); printf("** Exception: %s\n", e.what().c_str());
exit(0); exit(0);
} }
...@@ -92,9 +102,12 @@ int main(int argc, char* argv[]) ...@@ -92,9 +102,12 @@ int main(int argc, char* argv[])
CoXHelpQt* xhelp = new CoXHelpQt(NULL, xhelp_eUtility_Wtt, (int*)&sts); CoXHelpQt* xhelp = new CoXHelpQt(NULL, xhelp_eUtility_Wtt, (int*)&sts);
CoXHelpQt::set_default(xhelp); CoXHelpQt::set_default(xhelp);
try { try
{
viewer->update_devices(); viewer->update_devices();
} catch (co_error& e) { }
catch (co_error& e)
{
printf("** Exception: %s\n", e.what().c_str()); printf("** Exception: %s\n", e.what().c_str());
} }
...@@ -104,9 +117,6 @@ int main(int argc, char* argv[]) ...@@ -104,9 +117,6 @@ int main(int argc, char* argv[])
#else #else
#include <stdio.h> #include <stdio.h>
int main() int main() { printf("Softing PNAK not built with this Proview release\n"); }
{
printf("Softing PNAK not built with this Proview release\n");
}
#endif #endif
\ No newline at end of file
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
static int test = 0; static int test = 0;
PnViewer::PnViewer(void* v_parent_ctx, const char* v_name, const char* v_device, PnViewer::PnViewer(void* v_parent_ctx, const char* v_name, const char* v_device,
pwr_tStatus* status) pwr_tStatus* status)
: parent_ctx(v_parent_ctx), viewernav(NULL), viewernavconf(NULL), wow(0), : parent_ctx(v_parent_ctx), viewernav(NULL), viewernavconf(NULL), wow(0),
input_open(0), pnet(0), close_cb(0) input_open(0), pnet(0), close_cb(0)
{ {
...@@ -66,16 +66,14 @@ PnViewer::PnViewer(void* v_parent_ctx, const char* v_name, const char* v_device, ...@@ -66,16 +66,14 @@ PnViewer::PnViewer(void* v_parent_ctx, const char* v_name, const char* v_device,
pnet = new PnViewerPNAC(status, device); pnet = new PnViewerPNAC(status, device);
} }
PnViewer::~PnViewer() PnViewer::~PnViewer() { delete pnet; }
{
delete pnet;
}
void PnViewer::update_devices() void PnViewer::update_devices()
{ {
int sts; int sts;
if (!test) { if (!test)
{
dev_vect.clear(); dev_vect.clear();
pnet->fetch_devices(dev_vect); pnet->fetch_devices(dev_vect);
...@@ -86,7 +84,9 @@ void PnViewer::update_devices() ...@@ -86,7 +84,9 @@ void PnViewer::update_devices()
viewernav->set(dev_vect); viewernav->set(dev_vect);
viewernavconf->set(conf_vect); viewernavconf->set(conf_vect);
} else { }
else
{
dev_vect.clear(); dev_vect.clear();
sts = fetch_config(dev_vect); sts = fetch_config(dev_vect);
if (EVEN(sts)) if (EVEN(sts))
...@@ -104,7 +104,8 @@ void PnViewer::update_devices() ...@@ -104,7 +104,8 @@ void PnViewer::update_devices()
void PnViewer::filter(viewer_eFilterType filtertype) void PnViewer::filter(viewer_eFilterType filtertype)
{ {
switch (filtertype) { switch (filtertype)
{
case viewer_eFilterType_No: case viewer_eFilterType_No:
for (unsigned int i = 0; i < dev_vect.size(); i++) for (unsigned int i = 0; i < dev_vect.size(); i++)
dev_vect[i].hide = false; dev_vect[i].hide = false;
...@@ -119,15 +120,18 @@ void PnViewer::filter(viewer_eFilterType filtertype) ...@@ -119,15 +120,18 @@ void PnViewer::filter(viewer_eFilterType filtertype)
for (unsigned int i = 0; i < conf_vect.size(); i++) for (unsigned int i = 0; i < conf_vect.size(); i++)
conf_vect[i].hide = false; conf_vect[i].hide = false;
for (unsigned int i = 0; i < dev_vect.size(); i++) { for (unsigned int i = 0; i < dev_vect.size(); i++)
for (unsigned int j = 0; j < conf_vect.size(); j++) { {
if (streq(dev_vect[i].devname, conf_vect[j].devname) for (unsigned int j = 0; j < conf_vect.size(); j++)
&& dev_vect[i].vendorid == conf_vect[j].vendorid {
&& dev_vect[i].deviceid == conf_vect[j].deviceid if (streq(dev_vect[i].devname, conf_vect[j].devname) &&
&& dev_vect[i].ipaddress[0] == conf_vect[j].ipaddress[0] dev_vect[i].vendorid == conf_vect[j].vendorid &&
&& dev_vect[i].ipaddress[1] == conf_vect[j].ipaddress[1] dev_vect[i].deviceid == conf_vect[j].deviceid &&
&& dev_vect[i].ipaddress[2] == conf_vect[j].ipaddress[2] dev_vect[i].ipaddress[0] == conf_vect[j].ipaddress[0] &&
&& dev_vect[i].ipaddress[3] == conf_vect[j].ipaddress[3]) { dev_vect[i].ipaddress[1] == conf_vect[j].ipaddress[1] &&
dev_vect[i].ipaddress[2] == conf_vect[j].ipaddress[2] &&
dev_vect[i].ipaddress[3] == conf_vect[j].ipaddress[3])
{
dev_vect[i].hide = true; dev_vect[i].hide = true;
conf_vect[j].hide = true; conf_vect[j].hide = true;
break; break;
...@@ -160,17 +164,20 @@ int PnViewer::fetch_config(std::vector<PnDevice>& vect) ...@@ -160,17 +164,20 @@ int PnViewer::fetch_config(std::vector<PnDevice>& vect)
if (!fp) if (!fp)
return 0; return 0;
while (dcli_read_line(line, sizeof(line), fp)) { while (dcli_read_line(line, sizeof(line), fp))
{
nr = dcli_parse(line, " ", "", (char*)elemv, nr = dcli_parse(line, " ", "", (char*)elemv,
sizeof(elemv) / sizeof(elemv[0]), sizeof(elemv[0]), 0); sizeof(elemv) / sizeof(elemv[0]), sizeof(elemv[0]), 0);
if (nr != 6) if (nr != 6)
continue; continue;
strncpy(pndevice.devname, elemv[1], sizeof(pndevice.devname)); strncpy(pndevice.devname, elemv[1], sizeof(pndevice.devname));
sts = sscanf(elemv[2], "%hhu.%hhu.%hhu.%hhu", &pndevice.ipaddress[3], sts = sscanf(elemv[2], "%hhu.%hhu.%hhu.%hhu", &pndevice.ipaddress[3],
&pndevice.ipaddress[2], &pndevice.ipaddress[1], &pndevice.ipaddress[0]); &pndevice.ipaddress[2], &pndevice.ipaddress[1],
if (sts != 4) { &pndevice.ipaddress[0]);
if (sts != 4)
{
printf("Not a valid IP address: %s\n", elemv[2]); printf("Not a valid IP address: %s\n", elemv[2]);
pndevice.ipaddress[0] = 0; pndevice.ipaddress[0] = 0;
pndevice.ipaddress[1] = 0; pndevice.ipaddress[1] = 0;
...@@ -179,10 +186,11 @@ int PnViewer::fetch_config(std::vector<PnDevice>& vect) ...@@ -179,10 +186,11 @@ int PnViewer::fetch_config(std::vector<PnDevice>& vect)
} }
sts = sscanf(elemv[3], "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", sts = sscanf(elemv[3], "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
&pndevice.macaddress[5], &pndevice.macaddress[4], &pndevice.macaddress[5], &pndevice.macaddress[4],
&pndevice.macaddress[3], &pndevice.macaddress[2], &pndevice.macaddress[3], &pndevice.macaddress[2],
&pndevice.macaddress[1], &pndevice.macaddress[0]); &pndevice.macaddress[1], &pndevice.macaddress[0]);
if (sts != 6) { if (sts != 6)
{
printf("Not a valid MAC address: %s\n", elemv[3]); printf("Not a valid MAC address: %s\n", elemv[3]);
pndevice.macaddress[0] = 0; pndevice.macaddress[0] = 0;
pndevice.macaddress[1] = 0; pndevice.macaddress[1] = 0;
...@@ -205,8 +213,8 @@ int PnViewer::fetch_config(std::vector<PnDevice>& vect) ...@@ -205,8 +213,8 @@ int PnViewer::fetch_config(std::vector<PnDevice>& vect)
return 1; return 1;
} }
void PnViewer::set_device_properties( void PnViewer::set_device_properties(unsigned char* macaddress,
unsigned char* macaddress, unsigned char* ipaddress, char* devname) unsigned char* ipaddress, char* devname)
{ {
pnet->set_device_properties(macaddress, ipaddress, devname); pnet->set_device_properties(macaddress, ipaddress, devname);
} }
...@@ -227,9 +235,12 @@ void PnViewer::message_cb(void* ctx, int severity, const char* msg) ...@@ -227,9 +235,12 @@ void PnViewer::message_cb(void* ctx, int severity, const char* msg)
void PnViewer::activate_update() void PnViewer::activate_update()
{ {
try { try
{
update_devices(); update_devices();
} catch (co_error& e) { }
catch (co_error& e)
{
printf("** Update exception: %s\n", e.what().c_str()); printf("** Update exception: %s\n", e.what().c_str());
} }
} }
...@@ -245,28 +256,30 @@ void PnViewer::activate_setdevice() ...@@ -245,28 +256,30 @@ void PnViewer::activate_setdevice()
ItemDevice* dev; ItemDevice* dev;
sts = viewernav->get_selected_device(&dev); sts = viewernav->get_selected_device(&dev);
if (EVEN(sts)) { if (EVEN(sts))
{
message('E', "Select a device"); message('E', "Select a device");
return; return;
} }
try { try
{
set_device_properties(dev->macaddress, dev->ipaddress, dev->devname); set_device_properties(dev->macaddress, dev->ipaddress, dev->devname);
} catch (co_error& e) { }
catch (co_error& e)
{
printf("** Exception, %s\n", e.what().c_str()); printf("** Exception, %s\n", e.what().c_str());
} }
} }
void PnViewer::activate_changevalue() void PnViewer::activate_changevalue() { open_change_value(); }
{
open_change_value();
}
void PnViewer::activate_close() void PnViewer::activate_close()
{ {
if (close_cb) if (close_cb)
close_cb(parent_ctx); close_cb(parent_ctx);
else { else
{
delete this; delete this;
exit(0); exit(0);
} }
...@@ -274,8 +287,8 @@ void PnViewer::activate_close() ...@@ -274,8 +287,8 @@ void PnViewer::activate_close()
void PnViewer::activate_help() void PnViewer::activate_help()
{ {
CoXHelp::dhelp( CoXHelp::dhelp("profinet_viewer", 0, navh_eHelpFile_Other,
"profinet_viewer", 0, navh_eHelpFile_Other, "$pwr_lang/man_pb.dat", true); "$pwr_lang/man_pb.dat", true);
} }
#endif #endif
...@@ -45,25 +45,20 @@ class CoWow; ...@@ -45,25 +45,20 @@ class CoWow;
class CoWowFocusTimer; class CoWowFocusTimer;
class PnViewerPNAC; class PnViewerPNAC;
class PnViewer { class PnViewer
{
public: public:
PnViewer(void* v_parent_ctx, const char* v_name, const char* v_device, PnViewer(void* v_parent_ctx, const char* v_name, const char* v_device,
pwr_tStatus* status); pwr_tStatus* status);
virtual ~PnViewer(); virtual ~PnViewer();
virtual void message(char severity, const char* msg) virtual void message(char severity, const char* msg) {}
{ virtual void set_prompt(const char* prompt) {}
} virtual void open_change_value() {}
virtual void set_prompt(const char* prompt)
{
}
virtual void open_change_value()
{
}
void update_devices(); void update_devices();
void set_device_properties( void set_device_properties(unsigned char* macaddress,
unsigned char* macaddress, unsigned char* ipaddress, char* devname); unsigned char* ipaddress, char* devname);
int fetch_config(std::vector<PnDevice>& vect); int fetch_config(std::vector<PnDevice>& vect);
void filter(viewer_eFilterType filtertype); void filter(viewer_eFilterType filtertype);
void activate_update(); void activate_update();
......
...@@ -66,7 +66,8 @@ PnViewerPNAC::PnViewerPNAC(pwr_tStatus* sts, const char* dev_name) ...@@ -66,7 +66,8 @@ PnViewerPNAC::PnViewerPNAC(pwr_tStatus* sts, const char* dev_name)
pnak_init(); pnak_init();
*sts = pnak_start_profistack(0, PNAK_SUPERVISOR_MODE); *sts = pnak_start_profistack(0, PNAK_SUPERVISOR_MODE);
if (*sts != PNAK_OK) { if (*sts != PNAK_OK)
{
printf("Starting profistack returned with error code\n"); printf("Starting profistack returned with error code\n");
exit(0); exit(0);
} }
...@@ -75,19 +76,21 @@ PnViewerPNAC::PnViewerPNAC(pwr_tStatus* sts, const char* dev_name) ...@@ -75,19 +76,21 @@ PnViewerPNAC::PnViewerPNAC(pwr_tStatus* sts, const char* dev_name)
s = socket(AF_INET, SOCK_DGRAM, 0); s = socket(AF_INET, SOCK_DGRAM, 0);
strncpy(ifr.ifr_name, dev_name, sizeof(ifr.ifr_name)); strncpy(ifr.ifr_name, dev_name, sizeof(ifr.ifr_name));
if (ioctl(s, SIOCGIFADDR, &ifr) >= 0) { if (ioctl(s, SIOCGIFADDR, &ifr) >= 0)
{
strcpy(dev_data.ip_address, strcpy(dev_data.ip_address,
inet_ntoa(((struct sockaddr_in*)&ifr.ifr_addr)->sin_addr)); inet_ntoa(((struct sockaddr_in*)&ifr.ifr_addr)->sin_addr));
} }
if (ioctl(s, SIOCGIFNETMASK, &ifr) >= 0) { if (ioctl(s, SIOCGIFNETMASK, &ifr) >= 0)
{
strcpy(dev_data.subnet_mask, strcpy(dev_data.subnet_mask,
inet_ntoa(((struct sockaddr_in*)&ifr.ifr_netmask)->sin_addr)); inet_ntoa(((struct sockaddr_in*)&ifr.ifr_netmask)->sin_addr));
} }
sscanf(dev_data.ip_address, "%hhu.%hhu.%hhu.%hhu", &local->ipaddress[3], sscanf(dev_data.ip_address, "%hhu.%hhu.%hhu.%hhu", &local->ipaddress[3],
&local->ipaddress[2], &local->ipaddress[1], &local->ipaddress[0]); &local->ipaddress[2], &local->ipaddress[1], &local->ipaddress[0]);
sscanf(dev_data.subnet_mask, "%hhu.%hhu.%hhu.%hhu", &local->subnetmask[3], sscanf(dev_data.subnet_mask, "%hhu.%hhu.%hhu.%hhu", &local->subnetmask[3],
&local->subnetmask[2], &local->subnetmask[1], &local->subnetmask[0]); &local->subnetmask[2], &local->subnetmask[1], &local->subnetmask[0]);
strcpy(dev_data.device_name, "dumle"); strcpy(dev_data.device_name, "dumle");
dev_data.device_num = PN_DEVICE_REFERENCE_THIS_STATION; dev_data.device_num = PN_DEVICE_REFERENCE_THIS_STATION;
...@@ -104,15 +107,17 @@ PnViewerPNAC::PnViewerPNAC(pwr_tStatus* sts, const char* dev_name) ...@@ -104,15 +107,17 @@ PnViewerPNAC::PnViewerPNAC(pwr_tStatus* sts, const char* dev_name)
/* Download config */ /* Download config */
pack_download_req( pack_download_req(&local->service_req_res, &dev_data,
&local->service_req_res, &dev_data, pn_dev_data->device_ref); pn_dev_data->device_ref);
*sts = pnak_send_service_req_res(0, &local->service_req_res); *sts = pnak_send_service_req_res(0, &local->service_req_res);
if (*sts == PNAK_OK) { if (*sts == PNAK_OK)
{
*sts = wait_service_con(local, 0); *sts = wait_service_con(local, 0);
if (*sts != PNAK_OK) { if (*sts != PNAK_OK)
{
/* Loop through devices and calculate offset for io */ /* Loop through devices and calculate offset for io */
} }
} }
...@@ -123,7 +128,8 @@ PnViewerPNAC::PnViewerPNAC(pwr_tStatus* sts, const char* dev_name) ...@@ -123,7 +128,8 @@ PnViewerPNAC::PnViewerPNAC(pwr_tStatus* sts, const char* dev_name)
*sts = pnak_send_service_req_res(0, &local->service_req_res); *sts = pnak_send_service_req_res(0, &local->service_req_res);
if (*sts == PNAK_OK) { if (*sts == PNAK_OK)
{
*sts = wait_service_con(local, 0); *sts = wait_service_con(local, 0);
} }
...@@ -135,7 +141,8 @@ PnViewerPNAC::PnViewerPNAC(pwr_tStatus* sts, const char* dev_name) ...@@ -135,7 +141,8 @@ PnViewerPNAC::PnViewerPNAC(pwr_tStatus* sts, const char* dev_name)
*sts = pnak_wait_for_multiple_objects(0, &wait_object, PNAK_INFINITE_TIMEOUT); *sts = pnak_wait_for_multiple_objects(0, &wait_object, PNAK_INFINITE_TIMEOUT);
if (*sts != PNAK_OK) { if (*sts != PNAK_OK)
{
printf("Setting state failed, sts: %d\r\n", *sts); printf("Setting state failed, sts: %d\r\n", *sts);
return; return;
} }
...@@ -154,8 +161,10 @@ void PnViewerPNAC::fetch_devices(std::vector<PnDevice>& dev_vect) ...@@ -154,8 +161,10 @@ void PnViewerPNAC::fetch_devices(std::vector<PnDevice>& dev_vect)
unsigned int ii; unsigned int ii;
int sts; int sts;
while (1) { while (1)
for (ii = 0; ii < local->dev_info.size(); ii++) { {
for (ii = 0; ii < local->dev_info.size(); ii++)
{
delete local->dev_info[ii]; delete local->dev_info[ii];
} }
...@@ -165,11 +174,15 @@ void PnViewerPNAC::fetch_devices(std::vector<PnDevice>& dev_vect) ...@@ -165,11 +174,15 @@ void PnViewerPNAC::fetch_devices(std::vector<PnDevice>& dev_vect)
sts = pnak_send_service_req_res(0, &local->service_req_res); sts = pnak_send_service_req_res(0, &local->service_req_res);
if (sts == PNAK_OK) { if (sts == PNAK_OK)
{
sts = wait_service_con(local, 0); sts = wait_service_con(local, 0);
if (sts == PNAK_OK) { if (sts == PNAK_OK)
if (local->dev_info.size() > 0) { {
for (ii = 0; ii < local->dev_info.size(); ii++) { if (local->dev_info.size() > 0)
{
for (ii = 0; ii < local->dev_info.size(); ii++)
{
device.ipaddress[0] = local->dev_info[ii]->ipaddress[0]; device.ipaddress[0] = local->dev_info[ii]->ipaddress[0];
device.ipaddress[1] = local->dev_info[ii]->ipaddress[1]; device.ipaddress[1] = local->dev_info[ii]->ipaddress[1];
device.ipaddress[2] = local->dev_info[ii]->ipaddress[2]; device.ipaddress[2] = local->dev_info[ii]->ipaddress[2];
...@@ -181,13 +194,14 @@ void PnViewerPNAC::fetch_devices(std::vector<PnDevice>& dev_vect) ...@@ -181,13 +194,14 @@ void PnViewerPNAC::fetch_devices(std::vector<PnDevice>& dev_vect)
device.macaddress[4] = local->dev_info[ii]->macaddress[4]; device.macaddress[4] = local->dev_info[ii]->macaddress[4];
device.macaddress[5] = local->dev_info[ii]->macaddress[5]; device.macaddress[5] = local->dev_info[ii]->macaddress[5];
strncpy(device.devname, local->dev_info[ii]->devname, strncpy(device.devname, local->dev_info[ii]->devname,
sizeof(device.devname)); sizeof(device.devname));
device.vendorid = local->dev_info[ii]->vendorid; device.vendorid = local->dev_info[ii]->vendorid;
device.deviceid = local->dev_info[ii]->deviceid; device.deviceid = local->dev_info[ii]->deviceid;
dev_vect.push_back(device); dev_vect.push_back(device);
} }
break; break;
} else }
else
continue; continue;
} }
} }
...@@ -209,8 +223,9 @@ void PnViewerPNAC::fetch_devices(std::vector<PnDevice>& dev_vect) ...@@ -209,8 +223,9 @@ void PnViewerPNAC::fetch_devices(std::vector<PnDevice>& dev_vect)
// if ( ...error... ) throw co_error_str( "Somethings is wrong..."); // if ( ...error... ) throw co_error_str( "Somethings is wrong...");
} }
void PnViewerPNAC::set_device_properties( void PnViewerPNAC::set_device_properties(unsigned char* macaddress,
unsigned char* macaddress, unsigned char* ipaddress, char* devname) unsigned char* ipaddress,
char* devname)
{ {
PnDevice device; PnDevice device;
int sts; int sts;
...@@ -237,7 +252,8 @@ void PnViewerPNAC::set_device_properties( ...@@ -237,7 +252,8 @@ void PnViewerPNAC::set_device_properties(
pack_set_device_name_req(&local->service_req_res, &dev_info); pack_set_device_name_req(&local->service_req_res, &dev_info);
sts = pnak_send_service_req_res(0, &local->service_req_res); sts = pnak_send_service_req_res(0, &local->service_req_res);
if (sts == PNAK_OK) { if (sts == PNAK_OK)
{
sts = wait_service_con(local, 0); sts = wait_service_con(local, 0);
} }
...@@ -246,7 +262,8 @@ void PnViewerPNAC::set_device_properties( ...@@ -246,7 +262,8 @@ void PnViewerPNAC::set_device_properties(
pack_set_ip_settings_req(&local->service_req_res, &dev_info); pack_set_ip_settings_req(&local->service_req_res, &dev_info);
sts = pnak_send_service_req_res(0, &local->service_req_res); sts = pnak_send_service_req_res(0, &local->service_req_res);
if (sts == PNAK_OK) { if (sts == PNAK_OK)
{
sts = wait_service_con(local, 0); sts = wait_service_con(local, 0);
} }
} }
......
...@@ -45,14 +45,15 @@ ...@@ -45,14 +45,15 @@
#include "rt_io_pnak_locals.h" #include "rt_io_pnak_locals.h"
#include "rt_pn_gsdml_data.h" #include "rt_pn_gsdml_data.h"
class PnViewerPNAC { class PnViewerPNAC
{
public: public:
PnViewerPNAC(pwr_tStatus* sts, const char* dev_name); PnViewerPNAC(pwr_tStatus* sts, const char* dev_name);
~PnViewerPNAC(); ~PnViewerPNAC();
void fetch_devices(std::vector<PnDevice>& dev_vect); void fetch_devices(std::vector<PnDevice>& dev_vect);
void set_device_properties( void set_device_properties(unsigned char* macaddress,
unsigned char* macaddress, unsigned char* ipaddress, char* devname); unsigned char* ipaddress, char* devname);
GsdmlDeviceData dev_data; GsdmlDeviceData dev_data;
io_sAgentLocal* local; io_sAgentLocal* local;
}; };
......
...@@ -45,7 +45,8 @@ ...@@ -45,7 +45,8 @@
#include "flow_browapi.h" #include "flow_browapi.h"
class PnDevice { class PnDevice
{
public: public:
PnDevice(); PnDevice();
unsigned char ipaddress[4]; unsigned char ipaddress[4];
...@@ -70,10 +71,13 @@ typedef enum { ...@@ -70,10 +71,13 @@ typedef enum {
viewitem_eItemType_DeviceAttr viewitem_eItemType_DeviceAttr
} viewitem_eItemType; } viewitem_eItemType;
class PnViewerNavBrow { class PnViewerNavBrow
{
public: public:
PnViewerNavBrow(BrowCtx* brow_ctx, void* lvnav) PnViewerNavBrow(BrowCtx* brow_ctx, void* lvnav)
: ctx(brow_ctx), viewernav(lvnav){} : ctx(brow_ctx), viewernav(lvnav)
{
}
~PnViewerNavBrow(); ~PnViewerNavBrow();
BrowCtx* ctx; BrowCtx* ctx;
...@@ -91,7 +95,8 @@ public: ...@@ -91,7 +95,8 @@ public:
void brow_setup(); void brow_setup();
}; };
class PnViewerNav { class PnViewerNav
{
public: public:
PnViewerNav(void* l_parent_ctx, viewer_eType l_type); PnViewerNav(void* l_parent_ctx, viewer_eType l_type);
virtual ~PnViewerNav(); virtual ~PnViewerNav();
...@@ -102,9 +107,7 @@ public: ...@@ -102,9 +107,7 @@ public:
void (*change_value_cb)(void*); void (*change_value_cb)(void*);
void (*message_cb)(void*, int, const char*); void (*message_cb)(void*, int, const char*);
virtual void set_input_focus() virtual void set_input_focus() {}
{
}
void message(int severity, const char* msg); void message(int severity, const char* msg);
void zoom(double zoom_factor); void zoom(double zoom_factor);
...@@ -115,20 +118,21 @@ public: ...@@ -115,20 +118,21 @@ public:
int get_selected_device(ItemDevice** device); int get_selected_device(ItemDevice** device);
void vendorid_to_str(unsigned int vendorid, char* vendorid_str, int size); void vendorid_to_str(unsigned int vendorid, char* vendorid_str, int size);
void get_device_info(unsigned int vendorid, unsigned int deviceid, char* info, void get_device_info(unsigned int vendorid, unsigned int deviceid, char* info,
int info_size, char* family, int family_size); int info_size, char* family, int family_size);
static int init_brow_cb(FlowCtx* fctx, void* client_data); static int init_brow_cb(FlowCtx* fctx, void* client_data);
static int brow_cb(FlowCtx* ctx, flow_tEvent event); static int brow_cb(FlowCtx* ctx, flow_tEvent event);
}; };
class ItemDevice { class ItemDevice
{
public: public:
ItemDevice(PnViewerNav* viewernav, const char* item_name, ItemDevice(PnViewerNav* viewernav, const char* item_name,
unsigned char* item_ipaddress, unsigned char* item_macaddress, unsigned char* item_ipaddress, unsigned char* item_macaddress,
char* item_devname, int vendorid, int deviceid, brow_tNode dest, char* item_devname, int vendorid, int deviceid, brow_tNode dest,
flow_eDest dest_code); flow_eDest dest_code);
virtual ~ItemDevice(); virtual ~ItemDevice();
viewitem_eItemType type; viewitem_eItemType type;
PnViewerNav* viewernav; PnViewerNav* viewernav;
brow_tNode node; brow_tNode node;
...@@ -148,11 +152,12 @@ public: ...@@ -148,11 +152,12 @@ public:
void close(PnViewerNav* viewernav); void close(PnViewerNav* viewernav);
}; };
class ItemDeviceAttr { class ItemDeviceAttr
{
public: public:
ItemDeviceAttr(PnViewerNav* viewernav, const char* item_name, ItemDeviceAttr(PnViewerNav* viewernav, const char* item_name,
pwr_eType item_attr_type, void* item_p, brow_tNode dest, pwr_eType item_attr_type, void* item_p, brow_tNode dest,
flow_eDest dest_code); flow_eDest dest_code);
virtual ~ItemDeviceAttr(); virtual ~ItemDeviceAttr();
viewitem_eItemType type; viewitem_eItemType type;
......
...@@ -41,9 +41,12 @@ ...@@ -41,9 +41,12 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++)
if (streq(argv[i], "-f")) { {
if (i + 1 >= argc) { if (streq(argv[i], "-f"))
{
if (i + 1 >= argc)
{
printf("\nUsage: profinet_viewer [-f windowmgr]"); printf("\nUsage: profinet_viewer [-f windowmgr]");
exit(0); exit(0);
} }
......
...@@ -60,10 +60,13 @@ void GsdAttrGtk::message(char severity, const char* message) ...@@ -60,10 +60,13 @@ void GsdAttrGtk::message(char severity, const char* message)
void GsdAttrGtk::set_prompt(const char* prompt) void GsdAttrGtk::set_prompt(const char* prompt)
{ {
if (streq(prompt, "")) { if (streq(prompt, ""))
{
g_object_set(cmd_prompt, "visible", FALSE, NULL); g_object_set(cmd_prompt, "visible", FALSE, NULL);
g_object_set(msg_label, "visible", TRUE, NULL); g_object_set(msg_label, "visible", TRUE, NULL);
} else { }
else
{
g_object_set(msg_label, "visible", FALSE, NULL); g_object_set(msg_label, "visible", FALSE, NULL);
g_object_set(cmd_prompt, "visible", TRUE, NULL); g_object_set(cmd_prompt, "visible", TRUE, NULL);
} }
...@@ -75,20 +78,23 @@ void GsdAttrGtk::change_value() ...@@ -75,20 +78,23 @@ void GsdAttrGtk::change_value()
GtkWidget* text_w; GtkWidget* text_w;
char* value; char* value;
if (input_open) { if (input_open)
{
g_object_set(cmd_input, "visible", FALSE, NULL); g_object_set(cmd_input, "visible", FALSE, NULL);
set_prompt(""); set_prompt("");
input_open = 0; input_open = 0;
return; return;
} }
if (!edit_mode) { if (!edit_mode)
{
message('E', "Not in edit mode"); message('E', "Not in edit mode");
return; return;
} }
sts = attrnav->check_attr_value(&value); sts = attrnav->check_attr_value(&value);
if (EVEN(sts)) { if (EVEN(sts))
{
if (sts == PB__NOATTRSEL) if (sts == PB__NOATTRSEL)
message('E', "No attribute is selected"); message('E', "No attribute is selected");
else else
...@@ -102,16 +108,19 @@ void GsdAttrGtk::change_value() ...@@ -102,16 +108,19 @@ void GsdAttrGtk::change_value()
message(' ', ""); message(' ', "");
gtk_widget_grab_focus(cmd_input); gtk_widget_grab_focus(cmd_input);
if (value) { if (value)
{
gint pos = 0; gint pos = 0;
gtk_editable_delete_text(GTK_EDITABLE(cmd_input), 0, -1); gtk_editable_delete_text(GTK_EDITABLE(cmd_input), 0, -1);
gtk_editable_insert_text( gtk_editable_insert_text(GTK_EDITABLE(cmd_input), value, strlen(value),
GTK_EDITABLE(cmd_input), value, strlen(value), &pos); &pos);
// Select the text // Select the text
gtk_editable_set_position(GTK_EDITABLE(cmd_input), -1); gtk_editable_set_position(GTK_EDITABLE(cmd_input), -1);
gtk_editable_select_region(GTK_EDITABLE(cmd_input), 0, -1); gtk_editable_select_region(GTK_EDITABLE(cmd_input), 0, -1);
} else { }
else
{
gtk_editable_delete_text(GTK_EDITABLE(cmd_input), 0, -1); gtk_editable_delete_text(GTK_EDITABLE(cmd_input), 0, -1);
} }
set_prompt("value >"); set_prompt("value >");
...@@ -224,7 +233,8 @@ void GsdAttrGtk::activate_cmd_input(GtkWidget* w, gpointer data) ...@@ -224,7 +233,8 @@ void GsdAttrGtk::activate_cmd_input(GtkWidget* w, gpointer data)
attr->attrnav->set_inputfocus(); attr->attrnav->set_inputfocus();
text = gtk_editable_get_chars(GTK_EDITABLE(w), 0, -1); text = gtk_editable_get_chars(GTK_EDITABLE(w), 0, -1);
if (attr->input_open) { if (attr->input_open)
{
sts = attr->attrnav->set_attr_value(text); sts = attr->attrnav->set_attr_value(text);
g_object_set(w, "visible", FALSE, NULL); g_object_set(w, "visible", FALSE, NULL);
attr->set_prompt(""); attr->set_prompt("");
...@@ -233,8 +243,8 @@ void GsdAttrGtk::activate_cmd_input(GtkWidget* w, gpointer data) ...@@ -233,8 +243,8 @@ void GsdAttrGtk::activate_cmd_input(GtkWidget* w, gpointer data)
g_free(text); g_free(text);
} }
gboolean GsdAttrGtk::action_inputfocus( gboolean GsdAttrGtk::action_inputfocus(GtkWidget* w, GdkEvent* event,
GtkWidget* w, GdkEvent* event, gpointer data) gpointer data)
{ {
GsdAttrGtk* attr = (GsdAttrGtk*)data; GsdAttrGtk* attr = (GsdAttrGtk*)data;
gboolean input_visible; gboolean input_visible;
...@@ -265,41 +275,40 @@ static gint delete_event(GtkWidget* w, GdkEvent* event, gpointer data) ...@@ -265,41 +275,40 @@ static gint delete_event(GtkWidget* w, GdkEvent* event, gpointer data)
return TRUE; return TRUE;
} }
static void destroy_event(GtkWidget* w, gpointer data) static void destroy_event(GtkWidget* w, gpointer data) {}
{
}
GsdAttrGtk::GsdAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx, GsdAttrGtk::GsdAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx,
void* a_object, pb_gsd* a_gsd, int a_edit_mode) void* a_object, pb_gsd* a_gsd, int a_edit_mode)
: GsdAttr(a_parent_ctx, a_object, a_gsd, a_edit_mode) : GsdAttr(a_parent_ctx, a_object, a_gsd, a_edit_mode)
{ {
int sts; int sts;
toplevel = (GtkWidget*)g_object_new(GTK_TYPE_WINDOW, "default-height", 600, toplevel = (GtkWidget*)g_object_new(GTK_TYPE_WINDOW, "default-height", 600,
"default-width", 500, "title", "pbGsdEditor", NULL); "default-width", 500, "title",
"pbGsdEditor", NULL);
g_signal_connect(toplevel, "delete_event", G_CALLBACK(delete_event), this); g_signal_connect(toplevel, "delete_event", G_CALLBACK(delete_event), this);
g_signal_connect(toplevel, "destroy", G_CALLBACK(destroy_event), this); g_signal_connect(toplevel, "destroy", G_CALLBACK(destroy_event), this);
g_signal_connect( g_signal_connect(toplevel, "focus-in-event", G_CALLBACK(action_inputfocus),
toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this); this);
GtkWidget* vbox = gtk_vbox_new(FALSE, 0); GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
// Menu // Menu
// Accelerators // Accelerators
GtkAccelGroup* accel_g GtkAccelGroup* accel_g =
= (GtkAccelGroup*)g_object_new(GTK_TYPE_ACCEL_GROUP, NULL); (GtkAccelGroup*)g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g); gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);
GtkMenuBar* menu_bar = (GtkMenuBar*)g_object_new(GTK_TYPE_MENU_BAR, NULL); GtkMenuBar* menu_bar = (GtkMenuBar*)g_object_new(GTK_TYPE_MENU_BAR, NULL);
// File entry // File entry
GtkWidget* file_print GtkWidget* file_print =
= gtk_image_menu_item_new_from_stock(GTK_STOCK_PRINT, accel_g); gtk_image_menu_item_new_from_stock(GTK_STOCK_PRINT, accel_g);
g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), this); g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), this);
GtkWidget* file_close GtkWidget* file_close =
= gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g); gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this); g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);
GtkMenu* file_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL); GtkMenu* file_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
...@@ -312,16 +321,16 @@ GsdAttrGtk::GsdAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx, ...@@ -312,16 +321,16 @@ GsdAttrGtk::GsdAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx,
// Edit entry // Edit entry
menubutton_copy = gtk_image_menu_item_new_from_stock(GTK_STOCK_COPY, accel_g); menubutton_copy = gtk_image_menu_item_new_from_stock(GTK_STOCK_COPY, accel_g);
g_signal_connect( g_signal_connect(menubutton_copy, "activate", G_CALLBACK(activate_copy),
menubutton_copy, "activate", G_CALLBACK(activate_copy), this); this);
menubutton_cut = gtk_image_menu_item_new_from_stock(GTK_STOCK_CUT, accel_g); menubutton_cut = gtk_image_menu_item_new_from_stock(GTK_STOCK_CUT, accel_g);
g_signal_connect(menubutton_cut, "activate", G_CALLBACK(activate_cut), this); g_signal_connect(menubutton_cut, "activate", G_CALLBACK(activate_cut), this);
menubutton_paste menubutton_paste =
= gtk_image_menu_item_new_from_stock(GTK_STOCK_PASTE, accel_g); gtk_image_menu_item_new_from_stock(GTK_STOCK_PASTE, accel_g);
g_signal_connect( g_signal_connect(menubutton_paste, "activate", G_CALLBACK(activate_paste),
menubutton_paste, "activate", G_CALLBACK(activate_paste), this); this);
GtkMenu* edit_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL); GtkMenu* edit_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), menubutton_copy); gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), menubutton_copy);
...@@ -335,9 +344,9 @@ GsdAttrGtk::GsdAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx, ...@@ -335,9 +344,9 @@ GsdAttrGtk::GsdAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx,
// Functions entry // Functions entry
menubutton_changevalue = gtk_menu_item_new_with_mnemonic("_Change Value"); menubutton_changevalue = gtk_menu_item_new_with_mnemonic("_Change Value");
g_signal_connect(menubutton_changevalue, "activate", g_signal_connect(menubutton_changevalue, "activate",
G_CALLBACK(activate_change_value), this); G_CALLBACK(activate_change_value), this);
gtk_widget_add_accelerator(menubutton_changevalue, "activate", accel_g, 'q', gtk_widget_add_accelerator(menubutton_changevalue, "activate", accel_g, 'q',
GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkMenu* func_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL); GtkMenu* func_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), menubutton_changevalue); gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), menubutton_changevalue);
...@@ -348,26 +357,29 @@ GsdAttrGtk::GsdAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx, ...@@ -348,26 +357,29 @@ GsdAttrGtk::GsdAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx,
// View Entry // View Entry
GtkWidget* view_zoom_in GtkWidget* view_zoom_in =
= gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_IN, NULL); gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_IN, NULL);
g_signal_connect( g_signal_connect(view_zoom_in, "activate", G_CALLBACK(activate_zoom_in),
view_zoom_in, "activate", G_CALLBACK(activate_zoom_in), this); this);
gtk_widget_add_accelerator(view_zoom_in, "activate", accel_g, 'i', gtk_widget_add_accelerator(view_zoom_in, "activate", accel_g, 'i',
GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE); GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget* view_zoom_out GtkWidget* view_zoom_out =
= gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, NULL); gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, NULL);
g_signal_connect( g_signal_connect(view_zoom_out, "activate", G_CALLBACK(activate_zoom_out),
view_zoom_out, "activate", G_CALLBACK(activate_zoom_out), this); this);
gtk_widget_add_accelerator(view_zoom_out, "activate", accel_g, 'o', gtk_widget_add_accelerator(view_zoom_out, "activate", accel_g, 'o',
GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE); GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget* view_zoom_reset GtkWidget* view_zoom_reset =
= gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_100, NULL); gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_100, NULL);
g_signal_connect( g_signal_connect(view_zoom_reset, "activate", G_CALLBACK(activate_zoom_reset),
view_zoom_reset, "activate", G_CALLBACK(activate_zoom_reset), this); this);
gtk_widget_add_accelerator(view_zoom_reset, "activate", accel_g, 'b', gtk_widget_add_accelerator(view_zoom_reset, "activate", accel_g, 'b',
GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE); GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkMenu* view_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL); GtkMenu* view_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in); gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
...@@ -379,8 +391,8 @@ GsdAttrGtk::GsdAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx, ...@@ -379,8 +391,8 @@ GsdAttrGtk::GsdAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx,
gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu)); gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));
// Help entry // Help entry
GtkWidget* help_help GtkWidget* help_help =
= gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, accel_g); gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, accel_g);
g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this); g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);
GtkMenu* help_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL); GtkMenu* help_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
...@@ -391,8 +403,8 @@ GsdAttrGtk::GsdAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx, ...@@ -391,8 +403,8 @@ GsdAttrGtk::GsdAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx,
gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu)); gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));
// Navigator // Navigator
attrnav = new GsdAttrNavGtk( attrnav = new GsdAttrNavGtk(this, vbox, "Plant", gsd, edit_mode, &brow_widget,
this, vbox, "Plant", gsd, edit_mode, &brow_widget, &sts); &sts);
attrnav->message_cb = &GsdAttr::gsdattr_message; attrnav->message_cb = &GsdAttr::gsdattr_message;
attrnav->change_value_cb = &GsdAttr::gsdattr_change_value_cb; attrnav->change_value_cb = &GsdAttr::gsdattr_change_value_cb;
...@@ -438,7 +450,8 @@ GsdAttrGtk::GsdAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx, ...@@ -438,7 +450,8 @@ GsdAttrGtk::GsdAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx,
g_object_set(cmd_prompt, "visible", FALSE, NULL); g_object_set(cmd_prompt, "visible", FALSE, NULL);
g_object_set(cmd_input, "visible", FALSE, NULL); g_object_set(cmd_input, "visible", FALSE, NULL);
if (!edit_mode) { if (!edit_mode)
{
gtk_widget_set_sensitive(cmd_ok, FALSE); gtk_widget_set_sensitive(cmd_ok, FALSE);
gtk_widget_set_sensitive(cmd_apply, FALSE); gtk_widget_set_sensitive(cmd_apply, FALSE);
gtk_widget_set_sensitive(menubutton_copy, FALSE); gtk_widget_set_sensitive(menubutton_copy, FALSE);
......
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
#include "cow_pb_gsd_attr.h" #include "cow_pb_gsd_attr.h"
#include "cow_wow_gtk.h" #include "cow_wow_gtk.h"
class GsdAttrGtk : public GsdAttr { class GsdAttrGtk : public GsdAttr
{
public: public:
GtkWidget* parent_wid; GtkWidget* parent_wid;
GtkWidget* brow_widget; GtkWidget* brow_widget;
...@@ -62,7 +63,7 @@ public: ...@@ -62,7 +63,7 @@ public:
CoWowFocusTimerGtk focustimer; CoWowFocusTimerGtk focustimer;
GsdAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx, void* a_object, GsdAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx, void* a_object,
pb_gsd* a_gsd, int a_edit_mode); pb_gsd* a_gsd, int a_edit_mode);
~GsdAttrGtk(); ~GsdAttrGtk();
void message(char severity, const char* message); void message(char severity, const char* message);
...@@ -87,8 +88,8 @@ public: ...@@ -87,8 +88,8 @@ public:
static void cmd_close_apply_cb(void* ctx, void* data); static void cmd_close_apply_cb(void* ctx, void* data);
static void cmd_close_no_cb(void* ctx, void* data); static void cmd_close_no_cb(void* ctx, void* data);
static void activate_cmd_ca(GtkWidget* w, gpointer dataxo); static void activate_cmd_ca(GtkWidget* w, gpointer dataxo);
static gboolean action_inputfocus( static gboolean action_inputfocus(GtkWidget* w, GdkEvent* event,
GtkWidget* w, GdkEvent* event, gpointer data); gpointer data);
// static void valchanged_cmd_input( GtkWidget *w, gpointer data); // static void valchanged_cmd_input( GtkWidget *w, gpointer data);
}; };
......
...@@ -56,8 +56,9 @@ ...@@ -56,8 +56,9 @@
// Create the navigator widget // Create the navigator widget
// //
GsdAttrNavGtk::GsdAttrNavGtk(void* xn_parent_ctx, GtkWidget* xn_parent_wid, GsdAttrNavGtk::GsdAttrNavGtk(void* xn_parent_ctx, GtkWidget* xn_parent_wid,
const char* xn_name, pb_gsd* xn_gsd, int xn_edit_mode, GtkWidget** w, const char* xn_name, pb_gsd* xn_gsd,
pwr_tStatus* status) int xn_edit_mode, GtkWidget** w,
pwr_tStatus* status)
: GsdAttrNav(xn_parent_ctx, xn_name, xn_gsd, xn_edit_mode, status), : GsdAttrNav(xn_parent_ctx, xn_name, xn_gsd, xn_edit_mode, status),
parent_wid(xn_parent_wid) parent_wid(xn_parent_wid)
{ {
...@@ -82,7 +83,4 @@ GsdAttrNavGtk::~GsdAttrNavGtk() ...@@ -82,7 +83,4 @@ GsdAttrNavGtk::~GsdAttrNavGtk()
gtk_widget_destroy(form_widget); gtk_widget_destroy(form_widget);
} }
void GsdAttrNavGtk::set_inputfocus() void GsdAttrNavGtk::set_inputfocus() { gtk_widget_grab_focus(brow_widget); }
{
gtk_widget_grab_focus(brow_widget);
}
...@@ -42,11 +42,12 @@ ...@@ -42,11 +42,12 @@
#include "cow_pb_gsd_attrnav.h" #include "cow_pb_gsd_attrnav.h"
//! The navigation area of the attribute editor. //! The navigation area of the attribute editor.
class GsdAttrNavGtk : public GsdAttrNav { class GsdAttrNavGtk : public GsdAttrNav
{
public: public:
GsdAttrNavGtk(void* xn_parent_ctx, GtkWidget* xn_parent_wid, GsdAttrNavGtk(void* xn_parent_ctx, GtkWidget* xn_parent_wid,
const char* xn_name, pb_gsd* xn_gsd, int xn_edit_mode, GtkWidget** w, const char* xn_name, pb_gsd* xn_gsd, int xn_edit_mode,
pwr_tStatus* status); GtkWidget** w, pwr_tStatus* status);
~GsdAttrNavGtk(); ~GsdAttrNavGtk();
void set_inputfocus(); void set_inputfocus();
......
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
#include "cow_pn_gsdml_attr.h" #include "cow_pn_gsdml_attr.h"
#include "cow_wow_gtk.h" #include "cow_wow_gtk.h"
class GsdmlAttrGtk : public GsdmlAttr { class GsdmlAttrGtk : public GsdmlAttr
{
public: public:
GtkWidget* parent_wid; GtkWidget* parent_wid;
GtkWidget* brow_widget; GtkWidget* brow_widget;
...@@ -65,8 +66,8 @@ public: ...@@ -65,8 +66,8 @@ public:
CoWowEntryGtk* cmd_entry; CoWowEntryGtk* cmd_entry;
GsdmlAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx, void* a_object, GsdmlAttrGtk(GtkWidget* a_parent_wid, void* a_parent_ctx, void* a_object,
pn_gsdml* a_gsdml, int a_edit_mode, const char* a_data_filename, pn_gsdml* a_gsdml, int a_edit_mode, const char* a_data_filename,
pwr_tStatus* a_sts); pwr_tStatus* a_sts);
~GsdmlAttrGtk(); ~GsdmlAttrGtk();
void message(char severity, const char* message); void message(char severity, const char* message);
...@@ -103,8 +104,8 @@ public: ...@@ -103,8 +104,8 @@ public:
static void cmd_close_apply_cb(void* ctx, void* data); static void cmd_close_apply_cb(void* ctx, void* data);
static void cmd_close_no_cb(void* ctx, void* data); static void cmd_close_no_cb(void* ctx, void* data);
static void activate_cmd_ca(GtkWidget* w, gpointer dataxo); static void activate_cmd_ca(GtkWidget* w, gpointer dataxo);
static gboolean action_inputfocus( static gboolean action_inputfocus(GtkWidget* w, GdkEvent* event,
GtkWidget* w, GdkEvent* event, gpointer data); gpointer data);
// static void valchanged_cmd_input( GtkWidget *w, gpointer data); // static void valchanged_cmd_input( GtkWidget *w, gpointer data);
}; };
......
...@@ -53,8 +53,9 @@ ...@@ -53,8 +53,9 @@
// Create the navigator widget // Create the navigator widget
// //
GsdmlAttrNavGtk::GsdmlAttrNavGtk(void* xn_parent_ctx, GtkWidget* xn_parent_wid, GsdmlAttrNavGtk::GsdmlAttrNavGtk(void* xn_parent_ctx, GtkWidget* xn_parent_wid,
const char* xn_name, pn_gsdml* xn_gsdml, int xn_edit_mode, GtkWidget** w, const char* xn_name, pn_gsdml* xn_gsdml,
pwr_tStatus* status) int xn_edit_mode, GtkWidget** w,
pwr_tStatus* status)
: GsdmlAttrNav(xn_parent_ctx, xn_name, xn_gsdml, xn_edit_mode, status), : GsdmlAttrNav(xn_parent_ctx, xn_name, xn_gsdml, xn_edit_mode, status),
parent_wid(xn_parent_wid) parent_wid(xn_parent_wid)
{ {
...@@ -79,10 +80,7 @@ GsdmlAttrNavGtk::~GsdmlAttrNavGtk() ...@@ -79,10 +80,7 @@ GsdmlAttrNavGtk::~GsdmlAttrNavGtk()
gtk_widget_destroy(form_widget); gtk_widget_destroy(form_widget);
} }
void GsdmlAttrNavGtk::set_inputfocus() void GsdmlAttrNavGtk::set_inputfocus() { gtk_widget_grab_focus(brow_widget); }
{
gtk_widget_grab_focus(brow_widget);
}
void GsdmlAttrNavGtk::display_attr_help_text() void GsdmlAttrNavGtk::display_attr_help_text()
{ {
...@@ -97,14 +95,16 @@ void GsdmlAttrNavGtk::display_attr_help_text() ...@@ -97,14 +95,16 @@ void GsdmlAttrNavGtk::display_attr_help_text()
brow_GetUserData(node_list[0], (void**)&base_item); brow_GetUserData(node_list[0], (void**)&base_item);
free(node_list); free(node_list);
switch (base_item->type) { switch (base_item->type)
{
/* /*
* The following two item types could make use of the same info_text that the * The following two item types could make use of the same info_text that the
* the base class does, * the base class does,
* but since they already contained references they were used instead... * but since they already contained references they were used instead...
*/ */
case attrnav_eItemType_PnParValue: case attrnav_eItemType_PnParValue:
case attrnav_eItemType_PnParEnum: { case attrnav_eItemType_PnParEnum:
{
ItemPnParEnum* item = (ItemPnParEnum*)base_item; ItemPnParEnum* item = (ItemPnParEnum*)base_item;
gsdml_ValueItem* vi = 0; gsdml_ValueItem* vi = 0;
...@@ -119,7 +119,8 @@ void GsdmlAttrNavGtk::display_attr_help_text() ...@@ -119,7 +119,8 @@ void GsdmlAttrNavGtk::display_attr_help_text()
break; break;
} }
default: { default:
{
// Do we have an associated info text string to show the user some more // Do we have an associated info text string to show the user some more
// info? // info?
if (base_item->info_text) if (base_item->info_text)
......
...@@ -42,11 +42,12 @@ ...@@ -42,11 +42,12 @@
#include "cow_pn_gsdml_attrnav.h" #include "cow_pn_gsdml_attrnav.h"
//! The navigation area of the attribute editor. //! The navigation area of the attribute editor.
class GsdmlAttrNavGtk : public GsdmlAttrNav { class GsdmlAttrNavGtk : public GsdmlAttrNav
{
public: public:
GsdmlAttrNavGtk(void* xn_parent_ctx, GtkWidget* xn_parent_wid, GsdmlAttrNavGtk(void* xn_parent_ctx, GtkWidget* xn_parent_wid,
const char* xn_name, pn_gsdml* xn_gsdml, int xn_edit_mode, GtkWidget** w, const char* xn_name, pn_gsdml* xn_gsdml, int xn_edit_mode,
pwr_tStatus* status); GtkWidget** w, pwr_tStatus* status);
~GsdmlAttrNavGtk(); ~GsdmlAttrNavGtk();
void set_inputfocus(); void set_inputfocus();
void display_attr_help_text(); void display_attr_help_text();
......
...@@ -41,7 +41,8 @@ ...@@ -41,7 +41,8 @@
#include "cow_pb_gsd_attr.h" #include "cow_pb_gsd_attr.h"
class GsdAttrMotif : public GsdAttr { class GsdAttrMotif : public GsdAttr
{
public: public:
Widget parent_wid; Widget parent_wid;
Widget brow_widget; Widget brow_widget;
...@@ -59,7 +60,7 @@ public: ...@@ -59,7 +60,7 @@ public:
Widget menubutton_changevalue; Widget menubutton_changevalue;
GsdAttrMotif(Widget a_parent_wid, void* a_parent_ctx, void* a_object, GsdAttrMotif(Widget a_parent_wid, void* a_parent_ctx, void* a_object,
pb_gsd* a_gsd, int a_edit_mode); pb_gsd* a_gsd, int a_edit_mode);
~GsdAttrMotif(); ~GsdAttrMotif();
void message(char severity, const char* message); void message(char severity, const char* message);
...@@ -68,40 +69,40 @@ public: ...@@ -68,40 +69,40 @@ public:
static void gsdattr_message(void* attr, char severity, char* message); static void gsdattr_message(void* attr, char severity, char* message);
static void gsdattr_change_value_cb(void* attr_ctx); static void gsdattr_change_value_cb(void* attr_ctx);
static void activate_change_value( static void activate_change_value(Widget w, GsdAttr* attr,
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); XmAnyCallbackStruct* data);
static void activate_exit(Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); static void activate_exit(Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void activate_help(Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); static void activate_help(Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void activate_copy(Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); static void activate_copy(Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void activate_cut(Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); static void activate_cut(Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void activate_paste( static void activate_paste(Widget w, GsdAttr* attr,
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); XmAnyCallbackStruct* data);
static void activate_zoom_in( static void activate_zoom_in(Widget w, GsdAttr* attr,
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); XmAnyCallbackStruct* data);
static void activate_zoom_out( static void activate_zoom_out(Widget w, GsdAttr* attr,
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); XmAnyCallbackStruct* data);
static void activate_zoom_reset( static void activate_zoom_reset(Widget w, GsdAttr* attr,
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); XmAnyCallbackStruct* data);
static void activate_print( static void activate_print(Widget w, GsdAttr* attr,
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); XmAnyCallbackStruct* data);
static void activate_cmd_ok( static void activate_cmd_ok(Widget w, GsdAttr* attr,
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); XmAnyCallbackStruct* data);
static void cmd_close_apply_cb(void* ctx, void* data); static void cmd_close_apply_cb(void* ctx, void* data);
static void cmd_close_no_cb(void* ctx, void* data); static void cmd_close_no_cb(void* ctx, void* data);
static void activate_cmd_ca( static void activate_cmd_ca(Widget w, GsdAttr* attr,
Widget w, GsdAttr* attr, XmAnyCallbackStruct* dataxo); XmAnyCallbackStruct* dataxo);
static void create_menubutton( static void create_menubutton(Widget w, GsdAttr* attr,
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); XmAnyCallbackStruct* data);
static void create_msg_label( static void create_msg_label(Widget w, GsdAttr* attr,
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); XmAnyCallbackStruct* data);
static void create_cmd_prompt( static void create_cmd_prompt(Widget w, GsdAttr* attr,
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); XmAnyCallbackStruct* data);
static void create_cmd_ok(Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); static void create_cmd_ok(Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void create_cmd_ca(Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); static void create_cmd_ca(Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void create_cmd_input( static void create_cmd_input(Widget w, GsdAttr* attr,
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); XmAnyCallbackStruct* data);
static void create_attrnav_form( static void create_attrnav_form(Widget w, GsdAttr* attr,
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data); XmAnyCallbackStruct* data);
static void action_inputfocus(Widget w, XmAnyCallbackStruct* data); static void action_inputfocus(Widget w, XmAnyCallbackStruct* data);
static void valchanged_cmd_input(Widget w, XEvent* event); static void valchanged_cmd_input(Widget w, XEvent* event);
}; };
......
...@@ -71,13 +71,14 @@ ...@@ -71,13 +71,14 @@
// Create the navigator widget // Create the navigator widget
// //
GsdAttrNavMotif::GsdAttrNavMotif(void* xn_parent_ctx, Widget xn_parent_wid, GsdAttrNavMotif::GsdAttrNavMotif(void* xn_parent_ctx, Widget xn_parent_wid,
char* xn_name, pb_gsd* xn_gsd, int xn_edit_mode, Widget* w, char* xn_name, pb_gsd* xn_gsd,
pwr_tStatus* status) int xn_edit_mode, Widget* w,
pwr_tStatus* status)
: GsdAttrNav(xn_parent_ctx, xn_name, xn_gsd, xn_edit_mode, status), : GsdAttrNav(xn_parent_ctx, xn_name, xn_gsd, xn_edit_mode, status),
parent_wid(xn_parent_wid) parent_wid(xn_parent_wid)
{ {
form_widget = ScrolledBrowCreate( form_widget = ScrolledBrowCreate(parent_wid, name, NULL, 0, init_brow_cb,
parent_wid, name, NULL, 0, init_brow_cb, this, (Widget*)&brow_widget); this, (Widget*)&brow_widget);
XtManageChild(form_widget); XtManageChild(form_widget);
// Create the root item // Create the root item
......
...@@ -44,10 +44,12 @@ ...@@ -44,10 +44,12 @@
#endif #endif
//! The navigation area of the attribute editor. //! The navigation area of the attribute editor.
class GsdAttrNavMotif : public GsdAttrNav { class GsdAttrNavMotif : public GsdAttrNav
{
public: public:
GsdAttrNavMotif(void* xn_parent_ctx, Widget xn_parent_wid, char* xn_name, GsdAttrNavMotif(void* xn_parent_ctx, Widget xn_parent_wid, char* xn_name,
pb_gsd* xn_gsd, int xn_edit_mode, Widget* w, pwr_tStatus* status); pb_gsd* xn_gsd, int xn_edit_mode, Widget* w,
pwr_tStatus* status);
~GsdAttrNavMotif(); ~GsdAttrNavMotif();
void set_inputfocus(); void set_inputfocus();
......
...@@ -47,7 +47,8 @@ ...@@ -47,7 +47,8 @@
class GsdAttrQtWidget; class GsdAttrQtWidget;
class GsdAttrQt : public GsdAttr { class GsdAttrQt : public GsdAttr
{
public: public:
QWidget* brow_widget; QWidget* brow_widget;
QWidget* form_widget; QWidget* form_widget;
...@@ -72,7 +73,8 @@ private: ...@@ -72,7 +73,8 @@ private:
GsdAttrQtWidget* toplevel; GsdAttrQtWidget* toplevel;
}; };
class GsdAttrQtWidget : public QWidget { class GsdAttrQtWidget : public QWidget
{
Q_OBJECT Q_OBJECT
public: public:
...@@ -97,10 +99,10 @@ public slots: ...@@ -97,10 +99,10 @@ public slots:
void activate_cmd_ok(); void activate_cmd_ok();
void activate_cmd_apply(); void activate_cmd_apply();
void valchanged_cmd_input(){} void valchanged_cmd_input() {}
private: private:
GsdAttrQt* attr; GsdAttrQt* attr;
}; };
#endif #endif
\ No newline at end of file
...@@ -44,7 +44,8 @@ ...@@ -44,7 +44,8 @@
#include "cow_pb_gsd_attrnav_qt.h" #include "cow_pb_gsd_attrnav_qt.h"
GsdAttrNavQt::GsdAttrNavQt(void* xn_parent_ctx, const char* xn_name, GsdAttrNavQt::GsdAttrNavQt(void* xn_parent_ctx, const char* xn_name,
pb_gsd* xn_gsd, int xn_edit_mode, QWidget** w, pwr_tStatus* status) pb_gsd* xn_gsd, int xn_edit_mode, QWidget** w,
pwr_tStatus* status)
: GsdAttrNav(xn_parent_ctx, xn_name, xn_gsd, xn_edit_mode, status) : GsdAttrNav(xn_parent_ctx, xn_name, xn_gsd, xn_edit_mode, status)
{ {
form_widget = scrolledbrowwidgetqt_new(init_brow_cb, this, &brow_widget); form_widget = scrolledbrowwidgetqt_new(init_brow_cb, this, &brow_widget);
...@@ -64,7 +65,4 @@ GsdAttrNavQt::~GsdAttrNavQt() ...@@ -64,7 +65,4 @@ GsdAttrNavQt::~GsdAttrNavQt()
form_widget->close(); form_widget->close();
} }
void GsdAttrNavQt::set_inputfocus() void GsdAttrNavQt::set_inputfocus() { brow_widget->setFocus(); }
{
brow_widget->setFocus();
}
\ No newline at end of file
...@@ -44,7 +44,8 @@ ...@@ -44,7 +44,8 @@
#include <QWidget> #include <QWidget>
//! The navigation area of the attribute editor. //! The navigation area of the attribute editor.
class GsdAttrNavQt : public GsdAttrNav { class GsdAttrNavQt : public GsdAttrNav
{
public: public:
GsdAttrNavQt(void* xn_parent_ctx, const char* xn_name, pb_gsd* xn_gsd, GsdAttrNavQt(void* xn_parent_ctx, const char* xn_name, pb_gsd* xn_gsd,
int xn_edit_mode, QWidget** w, pwr_tStatus* status); int xn_edit_mode, QWidget** w, pwr_tStatus* status);
...@@ -55,4 +56,4 @@ public: ...@@ -55,4 +56,4 @@ public:
QWidget* form_widget; QWidget* form_widget;
}; };
#endif #endif
\ No newline at end of file
...@@ -49,7 +49,8 @@ ...@@ -49,7 +49,8 @@
class GsdmlAttrQtWidget; class GsdmlAttrQtWidget;
class GsdmlAttrQt : public GsdmlAttr { class GsdmlAttrQt : public GsdmlAttr
{
public: public:
GsdmlAttrQtWidget* toplevel; GsdmlAttrQtWidget* toplevel;
QWidget* brow_widget; QWidget* brow_widget;
...@@ -75,7 +76,8 @@ public: ...@@ -75,7 +76,8 @@ public:
void change_value(); void change_value();
}; };
class GsdmlAttrQtWidget : public QWidget { class GsdmlAttrQtWidget : public QWidget
{
Q_OBJECT Q_OBJECT
public: public:
...@@ -106,10 +108,10 @@ public slots: ...@@ -106,10 +108,10 @@ public slots:
void activate_cmd_ok(); void activate_cmd_ok();
void activate_cmd_apply(); void activate_cmd_apply();
void valchanged_cmd_entry(){} void valchanged_cmd_entry() {}
private: private:
GsdmlAttrQt* attr; GsdmlAttrQt* attr;
}; };
#endif #endif
\ No newline at end of file
...@@ -44,7 +44,8 @@ ...@@ -44,7 +44,8 @@
#include "cow_pn_gsdml_attrnav_qt.h" #include "cow_pn_gsdml_attrnav_qt.h"
GsdmlAttrNavQt::GsdmlAttrNavQt(void* xn_parent_ctx, const char* xn_name, GsdmlAttrNavQt::GsdmlAttrNavQt(void* xn_parent_ctx, const char* xn_name,
pn_gsdml* xn_gsdml, int xn_edit_mode, QWidget** w, pwr_tStatus* status) pn_gsdml* xn_gsdml, int xn_edit_mode,
QWidget** w, pwr_tStatus* status)
: GsdmlAttrNav(xn_parent_ctx, xn_name, xn_gsdml, xn_edit_mode, status) : GsdmlAttrNav(xn_parent_ctx, xn_name, xn_gsdml, xn_edit_mode, status)
{ {
form_widget = scrolledbrowwidgetqt_new(init_brow_cb, this, &brow_widget); form_widget = scrolledbrowwidgetqt_new(init_brow_cb, this, &brow_widget);
...@@ -64,10 +65,7 @@ GsdmlAttrNavQt::~GsdmlAttrNavQt() ...@@ -64,10 +65,7 @@ GsdmlAttrNavQt::~GsdmlAttrNavQt()
form_widget->close(); form_widget->close();
} }
void GsdmlAttrNavQt::set_inputfocus() void GsdmlAttrNavQt::set_inputfocus() { brow_widget->setFocus(); }
{
brow_widget->setFocus();
}
void GsdmlAttrNavQt::display_attr_help_text() void GsdmlAttrNavQt::display_attr_help_text()
{ {
...@@ -82,14 +80,16 @@ void GsdmlAttrNavQt::display_attr_help_text() ...@@ -82,14 +80,16 @@ void GsdmlAttrNavQt::display_attr_help_text()
brow_GetUserData(node_list[0], (void**)&base_item); brow_GetUserData(node_list[0], (void**)&base_item);
free(node_list); free(node_list);
switch (base_item->type) { switch (base_item->type)
{
/* /*
* The following two item types could make use of the same info_text that the * The following two item types could make use of the same info_text that the
* the base class does, * the base class does,
* but since they already contained references they were used instead... * but since they already contained references they were used instead...
*/ */
case attrnav_eItemType_PnParValue: case attrnav_eItemType_PnParValue:
case attrnav_eItemType_PnParEnum: { case attrnav_eItemType_PnParEnum:
{
ItemPnParEnum* item = (ItemPnParEnum*)base_item; ItemPnParEnum* item = (ItemPnParEnum*)base_item;
gsdml_ValueItem* vi = 0; gsdml_ValueItem* vi = 0;
...@@ -104,11 +104,12 @@ void GsdmlAttrNavQt::display_attr_help_text() ...@@ -104,11 +104,12 @@ void GsdmlAttrNavQt::display_attr_help_text()
break; break;
} }
default: { default:
{
if (base_item->info_text) if (base_item->info_text)
((GsdmlAttrQt*)parent_ctx)->attr_help_text(base_item->info_text); ((GsdmlAttrQt*)parent_ctx)->attr_help_text(base_item->info_text);
else else
((GsdmlAttrQt*)parent_ctx)->attr_help_text(""); ((GsdmlAttrQt*)parent_ctx)->attr_help_text("");
} }
} }
} }
\ No newline at end of file
...@@ -44,7 +44,8 @@ ...@@ -44,7 +44,8 @@
#include <QWidget> #include <QWidget>
//! The navigation area of the attribute editor. //! The navigation area of the attribute editor.
class GsdmlAttrNavQt : public GsdmlAttrNav { class GsdmlAttrNavQt : public GsdmlAttrNav
{
public: public:
GsdmlAttrNavQt(void* xn_parent_ctx, const char* xn_name, pn_gsdml* xn_gsdml, GsdmlAttrNavQt(void* xn_parent_ctx, const char* xn_name, pn_gsdml* xn_gsdml,
int xn_edit_mode, QWidget** w, pwr_tStatus* status); int xn_edit_mode, QWidget** w, pwr_tStatus* status);
...@@ -56,4 +57,4 @@ public: ...@@ -56,4 +57,4 @@ public:
QWidget* form_widget; QWidget* form_widget;
}; };
#endif #endif
\ No newline at end of file
This diff is collapsed.
...@@ -83,7 +83,8 @@ typedef enum { ...@@ -83,7 +83,8 @@ typedef enum {
gsd_End gsd_End
} gsd_eType; } gsd_eType;
typedef struct { typedef struct
{
char name[50]; char name[50];
char group[50]; char group[50];
int option; int option;
...@@ -91,19 +92,22 @@ typedef struct { ...@@ -91,19 +92,22 @@ typedef struct {
unsigned int value_default; unsigned int value_default;
} gsd_sKeyword; } gsd_sKeyword;
typedef struct { typedef struct
{
char name[32]; char name[32];
pwr_tCid cid; pwr_tCid cid;
} gsd_sModuleClass; } gsd_sModuleClass;
typedef struct { typedef struct
{
unsigned int value; unsigned int value;
void* data; void* data;
int found; int found;
int len; int len;
} gsd_sData; } gsd_sData;
typedef struct sArea { typedef struct sArea
{
char Area_Name[33]; char Area_Name[33];
int Related_CFG_Identifier; int Related_CFG_Identifier;
int IO_Direction; int IO_Direction;
...@@ -116,25 +120,29 @@ typedef struct sArea { ...@@ -116,25 +120,29 @@ typedef struct sArea {
struct sArea* next; struct sArea* next;
} gsd_sArea; } gsd_sArea;
typedef struct { typedef struct
{
int Const_Offset; int Const_Offset;
unsigned char Const_Prm_Data[237]; unsigned char Const_Prm_Data[237];
int len; int len;
} gsd_sExtUserPrmDataConst; } gsd_sExtUserPrmDataConst;
typedef struct sText { typedef struct sText
{
int Prm_Data_Value; int Prm_Data_Value;
char Text[33]; char Text[33];
struct sText* next; struct sText* next;
} gsd_sText; } gsd_sText;
typedef struct sPrmText { typedef struct sPrmText
{
int Reference_Number; int Reference_Number;
gsd_sText* text_list; gsd_sText* text_list;
struct sPrmText* next; struct sPrmText* next;
} gsd_sPrmText; } gsd_sPrmText;
typedef struct sExtUserPrmData { typedef struct sExtUserPrmData
{
int Reference_Number; int Reference_Number;
char Ext_User_Prm_Data_Name[33]; char Ext_User_Prm_Data_Name[33];
char Data_Type_Name[33]; char Data_Type_Name[33];
...@@ -154,19 +162,22 @@ typedef struct sExtUserPrmData { ...@@ -154,19 +162,22 @@ typedef struct sExtUserPrmData {
struct sExtUserPrmData* next; struct sExtUserPrmData* next;
} gsd_sExtUserPrmData; } gsd_sExtUserPrmData;
typedef struct sExtUserPrmDataRef { typedef struct sExtUserPrmDataRef
{
int Reference_Offset; int Reference_Offset;
int Reference_Number; int Reference_Number;
gsd_sExtUserPrmData* prm_data; gsd_sExtUserPrmData* prm_data;
sExtUserPrmDataRef* next; sExtUserPrmDataRef* next;
} gsd_sExtUserPrmDataRef; } gsd_sExtUserPrmDataRef;
typedef struct { typedef struct
{
gsd_sExtUserPrmDataRef* ref; gsd_sExtUserPrmDataRef* ref;
int value; int value;
} gsd_sPrmDataItem; } gsd_sPrmDataItem;
typedef struct sModule { typedef struct sModule
{
char Mod_Name[33]; char Mod_Name[33];
unsigned char* Config; unsigned char* Config;
int config_size; int config_size;
...@@ -180,7 +191,8 @@ typedef struct sModule { ...@@ -180,7 +191,8 @@ typedef struct sModule {
struct sModule* next; struct sModule* next;
} gsd_sModule; } gsd_sModule;
typedef struct { typedef struct
{
int idx; int idx;
gsd_sModule* module; gsd_sModule* module;
char name[80]; char name[80];
...@@ -191,7 +203,8 @@ typedef struct { ...@@ -191,7 +203,8 @@ typedef struct {
unsigned char prm_data[237]; unsigned char prm_data[237];
} gsd_sModuleConf; } gsd_sModuleConf;
class pb_gsd { class pb_gsd
{
public: public:
pb_gsd(); pb_gsd();
~pb_gsd(); ~pb_gsd();
...@@ -236,17 +249,15 @@ public: ...@@ -236,17 +249,15 @@ public:
int prm_len(gsd_sPrmDataItem* item, int item_size); int prm_len(gsd_sPrmDataItem* item, int item_size);
int prm_items_set_default_data(gsd_sPrmDataItem* item, int item_size); int prm_items_set_default_data(gsd_sPrmDataItem* item, int item_size);
int prm_items_to_data(gsd_sPrmDataItem* item, int item_size, int prm_items_to_data(gsd_sPrmDataItem* item, int item_size,
unsigned char* data, int data_size); unsigned char* data, int data_size);
int prm_data_to_items(gsd_sPrmDataItem* item, int item_size, int prm_data_to_items(gsd_sPrmDataItem* item, int item_size,
unsigned char* data, int data_size, int set_default = 0); unsigned char* data, int data_size,
void set_classes(gsd_sModuleClass* mclist) int set_default = 0);
{ void set_classes(gsd_sModuleClass* mclist) { module_classlist = mclist; }
module_classlist = mclist;
}
int get_svalue(const char* key, char* value, int size); int get_svalue(const char* key, char* value, int size);
int get_ivalue(const char* key, int* value); int get_ivalue(const char* key, int* value);
int add_module_conf( int add_module_conf(pwr_tCid cid, pwr_tOid oid, char* name,
pwr_tCid cid, pwr_tOid oid, char* name, char* module_name); char* module_name);
int move_module_conf(gsd_sModuleConf* src, gsd_sModuleConf* dest); int move_module_conf(gsd_sModuleConf* src, gsd_sModuleConf* dest);
int copy_module_conf(gsd_sModuleConf* m); int copy_module_conf(gsd_sModuleConf* m);
int cut_module_conf(gsd_sModuleConf* m); int cut_module_conf(gsd_sModuleConf* m);
...@@ -257,14 +268,8 @@ public: ...@@ -257,14 +268,8 @@ public:
void pack_ext_user_prm_data(char* data, int* len); void pack_ext_user_prm_data(char* data, int* len);
void compress(char* line); void compress(char* line);
int syntax_check(int* idx); int syntax_check(int* idx);
void set_modified(int mod) void set_modified(int mod) { modified = mod; }
{ int is_modified() { return modified; }
modified = mod;
}
int is_modified()
{
return modified;
}
}; };
#endif #endif
...@@ -70,14 +70,17 @@ void GsdAttr::gsdattr_change_value_cb(void* attr_ctx) ...@@ -70,14 +70,17 @@ void GsdAttr::gsdattr_change_value_cb(void* attr_ctx)
// //
void GsdAttr::activate_exit() void GsdAttr::activate_exit()
{ {
if (close_cb) { if (close_cb)
if (gsd->is_modified()) { {
if (gsd->is_modified())
{
wow->DisplayQuestion((void*)this, "Apply", "Do you want to apply changes", wow->DisplayQuestion((void*)this, "Apply", "Do you want to apply changes",
cmd_close_apply_cb, cmd_close_no_cb, 0); cmd_close_apply_cb, cmd_close_no_cb, 0);
}
} else else
(close_cb)(parent_ctx); (close_cb)(parent_ctx);
} else }
else
delete this; delete this;
} }
...@@ -86,7 +89,8 @@ void GsdAttr::activate_help() ...@@ -86,7 +89,8 @@ void GsdAttr::activate_help()
int sts; int sts;
if (help_cb) if (help_cb)
sts = (help_cb)(parent_ctx, sts = (help_cb)(
parent_ctx,
"pb_slave_editor /helpfile=\"$pwr_exe/profibus_xtthelp.dat\""); "pb_slave_editor /helpfile=\"$pwr_exe/profibus_xtthelp.dat\"");
} }
...@@ -96,12 +100,14 @@ void GsdAttr::activate_copy() ...@@ -96,12 +100,14 @@ void GsdAttr::activate_copy()
int sts; int sts;
sts = attrnav->get_select((ItemPb**)&item); sts = attrnav->get_select((ItemPb**)&item);
if (EVEN(sts)) { if (EVEN(sts))
{
message('E', "Select a module"); message('E', "Select a module");
return; return;
} }
if (item->type != attrnav_eItemType_PbModule) { if (item->type != attrnav_eItemType_PbModule)
{
message('E', "Only modules can be copied"); message('E', "Only modules can be copied");
return; return;
} }
...@@ -116,12 +122,14 @@ void GsdAttr::activate_cut() ...@@ -116,12 +122,14 @@ void GsdAttr::activate_cut()
int sts; int sts;
sts = attrnav->get_select((ItemPb**)&item); sts = attrnav->get_select((ItemPb**)&item);
if (EVEN(sts)) { if (EVEN(sts))
{
message('E', "Select a module"); message('E', "Select a module");
return; return;
} }
if (item->type != attrnav_eItemType_PbModule) { if (item->type != attrnav_eItemType_PbModule)
{
message('E', "Only modules can be copied"); message('E', "Only modules can be copied");
return; return;
} }
...@@ -135,12 +143,14 @@ void GsdAttr::activate_paste() ...@@ -135,12 +143,14 @@ void GsdAttr::activate_paste()
int sts; int sts;
sts = attrnav->get_select((ItemPb**)&item); sts = attrnav->get_select((ItemPb**)&item);
if (EVEN(sts)) { if (EVEN(sts))
{
message('E', "Select a module"); message('E', "Select a module");
return; return;
} }
if (item->type != attrnav_eItemType_PbModule) { if (item->type != attrnav_eItemType_PbModule)
{
message('E', "Only modules can be copied"); message('E', "Only modules can be copied");
return; return;
} }
...@@ -170,10 +180,7 @@ void GsdAttr::activate_zoom_out() ...@@ -170,10 +180,7 @@ void GsdAttr::activate_zoom_out()
attrnav->zoom(1.0 / 1.18); attrnav->zoom(1.0 / 1.18);
} }
void GsdAttr::activate_zoom_reset() void GsdAttr::activate_zoom_reset() { attrnav->unzoom(); }
{
attrnav->unzoom();
}
void GsdAttr::activate_print() void GsdAttr::activate_print()
{ {
...@@ -194,21 +201,24 @@ void GsdAttr::activate_cmd_ok() ...@@ -194,21 +201,24 @@ void GsdAttr::activate_cmd_ok()
int idx; int idx;
char msg[80]; char msg[80];
if (save_cb) { if (save_cb)
{
// Check syntax // Check syntax
sts = gsd->syntax_check(&idx); sts = gsd->syntax_check(&idx);
if (EVEN(sts)) { if (EVEN(sts))
switch (sts) { {
switch (sts)
{
case PB__NOMODULENAME: case PB__NOMODULENAME:
sprintf(msg, "Syntax error in module %d, No module name", idx + 1); sprintf(msg, "Syntax error in module %d, No module name", idx + 1);
break; break;
case PB__DUPLMODULENAME: case PB__DUPLMODULENAME:
sprintf(msg, "Syntax error in module %s, Duplicate module name", sprintf(msg, "Syntax error in module %s, Duplicate module name",
gsd->module_conf[idx].name); gsd->module_conf[idx].name);
break; break;
case PB__NOMODULECLASS: case PB__NOMODULECLASS:
sprintf(msg, "Syntax error in module %s, Module class is missing", sprintf(msg, "Syntax error in module %s, Module class is missing",
gsd->module_conf[idx].name); gsd->module_conf[idx].name);
break; break;
default: default:
sprintf(msg, "Syntax error in module %d", idx + 1); sprintf(msg, "Syntax error in module %d", idx + 1);
...@@ -222,7 +232,8 @@ void GsdAttr::activate_cmd_ok() ...@@ -222,7 +232,8 @@ void GsdAttr::activate_cmd_ok()
message('E', "Error saving profibus data"); message('E', "Error saving profibus data");
else if (close_cb) else if (close_cb)
(close_cb)(parent_ctx); (close_cb)(parent_ctx);
} else if (close_cb) }
else if (close_cb)
(close_cb)(parent_ctx); (close_cb)(parent_ctx);
} }
...@@ -232,21 +243,24 @@ void GsdAttr::activate_cmd_apply() ...@@ -232,21 +243,24 @@ void GsdAttr::activate_cmd_apply()
int idx; int idx;
char msg[80]; char msg[80];
if (save_cb) { if (save_cb)
{
// Check syntax // Check syntax
sts = gsd->syntax_check(&idx); sts = gsd->syntax_check(&idx);
if (EVEN(sts)) { if (EVEN(sts))
switch (sts) { {
switch (sts)
{
case PB__NOMODULENAME: case PB__NOMODULENAME:
sprintf(msg, "Syntax error in module %d, No module name", idx + 1); sprintf(msg, "Syntax error in module %d, No module name", idx + 1);
break; break;
case PB__DUPLMODULENAME: case PB__DUPLMODULENAME:
sprintf(msg, "Syntax error in module %s, Duplicate module name", sprintf(msg, "Syntax error in module %s, Duplicate module name",
gsd->module_conf[idx].name); gsd->module_conf[idx].name);
break; break;
case PB__NOMODULECLASS: case PB__NOMODULECLASS:
sprintf(msg, "Syntax error in module %s, Module class is missing", sprintf(msg, "Syntax error in module %s, Module class is missing",
gsd->module_conf[idx].name); gsd->module_conf[idx].name);
break; break;
default: default:
sprintf(msg, "Syntax error in module %d", idx + 1); sprintf(msg, "Syntax error in module %d", idx + 1);
...@@ -271,7 +285,8 @@ void GsdAttr::cmd_close_apply_cb(void* ctx, void* data) ...@@ -271,7 +285,8 @@ void GsdAttr::cmd_close_apply_cb(void* ctx, void* data)
sts = (attr->save_cb)(attr->parent_ctx); sts = (attr->save_cb)(attr->parent_ctx);
if (EVEN(sts)) if (EVEN(sts))
attr->message('E', "Error saving profibus data"); attr->message('E', "Error saving profibus data");
else { else
{
attr->gsd->set_modified(0); attr->gsd->set_modified(0);
(attr->close_cb)(attr->parent_ctx); (attr->close_cb)(attr->parent_ctx);
} }
...@@ -286,22 +301,22 @@ void GsdAttr::cmd_close_no_cb(void* ctx, void* data) ...@@ -286,22 +301,22 @@ void GsdAttr::cmd_close_no_cb(void* ctx, void* data)
void GsdAttr::activate_cmd_ca() void GsdAttr::activate_cmd_ca()
{ {
if (close_cb) { if (close_cb)
if (gsd->is_modified()) { {
if (gsd->is_modified())
{
wow->DisplayQuestion((void*)this, "Apply", "Do you want to apply changes", wow->DisplayQuestion((void*)this, "Apply", "Do you want to apply changes",
cmd_close_apply_cb, cmd_close_no_cb, 0); cmd_close_apply_cb, cmd_close_no_cb, 0);
}
} else else
(close_cb)(parent_ctx); (close_cb)(parent_ctx);
} }
} }
GsdAttr::~GsdAttr() GsdAttr::~GsdAttr() {}
{
}
GsdAttr::GsdAttr( GsdAttr::GsdAttr(void* a_parent_ctx, void* a_object, pb_gsd* a_gsd,
void* a_parent_ctx, void* a_object, pb_gsd* a_gsd, int a_edit_mode) int a_edit_mode)
: parent_ctx(a_parent_ctx), gsd(a_gsd), edit_mode(a_edit_mode), : parent_ctx(a_parent_ctx), gsd(a_gsd), edit_mode(a_edit_mode),
input_open(0), object(a_object), close_cb(0), save_cb(0), help_cb(0), input_open(0), object(a_object), close_cb(0), save_cb(0), help_cb(0),
client_data(0), recall_idx(-1), value_current_recall(0) client_data(0), recall_idx(-1), value_current_recall(0)
......
...@@ -41,7 +41,8 @@ ...@@ -41,7 +41,8 @@
#include "cow_pb_gsd.h" #include "cow_pb_gsd.h"
typedef struct { typedef struct
{
void* value; void* value;
char name[80]; char name[80];
int type; int type;
...@@ -56,7 +57,8 @@ typedef struct { ...@@ -56,7 +57,8 @@ typedef struct {
class GsdAttrNav; class GsdAttrNav;
class CoWow; class CoWow;
class GsdAttr { class GsdAttr
{
public: public:
void* parent_ctx; void* parent_ctx;
char name[80]; char name[80];
...@@ -77,15 +79,9 @@ public: ...@@ -77,15 +79,9 @@ public:
GsdAttr(void* a_parent_ctx, void* a_object, pb_gsd* a_gsd, int a_edit_mode); GsdAttr(void* a_parent_ctx, void* a_object, pb_gsd* a_gsd, int a_edit_mode);
virtual ~GsdAttr(); virtual ~GsdAttr();
virtual void message(char severity, const char* message) virtual void message(char severity, const char* message) {}
{ virtual void set_prompt(const char* prompt) {}
} virtual void change_value() {}
virtual void set_prompt(const char* prompt)
{
}
virtual void change_value()
{
}
void activate_exit(); void activate_exit();
void activate_help(); void activate_help();
......
This diff is collapsed.
...@@ -67,9 +67,10 @@ typedef enum { ...@@ -67,9 +67,10 @@ typedef enum {
class ItemPb; class ItemPb;
//! Class for handling of brow. //! Class for handling of brow.
class GsdAttrNavBrow { class GsdAttrNavBrow
{
public: public:
GsdAttrNavBrow(BrowCtx* brow_ctx, void* xn) : ctx(brow_ctx), attrnav(xn){} GsdAttrNavBrow(BrowCtx* brow_ctx, void* xn) : ctx(brow_ctx), attrnav(xn) {}
~GsdAttrNavBrow(); ~GsdAttrNavBrow();
BrowCtx* ctx; BrowCtx* ctx;
...@@ -98,7 +99,8 @@ class CoWow; ...@@ -98,7 +99,8 @@ class CoWow;
class CoWowTimer; class CoWowTimer;
//! The navigation area of the attribute editor. //! The navigation area of the attribute editor.
class GsdAttrNav { class GsdAttrNav
{
public: public:
void* parent_ctx; void* parent_ctx;
pb_gsd* gsd; pb_gsd* gsd;
...@@ -115,12 +117,10 @@ public: ...@@ -115,12 +117,10 @@ public:
char modelname[80]; char modelname[80];
GsdAttrNav(void* xn_parent_ctx, const char* xn_name, pb_gsd* xn_gsd, GsdAttrNav(void* xn_parent_ctx, const char* xn_name, pb_gsd* xn_gsd,
int xn_edit_mode, pwr_tStatus* status); int xn_edit_mode, pwr_tStatus* status);
virtual ~GsdAttrNav(); virtual ~GsdAttrNav();
virtual void set_inputfocus() virtual void set_inputfocus() {}
{
}
void start_trace(pwr_tObjid Objid, char* object_str); void start_trace(pwr_tObjid Objid, char* object_str);
int set_attr_value(const char* value_str); int set_attr_value(const char* value_str);
...@@ -135,22 +135,24 @@ public: ...@@ -135,22 +135,24 @@ public:
void unzoom(); void unzoom();
void get_zoom(double* zoom_factor); void get_zoom(double* zoom_factor);
int search_class(const char* filename, const char* model, const char* module, int search_class(const char* filename, const char* model, const char* module,
char* mclass); char* mclass);
static void trace_scan(void* data); static void trace_scan(void* data);
static int trace_scan_bc(brow_tObject object, void* p); static int trace_scan_bc(brow_tObject object, void* p);
static int trace_connect_bc(brow_tObject object, char* name, char* attr, static int trace_connect_bc(brow_tObject object, char* name, char* attr,
flow_eTraceType type, void** p); flow_eTraceType type, void** p);
static int trace_disconnect_bc(brow_tObject object); static int trace_disconnect_bc(brow_tObject object);
static int init_brow_cb(FlowCtx* fctx, void* client_data); static int init_brow_cb(FlowCtx* fctx, void* client_data);
static int attr_string_to_value(int type_id, const char* value_str, static int attr_string_to_value(int type_id, const char* value_str,
void* buffer_ptr, int buff_size, int attr_size); void* buffer_ptr, int buff_size,
int attr_size);
static void attrvalue_to_string(int type_id, void* value_ptr, char* str, static void attrvalue_to_string(int type_id, void* value_ptr, char* str,
int size, int* len, char* format); int size, int* len, char* format);
static int brow_cb(FlowCtx* ctx, flow_tEvent event); static int brow_cb(FlowCtx* ctx, flow_tEvent event);
}; };
class ItemPb { class ItemPb
{
public: public:
ItemPb(); ItemPb();
virtual ~ItemPb(); virtual ~ItemPb();
...@@ -165,12 +167,14 @@ public: ...@@ -165,12 +167,14 @@ public:
}; };
//! Item for a normal attribute. //! Item for a normal attribute.
class ItemPbBase : public ItemPb { class ItemPbBase : public ItemPb
{
public: public:
ItemPbBase(GsdAttrNav* attrnav, const char* item_name, const char* attr, ItemPbBase(GsdAttrNav* attrnav, const char* item_name, const char* attr,
int attr_type, int attr_size, double attr_min_limit, int attr_type, int attr_size, double attr_min_limit,
double attr_max_limit, void* attr_value_p, int attr_noedit, double attr_max_limit, void* attr_value_p, int attr_noedit,
gsd_sPrmText* attr_enumtext, brow_tNode dest, flow_eDest dest_code); gsd_sPrmText* attr_enumtext, brow_tNode dest,
flow_eDest dest_code);
virtual ~ItemPbBase(); virtual ~ItemPbBase();
void* value_p; void* value_p;
...@@ -185,12 +189,14 @@ public: ...@@ -185,12 +189,14 @@ public:
int subgraph; int subgraph;
}; };
class ItemPbEnum : public ItemPbBase { class ItemPbEnum : public ItemPbBase
{
public: public:
ItemPbEnum(GsdAttrNav* attrnav, const char* item_name, const char* attr, ItemPbEnum(GsdAttrNav* attrnav, const char* item_name, const char* attr,
int attr_type, int attr_size, double attr_min_limit, int attr_type, int attr_size, double attr_min_limit,
double attr_max_limit, void* attr_value_p, int attr_noedit, double attr_max_limit, void* attr_value_p, int attr_noedit,
gsd_sPrmText* attr_enumtext, brow_tNode dest, flow_eDest dest_code); gsd_sPrmText* attr_enumtext, brow_tNode dest,
flow_eDest dest_code);
virtual ~ItemPbEnum(); virtual ~ItemPbEnum();
int old_value; int old_value;
...@@ -199,11 +205,12 @@ public: ...@@ -199,11 +205,12 @@ public:
}; };
//! Item for an enum attribute. //! Item for an enum attribute.
class ItemPbEnumValue : public ItemPb { class ItemPbEnumValue : public ItemPb
{
public: public:
ItemPbEnumValue(GsdAttrNav* attrnav, const char* item_name, int item_num, ItemPbEnumValue(GsdAttrNav* attrnav, const char* item_name, int item_num,
int item_type_id, void* attr_value_p, brow_tNode dest, int item_type_id, void* attr_value_p, brow_tNode dest,
flow_eDest dest_code); flow_eDest dest_code);
virtual ~ItemPbEnumValue(); virtual ~ItemPbEnumValue();
int num; int num;
...@@ -214,13 +221,13 @@ public: ...@@ -214,13 +221,13 @@ public:
}; };
//! Item for a module. //! Item for a module.
class ItemPbModule : public ItemPb { class ItemPbModule : public ItemPb
{
public: public:
ItemPbModule(GsdAttrNav* attrnav, const char* item_name, ItemPbModule(GsdAttrNav* attrnav, const char* item_name,
gsd_sModuleConf* item_mconf, brow_tNode dest, flow_eDest dest_code); gsd_sModuleConf* item_mconf, brow_tNode dest,
virtual ~ItemPbModule() flow_eDest dest_code);
{ virtual ~ItemPbModule() {}
}
gsd_sModuleConf* mconf; gsd_sModuleConf* mconf;
char old_value[80]; char old_value[80];
...@@ -231,13 +238,13 @@ public: ...@@ -231,13 +238,13 @@ public:
}; };
//! Item for module type selection. //! Item for module type selection.
class ItemPbModuleType : public ItemPb { class ItemPbModuleType : public ItemPb
{
public: public:
ItemPbModuleType(GsdAttrNav* attrnav, const char* item_name, ItemPbModuleType(GsdAttrNav* attrnav, const char* item_name,
gsd_sModuleConf* item_mconf, brow_tNode dest, flow_eDest dest_code); gsd_sModuleConf* item_mconf, brow_tNode dest,
virtual ~ItemPbModuleType() flow_eDest dest_code);
{ virtual ~ItemPbModuleType() {}
}
gsd_sModuleConf* mconf; gsd_sModuleConf* mconf;
int old_value; int old_value;
...@@ -247,13 +254,13 @@ public: ...@@ -247,13 +254,13 @@ public:
}; };
//! Item for module type selection. //! Item for module type selection.
class ItemPbModuleData : public ItemPb { class ItemPbModuleData : public ItemPb
{
public: public:
ItemPbModuleData(GsdAttrNav* attrnav, const char* item_name, ItemPbModuleData(GsdAttrNav* attrnav, const char* item_name,
gsd_sModuleConf* item_mconf, brow_tNode dest, flow_eDest dest_code); gsd_sModuleConf* item_mconf, brow_tNode dest,
virtual ~ItemPbModuleData() flow_eDest dest_code);
{ virtual ~ItemPbModuleData() {}
}
gsd_sModuleConf* mconf; gsd_sModuleConf* mconf;
...@@ -262,13 +269,13 @@ public: ...@@ -262,13 +269,13 @@ public:
}; };
//! Item for module class selection. //! Item for module class selection.
class ItemPbModuleClass : public ItemPb { class ItemPbModuleClass : public ItemPb
{
public: public:
ItemPbModuleClass(GsdAttrNav* attrnav, const char* item_name, ItemPbModuleClass(GsdAttrNav* attrnav, const char* item_name,
gsd_sModuleConf* item_mconf, brow_tNode dest, flow_eDest dest_code); gsd_sModuleConf* item_mconf, brow_tNode dest,
virtual ~ItemPbModuleClass() flow_eDest dest_code);
{ virtual ~ItemPbModuleClass() {}
}
gsd_sModuleConf* mconf; gsd_sModuleConf* mconf;
int old_value; int old_value;
...@@ -278,38 +285,36 @@ public: ...@@ -278,38 +285,36 @@ public:
}; };
//! Item for slave prmdata. //! Item for slave prmdata.
class ItemPbPrmData : public ItemPb { class ItemPbPrmData : public ItemPb
{
public: public:
ItemPbPrmData(GsdAttrNav* attrnav, const char* item_name, brow_tNode dest, ItemPbPrmData(GsdAttrNav* attrnav, const char* item_name, brow_tNode dest,
flow_eDest dest_code); flow_eDest dest_code);
virtual ~ItemPbPrmData() virtual ~ItemPbPrmData() {}
{
}
virtual int open_children(GsdAttrNav* attrnav, double x, double y); virtual int open_children(GsdAttrNav* attrnav, double x, double y);
}; };
//! Item for slave prmdata. //! Item for slave prmdata.
class ItemPbMoreData : public ItemPb { class ItemPbMoreData : public ItemPb
{
public: public:
ItemPbMoreData(GsdAttrNav* attrnav, const char* item_name, brow_tNode dest, ItemPbMoreData(GsdAttrNav* attrnav, const char* item_name, brow_tNode dest,
flow_eDest dest_code); flow_eDest dest_code);
virtual ~ItemPbMoreData() virtual ~ItemPbMoreData() {}
{
}
virtual int open_children(GsdAttrNav* attrnav, double x, double y); virtual int open_children(GsdAttrNav* attrnav, double x, double y);
}; };
//! Item for slave byte order. //! Item for slave byte order.
class ItemPbEnumByteOrder : public ItemPbBase { class ItemPbEnumByteOrder : public ItemPbBase
{
public: public:
ItemPbEnumByteOrder(GsdAttrNav* attrnav, const char* item_name, ItemPbEnumByteOrder(GsdAttrNav* attrnav, const char* item_name,
const char* attr, int attr_type, int attr_size, double attr_min_limit, const char* attr, int attr_type, int attr_size,
double attr_max_limit, void* attr_value_p, int attr_noedit, double attr_min_limit, double attr_max_limit,
brow_tNode dest, flow_eDest dest_code); void* attr_value_p, int attr_noedit, brow_tNode dest,
virtual ~ItemPbEnumByteOrder() flow_eDest dest_code);
{ virtual ~ItemPbEnumByteOrder() {}
}
int old_value; int old_value;
......
This diff is collapsed.
This diff is collapsed.
...@@ -54,8 +54,8 @@ ...@@ -54,8 +54,8 @@
// Static member variables // Static member variables
char GsdmlAttr::value_recall[30][160]; char GsdmlAttr::value_recall[30][160];
void GsdmlAttr::gsdmlattr_message( void GsdmlAttr::gsdmlattr_message(void* attr, char severity,
void* attr, char severity, const char* message) const char* message)
{ {
((GsdmlAttr*)attr)->message(severity, message); ((GsdmlAttr*)attr)->message(severity, message);
} }
...@@ -71,14 +71,17 @@ void GsdmlAttr::gsdmlattr_change_value_cb(void* attr_ctx) ...@@ -71,14 +71,17 @@ void GsdmlAttr::gsdmlattr_change_value_cb(void* attr_ctx)
// //
void GsdmlAttr::activate_exit() void GsdmlAttr::activate_exit()
{ {
if (close_cb) { if (close_cb)
if (edit_mode && attrnav->is_modified()) { {
if (edit_mode && attrnav->is_modified())
{
wow->DisplayQuestion((void*)this, "Apply", "Do you want to apply changes", wow->DisplayQuestion((void*)this, "Apply", "Do you want to apply changes",
cmd_close_apply_cb, cmd_close_no_cb, 0); cmd_close_apply_cb, cmd_close_no_cb, 0);
}
} else else
(close_cb)(parent_ctx); (close_cb)(parent_ctx);
} else }
else
delete this; delete this;
} }
...@@ -92,7 +95,8 @@ void GsdmlAttr::activate_help() ...@@ -92,7 +95,8 @@ void GsdmlAttr::activate_help()
int sts; int sts;
if (help_cb) if (help_cb)
sts = (help_cb)(parent_ctx, sts = (help_cb)(
parent_ctx,
"pn_device_editor /helpfile=\"$pwr_exe/profibus_xtthelp.dat\""); "pn_device_editor /helpfile=\"$pwr_exe/profibus_xtthelp.dat\"");
} }
...@@ -102,12 +106,14 @@ void GsdmlAttr::activate_copy() ...@@ -102,12 +106,14 @@ void GsdmlAttr::activate_copy()
int sts; int sts;
sts = attrnav->get_select((ItemPn**)&item); sts = attrnav->get_select((ItemPn**)&item);
if (EVEN(sts)) { if (EVEN(sts))
{
message('E', "Select a module"); message('E', "Select a module");
return; return;
} }
if (item->type != attrnav_eItemType_PnSlot) { if (item->type != attrnav_eItemType_PnSlot)
{
message('E', "Only slots can be copied"); message('E', "Only slots can be copied");
return; return;
} }
...@@ -123,12 +129,14 @@ void GsdmlAttr::activate_cut() ...@@ -123,12 +129,14 @@ void GsdmlAttr::activate_cut()
int sts; int sts;
sts = attrnav->get_select((ItemPn**)&item); sts = attrnav->get_select((ItemPn**)&item);
if (EVEN(sts)) { if (EVEN(sts))
{
message('E', "Select a slot"); message('E', "Select a slot");
return; return;
} }
if (item->type != attrnav_eItemType_PnSlot) { if (item->type != attrnav_eItemType_PnSlot)
{
message('E', "Only slots can be cut"); message('E', "Only slots can be cut");
return; return;
} }
...@@ -143,12 +151,14 @@ void GsdmlAttr::activate_paste() ...@@ -143,12 +151,14 @@ void GsdmlAttr::activate_paste()
int sts; int sts;
sts = attrnav->get_select((ItemPn**)&item); sts = attrnav->get_select((ItemPn**)&item);
if (EVEN(sts)) { if (EVEN(sts))
{
message('E', "Select a slot"); message('E', "Select a slot");
return; return;
} }
if (item->type != attrnav_eItemType_PnSlot) { if (item->type != attrnav_eItemType_PnSlot)
{
message('E', "Select a slot"); message('E', "Select a slot");
return; return;
} }
...@@ -157,10 +167,7 @@ void GsdmlAttr::activate_paste() ...@@ -157,10 +167,7 @@ void GsdmlAttr::activate_paste()
attrnav->redraw(); attrnav->redraw();
} }
void GsdmlAttr::activate_viewio(int set) void GsdmlAttr::activate_viewio(int set) { attrnav->set_viewio(set); }
{
attrnav->set_viewio(set);
}
void GsdmlAttr::activate_zoom_in() void GsdmlAttr::activate_zoom_in()
{ {
...@@ -184,20 +191,11 @@ void GsdmlAttr::activate_zoom_out() ...@@ -184,20 +191,11 @@ void GsdmlAttr::activate_zoom_out()
attrnav->zoom(1.0 / 1.18); attrnav->zoom(1.0 / 1.18);
} }
void GsdmlAttr::activate_zoom_reset() void GsdmlAttr::activate_zoom_reset() { attrnav->unzoom(); }
{
attrnav->unzoom();
}
void GsdmlAttr::activate_collapse() void GsdmlAttr::activate_collapse() { attrnav->collapse(); }
{
attrnav->collapse();
}
void GsdmlAttr::activate_expand_all() void GsdmlAttr::activate_expand_all() { attrnav->expand_all(); }
{
attrnav->expand_all();
}
void GsdmlAttr::activate_print() void GsdmlAttr::activate_print()
{ {
...@@ -218,13 +216,15 @@ void GsdmlAttr::activate_cmd_ok() ...@@ -218,13 +216,15 @@ void GsdmlAttr::activate_cmd_ok()
attrnav->save(data_filename); attrnav->save(data_filename);
if (save_cb) { if (save_cb)
{
sts = (save_cb)(parent_ctx); sts = (save_cb)(parent_ctx);
if (EVEN(sts)) if (EVEN(sts))
message('E', "Error saving profibus data"); message('E', "Error saving profibus data");
else if (close_cb) else if (close_cb)
(close_cb)(parent_ctx); (close_cb)(parent_ctx);
} else if (close_cb) }
else if (close_cb)
(close_cb)(parent_ctx); (close_cb)(parent_ctx);
} }
...@@ -234,7 +234,8 @@ void GsdmlAttr::activate_cmd_apply() ...@@ -234,7 +234,8 @@ void GsdmlAttr::activate_cmd_apply()
attrnav->save(data_filename); attrnav->save(data_filename);
if (save_cb) { if (save_cb)
{
sts = (save_cb)(parent_ctx); sts = (save_cb)(parent_ctx);
if (EVEN(sts)) if (EVEN(sts))
message('E', "Error saving profibus data"); message('E', "Error saving profibus data");
...@@ -250,7 +251,8 @@ void GsdmlAttr::cmd_close_apply_cb(void* ctx, void* data) ...@@ -250,7 +251,8 @@ void GsdmlAttr::cmd_close_apply_cb(void* ctx, void* data)
attr->attrnav->save(attr->data_filename); attr->attrnav->save(attr->data_filename);
if (attr->save_cb) { if (attr->save_cb)
{
sts = (attr->save_cb)(attr->parent_ctx); sts = (attr->save_cb)(attr->parent_ctx);
if (EVEN(sts)) if (EVEN(sts))
attr->message('E', "Error saving profibus data"); attr->message('E', "Error saving profibus data");
...@@ -268,22 +270,22 @@ void GsdmlAttr::cmd_close_no_cb(void* ctx, void* data) ...@@ -268,22 +270,22 @@ void GsdmlAttr::cmd_close_no_cb(void* ctx, void* data)
void GsdmlAttr::activate_cmd_ca() void GsdmlAttr::activate_cmd_ca()
{ {
if (close_cb) { if (close_cb)
if (edit_mode && attrnav->is_modified()) { {
if (edit_mode && attrnav->is_modified())
{
wow->DisplayQuestion((void*)this, "Apply", "Do you want to apply changes", wow->DisplayQuestion((void*)this, "Apply", "Do you want to apply changes",
cmd_close_apply_cb, cmd_close_no_cb, 0); cmd_close_apply_cb, cmd_close_no_cb, 0);
}
} else else
(close_cb)(parent_ctx); (close_cb)(parent_ctx);
} }
} }
GsdmlAttr::~GsdmlAttr() GsdmlAttr::~GsdmlAttr() {}
{
}
GsdmlAttr::GsdmlAttr(void* a_parent_ctx, void* a_object, pn_gsdml* a_gsdml, GsdmlAttr::GsdmlAttr(void* a_parent_ctx, void* a_object, pn_gsdml* a_gsdml,
int a_edit_mode, const char* a_data_filename) int a_edit_mode, const char* a_data_filename)
: parent_ctx(a_parent_ctx), gsdml(a_gsdml), edit_mode(a_edit_mode), : parent_ctx(a_parent_ctx), gsdml(a_gsdml), edit_mode(a_edit_mode),
input_open(0), object(a_object), close_cb(0), save_cb(0), help_cb(0), input_open(0), object(a_object), close_cb(0), save_cb(0), help_cb(0),
client_data(0), recall_idx(-1), value_current_recall(0) client_data(0), recall_idx(-1), value_current_recall(0)
......
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
#include "cow_pn_gsdml.h" #include "cow_pn_gsdml.h"
#include "rt_pn_gsdml_data.h" #include "rt_pn_gsdml_data.h"
typedef struct { typedef struct
{
void* value; void* value;
char name[80]; char name[80];
int type; int type;
...@@ -63,7 +64,8 @@ typedef enum { ...@@ -63,7 +64,8 @@ typedef enum {
class GsdmlAttrNav; class GsdmlAttrNav;
class CoWow; class CoWow;
class GsdmlAttr { class GsdmlAttr
{
public: public:
void* parent_ctx; void* parent_ctx;
char name[80]; char name[80];
...@@ -83,21 +85,13 @@ public: ...@@ -83,21 +85,13 @@ public:
CoWow* wow; CoWow* wow;
GsdmlAttr(void* a_parent_ctx, void* a_object, pn_gsdml* a_gsdml, GsdmlAttr(void* a_parent_ctx, void* a_object, pn_gsdml* a_gsdml,
int a_edit_mode, const char* a_data_filename); int a_edit_mode, const char* a_data_filename);
virtual ~GsdmlAttr(); virtual ~GsdmlAttr();
virtual void message(char severity, const char* message) virtual void message(char severity, const char* message) {}
{ virtual void attr_help_text(const char* help_text) {}
} virtual void set_prompt(const char* prompt) {}
virtual void attr_help_text(const char* help_text) virtual void change_value() {}
{
}
virtual void set_prompt(const char* prompt)
{
}
virtual void change_value()
{
}
void activate_ordermoduletype(attr_eOrderModuleType type); void activate_ordermoduletype(attr_eOrderModuleType type);
void activate_exit(); void activate_exit();
......
This diff is collapsed.
This diff is collapsed.
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
printk(fmt, function, lineno, ##args) printk(fmt, function, lineno, ##args)
#define DBG_PRN(fmt, args...) \ #define DBG_PRN(fmt, args...) \
CIF_PRN((__FUNCTION__), (__LINE__), KERN_INFO __FILE__ "::%s(L%.4d): " fmt, \ CIF_PRN((__FUNCTION__), (__LINE__), KERN_INFO __FILE__ "::%s(L%.4d): " fmt, \
##args) ##args)
#else #else
#define DBG_PRN(fmt, args...) /* not debugging: nothing */ #define DBG_PRN(fmt, args...) /* not debugging: nothing */
#endif #endif
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
/* rt_io_pn_locals.h -- Profinet io handling locals. */ /* rt_io_pn_locals.h -- Profinet io handling locals. */
typedef struct _io_sPnRackLocal { typedef struct _io_sPnRackLocal
{
unsigned short bytes_of_input; unsigned short bytes_of_input;
unsigned short bytes_of_output; unsigned short bytes_of_output;
unsigned char* inputs; unsigned char* inputs;
...@@ -49,7 +50,8 @@ typedef struct _io_sPnRackLocal { ...@@ -49,7 +50,8 @@ typedef struct _io_sPnRackLocal {
unsigned int start_cnt; unsigned int start_cnt;
} io_sPnRackLocal; } io_sPnRackLocal;
typedef struct _io_sPnCardLocal { typedef struct _io_sPnCardLocal
{
unsigned int input_area_size; unsigned int input_area_size;
unsigned int output_area_size; unsigned int output_area_size;
unsigned char* input_area; unsigned char* input_area;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -52,4 +52,4 @@ using namespace std; ...@@ -52,4 +52,4 @@ using namespace std;
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindMethods(PnDevice) = { pwr_NullMethod }; pwr_dExport pwr_BindMethods(PnDevice) = {pwr_NullMethod};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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