Commit df3362a2 authored by Marcus Nordenberg's avatar Marcus Nordenberg

beautify/format only

parent 26660d44
......@@ -57,7 +57,8 @@ int main(int argc, char* argv[])
pwr_tStatus sts;
if (argc < 2 || streq(argv[1], "-h")) {
if (argc < 2 || streq(argv[1], "-h"))
{
printf("\nUsage: pn_get_deviceid \"file-pattern\" > "
"profinet_deviceid.dat\n\n");
exit(0);
......@@ -66,7 +67,8 @@ int main(int argc, char* argv[])
dcli_translate_filename(file_spec, argv[1]);
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);
parse_file(found_file);
......@@ -89,7 +91,8 @@ void parse_file(char* filename)
dcli_translate_filename(fname, filename);
fp.open(fname);
if (!fp) {
if (!fp)
{
printf("# Unable to open file\n");
exit(0);
}
......@@ -102,19 +105,26 @@ void parse_file(char* filename)
int vendorid_found = 0;
int infotextid_found = 0;
int infotext_found = 0;
while (fp.getline(line, sizeof(line))) {
while (fp.getline(line, sizeof(line)))
{
char* s;
if (!in_deviceid) {
if (!in_deviceid)
{
if ((s = strstr(line, "<DeviceIdentity")))
in_deviceid = 1;
}
if (in_deviceid) {
if (!deviceid_found) {
if ((s = strstr(line, "DeviceID"))) {
for (s += 9; *s; s++) {
if (*s == '\"') {
if (in_deviceid)
{
if (!deviceid_found)
{
if ((s = strstr(line, "DeviceID")))
{
for (s += 9; *s; s++)
{
if (*s == '\"')
{
sscanf(s + 3, "%x", &deviceid);
deviceid_found = 1;
break;
......@@ -122,10 +132,14 @@ void parse_file(char* filename)
}
}
}
if (!vendorid_found) {
if ((s = strstr(line, "VendorID"))) {
for (s += 9; *s; s++) {
if (*s == '\"') {
if (!vendorid_found)
{
if ((s = strstr(line, "VendorID")))
{
for (s += 9; *s; s++)
{
if (*s == '\"')
{
sscanf(s + 3, "%x", &vendorid);
vendorid_found = 1;
break;
......@@ -133,10 +147,14 @@ void parse_file(char* filename)
}
}
}
if (!infotextid_found) {
if ((s = strstr(line, "<InfoText"))) {
for (s += 16; *s; s++) {
if (*s == '\"') {
if (!infotextid_found)
{
if ((s = strstr(line, "<InfoText")))
{
for (s += 16; *s; s++)
{
if (*s == '\"')
{
strncpy(infotextid, s + 1, sizeof(infotextid));
if ((s = strchr(infotextid, '\"')))
*s = 0;
......@@ -146,7 +164,8 @@ void parse_file(char* filename)
}
}
}
if (strstr(line, "</DeviceIdentity>")) {
if (strstr(line, "</DeviceIdentity>"))
{
in_deviceid = 0;
printf("%u %u\n", vendorid, deviceid);
......@@ -161,16 +180,22 @@ void parse_file(char* filename)
}
}
if (!in_devicefunction) {
if (!in_devicefunction)
{
if ((s = strstr(line, "<DeviceFunction")))
in_devicefunction = 1;
}
if (in_devicefunction) {
if (!family_found) {
if ((s = strstr(line, "ProductFamily"))) {
for (s += 14; *s; s++) {
if (*s == '\"') {
if (in_devicefunction)
{
if (!family_found)
{
if ((s = strstr(line, "ProductFamily")))
{
for (s += 14; *s; s++)
{
if (*s == '\"')
{
strncpy(family, s + 1, sizeof(family));
if ((s = strchr(family, '\"')))
*s = 0;
......@@ -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))
in_text = 1;
if (in_text) {
if ((s = strstr(line, "Value"))) {
for (s += 6; *s; s++) {
if (*s == '\"') {
if (in_text)
{
if ((s = strstr(line, "Value")))
{
for (s += 6; *s; s++)
{
if (*s == '\"')
{
strncpy(infotext, s + 1, sizeof(infotext));
if ((s = strchr(infotext, '\"')))
*s = 0;
......
......@@ -43,10 +43,11 @@
#include "../src/pn_viewer.h"
class PnViewerGtk : public PnViewer {
class PnViewerGtk : public PnViewer
{
public:
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();
GtkWidget* parent_wid;
......@@ -66,8 +67,8 @@ public:
void set_prompt(const char* prompt);
void open_change_value();
static gboolean action_inputfocus(
GtkWidget* w, GdkEvent* event, gpointer data);
static gboolean action_inputfocus(GtkWidget* w, GdkEvent* event,
gpointer data);
static void valchanged_cmd_input(GtkWidget* w, gpointer data);
static void activate_exit(GtkWidget* w, gpointer data);
static void activate_update(GtkWidget* w, gpointer data);
......
......@@ -50,11 +50,11 @@ extern "C" {
#include "pn_viewernav_gtk.h"
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)
{
form_widget = scrolledbrowwidgetgtk_new(
PnViewerNav::init_brow_cb, this, &brow_widget);
form_widget =
scrolledbrowwidgetgtk_new(PnViewerNav::init_brow_cb, this, &brow_widget);
gtk_widget_show_all(brow_widget);
......@@ -71,9 +71,6 @@ PnViewerNavGtk::~PnViewerNavGtk()
gtk_widget_destroy(form_widget);
}
void PnViewerNavGtk::set_input_focus()
{
gtk_widget_grab_focus(brow_widget);
}
void PnViewerNavGtk::set_input_focus() { gtk_widget_grab_focus(brow_widget); }
#endif
......@@ -41,10 +41,11 @@
#include "../src/pn_viewernav.h"
class PnViewerNavGtk : public PnViewerNav {
class PnViewerNavGtk : public PnViewerNav
{
public:
PnViewerNavGtk(void* v_parent_ctx, GtkWidget* v_parent_wid,
viewer_eType v_type, GtkWidget** w);
viewer_eType v_type, GtkWidget** w);
~PnViewerNavGtk();
GtkWidget* parent_wid;
......
......@@ -49,7 +49,8 @@
#include "pn_viewer_gtk.h"
typedef struct {
typedef struct
{
GtkWidget* toplevel;
PnViewer* viewer;
} tViewer;
......@@ -80,35 +81,46 @@ int main(int argc, char* argv[])
setlocale(LC_TIME, "en_US");
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
CoXHelpGtk* xhelp
= new CoXHelpGtk(ctx->toplevel, 0, xhelp_eUtility_Wtt, (int*)&sts);
CoXHelpGtk* xhelp =
new CoXHelpGtk(ctx->toplevel, 0, xhelp_eUtility_Wtt, (int*)&sts);
CoXHelpGtk::set_default(xhelp);
for (i = 1; i < argc; i++) {
if (streq(argv[i], "-h")) {
for (i = 1; i < argc; i++)
{
if (streq(argv[i], "-h"))
{
usage();
exit(0);
} else if (streq(argv[i], "-l")) {
if (i + 1 >= argc) {
}
else if (streq(argv[i], "-l"))
{
if (i + 1 >= argc)
{
usage();
exit(0);
}
Lng::set(argv[i + 1]);
i++;
} else if (str_StartsWith(argv[i], "eth")) {
}
else if (str_StartsWith(argv[i], "eth"))
{
snprintf(dev_name, sizeof(dev_name), "%s", argv[i]);
}
}
// Open window
try {
ctx->viewer = new PnViewerGtk(
ctx, ctx->toplevel, "Profinet Viewer", dev_name, &sts);
try
{
ctx->viewer =
new PnViewerGtk(ctx, ctx->toplevel, "Profinet Viewer", dev_name, &sts);
ctx->viewer->close_cb = viewer_close;
} catch (co_error& e) {
}
catch (co_error& e)
{
printf("** Exception: %s\n", e.what().c_str());
exit(0);
}
......@@ -117,9 +129,12 @@ int main(int argc, char* argv[])
g_object_set(ctx->toplevel, "visible", FALSE, NULL);
try {
try
{
ctx->viewer->update_devices();
} catch (co_error& e) {
}
catch (co_error& e)
{
printf("** Exception: %s\n", e.what().c_str());
}
......@@ -130,8 +145,5 @@ int main(int argc, char* argv[])
#else
#include <stdio.h>
int main()
{
printf("Softing PNAK not built with this Proview release\n");
}
int main() { printf("Softing PNAK not built with this Proview release\n"); }
#endif
......@@ -47,10 +47,11 @@
class PnViewerQtWidget;
class PnViewerQt : public PnViewer {
class PnViewerQt : public PnViewer
{
public:
PnViewerQt(void* v_parent_ctx, QWidget* v_parent_wid, const char* v_name,
const char* v_device, pwr_tStatus* status);
const char* v_device, pwr_tStatus* status);
QWidget* nav_widget;
QWidget* navconf_widget;
......@@ -67,12 +68,15 @@ public:
PnViewerQtWidget* toplevel;
};
class PnViewerQtWidget : public QWidget {
class PnViewerQtWidget : public QWidget
{
Q_OBJECT
public:
PnViewerQtWidget(PnViewerQt* parent_ctx, QWidget* parent)
: QWidget(), viewer(parent_ctx){}
: QWidget(), viewer(parent_ctx)
{
}
protected:
void focusInEvent(QFocusEvent* event);
......
......@@ -43,13 +43,13 @@
#include "pn_viewernav_qt.h"
PnViewerNavQt::PnViewerNavQt(
void* l_parent_ctx, QWidget* l_parent_wid, viewer_eType l_type, QWidget** w)
PnViewerNavQt::PnViewerNavQt(void* l_parent_ctx, QWidget* l_parent_wid,
viewer_eType l_type, QWidget** w)
: PnViewerNav(l_parent_ctx, l_type)
{
debug_print("creating a scrolledbrowwidgetqt\n");
form_widget
= scrolledbrowwidgetqt_new(PnViewerNav::init_brow_cb, this, &brow_widget);
form_widget =
scrolledbrowwidgetqt_new(PnViewerNav::init_brow_cb, this, &brow_widget);
showNow(brow_widget);
......@@ -63,9 +63,6 @@ PnViewerNavQt::~PnViewerNavQt()
form_widget->close();
}
void PnViewerNavQt::set_input_focus()
{
brow_widget->setFocus();
}
void PnViewerNavQt::set_input_focus() { brow_widget->setFocus(); }
#endif
\ No newline at end of file
......@@ -41,10 +41,11 @@
#include "../src/pn_viewernav.h"
class PnViewerNavQt : public PnViewerNav {
class PnViewerNavQt : public PnViewerNav
{
public:
PnViewerNavQt(void* v_parent_ctx, QWidget* v_parent_wid, viewer_eType v_type,
QWidget** w);
QWidget** w);
~PnViewerNavQt();
QWidget* brow_widget;
......
......@@ -49,7 +49,8 @@
#include <QApplication>
typedef struct {
typedef struct
{
QWidget* toplevel;
PnViewer* viewer;
} tViewer;
......@@ -61,7 +62,8 @@ static void usage()
static void viewer_close(void* c)
{
debug_print("Shutting down...\n"); exit(0);
debug_print("Shutting down...\n");
exit(0);
}
int main(int argc, char* argv[])
......@@ -85,41 +87,57 @@ int main(int argc, char* argv[])
ctx->toplevel->setAttribute(Qt::WA_DeleteOnClose);
// Create help window
CoXHelpQt* xhelp
= new CoXHelpQt(ctx->toplevel, 0, xhelp_eUtility_Wtt, (int*)&sts);
CoXHelpQt* xhelp =
new CoXHelpQt(ctx->toplevel, 0, xhelp_eUtility_Wtt, (int*)&sts);
CoXHelpQt::set_default(xhelp);
for (i = 1; i < argc; i++) {
if (streq(argv[i], "-h")) {
for (i = 1; i < argc; i++)
{
if (streq(argv[i], "-h"))
{
usage();
debug_print("Shutting down...\n"); exit(0);
} else if (streq(argv[i], "-l")) {
if (i + 1 >= argc) {
debug_print("Shutting down...\n");
exit(0);
}
else if (streq(argv[i], "-l"))
{
if (i + 1 >= argc)
{
usage();
debug_print("Shutting down...\n"); exit(0);
debug_print("Shutting down...\n");
exit(0);
}
Lng::set(argv[i + 1]);
i++;
} else if (str_StartsWith(argv[i], "eth")) {
}
else if (str_StartsWith(argv[i], "eth"))
{
snprintf(dev_name, sizeof(dev_name), "%s", argv[i]);
}
}
// Open window
try {
ctx->viewer
= new PnViewerQt(ctx, ctx->toplevel, "Profinet Viewer", dev_name, &sts);
try
{
ctx->viewer =
new PnViewerQt(ctx, ctx->toplevel, "Profinet Viewer", dev_name, &sts);
ctx->viewer->close_cb = viewer_close;
} catch (co_error& e) {
}
catch (co_error& e)
{
printf("** Exception: %s\n", e.what().c_str());
debug_print("Shutting down...\n"); exit(0);
debug_print("Shutting down...\n");
exit(0);
}
ctx->toplevel->show();
try {
try
{
ctx->viewer->update_devices();
} catch (co_error& e) {
}
catch (co_error& e)
{
printf("** Exception: %s\n", e.what().c_str());
}
......@@ -129,9 +147,6 @@ int main(int argc, char* argv[])
#else
#include <stdio.h>
int main()
{
printf("Softing PNAK not built with this Proview release\n");
}
int main() { printf("Softing PNAK not built with this Proview release\n"); }
#endif
\ No newline at end of file
......@@ -55,7 +55,7 @@
static int test = 0;
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),
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,
pnet = new PnViewerPNAC(status, device);
}
PnViewer::~PnViewer()
{
delete pnet;
}
PnViewer::~PnViewer() { delete pnet; }
void PnViewer::update_devices()
{
int sts;
if (!test) {
if (!test)
{
dev_vect.clear();
pnet->fetch_devices(dev_vect);
......@@ -86,7 +84,9 @@ void PnViewer::update_devices()
viewernav->set(dev_vect);
viewernavconf->set(conf_vect);
} else {
}
else
{
dev_vect.clear();
sts = fetch_config(dev_vect);
if (EVEN(sts))
......@@ -104,7 +104,8 @@ void PnViewer::update_devices()
void PnViewer::filter(viewer_eFilterType filtertype)
{
switch (filtertype) {
switch (filtertype)
{
case viewer_eFilterType_No:
for (unsigned int i = 0; i < dev_vect.size(); i++)
dev_vect[i].hide = false;
......@@ -119,15 +120,18 @@ void PnViewer::filter(viewer_eFilterType filtertype)
for (unsigned int i = 0; i < conf_vect.size(); i++)
conf_vect[i].hide = false;
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)
&& dev_vect[i].vendorid == conf_vect[j].vendorid
&& dev_vect[i].deviceid == conf_vect[j].deviceid
&& dev_vect[i].ipaddress[0] == conf_vect[j].ipaddress[0]
&& 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]) {
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) &&
dev_vect[i].vendorid == conf_vect[j].vendorid &&
dev_vect[i].deviceid == conf_vect[j].deviceid &&
dev_vect[i].ipaddress[0] == conf_vect[j].ipaddress[0] &&
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;
conf_vect[j].hide = true;
break;
......@@ -160,17 +164,20 @@ int PnViewer::fetch_config(std::vector<PnDevice>& vect)
if (!fp)
return 0;
while (dcli_read_line(line, sizeof(line), fp)) {
while (dcli_read_line(line, sizeof(line), fp))
{
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)
continue;
strncpy(pndevice.devname, elemv[1], sizeof(pndevice.devname));
sts = sscanf(elemv[2], "%hhu.%hhu.%hhu.%hhu", &pndevice.ipaddress[3],
&pndevice.ipaddress[2], &pndevice.ipaddress[1], &pndevice.ipaddress[0]);
if (sts != 4) {
&pndevice.ipaddress[2], &pndevice.ipaddress[1],
&pndevice.ipaddress[0]);
if (sts != 4)
{
printf("Not a valid IP address: %s\n", elemv[2]);
pndevice.ipaddress[0] = 0;
pndevice.ipaddress[1] = 0;
......@@ -179,10 +186,11 @@ int PnViewer::fetch_config(std::vector<PnDevice>& vect)
}
sts = sscanf(elemv[3], "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
&pndevice.macaddress[5], &pndevice.macaddress[4],
&pndevice.macaddress[3], &pndevice.macaddress[2],
&pndevice.macaddress[1], &pndevice.macaddress[0]);
if (sts != 6) {
&pndevice.macaddress[5], &pndevice.macaddress[4],
&pndevice.macaddress[3], &pndevice.macaddress[2],
&pndevice.macaddress[1], &pndevice.macaddress[0]);
if (sts != 6)
{
printf("Not a valid MAC address: %s\n", elemv[3]);
pndevice.macaddress[0] = 0;
pndevice.macaddress[1] = 0;
......@@ -205,8 +213,8 @@ int PnViewer::fetch_config(std::vector<PnDevice>& vect)
return 1;
}
void PnViewer::set_device_properties(
unsigned char* macaddress, unsigned char* ipaddress, char* devname)
void PnViewer::set_device_properties(unsigned char* macaddress,
unsigned char* ipaddress, char* devname)
{
pnet->set_device_properties(macaddress, ipaddress, devname);
}
......@@ -227,9 +235,12 @@ void PnViewer::message_cb(void* ctx, int severity, const char* msg)
void PnViewer::activate_update()
{
try {
try
{
update_devices();
} catch (co_error& e) {
}
catch (co_error& e)
{
printf("** Update exception: %s\n", e.what().c_str());
}
}
......@@ -245,28 +256,30 @@ void PnViewer::activate_setdevice()
ItemDevice* dev;
sts = viewernav->get_selected_device(&dev);
if (EVEN(sts)) {
if (EVEN(sts))
{
message('E', "Select a device");
return;
}
try {
try
{
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());
}
}
void PnViewer::activate_changevalue()
{
open_change_value();
}
void PnViewer::activate_changevalue() { open_change_value(); }
void PnViewer::activate_close()
{
if (close_cb)
close_cb(parent_ctx);
else {
else
{
delete this;
exit(0);
}
......@@ -274,8 +287,8 @@ void PnViewer::activate_close()
void PnViewer::activate_help()
{
CoXHelp::dhelp(
"profinet_viewer", 0, navh_eHelpFile_Other, "$pwr_lang/man_pb.dat", true);
CoXHelp::dhelp("profinet_viewer", 0, navh_eHelpFile_Other,
"$pwr_lang/man_pb.dat", true);
}
#endif
......@@ -45,25 +45,20 @@ class CoWow;
class CoWowFocusTimer;
class PnViewerPNAC;
class PnViewer {
class PnViewer
{
public:
PnViewer(void* v_parent_ctx, const char* v_name, const char* v_device,
pwr_tStatus* status);
pwr_tStatus* status);
virtual ~PnViewer();
virtual void message(char severity, const char* msg)
{
}
virtual void set_prompt(const char* prompt)
{
}
virtual void open_change_value()
{
}
virtual void message(char severity, const char* msg) {}
virtual void set_prompt(const char* prompt) {}
virtual void open_change_value() {}
void update_devices();
void set_device_properties(
unsigned char* macaddress, unsigned char* ipaddress, char* devname);
void set_device_properties(unsigned char* macaddress,
unsigned char* ipaddress, char* devname);
int fetch_config(std::vector<PnDevice>& vect);
void filter(viewer_eFilterType filtertype);
void activate_update();
......
......@@ -66,7 +66,8 @@ PnViewerPNAC::PnViewerPNAC(pwr_tStatus* sts, const char* dev_name)
pnak_init();
*sts = pnak_start_profistack(0, PNAK_SUPERVISOR_MODE);
if (*sts != PNAK_OK) {
if (*sts != PNAK_OK)
{
printf("Starting profistack returned with error code\n");
exit(0);
}
......@@ -75,19 +76,21 @@ PnViewerPNAC::PnViewerPNAC(pwr_tStatus* sts, const char* dev_name)
s = socket(AF_INET, SOCK_DGRAM, 0);
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,
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,
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],
&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],
&local->subnetmask[2], &local->subnetmask[1], &local->subnetmask[0]);
&local->subnetmask[2], &local->subnetmask[1], &local->subnetmask[0]);
strcpy(dev_data.device_name, "dumle");
dev_data.device_num = PN_DEVICE_REFERENCE_THIS_STATION;
......@@ -104,15 +107,17 @@ PnViewerPNAC::PnViewerPNAC(pwr_tStatus* sts, const char* dev_name)
/* Download config */
pack_download_req(
&local->service_req_res, &dev_data, pn_dev_data->device_ref);
pack_download_req(&local->service_req_res, &dev_data,
pn_dev_data->device_ref);
*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);
if (*sts != PNAK_OK) {
if (*sts != PNAK_OK)
{
/* Loop through devices and calculate offset for io */
}
}
......@@ -123,7 +128,8 @@ PnViewerPNAC::PnViewerPNAC(pwr_tStatus* sts, const char* dev_name)
*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);
}
......@@ -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);
if (*sts != PNAK_OK) {
if (*sts != PNAK_OK)
{
printf("Setting state failed, sts: %d\r\n", *sts);
return;
}
......@@ -154,8 +161,10 @@ void PnViewerPNAC::fetch_devices(std::vector<PnDevice>& dev_vect)
unsigned int ii;
int sts;
while (1) {
for (ii = 0; ii < local->dev_info.size(); ii++) {
while (1)
{
for (ii = 0; ii < local->dev_info.size(); ii++)
{
delete local->dev_info[ii];
}
......@@ -165,11 +174,15 @@ void PnViewerPNAC::fetch_devices(std::vector<PnDevice>& dev_vect)
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);
if (sts == PNAK_OK) {
if (local->dev_info.size() > 0) {
for (ii = 0; ii < local->dev_info.size(); ii++) {
if (sts == PNAK_OK)
{
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[1] = local->dev_info[ii]->ipaddress[1];
device.ipaddress[2] = local->dev_info[ii]->ipaddress[2];
......@@ -181,13 +194,14 @@ void PnViewerPNAC::fetch_devices(std::vector<PnDevice>& dev_vect)
device.macaddress[4] = local->dev_info[ii]->macaddress[4];
device.macaddress[5] = local->dev_info[ii]->macaddress[5];
strncpy(device.devname, local->dev_info[ii]->devname,
sizeof(device.devname));
sizeof(device.devname));
device.vendorid = local->dev_info[ii]->vendorid;
device.deviceid = local->dev_info[ii]->deviceid;
dev_vect.push_back(device);
}
break;
} else
}
else
continue;
}
}
......@@ -209,8 +223,9 @@ void PnViewerPNAC::fetch_devices(std::vector<PnDevice>& dev_vect)
// if ( ...error... ) throw co_error_str( "Somethings is wrong...");
}
void PnViewerPNAC::set_device_properties(
unsigned char* macaddress, unsigned char* ipaddress, char* devname)
void PnViewerPNAC::set_device_properties(unsigned char* macaddress,
unsigned char* ipaddress,
char* devname)
{
PnDevice device;
int sts;
......@@ -237,7 +252,8 @@ void PnViewerPNAC::set_device_properties(
pack_set_device_name_req(&local->service_req_res, &dev_info);
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);
}
......@@ -246,7 +262,8 @@ void PnViewerPNAC::set_device_properties(
pack_set_ip_settings_req(&local->service_req_res, &dev_info);
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);
}
}
......
......@@ -45,14 +45,15 @@
#include "rt_io_pnak_locals.h"
#include "rt_pn_gsdml_data.h"
class PnViewerPNAC {
class PnViewerPNAC
{
public:
PnViewerPNAC(pwr_tStatus* sts, const char* dev_name);
~PnViewerPNAC();
void fetch_devices(std::vector<PnDevice>& dev_vect);
void set_device_properties(
unsigned char* macaddress, unsigned char* ipaddress, char* devname);
void set_device_properties(unsigned char* macaddress,
unsigned char* ipaddress, char* devname);
GsdmlDeviceData dev_data;
io_sAgentLocal* local;
};
......
......@@ -45,7 +45,8 @@
#include "flow_browapi.h"
class PnDevice {
class PnDevice
{
public:
PnDevice();
unsigned char ipaddress[4];
......@@ -70,10 +71,13 @@ typedef enum {
viewitem_eItemType_DeviceAttr
} viewitem_eItemType;
class PnViewerNavBrow {
class PnViewerNavBrow
{
public:
PnViewerNavBrow(BrowCtx* brow_ctx, void* lvnav)
: ctx(brow_ctx), viewernav(lvnav){}
: ctx(brow_ctx), viewernav(lvnav)
{
}
~PnViewerNavBrow();
BrowCtx* ctx;
......@@ -91,7 +95,8 @@ public:
void brow_setup();
};
class PnViewerNav {
class PnViewerNav
{
public:
PnViewerNav(void* l_parent_ctx, viewer_eType l_type);
virtual ~PnViewerNav();
......@@ -102,9 +107,7 @@ public:
void (*change_value_cb)(void*);
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 zoom(double zoom_factor);
......@@ -115,20 +118,21 @@ public:
int get_selected_device(ItemDevice** device);
void vendorid_to_str(unsigned int vendorid, char* vendorid_str, int size);
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 brow_cb(FlowCtx* ctx, flow_tEvent event);
};
class ItemDevice {
class ItemDevice
{
public:
ItemDevice(PnViewerNav* viewernav, const char* item_name,
unsigned char* item_ipaddress, unsigned char* item_macaddress,
char* item_devname, int vendorid, int deviceid, brow_tNode dest,
flow_eDest dest_code);
unsigned char* item_ipaddress, unsigned char* item_macaddress,
char* item_devname, int vendorid, int deviceid, brow_tNode dest,
flow_eDest dest_code);
virtual ~ItemDevice();
viewitem_eItemType type;
PnViewerNav* viewernav;
brow_tNode node;
......@@ -148,11 +152,12 @@ public:
void close(PnViewerNav* viewernav);
};
class ItemDeviceAttr {
class ItemDeviceAttr
{
public:
ItemDeviceAttr(PnViewerNav* viewernav, const char* item_name,
pwr_eType item_attr_type, void* item_p, brow_tNode dest,
flow_eDest dest_code);
pwr_eType item_attr_type, void* item_p, brow_tNode dest,
flow_eDest dest_code);
virtual ~ItemDeviceAttr();
viewitem_eItemType type;
......
......@@ -44,10 +44,7 @@
#include "co_string.h"
static void usage()
{
printf("\nUsage: profinet_viewer\n");
}
static void usage() { printf("\nUsage: profinet_viewer\n"); }
int main(int argc, char* argv[])
{
......@@ -56,10 +53,14 @@ int main(int argc, char* argv[])
char wmg[80];
pwr_tFileName file;
if (argc > 1) {
for (i = 1; i < argc; i++) {
if (streq(argv[i], "-f")) {
if (i + 1 >= argc) {
if (argc > 1)
{
for (i = 1; i < argc; i++)
{
if (streq(argv[i], "-f"))
{
if (i + 1 >= argc)
{
usage();
exit(0);
}
......
......@@ -60,10 +60,13 @@ void GsdAttrGtk::message(char severity, const char* message)
void GsdAttrGtk::set_prompt(const char* prompt)
{
if (streq(prompt, "")) {
if (streq(prompt, ""))
{
g_object_set(cmd_prompt, "visible", FALSE, NULL);
g_object_set(msg_label, "visible", TRUE, NULL);
} else {
}
else
{
g_object_set(msg_label, "visible", FALSE, NULL);
g_object_set(cmd_prompt, "visible", TRUE, NULL);
}
......@@ -75,20 +78,23 @@ void GsdAttrGtk::change_value()
GtkWidget* text_w;
char* value;
if (input_open) {
if (input_open)
{
g_object_set(cmd_input, "visible", FALSE, NULL);
set_prompt("");
input_open = 0;
return;
}
if (!edit_mode) {
if (!edit_mode)
{
message('E', "Not in edit mode");
return;
}
sts = attrnav->check_attr_value(&value);
if (EVEN(sts)) {
if (EVEN(sts))
{
if (sts == PB__NOATTRSEL)
message('E', "No attribute is selected");
else
......@@ -102,16 +108,19 @@ void GsdAttrGtk::change_value()
message(' ', "");
gtk_widget_grab_focus(cmd_input);
if (value) {
if (value)
{
gint pos = 0;
gtk_editable_delete_text(GTK_EDITABLE(cmd_input), 0, -1);
gtk_editable_insert_text(
GTK_EDITABLE(cmd_input), value, strlen(value), &pos);
gtk_editable_insert_text(GTK_EDITABLE(cmd_input), value, strlen(value),
&pos);
// Select the text
gtk_editable_set_position(GTK_EDITABLE(cmd_input), -1);
gtk_editable_select_region(GTK_EDITABLE(cmd_input), 0, -1);
} else {
}
else
{
gtk_editable_delete_text(GTK_EDITABLE(cmd_input), 0, -1);
}
set_prompt("value >");
......@@ -224,7 +233,8 @@ void GsdAttrGtk::activate_cmd_input(GtkWidget* w, gpointer data)
attr->attrnav->set_inputfocus();
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);
g_object_set(w, "visible", FALSE, NULL);
attr->set_prompt("");
......@@ -233,8 +243,8 @@ void GsdAttrGtk::activate_cmd_input(GtkWidget* w, gpointer data)
g_free(text);
}
gboolean GsdAttrGtk::action_inputfocus(
GtkWidget* w, GdkEvent* event, gpointer data)
gboolean GsdAttrGtk::action_inputfocus(GtkWidget* w, GdkEvent* event,
gpointer data)
{
GsdAttrGtk* attr = (GsdAttrGtk*)data;
gboolean input_visible;
......@@ -265,41 +275,40 @@ static gint delete_event(GtkWidget* w, GdkEvent* event, gpointer data)
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,
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)
{
int sts;
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, "destroy", G_CALLBACK(destroy_event), this);
g_signal_connect(
toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);
g_signal_connect(toplevel, "focus-in-event", G_CALLBACK(action_inputfocus),
this);
GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
// Menu
// Accelerators
GtkAccelGroup* accel_g
= (GtkAccelGroup*)g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
GtkAccelGroup* accel_g =
(GtkAccelGroup*)g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);
GtkMenuBar* menu_bar = (GtkMenuBar*)g_object_new(GTK_TYPE_MENU_BAR, NULL);
// File entry
GtkWidget* file_print
= gtk_image_menu_item_new_from_stock(GTK_STOCK_PRINT, accel_g);
GtkWidget* file_print =
gtk_image_menu_item_new_from_stock(GTK_STOCK_PRINT, accel_g);
g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), this);
GtkWidget* file_close
= gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
GtkWidget* file_close =
gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);
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,
// Edit entry
menubutton_copy = gtk_image_menu_item_new_from_stock(GTK_STOCK_COPY, accel_g);
g_signal_connect(
menubutton_copy, "activate", G_CALLBACK(activate_copy), this);
g_signal_connect(menubutton_copy, "activate", G_CALLBACK(activate_copy),
this);
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);
menubutton_paste
= gtk_image_menu_item_new_from_stock(GTK_STOCK_PASTE, accel_g);
g_signal_connect(
menubutton_paste, "activate", G_CALLBACK(activate_paste), this);
menubutton_paste =
gtk_image_menu_item_new_from_stock(GTK_STOCK_PASTE, accel_g);
g_signal_connect(menubutton_paste, "activate", G_CALLBACK(activate_paste),
this);
GtkMenu* edit_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
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,
// Functions entry
menubutton_changevalue = gtk_menu_item_new_with_mnemonic("_Change Value");
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',
GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkMenu* func_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
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,
// View Entry
GtkWidget* view_zoom_in
= gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_IN, NULL);
g_signal_connect(
view_zoom_in, "activate", G_CALLBACK(activate_zoom_in), this);
GtkWidget* view_zoom_in =
gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_IN, NULL);
g_signal_connect(view_zoom_in, "activate", G_CALLBACK(activate_zoom_in),
this);
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
= gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, NULL);
g_signal_connect(
view_zoom_out, "activate", G_CALLBACK(activate_zoom_out), this);
GtkWidget* view_zoom_out =
gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, NULL);
g_signal_connect(view_zoom_out, "activate", G_CALLBACK(activate_zoom_out),
this);
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
= gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_100, NULL);
g_signal_connect(
view_zoom_reset, "activate", G_CALLBACK(activate_zoom_reset), this);
GtkWidget* view_zoom_reset =
gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_100, NULL);
g_signal_connect(view_zoom_reset, "activate", G_CALLBACK(activate_zoom_reset),
this);
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);
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,
gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));
// Help entry
GtkWidget* help_help
= gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, accel_g);
GtkWidget* help_help =
gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, accel_g);
g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);
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,
gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));
// Navigator
attrnav = new GsdAttrNavGtk(
this, vbox, "Plant", gsd, edit_mode, &brow_widget, &sts);
attrnav = new GsdAttrNavGtk(this, vbox, "Plant", gsd, edit_mode, &brow_widget,
&sts);
attrnav->message_cb = &GsdAttr::gsdattr_message;
attrnav->change_value_cb = &GsdAttr::gsdattr_change_value_cb;
......@@ -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_input, "visible", FALSE, NULL);
if (!edit_mode) {
if (!edit_mode)
{
gtk_widget_set_sensitive(cmd_ok, FALSE);
gtk_widget_set_sensitive(cmd_apply, FALSE);
gtk_widget_set_sensitive(menubutton_copy, FALSE);
......
......@@ -42,7 +42,8 @@
#include "cow_pb_gsd_attr.h"
#include "cow_wow_gtk.h"
class GsdAttrGtk : public GsdAttr {
class GsdAttrGtk : public GsdAttr
{
public:
GtkWidget* parent_wid;
GtkWidget* brow_widget;
......@@ -62,7 +63,7 @@ public:
CoWowFocusTimerGtk focustimer;
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();
void message(char severity, const char* message);
......@@ -87,8 +88,8 @@ public:
static void cmd_close_apply_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 gboolean action_inputfocus(
GtkWidget* w, GdkEvent* event, gpointer data);
static gboolean action_inputfocus(GtkWidget* w, GdkEvent* event,
gpointer data);
// static void valchanged_cmd_input( GtkWidget *w, gpointer data);
};
......
......@@ -56,8 +56,9 @@
// Create the navigator widget
//
GsdAttrNavGtk::GsdAttrNavGtk(void* xn_parent_ctx, GtkWidget* xn_parent_wid,
const char* xn_name, pb_gsd* xn_gsd, int xn_edit_mode, GtkWidget** w,
pwr_tStatus* status)
const char* xn_name, pb_gsd* xn_gsd,
int xn_edit_mode, GtkWidget** w,
pwr_tStatus* status)
: GsdAttrNav(xn_parent_ctx, xn_name, xn_gsd, xn_edit_mode, status),
parent_wid(xn_parent_wid)
{
......@@ -82,7 +83,4 @@ GsdAttrNavGtk::~GsdAttrNavGtk()
gtk_widget_destroy(form_widget);
}
void GsdAttrNavGtk::set_inputfocus()
{
gtk_widget_grab_focus(brow_widget);
}
void GsdAttrNavGtk::set_inputfocus() { gtk_widget_grab_focus(brow_widget); }
......@@ -42,11 +42,12 @@
#include "cow_pb_gsd_attrnav.h"
//! The navigation area of the attribute editor.
class GsdAttrNavGtk : public GsdAttrNav {
class GsdAttrNavGtk : public GsdAttrNav
{
public:
GsdAttrNavGtk(void* xn_parent_ctx, GtkWidget* xn_parent_wid,
const char* xn_name, pb_gsd* xn_gsd, int xn_edit_mode, GtkWidget** w,
pwr_tStatus* status);
const char* xn_name, pb_gsd* xn_gsd, int xn_edit_mode,
GtkWidget** w, pwr_tStatus* status);
~GsdAttrNavGtk();
void set_inputfocus();
......
......@@ -42,7 +42,8 @@
#include "cow_pn_gsdml_attr.h"
#include "cow_wow_gtk.h"
class GsdmlAttrGtk : public GsdmlAttr {
class GsdmlAttrGtk : public GsdmlAttr
{
public:
GtkWidget* parent_wid;
GtkWidget* brow_widget;
......@@ -65,8 +66,8 @@ public:
CoWowEntryGtk* cmd_entry;
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,
pwr_tStatus* a_sts);
pn_gsdml* a_gsdml, int a_edit_mode, const char* a_data_filename,
pwr_tStatus* a_sts);
~GsdmlAttrGtk();
void message(char severity, const char* message);
......@@ -103,8 +104,8 @@ public:
static void cmd_close_apply_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 gboolean action_inputfocus(
GtkWidget* w, GdkEvent* event, gpointer data);
static gboolean action_inputfocus(GtkWidget* w, GdkEvent* event,
gpointer data);
// static void valchanged_cmd_input( GtkWidget *w, gpointer data);
};
......
......@@ -53,8 +53,9 @@
// Create the navigator widget
//
GsdmlAttrNavGtk::GsdmlAttrNavGtk(void* xn_parent_ctx, GtkWidget* xn_parent_wid,
const char* xn_name, pn_gsdml* xn_gsdml, int xn_edit_mode, GtkWidget** w,
pwr_tStatus* status)
const char* xn_name, pn_gsdml* xn_gsdml,
int xn_edit_mode, GtkWidget** w,
pwr_tStatus* status)
: GsdmlAttrNav(xn_parent_ctx, xn_name, xn_gsdml, xn_edit_mode, status),
parent_wid(xn_parent_wid)
{
......@@ -79,10 +80,7 @@ GsdmlAttrNavGtk::~GsdmlAttrNavGtk()
gtk_widget_destroy(form_widget);
}
void GsdmlAttrNavGtk::set_inputfocus()
{
gtk_widget_grab_focus(brow_widget);
}
void GsdmlAttrNavGtk::set_inputfocus() { gtk_widget_grab_focus(brow_widget); }
void GsdmlAttrNavGtk::display_attr_help_text()
{
......@@ -97,14 +95,16 @@ void GsdmlAttrNavGtk::display_attr_help_text()
brow_GetUserData(node_list[0], (void**)&base_item);
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 base class does,
* but since they already contained references they were used instead...
*/
case attrnav_eItemType_PnParValue:
case attrnav_eItemType_PnParEnum: {
case attrnav_eItemType_PnParEnum:
{
ItemPnParEnum* item = (ItemPnParEnum*)base_item;
gsdml_ValueItem* vi = 0;
......@@ -119,7 +119,8 @@ void GsdmlAttrNavGtk::display_attr_help_text()
break;
}
default: {
default:
{
// Do we have an associated info text string to show the user some more
// info?
if (base_item->info_text)
......
......@@ -42,11 +42,12 @@
#include "cow_pn_gsdml_attrnav.h"
//! The navigation area of the attribute editor.
class GsdmlAttrNavGtk : public GsdmlAttrNav {
class GsdmlAttrNavGtk : public GsdmlAttrNav
{
public:
GsdmlAttrNavGtk(void* xn_parent_ctx, GtkWidget* xn_parent_wid,
const char* xn_name, pn_gsdml* xn_gsdml, int xn_edit_mode, GtkWidget** w,
pwr_tStatus* status);
const char* xn_name, pn_gsdml* xn_gsdml, int xn_edit_mode,
GtkWidget** w, pwr_tStatus* status);
~GsdmlAttrNavGtk();
void set_inputfocus();
void display_attr_help_text();
......
......@@ -41,7 +41,8 @@
#include "cow_pb_gsd_attr.h"
class GsdAttrMotif : public GsdAttr {
class GsdAttrMotif : public GsdAttr
{
public:
Widget parent_wid;
Widget brow_widget;
......@@ -59,7 +60,7 @@ public:
Widget menubutton_changevalue;
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();
void message(char severity, const char* message);
......@@ -68,40 +69,40 @@ public:
static void gsdattr_message(void* attr, char severity, char* message);
static void gsdattr_change_value_cb(void* attr_ctx);
static void activate_change_value(
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void activate_change_value(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_copy(Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void activate_cut(Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void activate_paste(
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void activate_zoom_in(
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void activate_zoom_out(
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void activate_zoom_reset(
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void activate_print(
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void activate_cmd_ok(
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void activate_paste(Widget w, GsdAttr* attr,
XmAnyCallbackStruct* data);
static void activate_zoom_in(Widget w, GsdAttr* attr,
XmAnyCallbackStruct* data);
static void activate_zoom_out(Widget w, GsdAttr* attr,
XmAnyCallbackStruct* data);
static void activate_zoom_reset(Widget w, GsdAttr* attr,
XmAnyCallbackStruct* data);
static void activate_print(Widget w, GsdAttr* attr,
XmAnyCallbackStruct* data);
static void activate_cmd_ok(Widget w, GsdAttr* attr,
XmAnyCallbackStruct* data);
static void cmd_close_apply_cb(void* ctx, void* data);
static void cmd_close_no_cb(void* ctx, void* data);
static void activate_cmd_ca(
Widget w, GsdAttr* attr, XmAnyCallbackStruct* dataxo);
static void create_menubutton(
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void create_msg_label(
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void create_cmd_prompt(
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void activate_cmd_ca(Widget w, GsdAttr* attr,
XmAnyCallbackStruct* dataxo);
static void create_menubutton(Widget w, GsdAttr* attr,
XmAnyCallbackStruct* data);
static void create_msg_label(Widget w, GsdAttr* attr,
XmAnyCallbackStruct* data);
static void create_cmd_prompt(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_input(
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void create_attrnav_form(
Widget w, GsdAttr* attr, XmAnyCallbackStruct* data);
static void create_cmd_input(Widget w, GsdAttr* attr,
XmAnyCallbackStruct* data);
static void create_attrnav_form(Widget w, GsdAttr* attr,
XmAnyCallbackStruct* data);
static void action_inputfocus(Widget w, XmAnyCallbackStruct* data);
static void valchanged_cmd_input(Widget w, XEvent* event);
};
......
......@@ -71,13 +71,14 @@
// Create the navigator widget
//
GsdAttrNavMotif::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)
char* xn_name, pb_gsd* xn_gsd,
int xn_edit_mode, Widget* w,
pwr_tStatus* status)
: GsdAttrNav(xn_parent_ctx, xn_name, xn_gsd, xn_edit_mode, status),
parent_wid(xn_parent_wid)
{
form_widget = ScrolledBrowCreate(
parent_wid, name, NULL, 0, init_brow_cb, this, (Widget*)&brow_widget);
form_widget = ScrolledBrowCreate(parent_wid, name, NULL, 0, init_brow_cb,
this, (Widget*)&brow_widget);
XtManageChild(form_widget);
// Create the root item
......
......@@ -44,10 +44,12 @@
#endif
//! The navigation area of the attribute editor.
class GsdAttrNavMotif : public GsdAttrNav {
class GsdAttrNavMotif : public GsdAttrNav
{
public:
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();
void set_inputfocus();
......
......@@ -47,7 +47,8 @@
class GsdAttrQtWidget;
class GsdAttrQt : public GsdAttr {
class GsdAttrQt : public GsdAttr
{
public:
QWidget* brow_widget;
QWidget* form_widget;
......@@ -61,7 +62,7 @@ public:
CoWowFocusTimerQt focustimer;
GsdAttrQt(QWidget* 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);
void message(char severity, const char* message);
void set_prompt(const char* prompt);
......@@ -71,7 +72,8 @@ private:
GsdAttrQtWidget* toplevel;
};
class GsdAttrQtWidget : public QWidget {
class GsdAttrQtWidget : public QWidget
{
Q_OBJECT
public:
......@@ -100,7 +102,7 @@ public slots:
void activate_cmd_apply();
void activate_cmd_ca();
void valchanged_cmd_input(){}
void valchanged_cmd_input() {}
private:
GsdAttrQt* attr;
......
......@@ -44,8 +44,8 @@
#include "cow_pb_gsd_attrnav_qt.h"
GsdAttrNavQt::GsdAttrNavQt(void* xn_parent_ctx, QWidget* xn_parent_wid,
const char* xn_name, pb_gsd* xn_gsd, int xn_edit_mode, QWidget** w,
pwr_tStatus* status)
const char* xn_name, 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)
{
debug_print("creating a scrolledbrowwidgetqt\n");
......@@ -66,7 +66,4 @@ GsdAttrNavQt::~GsdAttrNavQt()
form_widget->close();
}
void GsdAttrNavQt::set_inputfocus()
{
brow_widget->setFocus();
}
\ No newline at end of file
void GsdAttrNavQt::set_inputfocus() { brow_widget->setFocus(); }
\ No newline at end of file
......@@ -44,10 +44,12 @@
#include <QWidget>
//! The navigation area of the attribute editor.
class GsdAttrNavQt : public GsdAttrNav {
class GsdAttrNavQt : public GsdAttrNav
{
public:
GsdAttrNavQt(void* xn_parent_ctx, QWidget* xn_parent_wid, 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);
~GsdAttrNavQt();
void set_inputfocus();
......
......@@ -49,7 +49,8 @@
class GsdmlAttrQtWidget;
class GsdmlAttrQt : public GsdmlAttr {
class GsdmlAttrQt : public GsdmlAttr
{
public:
GsdmlAttrQtWidget* toplevel;
QWidget* brow_widget;
......@@ -66,8 +67,8 @@ public:
CoWowEntryQt* cmd_entry;
GsdmlAttrQt(QWidget* a_parent_wid, void* a_parent_ctx, void* a_object,
pn_gsdml* a_gsdml, int a_edit_mode, const char* a_data_filename,
pwr_tStatus* a_sts);
pn_gsdml* a_gsdml, int a_edit_mode, const char* a_data_filename,
pwr_tStatus* a_sts);
void message(char severity, const char* message);
void attr_help_text(const char* help_text);
......@@ -75,7 +76,8 @@ public:
void change_value();
};
class GsdmlAttrQtWidget : public QWidget {
class GsdmlAttrQtWidget : public QWidget
{
Q_OBJECT
public:
......@@ -110,7 +112,7 @@ public slots:
void activate_cmd_apply();
void activate_cmd_ca();
void valchanged_cmd_entry(){}
void valchanged_cmd_entry() {}
private:
GsdmlAttrQt* attr;
......
......@@ -44,8 +44,9 @@
#include "cow_pn_gsdml_attrnav_qt.h"
GsdmlAttrNavQt::GsdmlAttrNavQt(void* xn_parent_ctx, QWidget* xn_parent_wid,
const char* xn_name, pn_gsdml* xn_gsdml, int xn_edit_mode, QWidget** w,
pwr_tStatus* status)
const char* xn_name, 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)
{
debug_print("creating a scrolledbrowwidgetqt\n");
......@@ -66,10 +67,7 @@ GsdmlAttrNavQt::~GsdmlAttrNavQt()
form_widget->close();
}
void GsdmlAttrNavQt::set_inputfocus()
{
brow_widget->setFocus();
}
void GsdmlAttrNavQt::set_inputfocus() { brow_widget->setFocus(); }
void GsdmlAttrNavQt::display_attr_help_text()
{
......@@ -84,14 +82,16 @@ void GsdmlAttrNavQt::display_attr_help_text()
brow_GetUserData(node_list[0], (void**)&base_item);
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 base class does,
* but since they already contained references they were used instead...
*/
case attrnav_eItemType_PnParValue:
case attrnav_eItemType_PnParEnum: {
case attrnav_eItemType_PnParEnum:
{
ItemPnParEnum* item = (ItemPnParEnum*)base_item;
gsdml_ValueItem* vi = 0;
......@@ -106,7 +106,8 @@ void GsdmlAttrNavQt::display_attr_help_text()
break;
}
default: {
default:
{
if (base_item->info_text)
((GsdmlAttrQt*)parent_ctx)->attr_help_text(base_item->info_text);
else
......
......@@ -44,11 +44,12 @@
#include <QWidget>
//! The navigation area of the attribute editor.
class GsdmlAttrNavQt : public GsdmlAttrNav {
class GsdmlAttrNavQt : public GsdmlAttrNav
{
public:
GsdmlAttrNavQt(void* xn_parent_ctx, QWidget* xn_parent_wid,
const char* xn_name, pn_gsdml* xn_gsdml, int xn_edit_mode, QWidget** w,
pwr_tStatus* status);
const char* xn_name, pn_gsdml* xn_gsdml, int xn_edit_mode,
QWidget** w, pwr_tStatus* status);
~GsdmlAttrNavQt();
void set_inputfocus();
void display_attr_help_text();
......
This diff is collapsed.
......@@ -83,7 +83,8 @@ typedef enum {
gsd_End
} gsd_eType;
typedef struct {
typedef struct
{
char name[50];
char group[50];
int option;
......@@ -91,19 +92,22 @@ typedef struct {
unsigned int value_default;
} gsd_sKeyword;
typedef struct {
typedef struct
{
char name[32];
pwr_tCid cid;
} gsd_sModuleClass;
typedef struct {
typedef struct
{
unsigned int value;
void* data;
int found;
int len;
} gsd_sData;
typedef struct sArea {
typedef struct sArea
{
char Area_Name[33];
int Related_CFG_Identifier;
int IO_Direction;
......@@ -116,25 +120,29 @@ typedef struct sArea {
struct sArea* next;
} gsd_sArea;
typedef struct {
typedef struct
{
int Const_Offset;
unsigned char Const_Prm_Data[237];
int len;
} gsd_sExtUserPrmDataConst;
typedef struct sText {
typedef struct sText
{
int Prm_Data_Value;
char Text[33];
struct sText* next;
} gsd_sText;
typedef struct sPrmText {
typedef struct sPrmText
{
int Reference_Number;
gsd_sText* text_list;
struct sPrmText* next;
} gsd_sPrmText;
typedef struct sExtUserPrmData {
typedef struct sExtUserPrmData
{
int Reference_Number;
char Ext_User_Prm_Data_Name[33];
char Data_Type_Name[33];
......@@ -154,19 +162,22 @@ typedef struct sExtUserPrmData {
struct sExtUserPrmData* next;
} gsd_sExtUserPrmData;
typedef struct sExtUserPrmDataRef {
typedef struct sExtUserPrmDataRef
{
int Reference_Offset;
int Reference_Number;
gsd_sExtUserPrmData* prm_data;
sExtUserPrmDataRef* next;
} gsd_sExtUserPrmDataRef;
typedef struct {
typedef struct
{
gsd_sExtUserPrmDataRef* ref;
int value;
} gsd_sPrmDataItem;
typedef struct sModule {
typedef struct sModule
{
char Mod_Name[33];
unsigned char* Config;
int config_size;
......@@ -180,7 +191,8 @@ typedef struct sModule {
struct sModule* next;
} gsd_sModule;
typedef struct {
typedef struct
{
int idx;
gsd_sModule* module;
char name[80];
......@@ -191,7 +203,8 @@ typedef struct {
unsigned char prm_data[237];
} gsd_sModuleConf;
class pb_gsd {
class pb_gsd
{
public:
pb_gsd();
~pb_gsd();
......@@ -236,17 +249,15 @@ public:
int prm_len(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,
unsigned char* data, int data_size);
unsigned char* data, int data_size);
int prm_data_to_items(gsd_sPrmDataItem* item, int item_size,
unsigned char* data, int data_size, int set_default = 0);
void set_classes(gsd_sModuleClass* mclist)
{
module_classlist = mclist;
}
unsigned char* data, int data_size,
int set_default = 0);
void set_classes(gsd_sModuleClass* mclist) { module_classlist = mclist; }
int get_svalue(const char* key, char* value, int size);
int get_ivalue(const char* key, int* value);
int add_module_conf(
pwr_tCid cid, pwr_tOid oid, char* name, char* module_name);
int add_module_conf(pwr_tCid cid, pwr_tOid oid, char* name,
char* module_name);
int move_module_conf(gsd_sModuleConf* src, gsd_sModuleConf* dest);
int copy_module_conf(gsd_sModuleConf* m);
int cut_module_conf(gsd_sModuleConf* m);
......@@ -257,14 +268,8 @@ public:
void pack_ext_user_prm_data(char* data, int* len);
void compress(char* line);
int syntax_check(int* idx);
void set_modified(int mod)
{
modified = mod;
}
int is_modified()
{
return modified;
}
void set_modified(int mod) { modified = mod; }
int is_modified() { return modified; }
};
#endif
......@@ -70,14 +70,17 @@ void GsdAttr::gsdattr_change_value_cb(void* attr_ctx)
//
void GsdAttr::activate_exit()
{
if (close_cb) {
if (gsd->is_modified()) {
if (close_cb)
{
if (gsd->is_modified())
{
wow->DisplayQuestion((void*)this, "Apply", "Do you want to apply changes",
cmd_close_apply_cb, cmd_close_no_cb, 0);
} else
cmd_close_apply_cb, cmd_close_no_cb, 0);
}
else
(close_cb)(parent_ctx);
} else
}
else
delete this;
}
......@@ -86,7 +89,8 @@ void GsdAttr::activate_help()
int sts;
if (help_cb)
sts = (help_cb)(parent_ctx,
sts = (help_cb)(
parent_ctx,
"pb_slave_editor /helpfile=\"$pwr_exe/profibus_xtthelp.dat\"");
}
......@@ -96,12 +100,14 @@ void GsdAttr::activate_copy()
int sts;
sts = attrnav->get_select((ItemPb**)&item);
if (EVEN(sts)) {
if (EVEN(sts))
{
message('E', "Select a module");
return;
}
if (item->type != attrnav_eItemType_PbModule) {
if (item->type != attrnav_eItemType_PbModule)
{
message('E', "Only modules can be copied");
return;
}
......@@ -116,12 +122,14 @@ void GsdAttr::activate_cut()
int sts;
sts = attrnav->get_select((ItemPb**)&item);
if (EVEN(sts)) {
if (EVEN(sts))
{
message('E', "Select a module");
return;
}
if (item->type != attrnav_eItemType_PbModule) {
if (item->type != attrnav_eItemType_PbModule)
{
message('E', "Only modules can be copied");
return;
}
......@@ -135,12 +143,14 @@ void GsdAttr::activate_paste()
int sts;
sts = attrnav->get_select((ItemPb**)&item);
if (EVEN(sts)) {
if (EVEN(sts))
{
message('E', "Select a module");
return;
}
if (item->type != attrnav_eItemType_PbModule) {
if (item->type != attrnav_eItemType_PbModule)
{
message('E', "Only modules can be copied");
return;
}
......@@ -170,10 +180,7 @@ void GsdAttr::activate_zoom_out()
attrnav->zoom(1.0 / 1.18);
}
void GsdAttr::activate_zoom_reset()
{
attrnav->unzoom();
}
void GsdAttr::activate_zoom_reset() { attrnav->unzoom(); }
void GsdAttr::activate_print()
{
......@@ -194,21 +201,24 @@ void GsdAttr::activate_cmd_ok()
int idx;
char msg[80];
if (save_cb) {
if (save_cb)
{
// Check syntax
sts = gsd->syntax_check(&idx);
if (EVEN(sts)) {
switch (sts) {
if (EVEN(sts))
{
switch (sts)
{
case PB__NOMODULENAME:
sprintf(msg, "Syntax error in module %d, No module name", idx + 1);
break;
case PB__DUPLMODULENAME:
sprintf(msg, "Syntax error in module %s, Duplicate module name",
gsd->module_conf[idx].name);
gsd->module_conf[idx].name);
break;
case PB__NOMODULECLASS:
sprintf(msg, "Syntax error in module %s, Module class is missing",
gsd->module_conf[idx].name);
gsd->module_conf[idx].name);
break;
default:
sprintf(msg, "Syntax error in module %d", idx + 1);
......@@ -222,7 +232,8 @@ void GsdAttr::activate_cmd_ok()
message('E', "Error saving profibus data");
else if (close_cb)
(close_cb)(parent_ctx);
} else if (close_cb)
}
else if (close_cb)
(close_cb)(parent_ctx);
}
......@@ -232,21 +243,24 @@ void GsdAttr::activate_cmd_apply()
int idx;
char msg[80];
if (save_cb) {
if (save_cb)
{
// Check syntax
sts = gsd->syntax_check(&idx);
if (EVEN(sts)) {
switch (sts) {
if (EVEN(sts))
{
switch (sts)
{
case PB__NOMODULENAME:
sprintf(msg, "Syntax error in module %d, No module name", idx + 1);
break;
case PB__DUPLMODULENAME:
sprintf(msg, "Syntax error in module %s, Duplicate module name",
gsd->module_conf[idx].name);
gsd->module_conf[idx].name);
break;
case PB__NOMODULECLASS:
sprintf(msg, "Syntax error in module %s, Module class is missing",
gsd->module_conf[idx].name);
gsd->module_conf[idx].name);
break;
default:
sprintf(msg, "Syntax error in module %d", idx + 1);
......@@ -271,7 +285,8 @@ void GsdAttr::cmd_close_apply_cb(void* ctx, void* data)
sts = (attr->save_cb)(attr->parent_ctx);
if (EVEN(sts))
attr->message('E', "Error saving profibus data");
else {
else
{
attr->gsd->set_modified(0);
(attr->close_cb)(attr->parent_ctx);
}
......@@ -286,22 +301,22 @@ void GsdAttr::cmd_close_no_cb(void* ctx, void* data)
void GsdAttr::activate_cmd_ca()
{
if (close_cb) {
if (gsd->is_modified()) {
if (close_cb)
{
if (gsd->is_modified())
{
wow->DisplayQuestion((void*)this, "Apply", "Do you want to apply changes",
cmd_close_apply_cb, cmd_close_no_cb, 0);
} else
cmd_close_apply_cb, cmd_close_no_cb, 0);
}
else
(close_cb)(parent_ctx);
}
}
GsdAttr::~GsdAttr()
{
}
GsdAttr::~GsdAttr() {}
GsdAttr::GsdAttr(
void* a_parent_ctx, void* a_object, pb_gsd* a_gsd, int a_edit_mode)
GsdAttr::GsdAttr(void* a_parent_ctx, void* a_object, pb_gsd* a_gsd,
int 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),
client_data(0), recall_idx(-1), value_current_recall(0)
......
......@@ -41,7 +41,8 @@
#include "cow_pb_gsd.h"
typedef struct {
typedef struct
{
void* value;
char name[80];
int type;
......@@ -56,7 +57,8 @@ typedef struct {
class GsdAttrNav;
class CoWow;
class GsdAttr {
class GsdAttr
{
public:
void* parent_ctx;
char name[80];
......@@ -77,15 +79,9 @@ public:
GsdAttr(void* a_parent_ctx, void* a_object, pb_gsd* a_gsd, int a_edit_mode);
virtual ~GsdAttr();
virtual void message(char severity, const char* message)
{
}
virtual void set_prompt(const char* prompt)
{
}
virtual void change_value()
{
}
virtual void message(char severity, const char* message) {}
virtual void set_prompt(const char* prompt) {}
virtual void change_value() {}
void activate_exit();
void activate_help();
......
This diff is collapsed.
......@@ -67,9 +67,10 @@ typedef enum {
class ItemPb;
//! Class for handling of brow.
class GsdAttrNavBrow {
class GsdAttrNavBrow
{
public:
GsdAttrNavBrow(BrowCtx* brow_ctx, void* xn) : ctx(brow_ctx), attrnav(xn){}
GsdAttrNavBrow(BrowCtx* brow_ctx, void* xn) : ctx(brow_ctx), attrnav(xn) {}
~GsdAttrNavBrow();
BrowCtx* ctx;
......@@ -98,7 +99,8 @@ class CoWow;
class CoWowTimer;
//! The navigation area of the attribute editor.
class GsdAttrNav {
class GsdAttrNav
{
public:
void* parent_ctx;
pb_gsd* gsd;
......@@ -115,12 +117,10 @@ public:
char modelname[80];
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 void set_inputfocus()
{
}
virtual void set_inputfocus() {}
void start_trace(pwr_tObjid Objid, char* object_str);
int set_attr_value(const char* value_str);
......@@ -135,22 +135,24 @@ public:
void unzoom();
void get_zoom(double* zoom_factor);
int search_class(const char* filename, const char* model, const char* module,
char* mclass);
char* mclass);
static void trace_scan(void* data);
static int trace_scan_bc(brow_tObject object, void* p);
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 init_brow_cb(FlowCtx* fctx, void* client_data);
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,
int size, int* len, char* format);
int size, int* len, char* format);
static int brow_cb(FlowCtx* ctx, flow_tEvent event);
};
class ItemPb {
class ItemPb
{
public:
ItemPb();
virtual ~ItemPb();
......@@ -165,12 +167,14 @@ public:
};
//! Item for a normal attribute.
class ItemPbBase : public ItemPb {
class ItemPbBase : public ItemPb
{
public:
ItemPbBase(GsdAttrNav* attrnav, const char* item_name, const char* attr,
int attr_type, int attr_size, double attr_min_limit,
double attr_max_limit, void* attr_value_p, int attr_noedit,
gsd_sPrmText* attr_enumtext, brow_tNode dest, flow_eDest dest_code);
int attr_type, int attr_size, double attr_min_limit,
double attr_max_limit, void* attr_value_p, int attr_noedit,
gsd_sPrmText* attr_enumtext, brow_tNode dest,
flow_eDest dest_code);
virtual ~ItemPbBase();
void* value_p;
......@@ -185,12 +189,14 @@ public:
int subgraph;
};
class ItemPbEnum : public ItemPbBase {
class ItemPbEnum : public ItemPbBase
{
public:
ItemPbEnum(GsdAttrNav* attrnav, const char* item_name, const char* attr,
int attr_type, int attr_size, double attr_min_limit,
double attr_max_limit, void* attr_value_p, int attr_noedit,
gsd_sPrmText* attr_enumtext, brow_tNode dest, flow_eDest dest_code);
int attr_type, int attr_size, double attr_min_limit,
double attr_max_limit, void* attr_value_p, int attr_noedit,
gsd_sPrmText* attr_enumtext, brow_tNode dest,
flow_eDest dest_code);
virtual ~ItemPbEnum();
int old_value;
......@@ -199,11 +205,12 @@ public:
};
//! Item for an enum attribute.
class ItemPbEnumValue : public ItemPb {
class ItemPbEnumValue : public ItemPb
{
public:
ItemPbEnumValue(GsdAttrNav* attrnav, const char* item_name, int item_num,
int item_type_id, void* attr_value_p, brow_tNode dest,
flow_eDest dest_code);
int item_type_id, void* attr_value_p, brow_tNode dest,
flow_eDest dest_code);
virtual ~ItemPbEnumValue();
int num;
......@@ -214,13 +221,13 @@ public:
};
//! Item for a module.
class ItemPbModule : public ItemPb {
class ItemPbModule : public ItemPb
{
public:
ItemPbModule(GsdAttrNav* attrnav, const char* item_name,
gsd_sModuleConf* item_mconf, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPbModule()
{
}
gsd_sModuleConf* item_mconf, brow_tNode dest,
flow_eDest dest_code);
virtual ~ItemPbModule() {}
gsd_sModuleConf* mconf;
char old_value[80];
......@@ -231,13 +238,13 @@ public:
};
//! Item for module type selection.
class ItemPbModuleType : public ItemPb {
class ItemPbModuleType : public ItemPb
{
public:
ItemPbModuleType(GsdAttrNav* attrnav, const char* item_name,
gsd_sModuleConf* item_mconf, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPbModuleType()
{
}
gsd_sModuleConf* item_mconf, brow_tNode dest,
flow_eDest dest_code);
virtual ~ItemPbModuleType() {}
gsd_sModuleConf* mconf;
int old_value;
......@@ -247,13 +254,13 @@ public:
};
//! Item for module type selection.
class ItemPbModuleData : public ItemPb {
class ItemPbModuleData : public ItemPb
{
public:
ItemPbModuleData(GsdAttrNav* attrnav, const char* item_name,
gsd_sModuleConf* item_mconf, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPbModuleData()
{
}
gsd_sModuleConf* item_mconf, brow_tNode dest,
flow_eDest dest_code);
virtual ~ItemPbModuleData() {}
gsd_sModuleConf* mconf;
......@@ -262,13 +269,13 @@ public:
};
//! Item for module class selection.
class ItemPbModuleClass : public ItemPb {
class ItemPbModuleClass : public ItemPb
{
public:
ItemPbModuleClass(GsdAttrNav* attrnav, const char* item_name,
gsd_sModuleConf* item_mconf, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPbModuleClass()
{
}
gsd_sModuleConf* item_mconf, brow_tNode dest,
flow_eDest dest_code);
virtual ~ItemPbModuleClass() {}
gsd_sModuleConf* mconf;
int old_value;
......@@ -278,38 +285,36 @@ public:
};
//! Item for slave prmdata.
class ItemPbPrmData : public ItemPb {
class ItemPbPrmData : public ItemPb
{
public:
ItemPbPrmData(GsdAttrNav* attrnav, const char* item_name, brow_tNode dest,
flow_eDest dest_code);
virtual ~ItemPbPrmData()
{
}
flow_eDest dest_code);
virtual ~ItemPbPrmData() {}
virtual int open_children(GsdAttrNav* attrnav, double x, double y);
};
//! Item for slave prmdata.
class ItemPbMoreData : public ItemPb {
class ItemPbMoreData : public ItemPb
{
public:
ItemPbMoreData(GsdAttrNav* attrnav, const char* item_name, brow_tNode dest,
flow_eDest dest_code);
virtual ~ItemPbMoreData()
{
}
flow_eDest dest_code);
virtual ~ItemPbMoreData() {}
virtual int open_children(GsdAttrNav* attrnav, double x, double y);
};
//! Item for slave byte order.
class ItemPbEnumByteOrder : public ItemPbBase {
class ItemPbEnumByteOrder : public ItemPbBase
{
public:
ItemPbEnumByteOrder(GsdAttrNav* attrnav, const char* item_name,
const char* attr, int attr_type, int attr_size, double attr_min_limit,
double attr_max_limit, void* attr_value_p, int attr_noedit,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPbEnumByteOrder()
{
}
const char* attr, int attr_type, int attr_size,
double attr_min_limit, double attr_max_limit,
void* attr_value_p, int attr_noedit, brow_tNode dest,
flow_eDest dest_code);
virtual ~ItemPbEnumByteOrder() {}
int old_value;
......
This diff is collapsed.
......@@ -82,7 +82,10 @@ typedef unsigned int gsdml_tUnsigned32;
typedef unsigned short gsdml_tUnsigned16hex;
typedef unsigned int gsdml_tUnsigned32hex;
typedef unsigned int gsdml_tBoolean;
typedef char gsdml_tSignedOrFloatValueList[4096]; //Allowed values can be pretty large. >3000 characters is not uncommon...
typedef char gsdml_tSignedOrFloatValueList[4096]; // Allowed values can be
// pretty large. >3000
// characters is not
// uncommon...
typedef enum {
gsdml_eType_,
......@@ -249,24 +252,24 @@ typedef enum {
gsdml_eTag_MenuRef,
gsdml_eTag_SystemRedundancy,
gsdml_eTag_PROFIenergy,
gsdml_eTag_Signature, //Ignored
gsdml_eTag_SignedInfo, //Ignored
gsdml_eTag_CanonicalizationMethod, //Ignored
gsdml_eTag_SignatureMethod, //Ignored
gsdml_eTag_Reference, //Ignored
gsdml_eTag_Transforms, //Ignored
gsdml_eTag_Transform, //Ignored
gsdml_eTag_DigestMethod, //Ignored
gsdml_eTag_DigestValue, //Ignored
gsdml_eTag_SignatureValue, //Ignored
gsdml_eTag_KeyInfo, //Ignored
gsdml_eTag_KeyValue, //Ignored
gsdml_eTag_RSAKeyValue, //Ignored
gsdml_eTag_Modulus, //Ignored
gsdml_eTag_Exponent, //Ignored
gsdml_eTag_Object, //Ignored
gsdml_eTag_SignatureProperties, //Ignored
gsdml_eTag_SignatureProperty, //Ignored
gsdml_eTag_Signature, // Ignored
gsdml_eTag_SignedInfo, // Ignored
gsdml_eTag_CanonicalizationMethod, // Ignored
gsdml_eTag_SignatureMethod, // Ignored
gsdml_eTag_Reference, // Ignored
gsdml_eTag_Transforms, // Ignored
gsdml_eTag_Transform, // Ignored
gsdml_eTag_DigestMethod, // Ignored
gsdml_eTag_DigestValue, // Ignored
gsdml_eTag_SignatureValue, // Ignored
gsdml_eTag_KeyInfo, // Ignored
gsdml_eTag_KeyValue, // Ignored
gsdml_eTag_RSAKeyValue, // Ignored
gsdml_eTag_Modulus, // Ignored
gsdml_eTag_Exponent, // Ignored
gsdml_eTag_Object, // Ignored
gsdml_eTag_SignatureProperties, // Ignored
gsdml_eTag_SignatureProperty, // Ignored
gsdml_eTag__
} gsdml_eTag;
......@@ -1321,7 +1324,7 @@ public:
gsdml_SystemRedundancy(pn_gsdml* g);
gsdml_sSystemRedundancy Body;
pn_gsdml* gsdml;
~gsdml_SystemRedundancy() {};
~gsdml_SystemRedundancy(){};
};
typedef struct
......@@ -1808,14 +1811,18 @@ public:
static int string_to_value_datatype(char* str, gsdml_eValueDataType* type);
int datavalue_to_string(gsdml_eValueDataType datatype, void* value,
unsigned int size, char* str, unsigned int strsize);
int string_to_datavalue(gsdml_eValueDataType datatype, void* value, void* value_reversed_endianess,
unsigned int size, const char* str);
int string_to_datavalue(gsdml_eValueDataType datatype, void* value,
void* value_reversed_endianess, unsigned int size,
const char* str);
int get_datavalue_length(gsdml_eValueDataType datatype, int strlength,
unsigned int* len);
void set_classes(gsdml_sModuleClass* mclist) { module_classlist = mclist; }
int set_par_record_default(unsigned char* data, unsigned char* data_reversed_endianess, int size,
int set_par_record_default(unsigned char* data,
unsigned char* data_reversed_endianess, int size,
gsdml_ParameterRecordDataItem* par_record);
int populate_and_align_par_reversed_record_data(unsigned char const* read_data, unsigned char* reversed_data, gsdml_ParameterRecordDataItem* par_record);
int populate_and_align_par_reversed_record_data(
unsigned char const* read_data, unsigned char* reversed_data,
gsdml_ParameterRecordDataItem* par_record);
bool next_token();
bool is_space(const char c);
......@@ -1835,12 +1842,14 @@ public:
void* object_factory(gsdml_eTag id);
void* find_value_ref(char* ref);
void* find_module_ref(char* ref);
void* find_submodule_ref(char* ref, gsdml_eSubmoduleType *type);
void* find_submodule_ref(char* ref, gsdml_eSubmoduleType* type);
void* find_category_ref(char* ref);
void* find_text_ref(char* ref);
void* find_graphic_ref(char* ref);
gsdml_Ref* find_ref_ref(char* ref, gsdml_ParameterRecordDataItem* search_domain);
gsdml_MenuItem* find_menuitem_ref(char* ref, gsdml_ParameterRecordDataItem* search_domain);
gsdml_Ref* find_ref_ref(char* ref,
gsdml_ParameterRecordDataItem* search_domain);
gsdml_MenuItem*
find_menuitem_ref(char* ref, gsdml_ParameterRecordDataItem* search_domain);
void gsdml_print();
void build();
};
......
......@@ -54,8 +54,8 @@
// Static member variables
char GsdmlAttr::value_recall[30][160];
void GsdmlAttr::gsdmlattr_message(
void* attr, char severity, const char* message)
void GsdmlAttr::gsdmlattr_message(void* attr, char severity,
const char* message)
{
((GsdmlAttr*)attr)->message(severity, message);
}
......@@ -71,14 +71,17 @@ void GsdmlAttr::gsdmlattr_change_value_cb(void* attr_ctx)
//
void GsdmlAttr::activate_exit()
{
if (close_cb) {
if (edit_mode && attrnav->is_modified()) {
if (close_cb)
{
if (edit_mode && attrnav->is_modified())
{
wow->DisplayQuestion((void*)this, "Apply", "Do you want to apply changes",
cmd_close_apply_cb, cmd_close_no_cb, 0);
} else
cmd_close_apply_cb, cmd_close_no_cb, 0);
}
else
(close_cb)(parent_ctx);
} else
}
else
delete this;
}
......@@ -92,7 +95,8 @@ void GsdmlAttr::activate_help()
int sts;
if (help_cb)
sts = (help_cb)(parent_ctx,
sts = (help_cb)(
parent_ctx,
"pn_device_editor /helpfile=\"$pwr_exe/profibus_xtthelp.dat\"");
}
......@@ -102,12 +106,14 @@ void GsdmlAttr::activate_copy()
int sts;
sts = attrnav->get_select((ItemPn**)&item);
if (EVEN(sts)) {
if (EVEN(sts))
{
message('E', "Select a module");
return;
}
if (item->type != attrnav_eItemType_PnSlot) {
if (item->type != attrnav_eItemType_PnSlot)
{
message('E', "Only slots can be copied");
return;
}
......@@ -123,12 +129,14 @@ void GsdmlAttr::activate_cut()
int sts;
sts = attrnav->get_select((ItemPn**)&item);
if (EVEN(sts)) {
if (EVEN(sts))
{
message('E', "Select a slot");
return;
}
if (item->type != attrnav_eItemType_PnSlot) {
if (item->type != attrnav_eItemType_PnSlot)
{
message('E', "Only slots can be cut");
return;
}
......@@ -143,12 +151,14 @@ void GsdmlAttr::activate_paste()
int sts;
sts = attrnav->get_select((ItemPn**)&item);
if (EVEN(sts)) {
if (EVEN(sts))
{
message('E', "Select a slot");
return;
}
if (item->type != attrnav_eItemType_PnSlot) {
if (item->type != attrnav_eItemType_PnSlot)
{
message('E', "Select a slot");
return;
}
......@@ -157,10 +167,7 @@ void GsdmlAttr::activate_paste()
attrnav->redraw();
}
void GsdmlAttr::activate_viewio(int set)
{
attrnav->set_viewio(set);
}
void GsdmlAttr::activate_viewio(int set) { attrnav->set_viewio(set); }
void GsdmlAttr::activate_zoom_in()
{
......@@ -184,20 +191,11 @@ void GsdmlAttr::activate_zoom_out()
attrnav->zoom(1.0 / 1.18);
}
void GsdmlAttr::activate_zoom_reset()
{
attrnav->unzoom();
}
void GsdmlAttr::activate_zoom_reset() { attrnav->unzoom(); }
void GsdmlAttr::activate_collapse()
{
attrnav->collapse();
}
void GsdmlAttr::activate_collapse() { attrnav->collapse(); }
void GsdmlAttr::activate_expand_all()
{
attrnav->expand_all();
}
void GsdmlAttr::activate_expand_all() { attrnav->expand_all(); }
void GsdmlAttr::activate_print()
{
......@@ -218,13 +216,15 @@ void GsdmlAttr::activate_cmd_ok()
attrnav->save(data_filename);
if (save_cb) {
if (save_cb)
{
sts = (save_cb)(parent_ctx);
if (EVEN(sts))
message('E', "Error saving profibus data");
else if (close_cb)
(close_cb)(parent_ctx);
} else if (close_cb)
}
else if (close_cb)
(close_cb)(parent_ctx);
}
......@@ -234,7 +234,8 @@ void GsdmlAttr::activate_cmd_apply()
attrnav->save(data_filename);
if (save_cb) {
if (save_cb)
{
sts = (save_cb)(parent_ctx);
if (EVEN(sts))
message('E', "Error saving profibus data");
......@@ -250,7 +251,8 @@ void GsdmlAttr::cmd_close_apply_cb(void* ctx, void* data)
attr->attrnav->save(attr->data_filename);
if (attr->save_cb) {
if (attr->save_cb)
{
sts = (attr->save_cb)(attr->parent_ctx);
if (EVEN(sts))
attr->message('E', "Error saving profibus data");
......@@ -268,22 +270,22 @@ void GsdmlAttr::cmd_close_no_cb(void* ctx, void* data)
void GsdmlAttr::activate_cmd_ca()
{
if (close_cb) {
if (edit_mode && attrnav->is_modified()) {
if (close_cb)
{
if (edit_mode && attrnav->is_modified())
{
wow->DisplayQuestion((void*)this, "Apply", "Do you want to apply changes",
cmd_close_apply_cb, cmd_close_no_cb, 0);
} else
cmd_close_apply_cb, cmd_close_no_cb, 0);
}
else
(close_cb)(parent_ctx);
}
}
GsdmlAttr::~GsdmlAttr()
{
}
GsdmlAttr::~GsdmlAttr() {}
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),
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)
......
......@@ -42,7 +42,8 @@
#include "cow_pn_gsdml.h"
#include "rt_pn_gsdml_data.h"
typedef struct {
typedef struct
{
void* value;
char name[80];
int type;
......@@ -63,7 +64,8 @@ typedef enum {
class GsdmlAttrNav;
class CoWow;
class GsdmlAttr {
class GsdmlAttr
{
public:
void* parent_ctx;
char name[80];
......@@ -83,21 +85,13 @@ public:
CoWow* wow;
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 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 change_value()
{
}
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 change_value() {}
void activate_ordermoduletype(attr_eOrderModuleType type);
void activate_exit();
......
This diff is collapsed.
This diff is collapsed.
......@@ -54,7 +54,7 @@
printk(fmt, function, lineno, ##args)
#define DBG_PRN(fmt, args...) \
CIF_PRN((__FUNCTION__), (__LINE__), KERN_INFO __FILE__ "::%s(L%.4d): " fmt, \
##args)
##args)
#else
#define DBG_PRN(fmt, args...) /* not debugging: nothing */
#endif
......
This diff is collapsed.
This diff is collapsed.
......@@ -152,32 +152,32 @@ typedef unsigned long DWORD;
/* -- constants of internal sizes of byte arrays --------------------------- */
#define VFD_STRING_LENGTH 32 /* max length of the VFD string */
#define VFD_STRING_LENGTH 32 /* max length of the VFD string */
#define IDENT_STRING_LENGTH 32 /* max length of the Ident string */
#define ACCESS_NAME_LENGTH 32 /* max length for name adressing */
#define OBJECT_NAME_LENGTH 32 /* max length of object name */
#define EXTENSION_LENGTH 32 /* max length of object extension */
#define ACCESS_NAME_LENGTH 32 /* max length for name adressing */
#define OBJECT_NAME_LENGTH 32 /* max length of object name */
#define EXTENSION_LENGTH 32 /* max length of object extension */
#define EXECUTION_ARGUMENT_LENGTH 32 /* max length of exec. argument */
#define ERROR_DESCR_LENGTH 32 /* max length of error descript.*/
#define CRL_SYMBOL_LENGTH 32 /* max length of crl symbol name */
#define CRL_EXTENSION_LENGTH 2 /* max length of crl extension */
#define ERROR_DESCR_LENGTH 32 /* max length of error descript.*/
#define CRL_SYMBOL_LENGTH 32 /* max length of crl symbol name */
#define CRL_EXTENSION_LENGTH 2 /* max length of crl extension */
#if (PB_VER < 500)
#define KBL_SYMBOL_LENGTH CRL_SYMBOL_LENGTH
#define KBL_EXTENSION_LENGTH CRL_EXTENSION_LENGTH
#endif
#define MAX_FMS_PDU_LENGTH 241 /* max size of the FMS/FM7-PDU-Buffer */
#define MAX_VAR_LIST_ELEMENTS 50 /* max count of variable list elements */
#define MAX_DOM_LIST_ELEMENTS 50 /* max count of domain list elements */
#define MAX_FMS_PDU_LENGTH 241 /* max size of the FMS/FM7-PDU-Buffer */
#define MAX_VAR_LIST_ELEMENTS 50 /* max count of variable list elements */
#define MAX_DOM_LIST_ELEMENTS 50 /* max count of domain list elements */
#define MAX_VAR_RECORD_ELEMENTS 10 /* max count of record elements */
#define MAX_COMREF 64 /* max supported communication references */
#define MAX_VFD 5 /* max supported VFDs */
#define MAX_VFD 5 /* max supported VFDs */
#if (PB_VER < 500)
#define MAX_KBL_LEN MAX_COMREF /* max entries in CRL */
#define MAX_KBL_LEN MAX_COMREF /* max entries in CRL */
#define MAX_PARA_LOC_SERVICES 5 /* max parallel local FMS-Services*/
#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.
......@@ -96,7 +96,7 @@
/* --- DPRAM SIZES / IRQ-VAL offset in DPR --------------------------------- */
#define DPRAM_SIZE_PROFIBOARD 0x4000 /* 16 KB DPRAM */
#define DPRAM_SIZE_PROFI_104 0x4000 /* 16 KB DPRAM */
#define DPRAM_SIZE_PROFI_104 0x4000 /* 16 KB DPRAM */
#define DPRAM_H_TO_C_IRQ_OFFSET 0x2 /* IRQ memory cells at DPRAM end */
#define DPRAM_C_TO_H_IRQ_OFFSET 0x4
......@@ -104,10 +104,10 @@
/* --- IRQ-VALUE ----------------------------------------------------------- */
#define RST_IRQ_VALUE 0xAA /* Reset */
#define REQ_IRQ_VALUE 0xF0 /* SND/RCV Request */
#define ACK_IRQ_VALUE 0x0F /* SND/RCV Acknowledge */
#define DP_SLAVE_IO_REQ_IRQ_VALUE 0xE0 /* DP-SLAVE-IO Request */
#define DP_SLAVE_IO_ACK_IRQ_VALUE 0x0E /* DP-SLAVE-IO Acknowldege */
#define REQ_IRQ_VALUE 0xF0 /* SND/RCV Request */
#define ACK_IRQ_VALUE 0x0F /* SND/RCV Acknowledge */
#define DP_SLAVE_IO_REQ_IRQ_VALUE 0xE0 /* DP-SLAVE-IO Request */
#define DP_SLAVE_IO_ACK_IRQ_VALUE 0x0E /* DP-SLAVE-IO Acknowldege */
#define DP_DATA_STOP_REQ_IRQ_VALUE 0xD0 /* data transfer stop Request */
#define DP_DATA_STOP_ACK_IRQ_VALUE 0x0D /* data transfer stop Acknowldege */
......@@ -119,19 +119,19 @@
/* --- Write Registers in the I/O Area of the PC --------------------------- */
#define BOARD_CTRL (IO_BASE_ADD + 0) /* Board Control Register */
#define BASE_ADD (IO_BASE_ADD + 1) /* DPRAM Base Address Register */
#define PAGE_SEL (IO_BASE_ADD + 2) /* Page Select Register */
#define CP_IRQ (IO_BASE_ADD + 3) /* Interrupt Register */
#define BASE_ADD (IO_BASE_ADD + 1) /* DPRAM Base Address Register */
#define PAGE_SEL (IO_BASE_ADD + 2) /* Page Select Register */
#define CP_IRQ (IO_BASE_ADD + 3) /* Interrupt Register */
/* -- Pindefinition of the Board Control Register -------------------------- */
#define C165_RESET 0x01 /* Reset of the C165 (low active)*/
#define EN_DPRAM 0x02 /* Enable DPRAM for PC (high active)*/
#define EN_DPRAM 0x02 /* Enable DPRAM for PC (high active)*/
#define SIZE_16_64 0x04 /* DPRAM size 1:16 kByte 0:64kByte*/
/* 64 kByte (low) */
#define BASE_A14 0x08 /* Address low within the 64 kByte */
#define BASE_A15 0x10 /* Address high within the 64 kByte */
#define BASE_A14 0x08 /* Address low within the 64 kByte */
#define BASE_A15 0x10 /* Address high within the 64 kByte */
#define DPR_WIDTH_8_16 0x20 /* DPRAM width 0:16Bit 1:8Bit */
#define MEMCS16_LA_SA 0x40 /* MEMCS16 generation 0:LA 1:SA */
#define MEMCS16_LA_SA 0x40 /* MEMCS16 generation 0:LA 1:SA */
/* --- Pindefinition of the DPRAM Base Adress Register --------------------- */
/* Bit 7: Base Address 23 (MSB) to */
......
This diff is collapsed.
......@@ -78,28 +78,31 @@
#ifdef __KERNEL__
extern int pb_ioctl(struct inode* inode, struct file* file, unsigned int cmd,
unsigned long arg);
unsigned long arg);
#endif
/*****************************************************************************/
/* Structure for data image description */
/*****************************************************************************/
typedef struct _StatusAndData {
typedef struct _StatusAndData
{
void* StatusImage;
int StatusLength;
void* Data;
int DataLength;
} StatusAndData;
typedef struct _NTIoctl {
typedef struct _NTIoctl
{
void* InBuf;
int InBufLength;
void* OutBuf;
int OutBufLength;
} NTIoctl;
typedef struct _DataImage {
typedef struct _DataImage
{
int id;
void* Buf;
unsigned short Length; // sizeof( Buf )
......@@ -110,7 +113,7 @@ typedef struct _DataImage {
/*****************************************************************************/
#define FMS_DPV1_MASTER_MODE 0x00 // FMS/DPV1-Master
#define DPV1_MASTER_MODE 0x01 // for future use
#define DPV1_SLAVE_MODE 0x02 // DP-Slave
#define DPV1_MASTER_MODE 0x01 // for future use
#define DPV1_SLAVE_MODE 0x02 // DP-Slave
#endif
This diff is collapsed.
......@@ -79,8 +79,8 @@ extern "C" {
/*----- function prototypes to get default busparameters -------------------*/
#ifdef __PB_DP__
FUNCTION extern PB_BOOL CALL_CONV pbt_get_dp_def_bus_param(IN USIGN8 BaudRate,
IN USIGN8 StationAddr, IN USIGN16 Mode,
FUNCTION extern PB_BOOL CALL_CONV pbt_get_dp_def_bus_param(
IN USIGN8 BaudRate, IN USIGN8 StationAddr, IN USIGN16 Mode,
OUT T_DP_BUS_PARA_SET FAR* pBusParameters)
/*----------------------------------------------------------------------------
......@@ -158,9 +158,9 @@ FUNCTION extern PB_BOOL CALL_CONV pbt_get_fdlif_def_bus_param(
#endif
#ifdef __PB_FMB__
FUNCTION extern PB_BOOL CALL_CONV pbt_get_fmb_def_bus_param(IN USIGN8 BaudRate,
IN USIGN8 StationAddr, IN PB_BOOL InRingDesired, IN USIGN16 Mode,
OUT T_FMB_SET_BUSPARAMETER_REQ FAR* pBusParameters)
FUNCTION extern PB_BOOL CALL_CONV pbt_get_fmb_def_bus_param(
IN USIGN8 BaudRate, IN USIGN8 StationAddr, IN PB_BOOL InRingDesired,
IN USIGN16 Mode, OUT T_FMB_SET_BUSPARAMETER_REQ FAR* pBusParameters)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
......@@ -200,8 +200,9 @@ FUNCTION extern VOID CALL_CONV ccrl_resrces_init(IN T_CRL_HDR FAR* pCrlHdr)
----------------------------------------------------------------------------*/
;
FUNCTION extern USIGN16 CALL_CONV ccrl_resrces_add_entry(IN USIGN16 Cr,
IN T_CRL_STATIC FAR* pCrlStatic, OUT T_FMB_CONFIG_CRL FAR* pCrlConfig)
FUNCTION extern USIGN16 CALL_CONV
ccrl_resrces_add_entry(IN USIGN16 Cr, IN T_CRL_STATIC FAR* pCrlStatic,
OUT T_FMB_CONFIG_CRL FAR* pCrlConfig)
/*------------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
......
This diff is collapsed.
This diff is collapsed.
......@@ -72,20 +72,23 @@
/* io_sAgentLocal now lives in the respective agent modules. */
typedef struct _io_sRackLocal {
typedef struct _io_sRackLocal
{
unsigned char fdl;
unsigned char dp;
unsigned int start_time;
unsigned int start_cnt;
} io_sRackLocal;
typedef struct {
typedef struct
{
void* input_area;
void* output_area;
int scancount[IO_MAXCHAN];
} io_sCardLocal;
typedef struct {
typedef struct
{
unsigned short invoke_id;
unsigned short input_area_size;
unsigned short output_area_size;
......@@ -95,21 +98,23 @@ typedef struct {
unsigned short float_representation;
} io_sFDLCardLocal;
typedef struct _agent_args {
typedef struct _agent_args
{
void* local;
io_sAgent* ap;
} agent_args;
typedef struct {
int hServiceReadDevice; // Handle for Service device
int hServiceWriteDevice; // Handle for Service device
int hDpDataDevice; // Handle for DP-Data device
int hDpsInputDataDevice; // Handle for DP-Slave Input-Data device
typedef struct
{
int hServiceReadDevice; // Handle for Service device
int hServiceWriteDevice; // Handle for Service device
int hDpDataDevice; // Handle for DP-Data device
int hDpsInputDataDevice; // Handle for DP-Slave Input-Data device
int hDpsOutputDataDevice; // Handle for DP-Slave Output-Data device
unsigned char CurrentBoardNumber;
int slave_diag_requested; // Slave diag requested
int parallel_service; // parallel activity
int hDpsBoardDevice; // Handle for DP-Slave Output-Data device
int parallel_service; // parallel activity
int hDpsBoardDevice; // Handle for DP-Slave Output-Data device
pthread_t events;
pthread_mutex_t mutex;
agent_args args;
......
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.
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