Commit bdf31a73 authored by Claes pwr46/data0/x4-6-0's avatar Claes pwr46/data0/x4-6-0

Conflicts fixed

parents da428b1c fb8481c7
/*
* Proview $Id: rt_pn_gsdml_attr_gtk.cpp,v 1.3 2008-10-31 12:51:29 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
/* rt_pn_gsdml_attr_gtk.cpp -- Display gsd attributes */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <gtk/gtk.h>
#include "co_cdh.h"
#include "co_time.h"
#include "co_dcli.h"
#include "co_wow_gtk.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "glow.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "flow_msg.h"
#include "rt_pb_msg.h"
#include "rt_pn_gsdml_attr_gtk.h"
#include "rt_pn_gsdml_attrnav_gtk.h"
void GsdmlAttrGtk::message( char severity, const char *message)
{
gtk_label_set_text( GTK_LABEL(msg_label), message);
}
void GsdmlAttrGtk::set_prompt( const char *prompt)
{
if ( strcmp(prompt, "") == 0) {
g_object_set( cmd_prompt, "visible", FALSE, NULL);
g_object_set( msg_label, "visible", TRUE, NULL);
}
else {
g_object_set( msg_label, "visible", FALSE, NULL);
g_object_set( cmd_prompt, "visible", TRUE, NULL);
}
}
void GsdmlAttrGtk::change_value()
{
int sts;
GtkWidget *text_w;
char *value;
if ( input_open) {
g_object_set( cmd_input, "visible", FALSE, NULL);
set_prompt( "");
input_open = 0;
return;
}
if ( !edit_mode) {
message( 'E', "Not in edit mode");
return;
}
sts = attrnav->check_attr_value( &value);
if ( EVEN(sts)) {
if ( sts == PB__NOATTRSEL)
message( 'E', "No attribute is selected");
else
message( 'E', "Attribute can't be modified");
return;
}
text_w = cmd_input;
g_object_set( text_w, "visible", TRUE, NULL);
message( ' ', "");
gtk_widget_grab_focus( cmd_input);
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);
// Select the text
gtk_editable_set_position( GTK_EDITABLE(cmd_input), -1);
gtk_editable_select_region( GTK_EDITABLE(cmd_input), 0, -1);
}
else {
gtk_editable_delete_text( GTK_EDITABLE(cmd_input), 0, -1);
}
set_prompt( "value >");
input_open = 1;
}
//
// Callbackfunctions from menu entries
//
void GsdmlAttrGtk::activate_change_value( GtkWidget *w, gpointer data)
{
GsdmlAttrGtk *attr = (GsdmlAttrGtk *)data;
attr->change_value();
}
void GsdmlAttrGtk::activate_exit( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_exit();
}
void GsdmlAttrGtk::activate_help( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_help();
}
void GsdmlAttrGtk::activate_copy( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_copy();
}
void GsdmlAttrGtk::activate_cut( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_cut();
}
void GsdmlAttrGtk::activate_paste( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_paste();
}
void GsdmlAttrGtk::activate_viewio( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
int set = (int) gtk_check_menu_item_get_active( GTK_CHECK_MENU_ITEM(w));
attr->activate_viewio( set);
}
void GsdmlAttrGtk::activate_zoom_in( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_zoom_in();
}
void GsdmlAttrGtk::activate_zoom_out( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_zoom_out();
}
void GsdmlAttrGtk::activate_zoom_reset( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_zoom_reset();
}
void GsdmlAttrGtk::activate_print( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_print();
}
void GsdmlAttrGtk::activate_cmd_ok( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_cmd_ok();
}
void GsdmlAttrGtk::activate_cmd_ca( GtkWidget *w, gpointer data)
{
GsdmlAttr *attr = (GsdmlAttr *)data;
attr->activate_cmd_ca();
}
void GsdmlAttrGtk::activate_cmd_input( GtkWidget *w, gpointer data)
{
char *text;
GsdmlAttrGtk *attr = (GsdmlAttrGtk *)data;
int sts;
g_object_set( attr->cmd_prompt, "visible", FALSE, NULL);
g_object_set( attr->cmd_input, "visible", FALSE, NULL);
attr->attrnav->set_inputfocus();
text = gtk_editable_get_chars( GTK_EDITABLE(w), 0, -1);
if ( attr->input_open) {
sts = attr->attrnav->set_attr_value( text);
g_object_set( w, "visible", FALSE, NULL);
attr->set_prompt( "");
attr->input_open = 0;
}
g_free( text);
}
gboolean GsdmlAttrGtk::action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data)
{
GsdmlAttrGtk *attr = (GsdmlAttrGtk *)data;
gboolean input_visible;
if ( attr->focustimer.disabled())
return FALSE;
g_object_get( attr->cmd_input, "visible", &input_visible, NULL);
if ( input_visible)
gtk_widget_grab_focus( attr->cmd_input);
else if ( attr->attrnav)
attr->attrnav->set_inputfocus();
attr->focustimer.disable( 400);
return FALSE;
}
#if 0
void GsdmlAttrGtk::valchanged_cmd_input( Widget w, XEvent *event)
{
GsdmlAttr *attr;
int sts;
char *text;
Arg args[2];
XtSetArg(args[0], XmNuserData, &attr);
XtGetValues(w, args, 1);
sts = mrm_TextInput( w, event, (char *)attr->value_recall, sizeof(attr->value_recall[0]),
sizeof( attr->value_recall)/sizeof(attr->value_recall[0]),
&attr->value_current_recall);
if ( sts) {
text = XmTextGetString( w);
if ( attr->input_open)
{
sts = ((GsdmlAttrNav *)attr->attrnav)->set_attr_value( text);
XtUnmanageChild( w);
attr->set_prompt( "");
attr->input_open = 0;
((GsdmlAttrNav *)attr->attrnav)->set_inputfocus();
}
}
}
#endif
GsdmlAttrGtk::~GsdmlAttrGtk()
{
delete (GsdmlAttrNav *)attrnav;
gtk_widget_destroy( toplevel);
}
static gint delete_event( GtkWidget *w, GdkEvent *event, gpointer data)
{
GsdmlAttrGtk::activate_exit( w, data);
return TRUE;
}
static void destroy_event( GtkWidget *w, gpointer data)
{
}
GsdmlAttrGtk::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) :
GsdmlAttr( a_parent_ctx, a_object, a_gsdml, a_edit_mode, a_data_filename)
{
int sts;
toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", 600,
"default-width", 500,
"title", "profinetConfigurator",
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);
GtkWidget *vbox = gtk_vbox_new( FALSE, 0);
// Menu
// Accelerators
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);
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);
g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
GtkWidget *file = gtk_menu_item_new_with_mnemonic("_File");
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));
// 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);
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);
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_cut);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), menubutton_paste);
GtkWidget *edit = gtk_menu_item_new_with_mnemonic("_Edit");
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), edit);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(edit), GTK_WIDGET(edit_menu));
// Functions entry
menubutton_changevalue = gtk_menu_item_new_with_mnemonic( "_Change Value");
g_signal_connect( menubutton_changevalue, "activate",
G_CALLBACK(activate_change_value), this);
gtk_widget_add_accelerator( menubutton_changevalue, "activate", accel_g,
'q', 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);
GtkWidget *functions = gtk_menu_item_new_with_mnemonic("_Functions");
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(func_menu));
// View Entry
// Edit entry
menubutton_viewio = gtk_check_menu_item_new_with_mnemonic( "_View I/O");
g_signal_connect(menubutton_viewio, "activate", G_CALLBACK(activate_viewio), 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);
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);
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);
GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), menubutton_viewio);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);
GtkWidget *view = gtk_menu_item_new_with_mnemonic("_View");
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
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);
g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);
GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);
GtkWidget *help = gtk_menu_item_new_with_mnemonic("_Help");
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));
// Navigator
attrnav = new GsdmlAttrNavGtk( this, vbox, "Plant",
gsdml, edit_mode, &brow_widget, &sts);
attrnav->message_cb = &GsdmlAttr::gsdmlattr_message;
attrnav->change_value_cb = &GsdmlAttr::gsdmlattr_change_value_cb;
// Status bar and value input
GtkWidget *statusbar = gtk_hbox_new( FALSE, 0);
msg_label = gtk_label_new( "");
gtk_widget_set_size_request( msg_label, -1, 25);
cmd_prompt = gtk_label_new( "value > ");
gtk_widget_set_size_request( cmd_prompt, -1, 25);
cmd_input = gtk_entry_new();
gtk_widget_set_size_request( cmd_input, -1, 25);
g_signal_connect( cmd_input, "activate",
G_CALLBACK(activate_cmd_input), this);
gtk_box_pack_start( GTK_BOX(statusbar), msg_label, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(statusbar), cmd_prompt, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(statusbar), cmd_input, TRUE, TRUE, 0);
// Apply and Ok buttons
cmd_ok = gtk_button_new_with_label( "Ok");
gtk_widget_set_size_request( cmd_ok, 70, 25);
g_signal_connect( cmd_ok, "clicked",
G_CALLBACK(activate_cmd_ok), this);
cmd_cancel = gtk_button_new_with_label( "Cancel");
gtk_widget_set_size_request( cmd_cancel, 70, 25);
g_signal_connect( cmd_cancel, "clicked",
G_CALLBACK(activate_cmd_ca), this);
GtkWidget *hboxbuttons = gtk_hbox_new( TRUE, 40);
gtk_box_pack_start( GTK_BOX(hboxbuttons), cmd_ok, FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(hboxbuttons), cmd_cancel, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox), brow_widget, TRUE, TRUE, 0);
gtk_box_pack_start( GTK_BOX(vbox), statusbar, FALSE, FALSE, 3);
gtk_box_pack_start( GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox), hboxbuttons, FALSE, FALSE, 5);
gtk_container_add( GTK_CONTAINER(toplevel), vbox);
gtk_widget_show_all( toplevel);
g_object_set( cmd_prompt, "visible", FALSE, NULL);
g_object_set( cmd_input, "visible", FALSE, NULL);
if ( !edit_mode) {
gtk_widget_set_sensitive( cmd_ok, FALSE);
gtk_widget_set_sensitive( menubutton_copy, FALSE);
gtk_widget_set_sensitive( menubutton_cut, FALSE);
gtk_widget_set_sensitive( menubutton_paste, FALSE);
gtk_widget_set_sensitive( menubutton_changevalue, FALSE);
}
wow = new CoWowGtk( toplevel);
attrnav->open( data_filename);
}
/*
* Proview $Id: rt_pn_gsdml_attr_gtk.h,v 1.3 2008-10-31 12:51:29 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#ifndef rt_pn_gsdml_attr_gtk_h
#define rt_pn_gsdml_attr_gtk_h
/* rt_pn_gsdml_attr_gtk.h -- Profibus gsd attribute editor */
#include "rt_pn_gsdml_attr.h"
#include "co_wow_gtk.h"
class GsdmlAttrGtk : public GsdmlAttr {
public:
GtkWidget *parent_wid;
GtkWidget *brow_widget;
GtkWidget *form_widget;
GtkWidget *toplevel;
GtkWidget *msg_label;
GtkWidget *cmd_prompt;
GtkWidget *cmd_input;
GtkWidget *attrnav_form;
GtkWidget *cmd_ok;
GtkWidget *cmd_cancel;
GtkWidget *menubutton_copy;
GtkWidget *menubutton_cut;
GtkWidget *menubutton_paste;
GtkWidget *menubutton_changevalue;
GtkWidget *menubutton_viewio;
CoWowFocusTimerGtk focustimer;
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);
~GsdmlAttrGtk();
void message( char severity, const char *message);
void set_prompt( const char *prompt);
void change_value();
static void gsdnkattr_message( void *attr, char severity, char *message);
static void gsdmlattr_change_value_cb( void *attr_ctx);
static void activate_change_value( GtkWidget *w, gpointer data);
static void activate_exit( GtkWidget *w, gpointer data);
static void activate_help( GtkWidget *w, gpointer data);
static void activate_copy( GtkWidget *w, gpointer data);
static void activate_cut( GtkWidget *w, gpointer data);
static void activate_paste( GtkWidget *w, gpointer data);
static void activate_viewio( GtkWidget *w, gpointer data);
static void activate_zoom_in( GtkWidget *w, gpointer data);
static void activate_zoom_out( GtkWidget *w, gpointer data);
static void activate_zoom_reset( GtkWidget *w, gpointer data);
static void activate_print( GtkWidget *w, gpointer data);
static void activate_cmd_input( GtkWidget *w, gpointer data);
static void activate_cmd_ok( GtkWidget *w, gpointer 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( GtkWidget *w, gpointer dataxo);
static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
//static void valchanged_cmd_input( GtkWidget *w, gpointer data);
};
#endif
/*
* Proview $Id: rt_pn_gsdml_attrnav_gtk.cpp,v 1.3 2008-10-31 12:51:29 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
/* rt_pn_gsdml_attrnav_gtk.cpp -- Display gsd attributes */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <gtk/gtk.h>
#include "co_cdh.h"
#include "co_time.h"
#include "co_wow_gtk.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget_gtk.h"
#include "flow_msg.h"
#include "glow.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "glow_growwidget_gtk.h"
#include "rt_pn_gsdml.h"
#include "rt_pn_gsdml_attr_gtk.h"
#include "rt_pn_gsdml_attrnav_gtk.h"
#include "rt_pb_msg.h"
//
// 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) :
GsdmlAttrNav( xn_parent_ctx, xn_name, xn_gsdml, xn_edit_mode, status),
parent_wid(xn_parent_wid)
{
form_widget = scrolledbrowwidgetgtk_new( init_brow_cb,
this, &brow_widget);
gtk_widget_show_all( brow_widget);
*w = form_widget;
wow = new CoWowGtk( brow_widget);
trace_timerid = wow->timer_new();
*status = 1;
}
//
// Delete a nav context
//
GsdmlAttrNavGtk::~GsdmlAttrNavGtk()
{
delete trace_timerid;
delete wow;
delete brow;
gtk_widget_destroy( form_widget);
}
void GsdmlAttrNavGtk::set_inputfocus()
{
gtk_widget_grab_focus( brow_widget);
}
/*
* Proview $Id: rt_pn_gsdml_attrnav_gtk.h,v 1.2 2008-10-31 12:51:29 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#ifndef rt_pn_gsdml_attrnav_gtk_h
#define rt_pn_gsdml_attrnav_gtk_h
/* rt_pn_gsdml_attrnav_gtk.h -- Profibus gsd configurator navigator */
#ifndef rt_pn_gsdml_attrnav_h
# include "rt_pn_gsdml_attrnav.h"
#endif
//! The navigation area of the attribute editor.
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);
~GsdmlAttrNavGtk();
void set_inputfocus();
GtkWidget *parent_wid;
GtkWidget *brow_widget;
GtkWidget *form_widget;
GtkWidget *toplevel;
};
#endif
/* <St> *******************************************************************
======================== Copyright =====================================
Copyright (C) 2004 Hilscher GmbH
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the program, if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
========================================================================
cif_api.c
-------------------------------------------------------------------------
CREATETED : D. Tsaava, Hilscher GmbH
DATE : 18.07.2000
PROJEKT : CIF device driver
=========================================================================
DISCRIPTION
CIF device driver api
=========================================================================
CHANGES
version name date Discription
V2.620 Oktober '06
******************************************************************** <En> */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/kd.h>
/* Paths modified to fit in Proview's build tree. */
#include "cif_types.h"
#include "cif_dev_i.h"
#include "rcsdef.h"
#define INVALID_HANDLE_VALUE -1
int hDevDrv = INVALID_HANDLE_VALUE; // handle to cifDevDrv
static unsigned short DrvOpenCount = 0; // no Application is logged in
typedef struct DEV_DPM_SIZEtag {
unsigned int ulDpmSize;
unsigned int ulDpmIOSize;
} DEV_DPM_SIZE;
DEV_DPM_SIZE tDevDPMSize[MAX_DEV_BOARDS] = { {0L,0L},
{0L,0L},
{0L,0L},
{0L,0L} }; // DPM size of each board
/* <ST> =================================================================================
Function: DevOpenDriver
opens a connection to the device driver
---------------------------------------------------------------------------------------
Input :
Output : -
Return : DRV_NO_ERROR - driver opens successfully
DRV_USR_OPEN_DRV_ERROR - open error
================================================================================= <En> */
short DevOpenDriver()
{
short sRet = DRV_NO_ERROR;
if( hDevDrv == INVALID_HANDLE_VALUE) {
// first application, search CIF device driver
if( (hDevDrv = open("/dev/cif",O_RDONLY) ) == -1 ) { // handle of file with attributes to copy
// error open CIF driver
sRet = DRV_USR_OPEN_ERROR;
} else {
// driver is opend for the 1st. time, store application in DrvOpencount
DrvOpenCount = 1;
}
} else {
// driver is already opend, store application in DrvOpencount
DrvOpenCount++;
}
//printf("*** DevOpenDriver(): OpenCount = %d, hDevDrv = %d\n\n", DrvOpenCount, hDevDrv);
return sRet;
}
/* <ST> =================================================================================
Function: DevCloseDriver
closes the connection to the DEV driver
---------------------------------------------------------------------------------------
Input : usDevNumber - not asigned
Output : -
Return : DRV_NO_ERROR - driver closed successfully
DRV_USR_NOT_INITIALIZED - driver not initialized
================================================================================= <En> */
short DevCloseDriver()
{
short sRet = DRV_NO_ERROR;
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else {
// test if other applications are logged in
if( DrvOpenCount > 1) {
// there are more applications logged in, do not close the driver
DrvOpenCount--;
} else {
// no more application are logged in, close File Handle
close( hDevDrv); // handle of object to close
DrvOpenCount = 0;
hDevDrv = INVALID_HANDLE_VALUE;
}
}
return sRet;
}
/* <ST> =================================================================================
Function: DevGetBoardInfo
reads special board informations from the driver
---------------------------------------------------------------------------------------
Input : usDevNumber - not asigned
usSize - length
*pvData - data pointer
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevGetBoardInfo( BOARD_INFO *pvData)
{
DEVIO_GETBOARDINFOCMD *ptBuffer = NULL;
BOARD_INFO *ptBoardInfo = NULL;
short sRet = DRV_NO_ERROR;
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else {
if( (ptBuffer = (DEVIO_GETBOARDINFOCMD *)malloc(sizeof(DEVIO_GETBOARDINFOCMD))) == NULL)
return DRV_USR_SENDBUF_PTR_NULL;
if( (ptBuffer->ptBoardInfo = (BOARD_INFO *)malloc(sizeof(BOARD_INFO))) == NULL) {
free( ptBuffer);
return DRV_USR_SENDBUF_PTR_NULL;
}
ptBuffer->sError = sRet;
ptBuffer->usInfoLen = sizeof( BOARD_INFO);
ptBoardInfo = ptBuffer->ptBoardInfo;
if( !ioctl( hDevDrv, CIF_IOCTLBOARDINFO, (unsigned long)ptBuffer) ) {
//fprintf(stderr, "CIF_IOCTLBOARDINFO: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else {
ptBuffer->ptBoardInfo = ptBoardInfo;
//printf("sRet=%X, &tBuffer=%lX, ->ptBI=%lX\n",sRet,(unsigned long)tBuffer,(unsigned long)ptBoardInfo);
//printf("BufferLen = %X\n", tBuffer->usInfoLen);
//printf("Vers = %s\n", ptBoardInfo->abDriverVersion);
//printf("Add = %lX\n", ptBoardInfo->tBoard[0].ulPhysicalAddress);
//printf("IRQ = %d\n", ptBoardInfo->tBoard[0].usIrq);
memcpy( pvData, ptBoardInfo, sizeof( BOARD_INFO));
sRet = ptBuffer->sError;
}
free( ptBoardInfo);
free( ptBuffer);
}
return sRet;
}
/* <ST> =================================================================================
Function: DevGetBoardInfoEx
reads special board informations from the driver
---------------------------------------------------------------------------------------
Input : usDevNumber - not asigned
usSize - length
*pvData - data pointer
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevGetBoardInfoEx ( BOARD_INFOEX *pvData)
{
DEVIO_GETBOARDINFOEXCMD *ptBuffer = NULL;
BOARD_INFOEX *ptBoardInfoEx = NULL;
short sRet = DRV_NO_ERROR;
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else {
if( (ptBuffer = (DEVIO_GETBOARDINFOEXCMD *)malloc(sizeof(DEVIO_GETBOARDINFOEXCMD))) == NULL)
return DRV_USR_SENDBUF_PTR_NULL;
ptBuffer->usInfoLen = sizeof( BOARD_INFOEX);
if( (ptBuffer->ptBoard = (BOARD_INFOEX *)malloc(sizeof(BOARD_INFOEX))) == NULL) {
free( ptBuffer);
return DRV_USR_SENDBUF_PTR_NULL;
}
ptBoardInfoEx = ptBuffer->ptBoard;
ptBuffer->usInfoLen = sizeof( BOARD_INFOEX);
ptBuffer->sError = sRet;
if( !ioctl( hDevDrv, CIF_IOCTLBOARDINFOEX, (unsigned long)ptBuffer) ) {
//fprintf(stderr, "CIF_IOCTLBOARDINFOEX: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else {
sRet = ptBuffer->sError;
ptBuffer->ptBoard = ptBoardInfoEx;
memcpy( pvData, ptBoardInfoEx, sizeof( BOARD_INFOEX));
}
free( ptBoardInfoEx);
free( ptBuffer);
}
return sRet;
}
/* <ST> =================================================================================
Function: DevSetOpMode
set polling || interrupt operation mode
---------------------------------------------------------------------------------------
Input : usBoard - number of the DEV board (0..3)
usMode - INTERRUPT_MODE || POLLING_MODE
Return : DRV_NO_ERROR - function successfull
DRV_DEV_IRQ_REQUEST_FAILED - function failed
================================================================================= <En> */
short DevSetOpMode( unsigned short usBoard,
unsigned short usMode,
unsigned short *usIrq)
{
DEVIO_SETOPMODE tBuffer;
short sRet = DRV_NO_ERROR;
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if(usBoard >= MAX_DEV_BOARDS) {
// number is invalid
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else {
// clear all data buffers
tBuffer.usBoard = usBoard;
tBuffer.usMode = usMode;
tBuffer.sError = sRet;
if( !ioctl( hDevDrv, CIF_IOCTL_IRQ_POLL, (unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "CIFAPI (CIF_IOCTL_IRQ_POLL): %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else {
sRet = tBuffer.sError;
*usIrq = tBuffer.usIrq;
}
}
return sRet;
}
/* <ST> =================================================================================
Function: DevInitBoard
initializes a DEV board
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
*pDevAddress - not used
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevInitBoard( unsigned short usDevNumber)
{
DEVIO_RESETCMD tBuffer;
short sRet = DRV_NO_ERROR;
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if( usDevNumber >= MAX_DEV_BOARDS) {
// number is invalid
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else {
// clear all data buffers
tBuffer.usBoard = usDevNumber;
tBuffer.sError = sRet;
if( !ioctl( hDevDrv, CIF_IOCTLINITDRV, (unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "CIFAPI (CIF_IOCTLINITDRV): %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else {
sRet = tBuffer.sError;
//printf("CIFAPI (CIF_IOCTLINITDRV): sRet = %d\n", sRet);
if( sRet == DRV_NO_ERROR) {
// Save the DPM size for further function calls and calculate the length
// of the DPM-IO data area
tDevDPMSize[usDevNumber].ulDpmSize = tBuffer.ulDpmSize;
tDevDPMSize[usDevNumber].ulDpmIOSize = ((tBuffer.ulDpmSize * 1024) - 1024) /2;
}
}
}
return sRet;
}
/* <ST> =================================================================================
Function: DevReset
reset a DEV board
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
usMode - reset mode (2,3)
ulTimeout - function timeout in milliseconds
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevReset ( unsigned char usDevNumber,
unsigned short usMode,
unsigned long ulTimeout)
{
DEVIO_RESETCMD tBuffer;
unsigned int lBytesReturned;
short sRet = DRV_NO_ERROR;
// valid handle available, driver is open
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if( usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if((usMode != COLDSTART) &&
(usMode != WARMSTART) &&
(usMode != BOOTSTART) ) {
sRet = DRV_USR_MODE_INVALID;
} else {
// fill in parameter data
lBytesReturned = 0;
// set output buffer
tBuffer.usBoard = usDevNumber;
tBuffer.usMode = usMode;
tBuffer.ulTimeout = ulTimeout;
tBuffer.sError
= sRet;
//printf("CIF_IOCTLRESETDEV: BOARD = %d, mode = %d, tout = %ld\n",
// tBuffer.ucBoard, tBuffer.usMode, tBuffer.ulTimeout);
if( !ioctl( hDevDrv, CIF_IOCTLRESETDEV, (unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "CIF_IOCTLRESETDEV: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else {
sRet = tBuffer.sError;
}
}
return sRet;
}
/* <ST> =================================================================================
Function: DevGetInfo
read the differnt information areas from a DEV board
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
usInfoArea - 1..n
usSize - size of the users data buffer
pvData - pointer to users data buffer
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevGetInfo( unsigned short usDevNumber,
unsigned short usInfoArea,
unsigned short usSize,
void *pvData)
{
DEVIO_GETDEVINFOCMD tBuffer;
unsigned int lBytesReturned;
short sRet = DRV_NO_ERROR;
// valid handle available, driver is open
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if ( usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if ( usSize == 0) {
sRet = DRV_USR_SIZE_ZERO;
} else {
// test area spezific data
switch ( usInfoArea) {
case GET_VERSION_INFO:
if ( usSize > sizeof(VERSIONINFO) ) {
sRet = DRV_USR_SIZE_TOO_LONG;
}
break;
case GET_DRIVER_INFO:
if ( usSize > sizeof(DRIVERINFO) ) {
sRet = DRV_USR_SIZE_TOO_LONG;
}
break;
case GET_FIRMWARE_INFO:
if ( usSize > sizeof(FIRMWAREINFO) ) {
sRet = DRV_USR_SIZE_TOO_LONG;
}
break;
case GET_RCS_INFO:
if ( usSize > sizeof(RCSINFO) ) {
sRet = DRV_USR_SIZE_TOO_LONG;
}
break;
case GET_DEV_INFO:
if ( usSize > sizeof(DEVINFO) ) {
sRet = DRV_USR_SIZE_TOO_LONG;
}
break;
case GET_TASK_INFO:
if ( usSize > sizeof(TASKINFO) ) {
sRet = DRV_USR_SIZE_TOO_LONG;
}
break;
case GET_IO_INFO:
if ( usSize > sizeof(IOINFO) ) {
sRet = DRV_USR_SIZE_TOO_LONG;
}
break;
case GET_IO_SEND_DATA:
if ( usSize > tDevDPMSize[usDevNumber].ulDpmIOSize) {
sRet = DRV_USR_SIZE_TOO_LONG;
}
break;
default:
sRet = DRV_USR_INFO_AREA_INVALID;
} /* end switch */
if ( sRet == DRV_NO_ERROR) {
// complete buffer length with return data
// usDataBufferLen = usSize;
// fill in parameter data
lBytesReturned = 0;
// set output buffer
tBuffer.usBoard = usDevNumber;
tBuffer.usInfoArea = usInfoArea;
tBuffer.usInfoLen = usSize;
tBuffer.pabInfoData = pvData; // needed in kernel-space to copy data back to it!
tBuffer.sError = sRet;
// activate function
if( !ioctl( hDevDrv, CIF_IOCTLGETINFO, (unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "(CIFAPI: (CIF_IOCTLGETINFO): %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else {
// memcpy(pvData, tBuffer.pabInfoData, usSize); already copied by driver direct !!!
sRet = tBuffer.sError;
}
}
}
return sRet;
}
/* <ST> =================================================================================
Function: DevPutTaskParameter
write communication parameters
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
usNumber - number of the parameter area (1..7)
usSize - size of the parameter area ( >0, <= max.Size)
pvData - pointer to task parameter buffer
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevPutTaskParameter( unsigned short usDevNumber,
unsigned short usNumber,
unsigned short usSize,
void *pvData)
{
DEVIO_PUTPARAMETERCMD tBuffer;
unsigned int lBytesReturned ;
short sRet = DRV_NO_ERROR;
// valid handle available, driver is open
if ( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if (usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if ( (usNumber < 1) ||
(usNumber > 7) ) { // 3...7 wird in MailBox memory area geschrieben
sRet = DRV_USR_NUMBER_INVALID;
} else if (usSize == 0) {
sRet = DRV_USR_SIZE_ZERO;
} else if ( usSize > sizeof(TASKPARAM)) {
sRet = DRV_USR_SIZE_TOO_LONG;
} else {
// fill in parameter data
lBytesReturned = 0;
// set command buffer
tBuffer.usBoard = usDevNumber;
tBuffer.usTaskParamNum = usNumber;
tBuffer.usTaskParamLen = usSize;
memcpy ( (unsigned char *)&(tBuffer.TaskParameter), (unsigned char *)pvData, usSize);
tBuffer.sError = sRet;
// activate function
if( !ioctl( hDevDrv, CIF_IOCTLPARAMETER, (unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "CIF_IOCTLRESETDEV: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else
sRet = tBuffer.sError;
}
return sRet;
}
/* <ST> =================================================================================
Function: DevGetTaskState
read a task state field form a DEV board
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
usNumber - number of the status field (1,2)
usSize - size of the users data buffer (>0..<= 64)
pvData - pointer to users data buffer
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevGetTaskState( unsigned short usDevNumber,
unsigned short usNumber,
unsigned short usSize,
void *pvData)
{
DEVIO_GETTASKSTATECMD tBuffer;
unsigned int lBytesReturned;
short sRet = DRV_NO_ERROR;
// valid handle available, driver is open
if ( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if ( usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if ( usNumber < 1 ||
usNumber > 2 ) {
sRet = DRV_USR_NUMBER_INVALID;
} else if (usSize == 0) {
sRet = DRV_USR_SIZE_ZERO;
} else if (usSize > sizeof(TASKSTATE) ) {
sRet = DRV_USR_SIZE_TOO_LONG;
} else {
// fill in parameter data
lBytesReturned = 0;
// set command buffer
tBuffer.ucBoard = usDevNumber;
tBuffer.usStateNum = usNumber;
tBuffer.usStateLen = usSize;
//memcpy( tBuffer.TaskState, pvData, usSize);
tBuffer.sError = sRet;
// activate function
if( !ioctl( hDevDrv, CIF_IOCTLTASKSTATE, (unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "CIF_IOCTLTASKSTATE: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else {
memcpy( pvData, tBuffer.TaskState, usSize);
sRet = tBuffer.sError;
}
}
return sRet;
}
/* <ST> =================================================================================
Function: DevGetMBXState
Test send and receive MBX
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0)
*pusDevMbxState - 0 = empty, 1 = full
*pusHostMBXState - 0 = empty, 1 = full
Output : -
Return : DRV_NO_ERROR - function successfull
================================================================================= <En> */
short DevGetMBXState( unsigned short usDevNumber,
unsigned short *pusDevMbxState,
unsigned short *pusHostMbxState)
{
DEVIO_MBXINFOCMD tBuffer;
unsigned int lBytesReturned ;
short sRet = DRV_NO_ERROR;
// valid handle available, driver is open
if ( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if ( usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else {
// fill in parameter data
lBytesReturned = 0;
// set output buffer
tBuffer.ucBoard = usDevNumber;
tBuffer.usDevMbxState = 0x00;//*pusDevMbxState;
tBuffer.usHostMbxState = 0x00;//*pusHostMbxState;
tBuffer.sError = sRet;
// activate function
if( !ioctl( hDevDrv, CIF_IOCTLMBXINFO, (unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "CIF_IOCTLMBXINFO: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
}
else {
*pusDevMbxState = tBuffer.usDevMbxState;
*pusHostMbxState = tBuffer.usHostMbxState;
sRet = tBuffer.sError;
}
}
return sRet;
}
/* <ST> =================================================================================
Function: DevGetMBXData
reads the device and the host mailbox
---------------------------------------------------------------------------------------
Input : usDevNumber - not asigned
usHostSize - length of the host data to be read
*pvHostData - buffer for host data pointer
usDevSize - length of the device data to be read
*pvHostData - buffer for device data pointer
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevGetMBXData( unsigned short usDevNumber,
unsigned short usHostSize,
void *pvHostData,
unsigned short usDevSize,
void *pvDevData)
{
DEVIO_GETMBXCMD tBuffer;
unsigned int lBytesReturned;
short sRet = DRV_NO_ERROR;
// valid handle available, driver is open
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if( usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if((usHostSize == 0) ||
(usDevSize == 0) ) {
sRet = DRV_USR_SIZE_ZERO;
} else if((usHostSize > sizeof(MSG_STRUC)) ||
(usDevSize > sizeof(MSG_STRUC)) ){
sRet = DRV_USR_SIZE_TOO_LONG;
} else {
// fill in parameter data
lBytesReturned = 0;
tBuffer.usBoard = usDevNumber;
tBuffer.usHostLen = usHostSize;
tBuffer.usDevLen = usDevSize;
tBuffer.sError = sRet;
// activate function
if( !ioctl( hDevDrv, // handle of the device
CIF_IOCTLGETMBX, // control code of operation to perform
(unsigned long)(&tBuffer) ))
/*, // address of buffer for input data
sizeof(tBuffer), // size of input buffer
NULL, // address of output buffer
0, // size of output buffer
(unsigned int *)&lBytesReturned, // address of actual bytes of output
NULL) ) // address of overlapped structure*/
{
//fprintf(stderr, "CIF_IOCTLGETMBX: %s\n", strerror(errno));
// function error
sRet = DRV_USR_COMM_ERR;
} else {
printf("cif_api::DevGetMBXData: after CIF_IOCTLGETMBX ...\n");
memcpy( pvDevData, tBuffer.abDevMbx, usDevSize);
printf("cif_api::DevGetMBXData: after memcpy ...\n");
memcpy( pvHostData, tBuffer.abHostMbx, usHostSize);
sRet = tBuffer.sError;
}
}
return sRet;
}
/* <ST> =================================================================================
Function: DevExitBoard
closes the connection to a DEV board
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevExitBoard( unsigned short usDevNumber)
{
DEVIO_EXITCMD tBuffer;
unsigned int lBytesReturned;
unsigned short usDrvOpenCount;
short sRet = DRV_NO_ERROR;
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if( usDevNumber >= MAX_DEV_BOARDS) {
// number is invalid
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else {
// valid handle available, driver is open
// clear all data buffers
lBytesReturned = 0;
tBuffer.usBoard = usDevNumber; // [in]
//tBuffer.usDrvOpenCount = usDrvOpenCount; // [out]
//tBuffer.sError = sRet; // [out]
if( !ioctl( hDevDrv, CIF_IOCTLEXITDRV, (unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "CIF_IOCTLEXITDRV: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else {
tBuffer.usDrvOpenCount = usDrvOpenCount; // [out]
sRet = tBuffer.sError; // [out]
}
}
return sRet;
}
/* <ST> =================================================================================
Function: DevReadSendData
reads the send data from the send area
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
usReadOffset -
usReadSize - size of the users data buffer
pvReadData - pointer to users data buffer
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevReadSendData( unsigned short usDevNumber,
unsigned short usOffset,
unsigned short usSize,
void *pvData)
{
DEVIO_READSENDCMD tBuffer;
unsigned int lBytesReturned;
short sRet = DRV_NO_ERROR;
// valid handle available, driver is open
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if( usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if( (usSize != 0) &&
((usSize + usOffset) > (unsigned short)tDevDPMSize[usDevNumber].ulDpmIOSize) ) {
sRet = DRV_USR_SIZE_TOO_LONG;
} else {
// fill in parameter data
lBytesReturned = 0;
// set output buffer
tBuffer.usBoard = usDevNumber;
tBuffer.usReadOffset = usOffset;
tBuffer.usReadLen = usSize;
tBuffer.pabReadData = pvData;
tBuffer.sError = sRet;
// activate function
if( !ioctl( hDevDrv, CIF_IOCTLREADSEND, (unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "CIF_IOCTLREADSEND: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else {
sRet = tBuffer.sError;
}
}
return sRet;
}
/* <ST> =================================================================================
Function: DevTriggerWatchDog
triggers the PC watchdog an delivers the actual DEV watchdog
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
usMode - 0 = start, 1 = stop
*pusDevWatchDog - size of the users data buffer
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevTriggerWatchDog( unsigned short usDevNumber,
unsigned short usMode,
unsigned short *pusDevWatchDog)
{
DEVIO_TRIGGERCMD tBuffer;
unsigned int lBytesReturned ;
short sRet = DRV_NO_ERROR;
// valid handle available, driver is open
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if( usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if( usMode > WATCHDOG_START) {
sRet = DRV_USR_MODE_INVALID;
} else {
// fill in parameter data
lBytesReturned = 0;
// set output buffer
tBuffer.usBoard = usDevNumber;
tBuffer.usMode = usMode;
//tBuffer.pusTriggerValue = pusDevWatchDog;
tBuffer.sError = sRet;
// activate function
if( !ioctl( hDevDrv, CIF_IOCTLTRIGGERWD, (unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "CIF_IOCTLREADSEND: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else {
*pusDevWatchDog = tBuffer.usTriggerValue;
sRet = tBuffer.sError;
}
}
return sRet;
}
/* <ST> =================================================================================
Function: DevSpecialControl
Change the special control value in DevFlags
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
usMode - 0 = SPC_CTRL_CLEAR, 1 = SPC_CTRL_SET
*pusDevWatchDog - size of the users data buffer
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevSpecialControl( unsigned short usDevNumber,
unsigned short usMode,
unsigned short *pusCtrlAck)
{
DEVIO_TRIGGERCMD tBuffer;
unsigned int lBytesReturned ;
short sRet = DRV_NO_ERROR;
// valid handle available, driver is open
if ( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if( usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if( pusCtrlAck == NULL) {
sRet = DRV_USR_BUF_PTR_NULL;
} else {
// fill in parameter data
lBytesReturned = 0;
// set output buffer
tBuffer.usBoard = usDevNumber;
tBuffer.usMode = usMode;
tBuffer.sError = sRet;
// activate function
if( !ioctl( hDevDrv, CIF_IOCTLSPCONTROL, (unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "CIF_IOCTLREADSEND: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else {
*pusCtrlAck = tBuffer.usTriggerValue;
sRet = tBuffer.sError;
}
}
return sRet;
}
/* <ST> =================================================================================
Function: DevExtendedData
extended data function
---------------------------------------------------------------------------------------
Input : usDevNumber - not asigned
usMode - 1 ...n
usSize - length of user data
*pvData - data pointer
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevExtendedData( unsigned short usDevNumber,
unsigned short usMode,
unsigned short usSize,
void *pvData)
{
DEVIO_EXTDATACMD tBuffer;
unsigned int lBytesReturned;
short sRet = DRV_NO_ERROR;
// valid handle available, driver is open
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if( usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if( usSize == 0) {
sRet = DRV_USR_SIZE_ZERO;
} else if( usSize > EXTDATASIZE) {
sRet = DRV_USR_SIZE_TOO_LONG;
} else if( (usMode == 0) ||
(usMode > 100) ) {
sRet = DRV_USR_MODE_INVALID;
} else {
// fill in parameter data
lBytesReturned = 0;
tBuffer.usBoard = usDevNumber;
tBuffer.usMode = usMode;
tBuffer.pabExtData = pvData;
tBuffer.sError = sRet;
// insert error for older driver versions, because function which are not included
// in the driver returns always DeviceIoControl success without setting an
// error into the tDataBuffer.
sRet = DRV_USR_COMM_ERR;
// activate function
if( !ioctl( hDevDrv, CIF_IOCTLEXTDATA, (unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "CIF_IOCTLEXTDATA: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else
sRet = tBuffer.sError;
}
return sRet;
}
/* <ST> =================================================================================
Function: DevGetTaskParameter
reads the task parameters from task 1 and 2
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
usArea - 1,2
usSize - size of the users data buffer
pvData - pointer to users data buffer
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevGetTaskParameter( unsigned short usDevNumber,
unsigned short usNumber,
unsigned short usSize,
void *pvData)
{
DEVIO_GETPARAMETERCMD tBuffer;
unsigned int lBytesReturned ;
short sRet = DRV_NO_ERROR;
// valid handle available, driver is open
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if(usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if( (usNumber < 1) ||
(usNumber > 2) ) {
sRet = DRV_USR_NUMBER_INVALID;
} else if(usSize == 0) {
sRet = DRV_USR_SIZE_ZERO;
} else if( usSize > sizeof(TASKPARAM)) {
sRet = DRV_USR_SIZE_TOO_LONG;
} else {
// fill in parameter data
lBytesReturned = 0;
// set command buffer
tBuffer.usBoard = usDevNumber;
tBuffer.usTaskParamNum = usNumber;
tBuffer.usTaskParamLen = usSize;
//tBuffer.ptTaskParam = pvData;
tBuffer.sError = sRet;
// activate function
if( !ioctl( hDevDrv, CIF_IOCTLGETPARAMETER, (unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "CIF_IOCTLGETPARAMETER: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else {
memcpy ( (unsigned char *)pvData, (unsigned char *)&(tBuffer.TaskParameter), usSize);
sRet = tBuffer.sError;
}
}
return sRet;
}
/* <ST> =================================================================================
Function: DevReadWriteDPMData
Function to access the whole DPM
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
*pusBytes - Amount of bytes sended
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevReadWriteDPMData( unsigned short usDevNumber,
unsigned short usMode,
unsigned short usOffset,
unsigned short usSize,
void *pvData)
{
DEVIO_RWDPMDATACMD tBuffer;
unsigned int lBytesReturned;
short sRet = DRV_NO_ERROR;
// valid handle available, driver is open
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if(usDevNumber >= MAX_DEV_BOARDS ) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if( (usMode != PARAMETER_READ) &&
(usMode != PARAMETER_WRITE) ) {
sRet = DRV_USR_MODE_INVALID;
} else if( ( usSize != 0) &&
( (usSize + usOffset) > (unsigned short)(tDevDPMSize[usDevNumber].ulDpmSize * 1024))) {
sRet = DRV_USR_SIZE_TOO_LONG;;
} else {
// fill in parameter data
lBytesReturned = 0;
tBuffer.usBoard = usDevNumber;
tBuffer.usMode = usMode;
tBuffer.usOffset = usOffset;
tBuffer.usLen = usSize;
tBuffer.pabData = pvData;
tBuffer.sError = sRet;
// activate function
if( !ioctl( hDevDrv, CIF_IOCTLRWDPMDATA, (unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "CIF_IOCTLRWDPMDATA: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else
sRet = tBuffer.sError;
} /* endif */
return sRet;
} /* end funktion */
/* <ST> =================================================================================
Function: DevReadWriteDPMRaw
reads and writes bytes from the DPM, last KByte
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0)
usMode - function read = 1, write = 2
usOffset - offset in the RAW data area
usSize - number of bytes to read or write
pvData - pointer to the user data buffer
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevReadWriteDPMRaw( unsigned short usDevNumber,
unsigned short usMode,
unsigned short usOffset,
unsigned short usSize,
void *pvData)
{
DEVIO_RWRAWDATACMD tBuffer;
unsigned int lBytesReturned;
short sRet = DRV_NO_ERROR;
// valid handle available, driver is open
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if(usDevNumber >= MAX_DEV_BOARDS ) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if( (usSize + usOffset) > sizeof(RAWDATA) ) {
sRet = DRV_USR_SIZE_TOO_LONG;
} else if( (usMode != PARAMETER_READ) &&
(usMode != PARAMETER_WRITE) ) {
sRet = DRV_USR_MODE_INVALID;
} else {
// fill in parameter data
lBytesReturned = 0;
tBuffer.usBoard = usDevNumber;
tBuffer.usMode = usMode;
tBuffer.usOffset = usOffset;
tBuffer.usLen = usSize;
tBuffer.pabData = pvData;
tBuffer.sError = sRet;
// activate function
if( !ioctl( hDevDrv, CIF_IOCTLRWRAW, (unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "CIF_IOCTLRWRAW: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else
sRet = tBuffer.sError;
} /* endif */
return sRet;
} /* end funktion */
/* <ST> =================================================================================
Function: DevExchangeIO
reads and writes IO datas
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
usInfoArea - 1..n
usSize - size of the users data buffer
pvData - pointer to users data buffer
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevExchangeIO( unsigned short usDevNumber,
unsigned short usSendOffset,
unsigned short usSendSize,
void *pvSendData,
unsigned short usReceiveOffset,
unsigned short usReceiveSize,
void *pvReceiveData,
unsigned long ulTimeout)
{
DEVIO_EXIOCMD tBuffer;
unsigned int lBytesReturned;
short sRet = DRV_NO_ERROR;
int lRet = 0;
// valid handle available, driver is open
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if( usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if( (usSendSize != 0) &&
((usSendSize + usSendOffset) > (unsigned short)tDevDPMSize[usDevNumber].ulDpmIOSize) ) {
sRet = DRV_USR_SENDSIZE_TOO_LONG;
} else if( (usReceiveSize != 0) &&
((usReceiveSize + usReceiveOffset) > (unsigned short)tDevDPMSize[usDevNumber].ulDpmIOSize) ) {
sRet = DRV_USR_RECVSIZE_TOO_LONG;
} else {
// fill in parameter data
lBytesReturned = 0;
// set output buffer
tBuffer.usBoard = usDevNumber;
tBuffer.usReceiveOffset = usReceiveOffset;
tBuffer.usReceiveLen = usReceiveSize;
tBuffer.usSendOffset = usSendOffset;
tBuffer.usSendLen = usSendSize;
tBuffer.pabSendData = pvSendData;
tBuffer.pabReceiveData = pvReceiveData;
tBuffer.sError = sRet;
tBuffer.ulTimeout = ulTimeout;
// activate function
lRet = ioctl( hDevDrv, CIF_IOCTLEXIO, (unsigned long)(&tBuffer));
if( lRet <= 0) {
//fprintf(stderr, "CIF_IOCTLEXIO: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else
sRet = tBuffer.sError;
}
return sRet;
}
/* <ST> =================================================================================
Function: DevExchangeIOEx
reads and writes IO datas
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
usMode - Exchange mode
usInfoArea - 1..n
usSize - size of the users data buffer
pvData - pointer to users data buffer
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevExchangeIOEx( unsigned short usDevNumber,
unsigned short usMode,
unsigned short usSendOffset,
unsigned short usSendSize,
void *pvSendData,
unsigned short usReceiveOffset,
unsigned short usReceiveSize,
void *pvReceiveData,
unsigned long ulTimeout)
{
DEVIO_EXIOCMDEX tBuffer;
unsigned int lBytesReturned;
short sRet = DRV_NO_ERROR;
int lRet = 0;
// valid handle available, driver is open
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if( usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if( (usSendSize != 0) &&
((usSendSize + usSendOffset) > (unsigned short)tDevDPMSize[usDevNumber].ulDpmIOSize) ) {
sRet = DRV_USR_SENDSIZE_TOO_LONG;
} else if( (usReceiveSize != 0) &&
((usReceiveSize + usReceiveOffset) > (unsigned short)tDevDPMSize[usDevNumber].ulDpmIOSize) ) {
sRet = DRV_USR_RECVSIZE_TOO_LONG;
} else if( usMode > 4) {
sRet = DRV_USR_MODE_INVALID;
} else {
// fill in parameter data
lBytesReturned = 0;
// set output buffer
tBuffer.usBoard = usDevNumber;
tBuffer.usReceiveOffset = usReceiveOffset;
tBuffer.usReceiveLen = usReceiveSize;
tBuffer.usSendOffset = usSendOffset;
tBuffer.usSendLen = usSendSize;
tBuffer.pabSendData = pvSendData;
tBuffer.pabReceiveData = pvReceiveData;
tBuffer.ulTimeout = ulTimeout;
tBuffer.sError = sRet;
tBuffer.usMode = (unsigned short)(usMode + 1); // Driver uses 1..5
// activate function
lRet = ioctl (hDevDrv, CIF_IOCTLEXIOEX, (unsigned long)(&tBuffer));
if( lRet <= 0) {
//fprintf(stderr, "CIF_IOCTLEXIO: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else
sRet = tBuffer.sError;
}
return sRet;
}
/* <ST> =================================================================================
Function: DevExchangeIOErr
reads and writes IO datas with state field information
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
usMode - Exchange mode
usInfoArea - 1..n
usSize - size of the users data buffer
pvData - pointer to users data buffer
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevExchangeIOErr( unsigned short usDevNumber,
unsigned short usSendOffset,
unsigned short usSendSize,
void *pvSendData,
unsigned short usReceiveOffset,
unsigned short usReceiveSize,
void *pvReceiveData,
COMSTATE *ptState,
unsigned long ulTimeout)
{
DEVIO_EXIOCMDERR tBuffer;
unsigned int lBytesReturned;
short sRet = DRV_NO_ERROR;
int lRet = 0;
// valid handle available, driver is open
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if( usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if( (usSendSize != 0) &&
((usSendSize + usSendOffset) > (unsigned short)tDevDPMSize[usDevNumber].ulDpmIOSize) ) {
sRet = DRV_USR_SENDSIZE_TOO_LONG;
} else if( (usReceiveSize != 0) &&
((usReceiveSize + usReceiveOffset) > (unsigned short)tDevDPMSize[usDevNumber].ulDpmIOSize) ) {
sRet = DRV_USR_RECVSIZE_TOO_LONG;
} else {
// fill in parameter data
lBytesReturned = 0;
// set output buffer
tBuffer.usBoard = usDevNumber;
tBuffer.usReceiveOffset = usReceiveOffset;
tBuffer.usReceiveLen = usReceiveSize;
tBuffer.usSendOffset = usSendOffset;
tBuffer.usSendLen = usSendSize;
tBuffer.pabSendData = pvSendData;
tBuffer.pabReceiveData = pvReceiveData;
tBuffer.ptStateData = ptState;
tBuffer.sError = sRet;
tBuffer.ulTimeout = ulTimeout;
// activate function
lRet = ioctl (hDevDrv, CIF_IOCTLEXIOERR, (unsigned long)(&tBuffer));
if( lRet <= 0) {
//fprintf(stderr, "CIF_IOCTLEXIO: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else
sRet = tBuffer.sError;
}
return sRet;
}
/* <ST> =================================================================================
Function: DevSetHostState
set the host state
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
usMode - 0 = Host not ready, 1 = Host ready
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevSetHostState( unsigned short usDevNumber,
unsigned short usMode,
unsigned long ulTimeout)
{
DEVIO_TRIGGERCMD tBuffer;
unsigned int lBytesReturned;
short sRet = DRV_NO_ERROR;
// valid handle available, driver is open
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if( usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if( usMode > HOST_READY) {
sRet = DRV_USR_MODE_INVALID;
} else {
// fill in parameter data
lBytesReturned = 0;
// set output buffer
tBuffer.usBoard = usDevNumber;
tBuffer.usMode = usMode;
tBuffer.ulTimeout = ulTimeout;
tBuffer.sError = sRet;
// activate function
if( !ioctl( hDevDrv, CIF_IOCTLSETHOST, (unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "CIF_IOCTLSETHOST: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else
sRet = tBuffer.sError;
}
return sRet;
}
/* <ST> =================================================================================
Function: DevPutMessage
send a message to a DEV board
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
ptMessage - pointer to users message
ulTimeout - function timeout in milliseconds
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevPutMessage( unsigned short usDevNumber,
MSG_STRUC *ptMessage,
unsigned long ulTimeout)
{
DEVIO_PUTMESSAGECMD tBuffer;
unsigned int lBytesReturned;
short sRet = DRV_NO_ERROR;
// valid handle available, driver is open
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if( usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else {
// fill in parameter data
lBytesReturned = 0;
// set output buffer
tBuffer.usBoard = usDevNumber;
tBuffer.ulTimeout = ulTimeout;
memcpy( &tBuffer.tMsg, ptMessage, sizeof(MSG_STRUC));
tBuffer.sError = sRet;
// activate function
if( !ioctl( hDevDrv, CIF_IOCTLPUTMSG, (unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "CIF_IOCTLPUTMSG: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else
sRet = tBuffer.sError;
}
return sRet;
}
/* <ST> =================================================================================
Function: DevGetMessage
read a message from a DEV board
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
usSize - size of the users data area (>0..<= sizeof(MSG_STRUC))
ptMessage - pointer to the users data buffer
ulTimeout - function timeout in milliseconds
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevGetMessage( unsigned short usDevNumber,
unsigned short usSize,
MSG_STRUC *ptMessage,
unsigned long ulTimeout)
{
DEVIO_GETMESSAGECMD tBuffer;
unsigned int lBytesReturned;
short sRet = DRV_NO_ERROR;
// valid handle available, driver is open
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if( usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if(usSize == 0 ||
usSize > sizeof(MSG_STRUC)) {
sRet = DRV_USR_SIZE_INVALID;
} else {
// fill in parameter data
lBytesReturned = 0;
// set output buffer
tBuffer.usBoard = usDevNumber;
tBuffer.ulTimeout = ulTimeout;
tBuffer.sError = sRet;
// activate function
if( !ioctl( hDevDrv, CIF_IOCTLGETMSG,(unsigned long)(&tBuffer)) ) {
//fprintf(stderr, "CIF_IOCTLGETMSG: %s\n", strerror(errno));
sRet = DRV_USR_COMM_ERR;
} else {
memcpy( ptMessage, &tBuffer.tMsg, sizeof(MSG_STRUC));
sRet = tBuffer.sError;
}
}
return sRet;
}
/* ======================================================================================
DOWNLOAD part
=================================================================================== */
/* ------------------------------------------------------------------------------------ */
/* Locale variables */
/* ------------------------------------------------------------------------------------ */
#define MAX_DOWNLOAD_MSG_LENGTH 240
#define TO_COLDSTART 10000L
#define TO_SEND_MSG 500L
#define TO_1ST_MSG 10000L
#define TO_CONT_MSG 1000L
#define TO_LAST_MSG 15000L
// File data structure
typedef struct tagFILEDATA {
int fd;
//struct stat *Info;//struct _stat *Info;
char *pabBuffer;
int lSize;
} FILEDATA;
typedef struct tagDEVICE_TYPE_INFO {
unsigned char bHerstellerkennung;
unsigned char bDeviceType;
unsigned char bDeviceModel;
unsigned char bReserve3;
} DEVICE_TYPE_INFO;
/* <ST> =================================================================================
Function: CloseFile
Close a previously opened file by OpenFile(), free all memory and handles
---------------------------------------------------------------------------------------
Input : ptFile - File data structure
Output : -
Return : -
================================================================================= <En> */
void closeFile ( FILEDATA *ptFile)
{
if ( ptFile->fd >= 0) {
if ( ptFile->pabBuffer != NULL) {
free( ptFile->pabBuffer);
}
close( ptFile->fd);
// Clear file structure
memset ( ptFile, 0, sizeof(FILEDATA));
}
}
/* <ST> =================================================================================
Function: openFile
Open a file and load the file into memory
---------------------------------------------------------------------------------------
Input : pwFileName - Filename including a path
ptFile - File data structure
Output : -
Return : DRV_NO_ERROR - File successfully opened and loaded into memory
================================================================================= <En> */
short openFile ( const char *fileName, FILEDATA *ptFile)
{
unsigned int lNumberOfBytesRead;
short sRet = DRV_NO_ERROR;
// Clear file structure
memset ( ptFile, 0, sizeof(FILEDATA));
// open the existing file
ptFile->fd = open( fileName, O_RDONLY);
if ( ptFile->fd < 0 ) {
// File not opend
sRet = DRV_USR_FILE_OPEN_FAILED;
} else {
// Get the file size
ptFile->lSize = lseek( ptFile->fd, 0, SEEK_END);
if ( ptFile->lSize <= 0) {
// File size is zero
sRet = DRV_USR_FILE_SIZE_ZERO;
} else {
if( lseek( ptFile->fd, 0, SEEK_SET) < 0)
sRet = DRV_USR_FILE_READ_FAILED;
else {
// Allocate memory for file data
if ( (ptFile->pabBuffer = (char*)malloc( ptFile->lSize)) == NULL) {
// Error by memory allocation
sRet = DRV_USR_FILE_NO_MEMORY;
closeFile( ptFile);
} else {
// Read file data into memory
if ( ( lNumberOfBytesRead = read( ptFile->fd, // handle of file to read
ptFile->pabBuffer, // address of buffer that receives data
ptFile->lSize) ) < 0) { // number of bytes to read
// File read into memory failed
sRet = DRV_USR_FILE_READ_FAILED;
closeFile( ptFile);
}
}
}
}
}
return sRet;
}
//----------------------------------------------------------------------------------------
// Free receive mailbox
//----------------------------------------------------------------------------------------
short FreeRecvMailbox( unsigned short usDevNumber)
{
// Read all messages from the device
MSG_STRUC tRecvMsg;
unsigned short usDevState, usHostState, usIdx;
short sRet;
// Read until no msg available
usIdx = 0;
do {
if( (sRet = DevGetMBXState( usDevNumber,
&usDevState,
&usHostState)) != DRV_NO_ERROR) {
// Something wrong, end function
break;
} else {
// Check if message available
if( usHostState == HOST_MBX_FULL) {
// Read message and throw away
DevGetMessage(usDevNumber,
sizeof(MSG_STRUC),
&tRecvMsg,
100L);
} else {
break;
}
}
usIdx++;
} while( usIdx < 150); // A maximum of 150 times
return sRet;
}
//----------------------------------------------------------------------------------------
// Create checksum
//----------------------------------------------------------------------------------------
unsigned short CreateChecksum( unsigned char *pabData,
int lDataLen,
MSG_STRUC *ptSendMsg)
{
int lIdx, lTempLen;
unsigned short usCheckSum, usTemp;
unsigned char *pByte;
// Create length for checksum calculating
usCheckSum = 0; // Clear checksum
lTempLen = lDataLen - 16384 - 64;
pByte = &ptSendMsg->data[3];
// Calculate the Checksum, start with the first message Msg.d[3] up to Msg.d[64]
for ( lIdx = 0; lIdx < 31; lIdx++) {
usTemp = (*(pByte+1));
usTemp = (unsigned short)((usTemp << 8) | (*pByte));
usCheckSum = (unsigned short)(usCheckSum + usTemp);
pByte +=2; // Next short value
}
pByte = &pabData[64];
// Create cheksum for the rest of the file
do {
usTemp = (*(pByte+1));
usTemp = (unsigned short)((usTemp << 8) | (*pByte));
usCheckSum = (unsigned short)(usCheckSum + usTemp);
pByte += 2; // Next short value
lTempLen-=2;
} while (lTempLen > 0);
// Return
return usCheckSum;
}
//----------------------------------------------------------------------------------------
// Transfer messages
//----------------------------------------------------------------------------------------
short TransferMessage( unsigned short usDevNumber,
MSG_STRUC *ptSendMsg,
MSG_STRUC *ptRecvMsg,
long lTimeout)
{
int lCount = 0;
short sRet = DRV_NO_ERROR;
if( (sRet = DevPutMessage(usDevNumber,
ptSendMsg,
TO_SEND_MSG)) == DRV_NO_ERROR) {
do {
if( (sRet = DevGetMessage(usDevNumber,
sizeof(MSG_STRUC),
ptRecvMsg,
lTimeout)) == DRV_NO_ERROR) {
// Check on message errors
if( (ptRecvMsg->tx == ptSendMsg->rx) &&
(ptRecvMsg->rx == ptSendMsg->tx) &&
(ptRecvMsg->a == ptSendMsg->b) &&
(ptRecvMsg->b == 0) &&
(ptRecvMsg->nr == ptSendMsg->nr) ) {
// Check on message error
if( ptRecvMsg->f != 0) {
sRet = (short)(ptRecvMsg->f + DRV_RCS_ERROR_OFFSET);
break;
} else {
break;
}
}
}
// else
lCount++;
} while( lCount < 10);
}
return sRet;
}
//----------------------------------------------------------------------------------------
// Read device information
//----------------------------------------------------------------------------------------
short ReadDeviceInformation( unsigned short usDevNumber,
const char *fileName)
{
int dwStrLen;
short sRet;
MSG_STRUC tSendMsg, tRecvMsg;
DEVICE_TYPE_INFO *pInfo;
memset( &tSendMsg, 0, sizeof( MSG_STRUC));
memset( &tRecvMsg, 0, sizeof( MSG_STRUC));
if ( (sRet = FreeRecvMailbox( usDevNumber)) == DRV_NO_ERROR) {
// Insert data into message
tSendMsg.rx = RCS_TASK;
tSendMsg.tx = MSG_SYSTEM_TX;
tSendMsg.ln = 1;
tSendMsg.nr = 0;
tSendMsg.a = 0;
tSendMsg.f = 0;
tSendMsg.b = RCS_B_SYSFKT;
tSendMsg.e = 0;
// Insert data
tSendMsg.data[0] = MODE_GET_PROJ_WERTE_HW;
if ( (sRet = TransferMessage ( usDevNumber,
&tSendMsg,
&tRecvMsg,
TO_SEND_MSG)) == DRV_NO_ERROR) {
// Check entry
dwStrLen = strlen( fileName);
pInfo = (DEVICE_TYPE_INFO*)&tRecvMsg.data[0];
if ( (pInfo->bHerstellerkennung != (char)(toupper( fileName[dwStrLen-3]))) ||
(pInfo->bDeviceType != (char)(toupper( fileName[dwStrLen-2]))) ||
(pInfo->bDeviceModel != (char)(toupper( fileName[dwStrLen-1]))) ) {
sRet = DRV_USR_INVALID_FILETYPE;
}
}
}
return sRet;
}
/* <ST> =================================================================================
Function: RunFirmwareDownload
Download a firmware to a device
---------------------------------------------------------------------------------------
Input : usDevNumber - Device number
pwFile - File name including a path
*pdwBytes - Already loaded bytes
Output : -
Return : DRV_NO_ERROR - Download successfully
================================================================================= <En> */
short RunFirmwareDownload( unsigned short usDevNumber,
FILEDATA *ptFile,
unsigned long *pdwByte)
{
int lFileLength, lSendLen, lActIdx;
unsigned short usCheckSum, usTemp;
unsigned char *pabData;
MSG_STRUC tSendMsg, tRecvMsg;
BOOL fRet;
short sRet;
unsigned int dwState = RCS_FIRST_MSK;
// Load pointer to data
pabData = (unsigned char*)ptFile->pabBuffer;
lActIdx = 0; // Clear actual index
*pdwByte = lActIdx;
// Clear messages
memset( &tSendMsg, 0, sizeof(MSG_STRUC));
memset( &tRecvMsg, 0, sizeof(MSG_STRUC));
// Set data length
lFileLength = ptFile->lSize;
// Set maximum message length
if ( lFileLength > MAX_DOWNLOAD_MSG_LENGTH) lSendLen = MAX_DOWNLOAD_MSG_LENGTH;
else lSendLen = lFileLength;
// Set program state
dwState = RCS_FIRST_MSK;
fRet = TRUE;
// Run download
do {
switch ( dwState) {
//--------------------------
// Send first message
//--------------------------
case RCS_FIRST_MSK:
// Set HOST_READY for download, maybe it is disabled
sRet = DevSetHostState( usDevNumber,
HOST_READY,
0L);
// Insert data into message
tSendMsg.rx = RCS_TASK;
tSendMsg.tx = MSG_SYSTEM_TX;
tSendMsg.ln = 65;
tSendMsg.nr = 1;
tSendMsg.a = 0;
tSendMsg.f = 0;
tSendMsg.b = RCS_B_LOADFKT;
tSendMsg.e = RCS_FIRST_MSK;
// Insert data
tSendMsg.data[0] = 6;
memcpy( &tSendMsg.data[3], "RCSCODE", 7);
usTemp = (unsigned short)( lFileLength / 16);
tSendMsg.data[13] = (unsigned char)(usTemp & 0x00FF);
tSendMsg.data[14] = (unsigned char)((usTemp >> 8) & 0x00FF);
tSendMsg.data[15] = 6;
memcpy( &tSendMsg.data[17], "RCSCODE", 7);
tSendMsg.data[27] = 255;
tSendMsg.data[49] = 255;
// Create check sum
usCheckSum = CreateChecksum( pabData,
lFileLength,
&tSendMsg);
// Insert check sum
tSendMsg.data[1] = (unsigned char)(usCheckSum & 0x00FF);
tSendMsg.data[2] = (unsigned char)((usCheckSum >> 8) & 0x00FF);
// Process message
if ( (sRet = TransferMessage( usDevNumber,
&tSendMsg,
&tRecvMsg,
TO_1ST_MSG)) != DRV_NO_ERROR ) {
// Could not process this message
fRet = FALSE;
} else {
// ----------------------------
// Message send second message
// ----------------------------
// Save fimware length given in this RCS message
// Set download length to this size
lFileLength = *(int*)(&tRecvMsg.data[0]);
// Send next message
tSendMsg.rx = RCS_TASK;
tSendMsg.tx = MSG_SYSTEM_TX;
tSendMsg.ln = (unsigned char)lSendLen;
tSendMsg.nr = ++tSendMsg.nr;
tSendMsg.a = 0;
tSendMsg.f = 0;
tSendMsg.b = RCS_B_LOADFKT;
tSendMsg.e = RCS_CONT_MSK;
// Set byte 0 to 63 to byte 1 to 65 of the 1st message
memcpy ( &tSendMsg.data[0], &tSendMsg.data[1], 64);
// Insert byte 64 to 239 from the abData[64]
memcpy ( &tSendMsg.data[64], &pabData[64], (unsigned char)(lSendLen - 64));
// Process message
if ( (sRet = TransferMessage( usDevNumber,
&tSendMsg,
&tRecvMsg,
TO_1ST_MSG)) != DRV_NO_ERROR ) {
// Could not process this message
fRet = FALSE;
} else {
// No error, send next message
lActIdx += lSendLen; // Add send size to actual index
*pdwByte = lActIdx;
// Calculate next message length
if ( lFileLength <= (lSendLen + lActIdx)) {
lSendLen = lFileLength - lActIdx; // Set length to rest of data
dwState = RCS_LAST_MSK;
} else {
dwState = RCS_CONT_MSK;
}
}
}
break;
//--------------------------
// Send continue message
//--------------------------
case RCS_CONT_MSK:
tSendMsg.e = RCS_CONT_MSK;
tSendMsg.ln = (unsigned char)lSendLen;
tSendMsg.nr = ++tSendMsg.nr;
// Send next message
memcpy ( &tSendMsg.data[0], &pabData[lActIdx], lSendLen);
// Process message
if ( (sRet = TransferMessage( usDevNumber,
&tSendMsg,
&tRecvMsg,
TO_CONT_MSG)) != DRV_NO_ERROR ) {
// Could not process this message
fRet = FALSE;
} else {
//printf("(A)===========================flen = %ld, Sndlen = %ld, ActIdx = %ld\n", lFileLength, lSendLen, lActIdx);
// No error, send next message
lActIdx += lSendLen; // Add send size to actual index
*pdwByte = lActIdx;
// Calculate next message length
if ( lFileLength <= (lSendLen + lActIdx)) {
lSendLen = lFileLength - lActIdx; // Set length to rest of data
dwState = RCS_LAST_MSK;
} else {
dwState = RCS_CONT_MSK;
}
}
break;
//--------------------------
// Send last message
//--------------------------
case RCS_LAST_MSK:
tSendMsg.ln = (unsigned char)lSendLen;
tSendMsg.nr = ++tSendMsg.nr;
tSendMsg.e = RCS_LAST_MSK;
memcpy ( &tSendMsg.data[0], &pabData[lActIdx] , lSendLen);
// Process message
sRet = TransferMessage( usDevNumber,
&tSendMsg,
&tRecvMsg,
TO_LAST_MSG);
*pdwByte = (lActIdx + lSendLen);
fRet = FALSE; // END after last message
break;
default:
// unkonwn, leave command
sRet = DRV_DEV_FUNCTION_FAILED;
fRet = FALSE;
break;
}
} while ( fRet == TRUE);
return sRet;
}
/* <ST> =================================================================================
Function: RunConfigDownload
Download a configuration to a device
---------------------------------------------------------------------------------------
Input : usDevNumber - Device number
pwFile - File name including a path
*pdwBytes - Already loaded bytes
Output : -
Return : DRV_NO_ERROR - Download successfully
================================================================================= <En> */
short RunConfigDownload( unsigned short usDevNumber,
FILEDATA *ptFile,
unsigned long *pdwByte)
{
unsigned int dwState;
int lSendLen, lActIdx, lOffset, lFileLength;
unsigned char *pabData;
MSG_STRUC tSendMsg, tRecvMsg;
BOOL fRet;
short sRet = DRV_NO_ERROR;
unsigned char ab1StMsgBuf1[16];
unsigned char ab1StMsgBuf2[60];
// Load pointer to data
pabData = (unsigned char*)ptFile->pabBuffer;
// Clear messages
memset( &tSendMsg, 0, sizeof(MSG_STRUC));
memset( &tRecvMsg, 0, sizeof(MSG_STRUC));
// Craete 1st data buffer from DBM file
memcpy( &ab1StMsgBuf1[0], &pabData[44], 16);
// Craete 2nd data buffer from DBM file
lOffset = (*((int*)(&pabData[40]))) + ((*((short*)(&pabData[60]))) * 2) + 14 ;
lOffset = (*(int*)(&pabData[40])) + ((*(short*)(&pabData[lOffset])) *2) + 12 ;
memcpy( &ab1StMsgBuf2[0], &pabData[lOffset], sizeof(ab1StMsgBuf2));
// Set data length
lFileLength = ptFile->lSize;
// Set maximum message length
if ( lFileLength > MAX_DOWNLOAD_MSG_LENGTH) lSendLen = MAX_DOWNLOAD_MSG_LENGTH;
else lSendLen = lFileLength;
lActIdx = 0;
*pdwByte = lActIdx;
// Set program state
dwState = RCS_FIRST_MSK;
fRet = TRUE;
do {
switch( dwState) {
//--------------------------
// Send first message
//--------------------------
case RCS_FIRST_MSK: // Send first message
// Set HOST_READY for download, maybe it is disabled
sRet = DevSetHostState( usDevNumber, HOST_READY, 0L);
// Insert data into message
tSendMsg.rx = RCS_TASK; // Receiver task number
tSendMsg.tx = MSG_SYSTEM_TX; // Transmitter task number
tSendMsg.ln = 51; // Message length first message
tSendMsg.nr = 1; // Message number
tSendMsg.a = 0; // Answer byte cleared
tSendMsg.f = 0; // Error byte cleared
tSendMsg.b = RCS_B_LOADFKT; // Function code
tSendMsg.e = RCS_FIRST_MSK; // First message
tSendMsg.data[0] = MODE_DOWNLOAD_DBM; // Download a configuration file
// Copy buffer 1st to message
memcpy ( &tSendMsg.data[1], &ab1StMsgBuf1[0], sizeof(ab1StMsgBuf1));
// Copy buffer 2nd to message, 34 Byte
memcpy ( &tSendMsg.data[17], &ab1StMsgBuf2[0], 34);
//printf("cifAPI: %ld\n", dwState);
// Process message
if ( (sRet = TransferMessage( usDevNumber,
&tSendMsg,
&tRecvMsg,
TO_1ST_MSG)) != DRV_NO_ERROR ) {
// Could not process this message
fRet = FALSE;
} else {
// Set Index for next message, start at offset 44
lActIdx = 44;
*pdwByte = lActIdx;
// Message send, goto next message
*pdwByte = lFileLength;
dwState = RCS_CONT_MSK;
}
break;
//--------------------------
// Send continue message
//--------------------------
case RCS_CONT_MSK:
//printf("cifAPI: (case RCS_CONT_MSK:) %ld\n", lActIdx);
// Insert data into message
tSendMsg.rx = RCS_TASK;
tSendMsg.tx = MSG_SYSTEM_TX;
tSendMsg.ln = (unsigned char)lSendLen;
tSendMsg.nr = ++tSendMsg.nr;
tSendMsg.a = 0;
tSendMsg.f = 0;
tSendMsg.b = RCS_B_LOADFKT;
tSendMsg.e = RCS_CONT_MSK;
memcpy ( &tSendMsg.data[0], &pabData[lActIdx] , lSendLen);
// Process message
if ( (sRet = TransferMessage( usDevNumber,
&tSendMsg,
&tRecvMsg,
TO_CONT_MSG)) != DRV_NO_ERROR ) {
// Could not process this message
fRet = FALSE;
} else {
// No error, send next message
lActIdx += lSendLen; // Add send size to actual index
*pdwByte = lActIdx;
// Calculate next message length
if ( lFileLength <= (lSendLen + lActIdx)) {
lSendLen = lFileLength - lActIdx; // Set length to rest of data
dwState = RCS_LAST_MSK; // Set to last mask
} else {
// Continue message
dwState = RCS_CONT_MSK;
}
}
break;
//--------------------------
// Send last message
//--------------------------
case RCS_LAST_MSK:
// Insert message data
tSendMsg.rx = RCS_TASK;
tSendMsg.tx = MSG_SYSTEM_TX;
tSendMsg.ln = (unsigned char)lSendLen;
tSendMsg.nr = ++tSendMsg.nr;
tSendMsg.a = 0;
tSendMsg.f = 0;
tSendMsg.b = RCS_B_LOADFKT;
tSendMsg.e = RCS_LAST_MSK;
memcpy ( &tSendMsg.data[0], &pabData[lActIdx] , lSendLen);
// Process message
sRet = TransferMessage( usDevNumber,
&tSendMsg,
&tRecvMsg,
TO_LAST_MSG);
*pdwByte = (lActIdx + lSendLen);
fRet = FALSE; // END after last message
break;
default:
// unkonwn, leave command
sRet = DRV_DEV_FUNCTION_FAILED;
fRet = FALSE;
break;
}
} while (fRet == TRUE);
return sRet;
}
/* <ST> =================================================================================
Function: FirmwareDownload
Download a firmware file to a device
---------------------------------------------------------------------------------------
Input : usDevNumber - Device number
pwFile - File name including a path
*pdwBytes - Already loaded bytes
Output : -
Return : DRV_NO_ERROR - Download successfully
================================================================================= <En> */
short FirmwareDownload ( unsigned short usDevNumber,
const char *fileName,
unsigned long *pdwByte)
{
short sRet = DRV_NO_ERROR;
FILEDATA tFileData;
// Read Device Information
if ( (sRet = ReadDeviceInformation( usDevNumber, fileName)) == DRV_NO_ERROR) {
// Firmware name is OK
if ( (sRet = openFile ( fileName, &tFileData)) == DRV_NO_ERROR) {
// Firmware file opened and loaded into RAM
sRet = RunFirmwareDownload( usDevNumber, &tFileData, pdwByte);
closeFile ( &tFileData);
}
}
return sRet;
}
/* <ST> =================================================================================
Function: ConfigDownload
Download a configuration file created by SyCon to a device
---------------------------------------------------------------------------------------
Input : usDevNumber - Device number
pwFile - File name including a path
*pdwBytes - Already loaded bytes
Output : -
Return : DRV_NO_ERROR - Download successfully
================================================================================= <En> */
short ConfigDownload( unsigned short usDevNumber,
const char *fileName,
unsigned long *pdwByte)
{
unsigned short sRet = DRV_NO_ERROR;
FILEDATA tFileData;
if ( (sRet = openFile ( fileName, &tFileData)) == DRV_NO_ERROR) {
// Configuration file opened and loaded into RAM
sRet = RunConfigDownload( usDevNumber, &tFileData, pdwByte);
closeFile ( &tFileData);
}
return sRet;
}
/* <ST> =================================================================================
Function: DevDownload
Download a firmware or configuration file
---------------------------------------------------------------------------------------
Input : usDevNumber - number of the DEV board (0..3)
usMode - 1 = FIRMWARE_DOWNLOAD, 2 = CONFIGURATION_DOWNLOAD
*pdwBytes - Amount of bytes sended
Output : -
Return : DRV_NO_ERROR - function successfull
!= DRV_NO_ERROR - function failed
================================================================================= <En> */
short DevDownload( unsigned short usDevNumber,
unsigned short usMode,
unsigned char *pszFileName,
unsigned long *pdwBytes)
{
short sRet = DRV_NO_ERROR;
// valid handle available, driver is open
if( hDevDrv == INVALID_HANDLE_VALUE) {
sRet = DRV_USR_NOT_INITIALIZED;
} else if( usDevNumber >= MAX_DEV_BOARDS) {
sRet = DRV_USR_DEV_NUMBER_INVALID;
} else if( (pdwBytes == NULL) ||
(pszFileName == NULL) ||
(pdwBytes == NULL) ) {
sRet = DRV_USR_BUF_PTR_NULL;
} else if( strlen( (const char*)pszFileName) == 0) {
sRet = DRV_USR_FILENAME_INVALID;
} else {
switch( usMode) {
case FIRMWARE_DOWNLOAD:
sRet = FirmwareDownload( usDevNumber,
(const char*)pszFileName,
pdwBytes);
break;
case CONFIGURATION_DOWNLOAD:
sRet = ConfigDownload( usDevNumber,
(const char*)pszFileName,
pdwBytes);
break;
default:
sRet = DRV_USR_MODE_INVALID;
} // end switch
}
return sRet;
}
/* <St> *******************************************************************
======================== Copyright =====================================
Copyright (C) 2004 Hilscher GmbH
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the program, if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
========================================================================
cifdev_i.h
-------------------------------------------------------------------------
CREATETED : D. Tsaava, Hilscher GmbH
DATE : 18.07.2000
PROJEKT : CIF device driver
=========================================================================
DISCRIPTION
Internal driver interface definition
=========================================================================
CHANGES
version name date Discription
March 2001
Juli 2004 Redesigned for the 2.6 Kernel
Copyright changed to GNU Lesser GPL
-------------------------------------------------------------------------
V2.602
NOTE: as groundwork for this header served Windows version of
the CIF device driver
******************************************************************** <En> */
#ifndef CIFDEV_I_H
# define CIFDEV_I_H
#ifdef _cplusplus
extern "C" {
#endif /* _cplusplus */
/* ------------------------------------------------------------------------------------ */
/* global definitions */
/* ------------------------------------------------------------------------------------ */
#define MAX_DEV_BOARDS 4 // maximum numbers of boards
/* ------------------------------------------------------------------------------------ */
/* driver errors */
/* ------------------------------------------------------------------------------------ */
#define DRV_NO_ERROR 0 // no error
#define DRV_BOARD_NOT_INITIALIZED -1 // DRIVER board not initialized
#define DRV_INIT_STATE_ERROR -2 // DRIVER error in internal init state
#define DRV_READ_STATE_ERROR -3 // DRIVER error in internal read state
#define DRV_CMD_ACTIVE -4 // DRIVER command on this chanal is activ
#define DRV_PARAMETER_UNKNOWN -5 // DRIVER unknown parameter in function occured
#define DRV_WRONG_DRIVER_VERSION -6 // DRIVER driver version is incompatible with DLL
#define DRV_PCI_SET_CONFIG_MODE -7 // DRIVER error during PCI set config mode
#define DRV_PCI_READ_DPM_LENGTH -8 // DRIVER could not read PCI DPM length
#define DRV_PCI_SET_RUN_MODE -9 // DRIVER error during PCI set run mode
#define DRV_DEV_DPM_ACCESS_ERROR -10 // DEVICE dual port ram not accessable
#define DRV_DEV_NOT_READY -11 // DEVICE not ready (ready flag failed)
#define DRV_DEV_NOT_RUNNING -12 // DEVICE not running (running flag failed)
#define DRV_DEV_WATCHDOG_FAILED -13 // DEVICE watch dog test failed
#define DRV_DEV_OS_VERSION_ERROR -14 // DEVICE signals wrong OS version
#define DRV_DEV_SYSERR -15 // DEVICE error in dual port flags
#define DRV_DEV_MAILBOX_FULL -16 // DEVICE send mailbox is full
#define DRV_DEV_PUT_TIMEOUT -17 // DEVICE PutMessage timeout
#define DRV_DEV_GET_TIMEOUT -18 // DEVICE GetMessage timeout
#define DRV_DEV_GET_NO_MESSAGE -19 // DEVICE no message available
#define DRV_DEV_RESET_TIMEOUT -20 // DEVICE RESET command timeout
#define DRV_DEV_NO_COM_FLAG -21 // DEVICE COM-flag not set
#define DRV_DEV_EXCHANGE_FAILED -22 // DEVICE IO data exchange failed
#define DRV_DEV_EXCHANGE_TIMEOUT -23 // DEVICE IO data exchange timeout
#define DRV_DEV_COM_MODE_UNKNOWN -24 // DEVICE IO data mode unknown
#define DRV_DEV_FUNCTION_FAILED -25 // DEVICE Function call failed
#define DRV_DEV_DPMSIZE_MISMATCH -26 // DEVICE DPM size differs from configuration
#define DRV_DEV_STATE_MODE_UNKNOWN -27 // DEVICE State mode unknown
// Error from Interface functions
#define DRV_USR_OPEN_ERROR -30 // USER driver not opened
#define DRV_USR_INIT_DRV_ERROR -31 // USER can't connect with DEV board
#define DRV_USR_NOT_INITIALIZED -32 // USER board not initialized
#define DRV_USR_COMM_ERR -33 // USER IOCTRL function faild
#define DRV_USR_DEV_NUMBER_INVALID -34 // USER parameter for DEV number invalid
#define DRV_USR_INFO_AREA_INVALID -35 // USER parameter InfoArea unknown
#define DRV_USR_NUMBER_INVALID -36 // USER parameter Number invalid
#define DRV_USR_MODE_INVALID -37 // USER parameter Mode invalid
#define DRV_USR_MSG_BUF_NULL_PTR -38 // USER NULL pointer assignment
#define DRV_USR_MSG_BUF_TOO_SHORT -39 // USER Messagebuffer too short
#define DRV_USR_SIZE_INVALID -40 // USER size parameter invalid
#define DRV_USR_SIZE_ZERO -42 // USER size parameter with zero length
#define DRV_USR_SIZE_TOO_LONG -43 // USER size parameter too long
#define DRV_USR_DEV_PTR_NULL -44 // USER device address null pointer
#define DRV_USR_BUF_PTR_NULL -45 // USER pointer to buffer is a null pointer
#define DRV_USR_SENDSIZE_TOO_LONG -46 // USER SendSize parameter too long
#define DRV_USR_RECVSIZE_TOO_LONG -47 // USER ReceiveSize parameter too long
#define DRV_USR_SENDBUF_PTR_NULL -48 // USER pointer to buffer is a null pointer
#define DRV_USR_RECVBUF_PTR_NULL -49 // USER pointer to buffer is a null pointer
#define DRV_DEV_NO_VIRTUAL_MEM -60 // DEVICE Virtual memory not available
#define DRV_DEV_UNMAP_VIRTUAL_MEM -61 // DEVICE Unmap virtual memory failed
#define DRV_DEV_REQUEST_IRQ_FAILED -62 // DEVICE Request irq failed
#define DRV_USR_FILE_OPEN_FAILED -100 // USER file not opend
#define DRV_USR_FILE_SIZE_ZERO -101 // USER file size zero
#define DRV_USR_FILE_NO_MEMORY -102 // USER not enough memory to load file
#define DRV_USR_FILE_READ_FAILED -103 // USER file read failed
#define DRV_USR_INVALID_FILETYPE -104 // USER file type invalid
#define DRV_USR_FILENAME_INVALID -105 // USER file name not valid
#define DRV_RCS_ERROR_OFFSET 1000 // RCS error number start
/* ------------------------------------------------------------------------------------ */
/* message definition */
/* ------------------------------------------------------------------------------------ */
#ifndef PACKED
# define PACKED __attribute__( (aligned(1)))
#endif /* PACKED */
// max. length is 255 + 8 Bytes
typedef struct tagMSG_STRUC {
unsigned char rx PACKED;
unsigned char tx PACKED;
unsigned char ln PACKED;
unsigned char nr PACKED;
unsigned char a PACKED;
unsigned char f PACKED;
unsigned char b PACKED;
unsigned char e PACKED;
unsigned char data[255] PACKED;
unsigned char dummy[25] PACKED;
} MSG_STRUC;
/* ------------------------------------------------------------------------------------ */
/* DEV DPM DATA structures */
/* ------------------------------------------------------------------------------------ */
typedef struct tagIOINFO {
unsigned char bComBit PACKED;
unsigned char bIOExchangeMode PACKED;
unsigned int ulIOExchangeCnt PACKED;
} IOINFO;
typedef struct tagVERSIONINFO { /* DEV serial number and OS versions */
unsigned int ulDate PACKED PACKED;
unsigned int ulDeviceNo PACKED;
unsigned int ulSerialNo PACKED;
unsigned int ulReserved PACKED;
unsigned char PcOsName0[4] PACKED;
unsigned char PcOsName1[4] PACKED;
unsigned char PcOsName2[4] PACKED;
unsigned char OemIdentifier[4] PACKED;
} VERSIONINFO;
typedef struct tagFIRMWAREINFO {
unsigned char FirmwareName[16] PACKED;
unsigned char FirmwareVersion[16] PACKED;
} FIRMWAREINFO;
typedef struct tagTASKSTATE {
unsigned char TaskState[64] PACKED;
} TASKSTATE;
typedef struct tagTASKPARAM {
unsigned char TaskParameter[64] PACKED;
} TASKPARAM;
typedef struct tagRAWDATA {
unsigned char abRawData[1022] PACKED;
} RAWDATA;
typedef struct tagTASKINFO {
struct {
char TaskName[8] PACKED; /* Task name */
unsigned short Version PACKED; /* Task version */
unsigned char TaskCondition PACKED;
unsigned char reserved[5] PACKED; /* n.c. */
} tInfo [7];
} TASKINFO;
typedef struct tagRCSINFO {
unsigned short RcsVersion PACKED; /* Operationsystem Version */
unsigned char RcsError PACKED;
unsigned char HostWatchDog PACKED;
unsigned char DevWatchDog PACKED;
unsigned char SegmentCount PACKED;
unsigned char DeviceAdress PACKED;
unsigned char DriverType PACKED;
} RCSINFO;
typedef struct tagDEVINFO {
unsigned char DpmSize PACKED;
unsigned char DevType PACKED;
unsigned char DevModel PACKED;
unsigned char DevIdentifier[3] PACKED;
} DEVINFO;
/* ------------------------------------------------------------------------------------ */
/* driver info structure definitions */
/* ------------------------------------------------------------------------------------ */
// Board information structure
typedef struct tagBOARD_INFO{
unsigned char abDriverVersion[16] PACKED; // DRV driver information string
struct {
unsigned short usBoard PACKED; // DRV board number
unsigned short usAvailable PACKED; // DRV board is available
unsigned long ulPhysicalAddress PACKED; // DRV physical DPM address
unsigned short usIrq PACKED; // DRV irq number
} tBoard [MAX_DEV_BOARDS];
unsigned short usBoards_detected PACKED;
} BOARD_INFO;
// Driver information structure
typedef struct tagDRIVERINFO{
unsigned long OpenCnt PACKED; // number of driver open
unsigned long CloseCnt PACKED; // number of driver close
unsigned long ReadCnt PACKED; // number of DevGetMessage commands
unsigned long WriteCnt PACKED; // number of DevPutMessage commands
unsigned long IRQCnt PACKED; // number of IRQs
unsigned char InitMsgFlag PACKED; // DPM state init
unsigned char ReadMsgFlag PACKED; // DPM state read message
unsigned char WriteMsgFlag PACKED; // DPM state write message
unsigned char LastFunction PACKED; // DRV last function in driver
unsigned char WriteState PACKED; // DRV actual write state
unsigned char ReadState PACKED; // DRV actual read state
unsigned char HostFlags PACKED; // DPM HostFlags (PcFlags)
unsigned char MyDevFlags PACKED; // DPM (internal) DevFlags
unsigned char ExComBit PACKED; // COM bit
unsigned long ExIOCnt PACKED; // IO data exchange count
} DRIVERINFO;
// Extended board information structure
typedef struct tagBOARD_INFOEX{
unsigned char abDriverVersion[16] PACKED; // DRV driver information string
struct {
unsigned short usBoard PACKED; // DRV board number
unsigned short usAvailable PACKED; // DRV board is available
unsigned long ulPhysicalAddress PACKED; // DRV physical DPM address
unsigned short usIrq PACKED; // DRV irq number
DRIVERINFO tDriverInfo PACKED; // Driver information
FIRMWAREINFO tFirmware PACKED;
DEVINFO tDeviceInfo PACKED;
RCSINFO tRcsInfo PACKED;
VERSIONINFO tVersion PACKED;
} tBoard [MAX_DEV_BOARDS];
} BOARD_INFOEX;
// State field structure
typedef struct tagCOMSTATE {
unsigned short usMode PACKED; // Actual STATE mode
unsigned short usStateFlag PACKED; // State flag
unsigned char abState[64] PACKED; // State area
} COMSTATE;
// state information in bLastFunction
#define FKT_OPEN 1;
#define FKT_CLOSE 2;
#define FKT_READ 3;
#define FKT_WRITE 4;
#define FKT_IO 5;
// state information in bWriteState and bReadState
#define STATE_IN 0x01;
#define STATE_WAIT 0x02;
#define STATE_OUT 0x03;
#define STATE_IN_IRQ 0x04;
/* ------------------------------------------------------------------------------------ */
/* IOCTRL data structures */
/* ------------------------------------------------------------------------------------ */
// IOCTRL funktion defines, always step 8
/*
* Ioctl definitions
*/
/* Use 'c' as magic number */
#define CIF_IOC_MAGIC 'c'
#define CIF_IOCRESET _IO(CIF_IOC_MAGIC, 0)
#define CIF_IOCTLNOFUNCTION _IO (CIF_IOC_MAGIC, 0)
#define CIF_IOCTLBOARDINFO _IOWR(CIF_IOC_MAGIC, 1, char[256])
#define CIF_IOCTLINITDRV _IOWR(CIF_IOC_MAGIC, 2, char[13])
#define CIF_IOCTLPARAMETER _IOW (CIF_IOC_MAGIC, 3, char[71])
#define CIF_IOCTLRESETDEV _IOW (CIF_IOC_MAGIC, 4, char[13])
#define CIF_IOCTLPUTMSG _IO (CIF_IOC_MAGIC, 5)
#define CIF_IOCTLGETMSG _IO (CIF_IOC_MAGIC, 6)
#define CIF_IOCTLTASKSTATE _IO (CIF_IOC_MAGIC, 7)
#define CIF_IOCTLMBXINFO _IO (CIF_IOC_MAGIC, 8)
#define CIF_IOCTLTRIGGERWD _IO (CIF_IOC_MAGIC, 9)
#define CIF_IOCTLGETINFO _IO (CIF_IOC_MAGIC, 10)
#define CIF_IOCTLEXITDRV _IO (CIF_IOC_MAGIC, 11)
#define CIF_IOCTLGETPARAMETER _IO (CIF_IOC_MAGIC, 12)
#define CIF_IOCTLEXIO _IO (CIF_IOC_MAGIC, 13)
#define CIF_IOCTLSETHOST _IO (CIF_IOC_MAGIC, 14)
#define CIF_IOCTLREADSEND _IO (CIF_IOC_MAGIC, 15)
#define CIF_IOCTLEXTDATA _IO (CIF_IOC_MAGIC, 16)
#define CIF_IOCTLGETMBX _IO (CIF_IOC_MAGIC, 17)
#define CIF_IOCTLBOARDINFOEX _IO (CIF_IOC_MAGIC, 18)
#define CIF_IOCTLEXIOEX _IO (CIF_IOC_MAGIC, 19)
#define CIF_IOCTLEXIOERR _IO (CIF_IOC_MAGIC, 20)
#define CIF_IOCTLRWRAW _IO (CIF_IOC_MAGIC, 21)
#define CIF_IOCTLSPCONTROL _IO (CIF_IOC_MAGIC, 22)
#define CIF_IOCTLGETDPMPTR _IO (CIF_IOC_MAGIC, 23)
#define CIF_IOCTLRWDPMDATA _IO (CIF_IOC_MAGIC, 24)
#define CIF_IOCTL_IRQ_POLL _IOWR(CIF_IOC_MAGIC, 25, char[13])
#define CIF_IOC_MAXNR 25
// interface structure for ioctl's
typedef struct cif_ioctl_data {
unsigned long lInpBuffLen PACKED;
unsigned long lOutBuffLen PACKED;
unsigned char *pInpBuff PACKED;
unsigned char *pOutBuff PACKED;
} cif_ioctl_data;
// SET BOARD OPERATION MODE
typedef struct tagDEVIO_SETOPMODE {
unsigned short usBoard PACKED;
unsigned short usMode PACKED; // Interrupt/polling mode
unsigned short usIrq PACKED;
short sError PACKED;
} DEVIO_SETOPMODE;
// GETBOARDINFORMATION
typedef struct tagDEVIO_GETBOARDINFOCMD {
unsigned short usDevNumber PACKED; // n.a.
unsigned short usInfoLen PACKED; // Information length
BOARD_INFO *ptBoardInfo PACKED;
short sError PACKED;
} DEVIO_GETBOARDINFOCMD;
// Extnded GETBOARDINFORMATION
typedef struct tagDEVIO_GETBOARDINFOEXCMD {
unsigned short usDevNumber PACKED; // n.a.
unsigned short usInfoLen PACKED; // Information length
BOARD_INFOEX * ptBoard PACKED;
short sError PACKED;
} DEVIO_GETBOARDINFOEXCMD;
// RESETDEV
#define COLDSTART 2
#define WARMSTART 3
#define BOOTSTART 4
typedef struct tagDEVIO_RESETCMD {
unsigned short usBoard PACKED; // DEV board number
unsigned short usMode PACKED; // DEV function
unsigned long ulTimeout PACKED; // Service timeout
unsigned long ulDpmSize PACKED;
short sError PACKED;
} DEVIO_RESETCMD;
// PUTTASKPARAMETER
typedef struct tagDEVIO_PUTPARAMETERCMD {
unsigned short usBoard PACKED; // DEV board number
unsigned short usTaskParamNum PACKED; // Number of the parameter area
unsigned short usTaskParamLen PACKED; // Lenght of parameter data
unsigned char TaskParameter[64] PACKED;
short sError PACKED;
} DEVIO_PUTPARAMETERCMD;
// PUTMESSAGE
typedef struct tagDEVIO_PUTMESSAGECMD {
unsigned short usBoard PACKED; // DEV board number
MSG_STRUC tMsg PACKED; // Message data
unsigned long ulTimeout PACKED; // Service timeout
short sError PACKED;
} DEVIO_PUTMESSAGECMD;
// GETMESSAGE
typedef struct tagDEVIO_GETMESSAGECMD {
unsigned short usBoard PACKED; // DEV board number
unsigned long ulTimeout PACKED; // Service timeout
unsigned long ulMsgSize PACKED; // User message buffer size
MSG_STRUC tMsg PACKED; // Message data
short sError PACKED;
} DEVIO_GETMESSAGECMD;
// GETTASKSTATE
typedef struct tagDEVIO_GETTASKSTATECMD {
unsigned char ucBoard PACKED; // DEV board number
unsigned short usStateNum PACKED; // Task state field number
unsigned short usStateLen PACKED; // Lenght of state data
unsigned char TaskState[64] PACKED;
short sError PACKED;
} DEVIO_GETTASKSTATECMD;
// DEVMBXINFO
#define DEVICE_MBX_EMPTY 0
#define DEVICE_MBX_FULL 1
#define HOST_MBX_EMPTY 0
#define HOST_MBX_FULL 1
#define HOST_MBX_SYSERR 2
typedef struct tagDEVIO_MBXINFOCMD {
unsigned char ucBoard PACKED; // DEV board number
unsigned short usDevMbxState PACKED; // State of the device mailbox
unsigned short usHostMbxState PACKED; // State of the host mailbox
short sError PACKED;
} DEVIO_MBXINFOCMD;
// Board operation mode
#define POLLING_MODE 0
#define INTERRUPT_MODE 1
// TRIGGERWATCHDOG and SETHOSTSTATE
#define WATCHDOG_STOP 0
#define WATCHDOG_START 1
#define HOST_NOT_READY 0
#define HOST_READY 1
#define SPECIAL_CONTROL_CLEAR 0
#define SPECIAL_CONTROL_SET 1
typedef struct tagDEVIO_TRIGGERCMD {
unsigned short usBoard PACKED; // DEV board number
unsigned short usMode PACKED; // DEV function
unsigned long ulTimeout PACKED; // DEV timeout
unsigned short usTriggerValue PACKED; // DEV trigger value
short sError PACKED;
} DEVIO_TRIGGERCMD;
// GETINFO
// InfoArea definitions
#define GET_DRIVER_INFO 1
#define GET_VERSION_INFO 2
#define GET_FIRMWARE_INFO 3
#define GET_TASK_INFO 4
#define GET_RCS_INFO 5
#define GET_DEV_INFO 6
#define GET_IO_INFO 7
#define GET_IO_SEND_DATA 8
typedef struct tagDEVIO_GETDEVINFOCMD {
unsigned short usBoard PACKED; // DEV board number
unsigned short usInfoArea PACKED; // Number of info area
unsigned short usInfoLen PACKED; // Lenght of info data
unsigned char * pabInfoData PACKED; // Pointer to info data area
short sError PACKED;
} DEVIO_GETDEVINFOCMD;
// EXITDRV
typedef struct tagDEVIO_EXITCMD {
unsigned short usBoard PACKED; // DEV board number
unsigned short usDrvOpenCount PACKED; // dr�er opencount
short sError PACKED;
} DEVIO_EXITCMD;
// GETTASKPARAMETER
typedef struct tagDEVIO_GETPARAMETERCMD {
unsigned short usBoard PACKED; // DEV board number
unsigned short usTaskParamNum PACKED; // Number of the parameter area
unsigned short usTaskParamLen PACKED; // Lenght of parameter data
unsigned char TaskParameter[64] PACKED;
short sError PACKED;
} DEVIO_GETPARAMETERCMD;
// EXIO
typedef struct tagDEVIO_EXIOCMD {
unsigned short usBoard PACKED; // DEV board number
unsigned short usSendOffset PACKED; // Byte offset send data
unsigned short usSendLen PACKED; // Length of send data
unsigned char *pabSendData PACKED; // Send data buffer
unsigned short usReceiveOffset PACKED; // Byte offset receive data
unsigned short usReceiveLen PACKED; // Length of receive data
unsigned char *pabReceiveData PACKED; // Receive data buffer
unsigned long ulTimeout PACKED; // Service timeout
short sError PACKED;
} DEVIO_EXIOCMD;
// EXIOEX
typedef struct tagDEVIO_EXIOCMDEX {
unsigned short usBoard PACKED; // DEV board number
unsigned short usSendOffset PACKED; // Byte offset send data
unsigned short usSendLen PACKED; // Length of send data
unsigned char * pabSendData PACKED; // Send data buffer
unsigned short usReceiveOffset PACKED; // Byte offset receive data
unsigned short usReceiveLen PACKED; // Length of receive data
unsigned char * pabReceiveData PACKED; // Receive data buffer
unsigned long ulTimeout PACKED; // Service timeout
short sError PACKED; // --- Equal to "ExcahangeIOCmd"
unsigned short usMode PACKED; // External exchange mode
} DEVIO_EXIOCMDEX;
// EXIOERR
#define STATE_ERR_NON 0
#define STATE_ERR 1
#define STATE_MODE_2 2
#define STATE_MODE_3 3
#define STATE_MODE_4 4
typedef struct tagDEVIO_EXIOCMDERR {
unsigned short usBoard PACKED; // DEV board number
unsigned short usSendOffset PACKED; // Byte offset send data
unsigned short usSendLen PACKED; // Length of send data
unsigned char *pabSendData PACKED; // Send data buffer
unsigned short usReceiveOffset PACKED; // Byte offset receive data
unsigned short usReceiveLen PACKED; // Length of receive data
unsigned char *pabReceiveData PACKED; // Receive data buffer
unsigned long ulTimeout PACKED; // Service timeout
short sError PACKED; // --- Equal to "ExcahangeIOCmd"
COMSTATE *ptStateData PACKED; // State data buffer
} DEVIO_EXIOCMDERR;
// READIO
typedef struct tagDEVIO_READSENDCMD {
unsigned short usBoard PACKED; // DEV board number
unsigned short usReadOffset PACKED; // Byte offset send/receive data
unsigned short usReadLen PACKED; // Length of send/receive data
unsigned char * pabReadData PACKED; // Read send data buffer
short sError PACKED;
} DEVIO_READSENDCMD;
// ExtData
#define EXTDATASIZE 20
typedef struct tagDEVIO_EXTDATACMD {
unsigned short usBoard PACKED; // DEV board number
unsigned short usMode PACKED; // DEV mode
unsigned char *pabExtData PACKED; // DEV Extended data
short sError PACKED;
} DEVIO_EXTDATACMD;
// GetMbxData
typedef struct tagDEVIO_GETMBXCMD {
unsigned short usBoard PACKED; // DEV board number
unsigned short usDevLen PACKED; // DEV length of dev data
unsigned short usHostLen PACKED; // DEV length of host data
unsigned char abHostMbx[288] PACKED; // DEV pointer to host data buffer
unsigned char abDevMbx[288] PACKED; // DEV pointer to device data buffer
short sError PACKED;
} DEVIO_GETMBXCMD;
// ReadWriteRawData
#define PARAMETER_READ 1
#define PARAMETER_WRITE 2
typedef struct tagDEVIO_RWRAWDATACMD {
unsigned short usBoard PACKED; // DEV board number
unsigned short usMode PACKED; // DEV read or write
unsigned short usOffset PACKED; // DEV offset in the DPM last kByte
unsigned short usLen PACKED; // DEV length of data
unsigned char *pabData PACKED; // DEV pointer to data buffer
short sError PACKED;
} DEVIO_RWRAWDATACMD;
// ReadWriteDPMData
typedef struct tagDEVIO_RWDPMDATACMD {
unsigned short usBoard PACKED; // DEV board number
unsigned short usMode PACKED; // DEV read or write
unsigned short usOffset PACKED; // DEV offset in the DPM last kByte
unsigned short usLen PACKED; // DEV length of data
unsigned char *pabData PACKED; // DEV pointer to data buffer
short sError PACKED;
} DEVIO_RWDPMDATACMD;
// GetDPMPtr
#define DPM_PTR_OPEN_DRV 1
#define DPM_PTR_OPEN_USR 2
#define DPM_PTR_CLOSE 3
typedef struct tagDEVIO_GETDPMPTR {
unsigned short usMode PACKED; // DEV mode
unsigned short usBoard PACKED; // DEV board number
void *pvUserData PACKED; // DEV user data for pmi
unsigned long *pulDPMSize PACKED; // DEV DPM size in bytes
unsigned char **pDPMBase PACKED; // DEV pointer to data buffer
unsigned long lError PACKED; // DEV system error
short sError PACKED; // DEV driver error
} DEVIO_GETDPMPTR;
#ifdef _cplusplus
}
#endif
#endif /* CIFDEV_I_H */
/* <St> *******************************************************************
======================== Copyright =====================================
Copyright (C) 2004 Hilscher GmbH
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the program, if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
=========================================================================
cif_types.h
-------------------------------------------------------------------------
CREATETED : D. Tsaava, Hilscher GmbH
DATE : 18.07.2000
PROJEKT : CIF device driver
=========================================================================
DISCRIPTION
Includefile for CIF device driver, DPM layout .
=========================================================================
CHANGES
version name date Discription
March 2001
Juli 2004 Redesigned for the 2.6 Kernel
Copyright changed to GNU Lesser GPL
-------------------------------------------------------------------------
V2.602
******************************************************************** <En> */
#ifndef CIF_TYPES_H
# define CIF_TYPES_H
/* Macros for debugging */
#undef DBG_PRN /* undef it, just in case */
#ifdef CIF_DEBUG
# define CIF_PRN(function, lineno,fmt,args...) printk(fmt,function,lineno,##args)
# define DBG_PRN(fmt,args...) CIF_PRN((__FUNCTION__),(__LINE__),KERN_INFO __FILE__"::%s(L%.4d): "fmt,##args)
#else
# define DBG_PRN(fmt, args...) /* not debugging: nothing */
#endif
#ifndef TRUE
# define TRUE 1
#endif
#ifndef FALSE
# define FALSE 0
#endif
#ifndef BOOL
# define BOOL int
#endif
#endif /* CIF_TYPES_H */
/* <St> *******************************************************************
======================== Copyright =====================================
Copyright (C) 2004 Hilscher GmbH
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the program, if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
========================================================================
cif_user.h
-------------------------------------------------------------------------
CREATETED : D. Tsaava, Hilscher GmbH
DATE : 18.07.2000
PROJEKT : CIF device driver
=========================================================================
DISCRIPTION
User interface definition.
=========================================================================
CHANGES
version name date Discription
Juli 2004 Copyright changed to GNU Lesser GPL
-------------------------------------------------------------------------
V2.000
NOTE: The Code from the Windows version of the driver related to
driver API was taken over for the most part unchanged
******************************************************************** <En> */
/* prevent multiple inclusion */
#ifndef CIFUSER_H_INCLUDED
#define CIFUSER_H_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif /* _cplusplus */
#ifndef _GNUC_
# define _GNUC_
#endif /* _GNUC_ */
/* ------------------------------------------------------------------------------------ */
/* global definitions */
/* ------------------------------------------------------------------------------------ */
#define MAX_DEV_BOARDS 4 // maximum numbers of boards
/* ------------------------------------------------------------------------------------ */
/* driver errors */
/* ------------------------------------------------------------------------------------ */
#define DRV_NO_ERROR 0 // no error
#define DRV_BOARD_NOT_INITIALIZED -1 // DRIVER Board not initialized
#define DRV_INIT_STATE_ERROR -2 // DRIVER Error in internal init state
#define DRV_READ_STATE_ERROR -3 // DRIVER Error in internal read state
#define DRV_CMD_ACTIVE -4 // DRIVER Command on this channel is activ
#define DRV_PARAMETER_UNKNOWN -5 // DRIVER Unknown parameter in function occured
#define DRV_WRONG_DRIVER_VERSION -6 // DRIVER Version is incompatible with DLL
#define DRV_PCI_SET_CONFIG_MODE -7 // DRIVER Error during PCI set run mode
#define DRV_PCI_READ_DPM_LENGTH -8 // DRIVER Could not read PCI dual port memory length
#define DRV_PCI_SET_RUN_MODE -9 // DRIVER Error during PCI set run mode
#define DRV_DEV_DPM_ACCESS_ERROR -10 // DEVICE Dual port ram not accessable(board not found)
#define DRV_DEV_NOT_READY -11 // DEVICE Not ready (ready flag failed)
#define DRV_DEV_NOT_RUNNING -12 // DEVICE Not running (running flag failed)
#define DRV_DEV_WATCHDOG_FAILED -13 // DEVICE Watchdog test failed
#define DRV_DEV_OS_VERSION_ERROR -14 // DEVICE Signals wrong OS version
#define DRV_DEV_SYSERR -15 // DEVICE Error in dual port flags
#define DRV_DEV_MAILBOX_FULL -16 // DEVICE Send mailbox is full
#define DRV_DEV_PUT_TIMEOUT -17 // DEVICE PutMessage timeout
#define DRV_DEV_GET_TIMEOUT -18 // DEVICE GetMessage timeout
#define DRV_DEV_GET_NO_MESSAGE -19 // DEVICE No message available
#define DRV_DEV_RESET_TIMEOUT -20 // DEVICE RESET command timeout
#define DRV_DEV_NO_COM_FLAG -21 // DEVICE COM-flag not set
#define DRV_DEV_EXCHANGE_FAILED -22 // DEVICE IO data exchange failed
#define DRV_DEV_EXCHANGE_TIMEOUT -23 // DEVICE IO data exchange timeout
#define DRV_DEV_COM_MODE_UNKNOWN -24 // DEVICE IO data mode unknown
#define DRV_DEV_FUNCTION_FAILED -25 // DEVICE Function call failed
#define DRV_DEV_DPMSIZE_MISMATCH -26 // DEVICE DPM size differs from configuration
#define DRV_DEV_STATE_MODE_UNKNOWN -27 // DEVICE State mode unknown
// Error from Interface functions
#define DRV_USR_OPEN_ERROR -30 // USER Driver not opened (device driver not loaded)
#define DRV_USR_INIT_DRV_ERROR -31 // USER Can't connect with device
#define DRV_USR_NOT_INITIALIZED -32 // USER Board not initialized (DevInitBoard not called)
#define DRV_USR_COMM_ERR -33 // USER IOCTRL function failed
#define DRV_USR_DEV_NUMBER_INVALID -34 // USER Parameter DeviceNumber invalid
#define DRV_USR_INFO_AREA_INVALID -35 // USER Parameter InfoArea unknown
#define DRV_USR_NUMBER_INVALID -36 // USER Parameter Number invalid
#define DRV_USR_MODE_INVALID -37 // USER Parameter Mode invalid
#define DRV_USR_MSG_BUF_NULL_PTR -38 // USER NULL pointer assignment
#define DRV_USR_MSG_BUF_TOO_SHORT -39 // USER Message buffer too short
#define DRV_USR_SIZE_INVALID -40 // USER Parameter Size invalid
#define DRV_USR_SIZE_ZERO -42 // USER Parameter Size with zero length
#define DRV_USR_SIZE_TOO_LONG -43 // USER Parameter Size too long
#define DRV_USR_DEV_PTR_NULL -44 // USER Device address null pointer
#define DRV_USR_BUF_PTR_NULL -45 // USER Pointer to buffer is a null pointer
#define DRV_USR_SENDSIZE_TOO_LONG -46 // USER Parameter SendSize too long
#define DRV_USR_RECVSIZE_TOO_LONG -47 // USER Parameter ReceiveSize too long
#define DRV_USR_SENDBUF_PTR_NULL -48 // USER Pointer to send buffer is a null pointer
#define DRV_USR_RECVBUF_PTR_NULL -49 // USER Pointer to receive buffer is a null pointer
#define DRV_DEV_NO_VIRTUAL_MEM -60 // DEVICE Virtual memory not available
#define DRV_DEV_UNMAP_VIRTUAL_MEM -61 // DEVICE Unmap virtual memory failed
#define DRV_DEV_REQUEST_IRQ_FAILED -62 // DEVICE Request irq failed
#define DRV_USR_FILE_OPEN_FAILED -100 // USER file not opend
#define DRV_USR_FILE_SIZE_ZERO -101 // USER file size zero
#define DRV_USR_FILE_NO_MEMORY -102 // USER not enough memory to load file
#define DRV_USR_FILE_READ_FAILED -103 // USER file read failed
#define DRV_USR_INVALID_FILETYPE -104 // USER file type invalid
#define DRV_USR_FILENAME_INVALID -105 // USER file name not valid
#define DRV_RCS_ERROR_OFFSET 1000 // RCS error number start
#ifndef PACKED
# define PACKED __attribute__( (aligned(1)))
#endif /* PACKED */
/* ------------------------------------------------------------------------------------ */
/* message definition */
/* ------------------------------------------------------------------------------------ */
// max. length is 288 Bytes, max message length is 255 + 8 Bytes
typedef struct tagMSG_STRUC {
unsigned char rx PACKED;
unsigned char tx PACKED;
unsigned char ln PACKED;
unsigned char nr PACKED;
unsigned char a PACKED;
unsigned char f PACKED;
unsigned char b PACKED;
unsigned char e PACKED;
unsigned char data[255] PACKED;
unsigned char dummy[25] PACKED; // for compatibility with older definitions (288 Bytes)
} MSG_STRUC;
/* ------------------------------------------------------------------------------------ */
/* INFO structure definitions */
/* ------------------------------------------------------------------------------------ */
// Board operation mode
#define POLLING_MODE 0
#define INTERRUPT_MODE 1
// DEVRESET
#define COLDSTART 2
#define WARMSTART 3
#define BOOTSTART 4
// DEVMBXINFO
#define DEVICE_MBX_EMPTY 0
#define DEVICE_MBX_FULL 1
#define HOST_MBX_EMPTY 0
#define HOST_MBX_FULL 1
// TRIGGERWATCHDOG
#define WATCHDOG_STOP 0
#define WATCHDOG_START 1
// GETINFO InfoArea definitions
#define GET_DRIVER_INFO 1
#define GET_VERSION_INFO 2
#define GET_FIRMWARE_INFO 3
#define GET_TASK_INFO 4
#define GET_RCS_INFO 5
#define GET_DEV_INFO 6
#define GET_IO_INFO 7
#define GET_IO_SEND_DATA 8
// HOST mode definition
#define HOST_NOT_READY 0
#define HOST_READY 1
// DEVREADWRITERAW
#define PARAMETER_READ 1
#define PARAMETER_WRITE 2
// STATE definition
#define STATE_ERR_NON 0
#define STATE_ERR 1
#define STATE_MODE_2 2
#define STATE_MODE_3 3
#define STATE_MODE_4 4
// DEVSPECIALCONTROL
#define SPECIAL_CONTROL_CLEAR 0
#define SPECIAL_CONTROL_SET 1
// DEVDOWNLOAD
#define FIRMWARE_DOWNLOAD 1
#define CONFIGURATION_DOWNLOAD 2
// Device exchange IO information
typedef struct tagIOINFO {
unsigned char bComBit PACKED; /* Actual state of the COM bit */
unsigned char bIOExchangeMode PACKED; /* Actual data exchange mode (0..5) */
unsigned int ulIOExchangeCnt PACKED; /* Exchange IO counter */
} IOINFO;
// Device version information
typedef struct tagVERSIONINFO { /* DEV serial number and OS versions */
unsigned int ulDate PACKED;
unsigned int ulDeviceNo PACKED;
unsigned int ulSerialNo PACKED;
unsigned int ulReserved PACKED;
unsigned char abPcOsName0[4] PACKED;
unsigned char abPcOsName1[4] PACKED;
unsigned char abPcOsName2[4] PACKED;
unsigned char abOemIdentifier[4] PACKED;
} VERSIONINFO;
// Device firmware information
typedef struct tagFIRMWAREINFO {
unsigned char abFirmwareName[16] PACKED; /* Firmware name */
unsigned char abFirmwareVersion[16] PACKED; /* Firmware version */
} FIRMWAREINFO;
// Device task state information
typedef struct tagTASKSTATE {
unsigned char abTaskState[64] PACKED; /* Task state field */
} TASKSTATE;
// Device task paramater data
typedef struct tagTASKPARAM {
unsigned char abTaskParameter[64] PACKED; /* Task parameter field */
} TASKPARAM;
// Device raw data structure
typedef struct tagRAWDATA {
unsigned char abRawData[1022] PACKED; /* Definition of the last kByte */
} RAWDATA;
// Device task information
typedef struct tagTASKINFO {
struct {
unsigned char abTaskName[8] PACKED; /* Task name */
unsigned short usTaskVersion PACKED; /* Task version */
unsigned char bTaskCondition PACKED; /* Actual task condition */
unsigned char abreserved[5] PACKED; /* n.c. */
} tTaskInfo [7];
} TASKINFO;
// Device operating system (RCS) information
typedef struct tagRCSINFO {
unsigned short usRcsVersion PACKED; /* Device operating system (RCS) version */
unsigned char bRcsError PACKED; /* Operating system errors */
unsigned char bHostWatchDog PACKED; /* Host watchdog value */
unsigned char bDevWatchDog PACKED; /* Device watchdog value */
unsigned char bSegmentCount PACKED; /* RCS segment free counter */
unsigned char bDeviceAdress PACKED; /* RCS device base address */
unsigned char bDriverType PACKED; /* RCS driver type */
} RCSINFO;
// Device description
typedef struct tagDEVINFO {
unsigned char bDpmSize PACKED; /* Device dpm size (2,8...) */
unsigned char bDevType PACKED; /* Device type (manufactor code) */
unsigned char bDevModel PACKED; /* Device model (manufactor code) */
unsigned char abDevIdentifier[3] PACKED; /* Device identification characters */
} DEVINFO;
/* ------------------------------------------------------------------------------------ */
/* driver info structure definitions */
/* ------------------------------------------------------------------------------------ */
// Board information structure
typedef struct tagBOARD_INFO{
unsigned char abDriverVersion[16] PACKED; // DRV driver information string
struct {
unsigned short usBoard PACKED; // DRV board number
unsigned short usAvailable PACKED; // DRV board is available
unsigned long ulPhysicalAddress PACKED; // DRV physical DPM address
unsigned short usIrq PACKED; // DRV irq number
} tBoard [MAX_DEV_BOARDS];
unsigned short usBoards_detected PACKED;
} BOARD_INFO;
// Internal driver state information structure
typedef struct tagDRIVERINFO {
unsigned long ulOpenCnt PACKED; // DevOpen() counter
unsigned long CloseCnt PACKED; // number of driver close
unsigned long ulReadCnt PACKED; // Number of DevGetMessage commands
unsigned long ulWriteCnt PACKED; // Number of DevPutMessage commands
unsigned long ulIRQCnt PACKED; // Number of board interrupts
unsigned char bInitMsgFlag PACKED; // Actual init sate
unsigned char bReadMsgFlag PACKED; // Actual read mailbox state
unsigned char bWriteMsgFlag PACKED; // Actual write mailbox state
unsigned char bLastFunction PACKED; // Last driver function
unsigned char bWriteState PACKED; // Actual write command state
unsigned char bReadState PACKED; // Actual read command state
unsigned char bHostFlags PACKED; // Actual host flags
unsigned char bMyDevFlags PACKED; // Actual device falgs
unsigned char bExIOFlag PACKED; // Actual IO flags
unsigned long ulExIOCnt PACKED; // DevExchangeIO() counter
} DRIVERINFO;
// Extended board information structure
typedef struct tagBOARD_INFOEX{
unsigned char abDriverVersion[16] PACKED; // DRV driver information string
struct {
unsigned short usBoard PACKED; // DRV board number
unsigned short usAvailable PACKED; // DRV board is available
unsigned long ulPhysicalAddress PACKED; // DRV physical DPM address
unsigned short usIrq PACKED; // DRV irq number
DRIVERINFO tDriverInfo PACKED; // Driver information
FIRMWAREINFO tFirmware PACKED;
DEVINFO tDeviceInfo PACKED;
RCSINFO tRcsInfo PACKED;
VERSIONINFO tVersion PACKED;
} tBoard [MAX_DEV_BOARDS];
} BOARD_INFOEX;
// changes made for 64-bit architecture
// 64-bit Linux machine & 32-bit Windows machine
// #ifdef CONFIG_64BIT
// Extended board information structure
typedef struct tagBOARD_INFOEX_32 {
unsigned char abDriverVersion[16] PACKED; // DRV driver information string
unsigned char abCatchall[484] PACKED; // catchall
/*struct {
unsigned short usBoard PACKED; // DRV board number
unsigned short usAvailable PACKED; // DRV board is available
unsigned long ulPhysicalAddress PACKED; // DRV physical DPM address
unsigned short usIrq PACKED; // DRV irq number
DRIVERINFO tDriverInfo PACKED; // Driver information
FIRMWAREINFO tFirmware PACKED;
DEVINFO tDeviceInfo PACKED;
RCSINFO tRcsInfo PACKED;
VERSIONINFO tVersion PACKED;
} tBoard [MAX_DEV_BOARDS];*/
} BOARD_INFOEX_32;
// Communication state field structure
typedef struct tagCOMSTATE {
unsigned short usMode PACKED; // Actual STATE mode
unsigned short usStateFlag PACKED; // State flag
unsigned char abState[64] PACKED; // State area
} COMSTATE;
// state information in bLastFunction
#define FKT_OPEN 1;
#define FKT_CLOSE 2;
#define FKT_READ 3;
#define FKT_WRITE 4;
#define FKT_IO 5;
// state information in bWriteState and bReadState
#define STATE_IN 0x01;
#define STATE_WAIT 0x02;
#define STATE_OUT 0x03;
#define STATE_IN_IRQ 0x04;
/* ------------------------------------------------------------------------------------ */
/* funcion prototypes */
/* ------------------------------------------------------------------------------------ */
extern short DevOpenDriver ( void);
extern short DevCloseDriver ( void);
extern short DevGetBoardInfo ( BOARD_INFO *pvData);
extern short DevInitBoard ( unsigned short usDevNumber);
extern short DevExitBoard ( unsigned short usDevNumber);
extern short DevPutTaskParameter ( unsigned short usDevNumber,
unsigned short usNumber,
unsigned short usSize,
void *pvData);
extern short DevReset ( unsigned short usDevNumber,
unsigned short usMode,
unsigned long ulTimeout);
extern short DevPutMessage ( unsigned short usDevNumber,
MSG_STRUC *ptMessage,
unsigned long ulTimeout);
extern short DevGetMessage ( unsigned short usDevNumber,
unsigned short usSize,
MSG_STRUC *ptMessage,
unsigned long ulTimeout);
extern short DevGetTaskState ( unsigned short usDevNumber,
unsigned short usNumber,
unsigned short usSize,
void *pvData);
extern short DevGetMBXState ( unsigned short usDevNumber,
unsigned short *pusDevMBXState,
unsigned short *pusHostMBXState);
extern short DevTriggerWatchDog ( unsigned short usDevNumber,
unsigned short usFunction,
unsigned short *usDevWatchDog);
extern short DevGetInfo ( unsigned short usDevNumber,
unsigned short usFunction,
unsigned short usSize,
void *pvData);
extern short DevGetTaskParameter ( unsigned short usDevNumber,
unsigned short usNumber,
unsigned short usSize,
void *pvData);
extern short DevExchangeIO ( unsigned short usDevNumber,
unsigned short usSendOffset,
unsigned short usSendSize,
void *pvSendData,
unsigned short usReceiveOffset,
unsigned short usReceiveSize,
void *pvReceiveData,
unsigned long ulTimeout);
extern short DevReadSendData ( unsigned short usDevNumber,
unsigned short usOffset,
unsigned short usSize,
void *pvData);
extern short DevSetHostState ( unsigned short usDevNumber,
unsigned short usMode,
unsigned long ulTimeout);
extern short DevExtendedData ( unsigned short usDevNumber,
unsigned short usMode,
unsigned short usSize,
void *pvData);
extern short DevGetMBXData ( unsigned short usDevNumber,
unsigned short usHostSize,
void *pvHostData,
unsigned short usDevSize,
void *pvDevData);
extern short DevGetBoardInfoEx ( void *pvData);
extern short DevExchangeIOEx ( unsigned short usDevNumber,
unsigned short usMode,
unsigned short usSendOffset,
unsigned short usSendSize,
void *pvSendData,
unsigned short usReceiveOffset,
unsigned short usReceiveSize,
void *pvReceiveData,
unsigned long ulTimeout);
extern short DevExchangeIOErr ( unsigned short usDevNumber,
unsigned short usSendOffset,
unsigned short usSendSize,
void *pvSendData,
unsigned short usReceiveOffset,
unsigned short usReceiveSize,
void *pvReceiveData,
COMSTATE *ptState,
unsigned long ulTimeout);
extern short DevReadWriteDPMRaw ( unsigned short usDevNumber,
unsigned short usMode,
unsigned short usOffset,
unsigned short usSize,
void *pvData);
extern short DevSpecialControl ( unsigned short usDevNumber,
unsigned short usMode,
unsigned short *pusCtrlAck);
extern short DevDownload( unsigned short usDevNumber,
unsigned short usMode,
unsigned char *pszFileName,
unsigned long *pdwBytes);
extern short DevReadWriteDPMData ( unsigned short usDevNumber,
unsigned short usMode,
unsigned short usOffset,
unsigned short usSize,
void *pvData);
extern short DevSetOpMode ( unsigned short usBoard,
unsigned short usMode ,
unsigned short *usIrq );
#ifdef __cplusplus
}
#endif
#endif // ifndef CIFUSER_H_INCLUDED
/* <St> *******************************************************************
======================== Copyright =====================================
Copyright (C) 2004 Hilscher GmbH
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the program, if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
========================================================================
FILENAME : DPM_USER.H
-------------------------------------------------------------------------
CREATED BY : Armin Beck, Hilscher GmbH
CREATED AT : 10.05.96
PROJECT :
=========================================================================
FUNCTION :
User-Interface to PROFIBUS DP-master
=========================================================================
CHANGES OF REVISIONS :
Version Name Date Change
-------------------------------------------------------------------------
V1.711 SW 16.02.04 - GNUC_PACKED added again
RH 24.09.03 - new bit at structure sl_flag
V1.710 AB 16.10.02 - new service FDL_Sap_Deactivate
- replacing FMA_ primitives by FDL_ primitves in
defined structures
V1.700 AB 03.07.02 - changing the value DPM_FORMAT_INTEL/MOTOROLA
to value DPM_FORMAT_SWAP/NO_SWAP
V1.600 AB 14.08.01 - changing order of bDsap und bSSsap
in structure FDL_DATA_ACK_IND_STU
and structure FDL_DATA_REPLY_IND_STU
- correction of definition FDL_Send_Data_Ack_Ind
- new indication command FDL_Send_Data_No_Ack_Ind
inserted
- corretion of FDL_DATA_ACK_IND_STU structure
V1.501 AB 23.05.01 definition EA_OFFSET_BYTE inserted
definition DDLM_RD_Input, DDLM_RD_Output
DDLM_Set_Slave_Add inserted
insert define __DPM_USER_H
09.05.01 new MPI primitives included
V1.500 AB 04.05.01 defining the DPV1_USR_PRM structure in the slave
parameter data set as union, to distinguish
slave with DPV1 capability and non capability
V1.404 AB 17.04.01 documentation of structure FDL_DATA_REPLY_IND_STU
V1.403 AB 19.11.01 new message FDL_Send_Data_Ack and
FDL_Send_Data_No_Ack and FDL_Reply_Update
V1.402 AB 17.12.00 new define DPM_MAX_NUM_DEVICES
new command DDLM_Life_List
V1.401 AB 19.10.00 New Message command MPI_Read_Write_DB and
disconnect
V1.400 AB 22.11.99 Extention of struct DPM_PLC_PARAMETER.(Identnumber)
V1.304 AB 27.06.99 Definition of FDL_Send_Data_Reply Service
V1.303 AB 16.06.99 Extention of FDL-error table. CON_AD, CON_NP
included
V1.302 AB 30.04.99 change the order of bAlarm_Mode and bAdd_Sl_Flag
in the structure DPM_SL_PRM_HEADER in accordance
to the DPV1-specification
V1.301 AB 23.02.99 Extention of the DPM_SL_PRM_PRM_DATA structure
for DPV1 usage
Extention of DPM_BUS_DP structure
new parameter bRedundancy and bSlStateMethod
in structure DPM_PLC_PARAMETER
new DPV1 message command definitions
V1.300 AB 22.01.99 Changing nomenclatura of service definitions
from DPM_... to DDLM_...
Insert new service DDLM_Upload
inser new command DDLM_Get_Cfg
V1.202 AB 02.04.98 correction of the definition
of CLEAR_DATA,SYNC...
bTout inserted in global statusfield
V1.201 AB 16.03.98 WatchDogTime extention in warmstart parameter
V1.200 AB 09.11.97 extended errors; extended diagnostic structure
V1.102 AB 09.09.97 extended errors; extended diagnostic structure
V1.101 AB 04.12.96 new #defines included
V1.100 AB 29.11.96 revision of all structures
V1.000 Mayer 29.05.96 changed
V1.000 AB 10.05.96 created
******************************************************************** <En> */
#ifndef __DPM_USER_H
#define __DPM_USER_H
#if _MSC_VER >= 1000
#pragma once
#endif /* _MSC_VER >= 1000 */
/* support for GNU compiler */
#ifdef __GNUC__
#define GNUC_PACKED __attribute__((__packed__))
#else
#define GNUC_PACKED
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if defined( _MSC_VER) /* Microsoft C */
#pragma pack(1) /* Byte Alignment */
#endif
/* ------------------------------------------------------------------------------------ */
/* process image transfer mode definitions */
/* ------------------------------------------------------------------------------------ */
#define DPM_GET_MODE_MASK 0xf0
#define DPM_GET_MODE_NOT_SUPPORTED 0x00
#define DPM_GET_MODE_BUSSYNC_DEVICE_CONTROLLED 0x10
#define DPM_GET_MODE_BUFFERED_DEVICE_CONTROLLED 0x20
#define DPM_GET_MODE_UNCONTROLLED 0x30
#define DPM_GET_MODE_BUFFERED_HOST_CONTROLLED 0x40
#define DPM_GET_MODE_BUSSYNC_HOST_CONTROLLED 0x50
/* ======================================================================== */
/* Protocol parameter structure */
/* ======================================================================== */
/* --------------------------- */
/* device warm start parameter */
/* --------------------------- */
typedef struct DPM_PLC_PARAMETERtag {
unsigned char bMode; /* handshake of process data */
#define DPM_SET_MODE_BUSSYNC_DEVICE_CONTROLLED 0
#define DPM_SET_MODE_BUFFERED_DEVICE_CONTROLLED 1
#define DPM_SET_MODE_UNCONTROLLED 2
#define DPM_SET_MODE_BUFFERED_HOST_CONTROLLED 3
#define DPM_SET_MODE_BUSSYNC_HOST_CONTROLLED 4
unsigned char bCycleTime; /* replace the min_slave_intervall */
unsigned char bFormat; /* storage format of word data */
#define DPM_FORMAT_NO_SWAP 0
#define DPM_FORMAT_SWAP 1
unsigned short usWatchDogTime; /* watchdog time in msec. for HOST-supervision */
unsigned char bRedundancy; /* enables or disables the redundancy logic */
unsigned char bSlStateMethod; /* defines the update method od Sl_State field */
#define DPM_SL_STATE_NOT_SYCHRONOUS 0
#define DPM_SL_STATE_SYCHRONOUS 1
struct
{
unsigned char biIdentNumberActive : 1;
unsigned char biHighPriorHandshake : 1;
unsigned char biReserved : 6;
} GNUC_PACKED bEnableBits;
unsigned short usIdentNumber;
unsigned char abReserved[6];
} GNUC_PACKED DPM_PLC_PARAMETER;
/* -------------------------------- */
/* structures to set slave data set */
/* -------------------------------- */
#define DPM_MAX_NUM_DEVICES 126
/* parameter data header structure of a slave station,
described in norm EN 50170 page 101 */
typedef struct DPM_SL_PRM_HEADERtag {
unsigned short usSlaveParaLen; /* length of whole parameter data set */
struct
{
unsigned char biReserved1 : 1;
unsigned char biExtra_Alarm_SAP : 1;
unsigned char biDPV1_Data_Types : 1;
unsigned char biDPV1_Supported : 1;
unsigned char biPublisher_Enable : 1;
unsigned char biFail_Safe : 1;
unsigned char biNew_Prm : 1;
unsigned char biActive : 1;
} GNUC_PACKED Sl_Flag; /* slave related flags */
unsigned char bSlave_Typ; /* type of slave */
unsigned char bMax_Diag_Data_Len;
unsigned char bMax_Alarm_Len;
unsigned char bMax_Channel_Data_Length;
unsigned char bDiag_Upd_Delay;
unsigned char bAlarm_Mode;
struct
{
unsigned char biNA_to_Abort : 1;
unsigned char biIgnore_Aclr : 1;
unsigned char abiReserved : 6;
} GNUC_PACKED bAdd_Sl_Flag;
unsigned char abOctet_String[6];
} GNUC_PACKED DPM_SL_PRM_HEADER;
/* parameter data 'Prm_Data' structure of a slave station,
described in norm EN 50170 page 51 */
#define MAX_USR_PRM_LEN 237
typedef struct DPV0_PRMtag {
unsigned char abUsr_Prm_Data[MAX_USR_PRM_LEN]; /* user parameter data without DPV1-bytes */
} GNUC_PACKED DPV0_PRM;
typedef struct DPV1_USR_PRMtag {
struct
{
unsigned char bReserved1 : 2;
unsigned char bWD_Base_1ms : 1;
unsigned char bReserved2 : 2;
unsigned char bPublisher_Enable : 1;
unsigned char bFail_Safe : 1;
unsigned char bDPV1_Enable : 1;
} GNUC_PACKED DPV1_Status_1;
struct
{
unsigned char bRun_On_Cfg_Fault : 1;
unsigned char bReserved1 : 1;
unsigned char bEnable_Update_Alarm : 1;
unsigned char bEnable_Status_Alarm : 1;
unsigned char bEnable_Manufacture_Alarm : 1;
unsigned char bEnable_Diagnostic_Alarm : 1;
unsigned char bEnable_Process_Alarm : 1;
unsigned char bEnable_Pull_plug_Alarm : 1;
} GNUC_PACKED DPV1_Status_2;
struct
{
unsigned char bAlarm_Mode : 3;
unsigned char bIsoM_Req : 1;
unsigned char bReserved1 : 4;
} GNUC_PACKED DPV1_Status_3;
} GNUC_PACKED DPV1_USR_PRM;
typedef struct DPV1_PRMtag {
DPV1_USR_PRM tDpv1;
unsigned char abUsr_Prm_Data[MAX_USR_PRM_LEN-sizeof(DPV1_USR_PRM)];
} GNUC_PACKED DPV1_PRM;
typedef struct DPV2_HEADERtag {
unsigned char bStructure_Length;
unsigned char bStructure_Type;
unsigned char bSlot_Number;
unsigned char bReserved;
} GNUC_PACKED DPV2_HEADER;
typedef struct DPV2_ISOM_PRMtag {
DPV2_HEADER tDpv2Header;
unsigned char bVersion;
unsigned long bTBase_Dp;
unsigned short bTDp;
unsigned char bTMapc;
unsigned long bTBase_Io;
unsigned short bTI;
unsigned short bTO;
unsigned long bTDx;
unsigned short bTPll_W;
unsigned short bTPll_D;
} GNUC_PACKED DPV2_ISOM_PRM;
typedef struct DPV2_DBX_LINK_FILTERtag {
unsigned char bPublisher_Addr;
unsigned char bPublisher_Length;
unsigned char bSample_Offset;
unsigned char bSample_Length;
} GNUC_PACKED DPV2_DBX_LINK_FILTER;
typedef struct DPV2_DBX_LINKtag {
DPV2_HEADER tDpv2Header;
unsigned char bVersion;
DPV2_DBX_LINK_FILTER tDbxLinkFilter;
} GNUC_PACKED DPV2_DBX_LINK;
typedef struct DPV2_PRMtag {
DPV1_USR_PRM tDpv1;
DPV2_ISOM_PRM tDpv2Iso;
unsigned char abUsr_Prm_Data[MAX_USR_PRM_LEN-
sizeof(DPV1_USR_PRM)-
sizeof(DPV2_ISOM_PRM)];
} GNUC_PACKED DPV2_PRM;
typedef struct DPM_SL_PRM_PRM_DATAtag {
unsigned short usPrmDataLen; /* length of PRM_PRM_DATA */
struct
{
unsigned char bReserved : 3;
unsigned char bWD_On : 1;
unsigned char bFreeze_Req : 1;
unsigned char bSync_Req : 1;
unsigned char bUnLock_Req : 1;
unsigned char bLock_Req : 1;
} GNUC_PACKED Station_Status; /* status of supported functions */
unsigned char bWD_Fact_1; /* watchdog factor 1 */
unsigned char bWD_Fact_2; /* watchdog factor 2 */
unsigned char bMin_Tsdr; /* min. station delay reponder */
unsigned short usIdent_Number; /* ident number of the station, motorola format */
unsigned char bGroup_Ident; /* configures group number */
union
{
DPV0_PRM tDpv0; /* standard parameter , or */
DPV1_PRM tDpv1Only; /* parameter data with DPV1 */
DPV2_PRM tDpv1Dpv2; /* parameter data with DPV1,DPV2 */
} GNUC_PACKED u;
} GNUC_PACKED DPM_SL_PRM_PRM_DATA;
/* configuration data 'Cfg_Data' structure of a slave station,
described in norm EN 50170 page 55 */
#define MAX_CFG_DATA_LEN 244
typedef struct DPM_SL_PRM_CFG_DATAtag {
unsigned short usCfg_Data_Len; /* length of CFG_DATA */
unsigned char abCfg_Data[MAX_CFG_DATA_LEN]; /* configuration data of the
slave station */
} GNUC_PACKED DPM_SL_PRM_CFG_DATA;
/* i/o offset table 'Add_Tab' structure of a slave station,
described in norm EN 50170 page 103 */
#define MAX_EA_OFFSET_LEN 244
typedef struct DPM_SL_PRM_ADD_TABtag {
unsigned short usAdd_Tab_Len; /* length of ADD_TAB */
unsigned char bInput_Count; /* counter of following input offsets */
unsigned char bOutput_Count; /* counter of following ouput offsets */
#define EA_OFFSET_BYTE 0x8000
unsigned short ausEA_Offset[MAX_EA_OFFSET_LEN]; /* user defined offsets */
} GNUC_PACKED DPM_SL_PRM_ADD_TAB;
/* extented data 'Slave_User_Data' structure of a slave station,
described in norm EN 50170 page 103 */
#define MAX_SL_PRM_LEN 100
typedef struct DPM_SL_PRM_USR_DATAtag {
unsigned short usSlave_Usr_Data_Len; /* length of USR_DATA */
unsigned char abSlave_Usr_Data[MAX_SL_PRM_LEN]; /* user paramteres */
} GNUC_PACKED DPM_SL_PRM_USR_DATA;
/* --------------------------------- */
/* structure to set master parameter */
/* --------------------------------- */
/* master parameter 'DPM_Bus_Dp' data set
described in norm DIN 19245-T3 page 98 */
typedef struct DPM_BUS_DPtag {
unsigned short usBus_Para_Len; /* length of BUS_DP */
unsigned char bFDL_Add; /* master address */
unsigned char bBaudrate; /* baudrate, see. #defines */
#define DP_BAUD_96 0
#define DP_BAUD_19_2 1
#define DP_BAUD_93_75 2
#define DP_BAUD_187_5 3
#define DP_BAUD_500 4
#define DP_BAUD_1500 6
#define DP_BAUD_3000 7
#define DP_BAUD_6000 8
#define DP_BAUD_12000 9
#define DP_BAUD_31_25 10
#define DP_BAUD_45_45 11
unsigned short usTSL; /* slot-time */
unsigned short usMin_TSDR; /* min. station delay responder */
unsigned short usMax_TSDR; /* max. station delay responder */
unsigned char bTQUI; /* quite time */
unsigned char bTSET; /* setup time */
unsigned long ulTTR; /* target rotation time */
unsigned char bG; /* gap update */
unsigned char bHSA; /* highest active station address */
unsigned char bMax_Retry_Limit; /* retries if error occurs */
struct
{
unsigned char bReserved : 7;
unsigned char bError_Action_Flag : 1;
} GNUC_PACKED Bp_Flag; /* auto_clear on/off */
unsigned short usMin_Slave_Intervall; /* min. slave intervall time */
unsigned short usPoll_Timeout; /* poll timeout */
unsigned short usData_Control_Time; /* data control time */
unsigned char bAlarm_Max; /* maximum alarms the master supports = 32 */
unsigned char bMax_User_Global_Control; /* maximum parallel Global-
Controls the master supports = 1*/
unsigned char abOctet[4];
} GNUC_PACKED DPM_BUS_DP;
/* ======================================================================== */
/* Protocol slave specific single diagnostic structure */
/* ======================================================================== */
#define MAX_EXT_DIAG_LEN 100
/* slave specific diagnostic structure
described in norm DIN 19245-T3 page 41 */
typedef struct DPM_SLAVE_SINGLE_DIAGNOTICStag {
struct
{
unsigned char bStation_Non_Existent : 1; /* no response */
unsigned char bStation_Not_Ready : 1; /* station not ready */
unsigned char bCfg_Fault : 1; /* configuration fault */
unsigned char bExt_Diag : 1; /* extended diagnostic */
unsigned char bNot_Supported : 1; /* sync, freeze not supported */
unsigned char bInvalid_Response : 1; /* response faulty */
unsigned char bPrm_Fault : 1; /* parameters faulty */
unsigned char bMaster_Lock : 1; /* locked by a master */
} GNUC_PACKED Stationstatus_1;
struct
{
unsigned char bPrm_Req : 1; /* request new parameters */
unsigned char bStat_Diag : 1; /* static diagnostic */
unsigned char bTrue : 1; /* set to 1 by a slave */
unsigned char bWd_On : 1; /* watchdog function on/off */
unsigned char bFreeze_Mode : 1; /* freeze mode active */
unsigned char bSync_Mode : 1; /* sync mode active */
unsigned char bReserved : 1; /* reserved */
unsigned char bDeactivated : 1; /* slave deactivated */
} GNUC_PACKED Stationstatus_2;
struct
{
unsigned char bReserved : 7;
unsigned char bExt_Diag_Overflow : 1; /* ext. diagnostic overflow */
} GNUC_PACKED Stationstatus_3;
unsigned char bMaster_Add; /* corresponding master address */
unsigned short usIdent_Number; /* ident number, motorola format */
unsigned char abExt_Diag_Data[MAX_EXT_DIAG_LEN];
/* extended diagnostic field */
} GNUC_PACKED DPM_SLAVE_SINGLE_DIAGNOSTICS;
/* ======================================================================== */
/* Protocol master state structure */
/* ======================================================================== */
typedef struct DPM_DIAGNOSTICStag {
/* unsigned char field to show bus and master main errors */
struct
{
unsigned char bCtrl : 1; /* wrong parameterization */
unsigned char bAClr : 1; /* auto_clear activated */
unsigned char bNonExch : 1; /* no data exchange to at least on station */
unsigned char bFatal : 1; /* fatal error occured */
unsigned char bEvent : 1; /* bus error events occured */
unsigned char bNRdy : 1; /* host program not ready */
unsigned char bTout : 1; /* PROFIBUS timeout event detected */
unsigned char bReserved : 1;
} GNUC_PACKED bGlobalBits;
/* global state for the different master main states */
unsigned char bDPM_state;
#define OFFLINE 0x00
#define STOP 0x40
#define CLEAR 0x80
#define OPERATE 0xC0
/* location of error and error code */
struct
{
unsigned char bErr_Rem_Adr; /* 0-125, 255 */
#define MST_ERR 0xFF
unsigned char bErr_Event; /* see #defines */
#define TASK_F_NO_USR_TASK 50 /* usr task not found */
#define TASK_F_NO_GLOBAL_DATA 51 /* no global entry in data base */
#define TASK_F_NO_FDL 52 /* fdl task not found */
#define TASK_F_NO_PLC 53 /* plc task not found */
#define TASK_F_NO_BUS_DP 54 /* no bus parameters */
#define TASK_F_INVALID_BUS_DP 55 /* bus parameters faulty */
#define TASK_F_NO_SL_TAB 56 /* no slave data sets */
#define TASK_F_INVALID_SL_TAB 57 /* slave data set faulty */
#define TASK_F_REM_ADR_DOUBLE 58 /* double station adress detected */
#define TASK_F_A_OFFSET_MAX 59 /* maximum output offset reached */
#define TASK_F_E_OFFSET_MAX 60 /* maximum input offset reached */
#define TASK_F_A_OVERLAP 61 /* overlap in output area */
#define TASK_F_E_OVERLAP 62 /* overlap in input area */
#define TASK_F_DPM_UNKNOWN_MODE 63 /* warm start with unknown mode */
#define TASK_F_RAM_OVERRUN 64 /* extended ram exeeded */
#define TASK_F_SL_PRM_FAULT 65 /* slave data set faulty */
#define TASK_F_WATCHDOG 220 /* user watchdog failure */
#define TASK_F_NO_DATA_ACK 221 /* mode0 no acknowledge */
#define TASK_F_AUTO_CLEAR 222 /* auto clear activated */
#define TASK_F_FATAL_ASIC_ERROR 223 /* fatal error occured */
#define TASK_F_UNKNOWN_EVENT 224 /* unknown event detected */
#define TASK_F_SEGMENT_CNT 225 /* no segments to communicate */
#define CON_NA 0x11 /* no reaction of the remote station */
#define CON_DS 0x12 /* cocal-FDL/PHY not in logical token ring */
#define CON_RS 0x03 /* master request not supported by the slave */
#define CON_NR 0x09 /* no response data */
#define CON_DS 0x12 /* local FDL not in logical token ring */
} GNUC_PACKED tError;
/* counter for the bus error events */
unsigned short usBus_Error_Cnt;
/* Zhler fr die BusTimeouts */
unsigned short usTime_Out_Cnt;
/* reserved area */
unsigned char abReserved[8];
/* Bit-Ready, Cfg-Ready and diagnostic display of slave devices */
unsigned char abSl_cfg [16]; /* Slave configuration area */
unsigned char abSl_state[16]; /* Slave state information area */
unsigned char abSl_diag [16]; /* Slave diagnostic area */
} GNUC_PACKED DPM_DIAGNOSTICS;
/* ======================================================================== */
/* Master Class2 definitions */
/* ======================================================================== */
#define UNDEFINED 1
typedef struct
{
unsigned char abNetwork_Address[6]; /* network address according ISO/OSI */
unsigned char abMAC_Address[UNDEFINED];/* MAC_Address */
} GNUC_PACKED ADDR_EXTENTION;
typedef struct
{
unsigned char bAPI; /* application process instance */
unsigned char bSCL; /* access level */
} GNUC_PACKED ADDR;
#define MAX_ADD_TABLE_LEN 235
typedef struct
{
#define TYPE_EXT_OFF 0 /* no optional Network/MAC address */
#define TYPE_EXT_ON 1 /* optional Network/MAC address available */
unsigned char bS_Type;
unsigned char bS_Len; /* length of S_Addr subparameter */
unsigned char bD_Type;
unsigned char bD_Len; /* length of D_Addr subparameter */
unsigned char abAddParam[ MAX_ADD_TABLE_LEN ];
} GNUC_PACKED ADD_ADDR_PARAM;
typedef struct
{
unsigned short usSend_Timeout; /* control time for supervision */
struct
{
unsigned char biDPV1_RW : 1; /* support of MSAC2_READ and WRITE */
unsigned char abiReserved : 7;
} GNUC_PACKED bFeatures_Supported_1;
struct
{
unsigned char abiReserved : 8;
} GNUC_PACKED bFeatures_Supported_2;
unsigned char bProfile_Features_Supported_1;
unsigned char bProfile_Features_Supported_2;
unsigned short usProfile_Ident_Number; /* 0 to 65535 */
#define NO_PROFILE 0
ADD_ADDR_PARAM tAdd_Addr_Param;
} GNUC_PACKED DPM_MSAC2M_INITIATE_REQ;
typedef struct
{
struct
{
unsigned char biDPV1_RW : 1; /* support of MSAC2_READ and WRITE */
unsigned char abiReserved : 7;
} GNUC_PACKED bFeatures_Supported_1;
struct
{
unsigned char abiReserved : 8;
} GNUC_PACKED bFeatures_Supported_2;
unsigned char bProfile_Features_Supported_1;
unsigned char bProfile_Features_Supported_2;
unsigned short usProfile_Ident_Number; /* 0 to 65535 */
#define NO_PROFILE 0
ADD_ADDR_PARAM tAdd_Addr_Param;
} GNUC_PACKED DPM_MSAC2M_INITIATE_CON;
/* ======================================================================== */
/* Protocol definition */
/* ======================================================================== */
/* DPV1 Class1 primitives */
#define MSAC1M_Read_Write 0x11
#define MSAL1M_Alarm 0x12
#define MSAC1M_Abort 0x1f
/* DPV1 Class2 primitives */
#define MSAC2M_Initiate 0x20
#define MSAC2M_Read_Write_Data 0x21
#define MSAC2M_Fault 0x2d
#define MSAC2M_Close 0x2e
#define MSAC2M_Abort 0x2f
/* MPI primitives */
#define MPI_Read_Write_DB 0x31
#define MPI_Get_OP_Status 0x32
#define MPI_Read_Write_M 0x33
#define MPI_Read_Write_IO 0x34
#define MPI_Read_Write_Cnt 0x35
#define MPI_Read_Write_Tim 0x36
#define MPI_Disconnect 0x3f
#define DPM_MAX_LEN_DATA_UNIT 240
/* ------------------------------- */
/* message: shared_memory */
/* ------------------------------- */
/* message command msg.b msg.a */
#define DPM_Shared_Memory 0x11
/* ------------------------------- */
/* message: slave_diag */
/* ------------------------------- */
/* message command msg.b msg.a */
#define DDLM_Slave_Diag 0x42
typedef struct DDLM_SLAVE_DIAG_CONFIRMtag {
DPM_SLAVE_SINGLE_DIAGNOSTICS tDiagData;
} GNUC_PACKED DDLM_SLAVE_DIAG_CONFIRM;
/* ------------------------------- */
/* message: set_prm */
/* ------------------------------- */
/* message command msg.b msg.a */
#define DDLM_Set_Prm 0x4a
typedef struct DDLM_SET_PRM_REQUESTtag {
unsigned char bRem_Add;
unsigned char abUsr_Prm_Data[DPM_MAX_LEN_DATA_UNIT];
} GNUC_PACKED DDLM_SET_PRM_REQUEST;
typedef struct DDLM_SET_PRM_CONFIRMtag {
unsigned char bRem_Add;
} GNUC_PACKED DDLM_SET_PRM_CONFIRM;
/* ------------------------------- */
/* message: get_cfg */
/* ------------------------------- */
/* message command msg.b msg.a */
#define DDLM_Get_Cfg 0xe8
/* ------------------------------- */
/* message: start_seq */
/* ------------------------------- */
/* message command msg.b msg.a */
#define DDLM_Start_Seq 0x43
typedef struct DDLM_START_SEQ_REQUESTtag {
unsigned char bReq_Add; /* 0 */
unsigned char bArea_Code; /* 0 - 125 */
unsigned short usTimeout; /* 0 - 65535 */
} GNUC_PACKED DDLM_START_SEQ_REQUEST;
typedef struct DDLM_START_SEQ_CONFIRMtag {
unsigned char bMax_Len_Data_Unit; /* 240 */
} GNUC_PACKED DDLM_START_SEQ_CONFIRM;
/* ------------------------------- */
/* message: download */
/* ------------------------------- */
/* message command msg.b msg.a */
#define DDLM_Download 0x44
#define DPM_DEVICE_PRM 127
/* message data structure */
typedef struct DDLM_DOWNLOAD_REQUESTtag {
unsigned char bReq_Add; /* 0 */
unsigned char bArea_Code; /* 0 - 125, 127 */
unsigned short usAdd_Offset; /* 0 - 760 */
unsigned char abData[DPM_MAX_LEN_DATA_UNIT];
} GNUC_PACKED DDLM_DOWNLOAD_REQUEST;
/* ------------------------------- */
/* message: upload */
/* ------------------------------- */
/* message command msg.b msg.a */
#define DDLM_Upload 0x50
/* message data structure */
typedef struct DDLM_UPLOAD_REQUESTtag {
unsigned char bReq_Add; /* 0 */
unsigned char bArea_Code; /* 0 - 125, 127 */
unsigned short usAdd_Offset; /* 0 - 760 */
unsigned char bData_Len; /* 1-240 */
} GNUC_PACKED DDLM_UPLOAD_REQUEST;
/* ------------------------------- */
/* message: end_sequence */
/* ------------------------------- */
/* message command msg.b msg.a */
#define DDLM_End_Seq 0x45
/* message data structure */
typedef struct DDLM_END_SEQ_REQUESTtag {
unsigned char bReq_Add; /* 0 */
} GNUC_PACKED DDLM_END_SEQ_REQUEST;
/* ------------------------------- */
/* message: global_control */
/* ------------------------------- */
/* message command msg.b msg.a */
#define DDLM_Global_Control 0x46
/* message data structure */
typedef struct DDLM_GLOBAL_CONTROL_REQUESTtag {
unsigned char bRem_Add; /* 0 - 127 */
unsigned char bControl_Command;
#define CLEAR_DATA 0x02
#define UNFREEZE 0x04
#define FREEZE 0x08
#define UNSYNC 0x10
#define SYNC 0x20 /* unsigned chars can be combined with an 'or' command */
unsigned char bGroup_Select;
} GNUC_PACKED DDLM_GLOBAL_CONTROL_REQUEST;
typedef struct DDLM_GLOBAL_CONTROL_CONFIRMtag {
unsigned char bRem_Add; /* 0 - 127 */
} GNUC_PACKED DDLM_GLOBAL_CONTROL_CONFIRM;
/* ------------------------------- */
/* message: life_list */
/* ------------------------------- */
#define DDLM_Life_List 0x96
/* ------------------------------- */
/* message: Read_Input */
/* ------------------------------- */
#define DDLM_RD_Input 0xE9
/* ------------------------------- */
/* message: Read_Output */
/* ------------------------------- */
#define DDLM_RD_Output 0xEA
/* ------------------------------- */
/* message: Set-Slaveadress */
/* ------------------------------- */
#define DDLM_Set_Slave_Add 0xEB
/* --------------------------------- */
/* message: FDL_Send_Data_Ack */
/* --------------------------------- */
#define FDL_Send_Data_Ack_Req 0x80
#define FDL_Send_Data_Ack_Con 0x80
#define FDL_Send_Data_Ack_Ind 0xC0
#define FDL_Send_Data_No_Ack_Ind 0xC1
#define DATA_STU_SIZE 244
typedef struct octet_strtag {
unsigned char bLen; /* length of data field 0 to 244 */
unsigned char bValue[ DATA_STU_SIZE ]; /* data field */
} GNUC_PACKED octet_str;
typedef struct FDL_DATA_ACK_REQ_STUtag {
unsigned char bSsap; /* Src.Serv.Acc.Point0-62,255 */
unsigned char bDsap; /* Dest.Serv.Acc.Point0-63,255 */
unsigned char bRem_add_da; /* Remote Address 0-126 */
unsigned char bServ_class; /* Prio Low=0,high=1*/
octet_str tL_sdu; /* data field structure */
} GNUC_PACKED FDL_DATA_ACK_REQ_STU;
typedef struct FDL_DATA_ACK_IND_STUtag {
unsigned char bDsap; /* Dest.Serv.Acc.Point0-63,255 */
unsigned char bSsap; /* Src.Serv.Acc.Point0-62,255 */
unsigned char bRem_add_da; /* Remote Address 0-126 */
unsigned char bLoc_add_da; /* local Address in PROFIBUS 0 to 127 */
unsigned char bServ_class; /* Prio Low=0,high=1*/
octet_str tL_sdu; /* data field structure */
} GNUC_PACKED FDL_DATA_ACK_IND_STU;
/* --------------------------------- */
/* message: */
/* --------------------------------- */
#define FDL_Send_Data_No_Ack_Req 0x81
#define FDL_Send_Data_No_Ack_Con 0x81
/* --------------------------------- */
/* message: FDL_Send_Data_With_Reply */
/* --------------------------------- */
#define FDL_Send_Data_Reply_Req 0x82
#define FDL_Send_Data_Reply_Con 0x82
#define FDL_Send_Data_Reply_Ind 0xC2
typedef struct FDL_DATA_REPLY_REQ_STUtag {
unsigned char bSsap; /* Source Service Access Point 0 to 126 */
unsigned char bDsap; /* Destination Service Access Point 0 to 127 */
unsigned char bRem_add_da;/* Remote Address in PROFIBUS 0 to 127 */
unsigned char bServ_class;/* Priority of service = 0 Low */
octet_str tL_sdu; /* data field structure */
} GNUC_PACKED FDL_DATA_REPLY_REQ_STU;
typedef struct FDL_DATA_REPLY_CON_STUtag {
unsigned char bSsap; /* Source Service Access Point 0 to 126 */
unsigned char bDsap; /* Destination Service Access Point 0 to 127 */
unsigned char bRem_add_da;/* Remote Address in PROFIBUS 0 to 127 */
unsigned char bServ_class;/* Priority of service = 0 Low */
unsigned char bL_status; /* Error code */
octet_str tL_sdu; /* data field structure */
} GNUC_PACKED FDL_DATA_REPLY_CON_STU;
typedef struct FDL_DATA_REPLY_IND_STUtag {
unsigned char bDsap; /* Destination Service Access Point 0 to 127 */
unsigned char bSsap; /* Source Service Access Point 0 to 126 */
unsigned char bRem_add_da; /* Remote Address in PROFIBUS 0 to 127 */
unsigned char bLoc_add_da; /* local Address in PROFIBUS 0 to 127 */
unsigned char bServ_class; /* Priority of service = 0 Low */
unsigned char bUpdate_status; /* reply data sent, or not */
octet_str tL_sdu; /* data field structure */
} GNUC_PACKED FDL_DATA_REPLY_IND_STU;
/* definition for bUpdate_status */
#define CON_LO 0x20 /* low priority data transmitted in response */
#define CON_HI 0x21 /* high priority data transmitted in response */
#define CON_NO_DATA 0x22 /* no data transmitted in response */
/* --------------------------------- */
/* message: FDL_Reply_Update */
/* --------------------------------- */
#define FDL_Reply_Update_Req 0x83
typedef struct FDL_REPLY_UPDATE_REQ_STUtag {
unsigned char bSsap; /* Src.Serv.Acc.Point 0-62 */
unsigned char bDsap; /* not used */
unsigned char bRem_add_da; /* not used */
unsigned char bServ_class; /* Prio Low=0,high=1*/
unsigned char bTransmit; /* Single=1/Multiple=2*/
octet_str tL_sdu; /* data field structure */
} GNUC_PACKED FDL_REPLY_UPDATE_REQ_STU;
typedef struct FDL_REPLY_UPDATE_CON_STUtag {
unsigned char bSsap; /* Src.Serv.Acc.Point 0-62 */
unsigned char bDsap; /* Dest.Serv.Acc.Point 0-63 */
unsigned char bRem_add_da; /* Remote Address 0-126 */
unsigned char bServ_class; /* Prio Low=0,high=1*/
unsigned char bL_status; /* error code */
} GNUC_PACKED FDL_REPLY_UPDATE_CON_STU;
/* --------------------------------- */
/* message: FDL_Activate_SSap */
/* --------------------------------- */
#define FDL_SSap_Activate_req 0x97
#define FDL_SSap_Activate_con 0x97
typedef struct FDL_SAP_ACTIVATE_REQ_STUtag {
unsigned char bSsap; /* Source Service Access Point 0-63,65 */
unsigned char bAccess; /* Accessright = 255 */
unsigned char bService_list_length; /* Length of followed list = 4 */
#define SERVICE_SDA 0
#define SERVICE_SDN 1
#define SERVICE_SRD 2
unsigned char abService_activate[4]; /* Service that shall be activated*/
#define ROLE_IN_BOTH 1 /* Role_IN-Service Both */
#define ROLE_IN_RESPONDER 2
#define ROLE_IN_INITIATOR 3
unsigned char abRole_in_service [4]; /* Configuration for the service */
struct {
unsigned char bReq_low; /* Maximum length of buffer = 240 */
unsigned char bReq_high; /* Maximum length of buffer = 240 */
unsigned char bInd_low; /* Maximum length of buffer = 240 */
unsigned char bInd_high; /* Maximum length of buffer = 240 */
} GNUC_PACKED tNon_cyclic_L_sdu_length_list[3];
} GNUC_PACKED FDL_SAP_ACTIVATE_REQ_STU;
typedef struct FDL_SAP_ACTIVATE_CON_STUtag {
unsigned char bSsap; /* Src. Service Access Pnt */
unsigned char bM_status;
} GNUC_PACKED FDL_SAP_ACTIVATE_CON_STU;
/* --------------------------------- */
/* message: FDL_Activate_RSap */
/* --------------------------------- */
#define FDL_RSap_Activate_Req 0x98
#define FDL_RSap_Activate_Con 0x98
typedef struct FDL_RSAP_ACTIVATE_REQ_STUtag {
unsigned char bSsap; /* Source Service Access Point 0-63,65 */
unsigned char bAccess; /* Accessright = 255 */
unsigned char bIndication_mode;
unsigned char bReq_low; /* Maximum length of buffer = 240 */
unsigned char bReq_high; /* Maximum length of buffer = 240 */
unsigned char bInd_low; /* Maximum length of buffer = 240 */
unsigned char bInd_high; /* Maximum length of buffer = 240 */
} GNUC_PACKED FDL_RSAP_ACTIVATE_REQ_STU;
typedef struct FDL_RSAP_ACTIVATE_CON_STUtag {
unsigned char bSsap; /* Src. Service Access Pnt */
unsigned char bM_status;
} GNUC_PACKED FDL_RSAP_ACTIVATE_CON_STU;
/* --------------------------------- */
/* message: FDL_Deactivate_Sap */
/* --------------------------------- */
#define FDL_Sap_Deactivate_Req 0x9A
#define FDL_Sap_Deactivate_Con 0x9A
typedef struct
{
unsigned char bSsap; /* Source Serv. Access Pnt 0-63,255 */
} GNUC_PACKED FDL_SAP_DEACTIVATE_REQ_STU;
typedef struct
{
unsigned char bSsap; /* Src. Service Access Pnt 0-63,255 */
unsigned char bM_status;
} GNUC_PACKED FDL_SAP_DEACTIVATE_CON_STU;
/* ======================================================================== */
/* message error numbers */
/* ======================================================================== */
#define CON_OK 0x00 /* no error */
#define CON_RS 0x03 /* Profibus-DP service not accessible */
#define CON_NO 0x13 /* no access in current master mode */
#define CON_IV 0x15 /* parameter fault in request */
#define CON_NP 0x19 /* no plausible reaction from remote station*/
#define CON_TO 0x30 /* function timeout */
#define CON_NI 0x34 /* function not available on responder */
#define CON_EA 0x35 /* area overflow */
#define CON_AD 0x36 /* access denied */
#define CON_IP 0x37 /* parameter error */
#define CON_SE 0x39 /* sequence fault */
#define CON_NE 0x3A /* requested data not available */
#define CON_DI 0x3B /* data fault or not complete */
#if defined( _MSC_VER) /* Microsoft C */
#pragma pack() /* Byte Alignment */
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
/* === eof 'DPM_USER.H' === */
/* <St> *******************************************************************
======================== Copyright =====================================
Copyright (C) 2004 Hilscher GmbH
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the program, if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
========================================================================
FILENAME : RCS_USER.H
-------------------------------------------------------------------------
CREATED BY : R.Mayer, Hilscher GmbH
CREATED AT : 10.05.96
PROJECT : global
=========================================================================
FUNCTION :
General RCS definitions
=========================================================================
CHANGES OF REVISIONS :
Version Name Date Change
-------------------------------------------------------------------------
V1.002 Mayer 14.05.98 RCS_TELEGRAMHEADERDATA_10 structure included
V1.001 Mayer 29.05.96 Task errors included
V1.000 Mayer 10.05.96 created from the file rc090203.h
******************************************************************** <En> */
#ifdef __cplusplus
}
#endif
#if defined( _MSC_VER) /* Microsoft C */
#pragma pack(1) /* Byte Alignment */
#endif
/* ======================================================================== */
/* General task errors */
/* ======================================================================== */
#define TASK_F_OK 0
#define TASK_F_NO_COMMUNICATION 1
#define TASK_F_IDLE 2
#define TASK_F_INIT_BASE 50
#define TASK_F_PARITY 100
#define TASK_F_FRAMING 101
#define TASK_F_OVERRUN 102
#define TASK_F_DATACOUNT 103
#define TASK_F_CHECKSUM 104
#define TASK_F_TIMEOUT 105
#define TASK_F_PROTOCOL 106
#define TASK_F_DATA 107
#define TASK_F_NACK 108
#define TASK_F_PROTOCOL_BASE 110
#define TASK_F_MESSAGEHEADER 150
#define TASK_F_MESSAGESIZE 151
#define TASK_F_MESSAGECOMMAND 152
#define TASK_F_MESSAGESTRUCTURE 153
#define TASK_F_MESSAGEERROR 154
#define TASK_F_MESSAGETIMEOUT 155
#define TASK_F_TELEGRAMHEADER 160
#define TASK_F_DEVICE_ADR 161
#define TASK_F_DATA_AREA 162
#define TASK_F_DATA_ADR 163
#define TASK_F_DATA_IDX 164
#define TASK_F_DATA_CNT 165
#define TASK_F_DATA_TYPE 166
#define TASK_F_FUNCTION 167
#define TASK_F_MESSAGE_BASE 170
#define TASK_F_NOT_INITIALIZED 200
#define TASK_F_BUSY 201
#define TASK_F_SEGMENT 202
#define TASK_F_USER 203
#define TASK_F_DATABASE 210
#define TASK_F_DATABASE_WRITE 211
#define TASK_F_DATABASE_READ 212
#define TASK_F_STRUCTURE 213
#define TASK_F_PARAMETER 214
#define TASK_F_CONFIGURATION 215
#define TASK_F_FUNCTIONLIST 216
#define TASK_F_SYSTEM 217
#define TASK_F_SYSTEM_BASE 220
/* ======================================================================== */
/* Task commands */
/* ======================================================================== */
#define TASK_B_10 16 /* RCS_TELEGRAMHEADER_10 */
#define TASK_B_11 17 /* Task specific */
/* ======================================================================== */
/* Message definitions */
/* ======================================================================== */
/* ----------------- Definition of the standard telegram header ----------- */
/* Keyword: MESSAGE ---------------------------------------------------- */
/* TelegramFunCtion */
#define TASK_TFC_UNUSED 0
#define TASK_TFC_READ 1
#define TASK_TFC_WRITE 2
#define TASK_TFC_QUERRY 3
/* TelegramDataArea */
/* 'data_area' */
#define TASK_TDA_UNUSED 0
#define TASK_TDA_BIT 1
#define TASK_TDA_BYTE 2
#define TASK_TDA_WORD 3
#define TASK_TDA_DWORD 4
#define TASK_TDA_FLOAT 5
/* TelegramDataType */
/* 'data_type' for MOTOROLA data types ! */
/* For INTEL data types, the 'RCS_TDT_IDF_MASK' flag must be set */
#define TASK_TDT_UNUSED 0
#define TASK_TDT_BOOLEAN 1
#define TASK_TDT_INT8 2
#define TASK_TDT_INT16 3
#define TASK_TDT_INT32 4
#define TASK_TDT_UINT8 5
#define TASK_TDT_UINT16 6
#define TASK_TDT_UINT32 7
#define TASK_TDT_FLOAT 8
#define TASK_TDT_ASCII 9
#define TASK_TDT_STRING 10
#define TASK_TDT_BIT 14
#define TASK_TDT_IDF_MSK 0X80
/* ======================================================================== */
/* Message structure definitions */
/* ======================================================================== */
/* -------------------- General RCS definitions -------------------------- */
/* Keyword: MESSAGE ------------------------------------------------------ */
#define RCS_SEGMENT_LEN 288
#define RCS_MESSAGEHEADER_LEN 8
#define RCS_TELEGRAMHEADER_LEN 8
/* ------------------------ RCS message definition ------------------------ */
typedef struct RCS_MESSAGEHEADERtag {
unsigned char rx; /* receiver */
unsigned char tx; /* transmitter */
unsigned char ln; /* lenght */
unsigned char nr; /* number */
unsigned char a; /* answer */
unsigned char f; /* fault */
unsigned char b; /* command */
unsigned char e; /* extension */
} RCS_MESSAGEHEADER;
typedef struct RCS_MESSAGEtag {
unsigned char rx; /* receiver */
unsigned char tx; /* transmitter */
unsigned char ln; /* lenght */
unsigned char nr; /* number */
unsigned char a; /* answer */
unsigned char f; /* fault */
unsigned char b; /* command */
unsigned char e; /* extension */
unsigned char d[ RCS_SEGMENT_LEN-RCS_MESSAGEHEADER_LEN ]; /* data */
} RCS_MESSAGE;
/* ----------------- Standard telegram header ----------------------------- */
/* Keyword: MESSAGE, TASK_B_10 --------------------------------------------*/
typedef struct RCS_TELEGRAMHEADER_10tag {
unsigned char device_adr; /* device address */
unsigned char data_area; /* data area */
unsigned short data_adr; /* data address */
unsigned char data_idx; /* data index */
unsigned char data_cnt; /* data count */
unsigned char data_type; /* data type */
unsigned char function; /* function */
} RCS_TELEGRAMHEADER_10;
typedef struct RCS_MESSAGETELEGRAMHEADER_10_tag {
unsigned char rx; /* receiver */
unsigned char tx; /* transmitter */
unsigned char ln; /* lenght */
unsigned char nr; /* number */
unsigned char a; /* answer */
unsigned char f; /* fault */
unsigned char b; /* command */
unsigned char e; /* extension */
unsigned char device_adr; /* device address */
unsigned char data_area; /* data area */
unsigned short data_adr; /* data address */
unsigned char data_idx; /* data index */
unsigned char data_cnt; /* data count */
unsigned char data_type; /* data type */
unsigned char function; /* function */
} RCS_MESSAGETELEGRAMHEADER_10;
typedef struct RCS_TELEGRAMHEADERDATA_10tag {
unsigned char device_adr;
unsigned char data_area;
unsigned short data_adr;
unsigned char data_idx;
unsigned char data_cnt;
unsigned char data_type;
unsigned char function;
unsigned char d[ RCS_SEGMENT_LEN-RCS_MESSAGEHEADER_LEN-RCS_TELEGRAMHEADER_LEN];
} RCS_TELEGRAMHEADERDATA_10;
typedef struct RCS_MESSAGETELEGRAM_10tag {
unsigned char rx; /* receiver */
unsigned char tx; /* transmitter */
unsigned char ln; /* lenght */
unsigned char nr; /* number */
unsigned char a; /* answer */
unsigned char f; /* fault */
unsigned char b; /* command */
unsigned char e; /* extension */
unsigned char device_adr; /* device address */
unsigned char data_area; /* data area */
unsigned short data_adr; /* data address */
unsigned char data_idx; /* data index */
unsigned char data_cnt; /* data count */
unsigned char data_type; /* data type */
unsigned char function; /* function */
unsigned char d[ RCS_SEGMENT_LEN-RCS_MESSAGEHEADER_LEN-RCS_TELEGRAMHEADER_LEN];
} RCS_MESSAGETELEGRAM_10;
#if defined( _MSC_VER) /* Microsoft C */
#pragma pack() /* Byte Alignment */
#endif
#ifdef __cplusplus
}
#endif
/* === eof 'RCS_USER.H' === */
/* <St> *******************************************************************
======================== Copyright =====================================
Copyright (C) 2004 Hilscher GmbH
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the program, if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
========================================================================
FILENAME : RcsDef.h
-------------------------------------------------------------------------
CREATED BY : R.Mayer, Hilscher GmbH
CREATED AT : 10.03.97
PROJECT :
=========================================================================
FUNCTION / CLASSDESCRIPTION:
=========================================================================
CHANGES OF REVISIONS :
Version Name Date Change
-------------------------------------------------------------------------
1.000 RM 10.03.97 Created
******************************************************************** <En> */
// Prevent multiple inclusion
#ifndef __RCSDEF_H__
#define __RCSDEF_H__
#ifdef _cplusplus
extern "C" {
#endif /* _cplusplus */
#define FIRMWARE_DOWNLOAD 1
#define CONFIGURATION_DOWNLOAD 2
/* ======================================================================== */
/* Message definitions */
/* ======================================================================== */
#define RCS_TASK 0x00 /* Number of RCS */
#define PLC_TASK 0x02 /* Number for PLC_TASK */
#define MSG_SYSTEM_TX 0xFF /* Transmitter for system functions number */
#define RCS_B_TASK_STATE 4 // Task state
/************************************************************************** */
/* Genaral RCS commands */
/************************************************************************** */
#define RCS_B_SYSFKT 1
#define RCS_B_TASKFKT 2
#define RCS_B_DIAGNOSE 3
#define RCS_B_STRUCTFNC 4
#define RCS_B_TRACE 5
#define RCS_B_LOADFKT 6
#define RCS_B_DBMFKT 10
/* ----------------------- */
/* Message extension masks */
/* ----------------------- */
#define RCS_FIFO_MSK 0
#define RCS_LIFO_MSK 1
#define RCS_NAK_MSK 2
#define RCS_NORM_MSK 0
#define RCS_FIRST_MSK 4
#define RCS_CONT_MSK 8
#define RCS_LAST_MSK 0x0C
#define RCS_SEQ_MSK 0x0C
/* ------------------ */
/* Mode definitions */
/* ------------------ */
#define MODE_NEUSTART 0 /* Command: B_SYSFKT */
#define MODE_KALTSTART 1 /* Command: B_SYSFKT */
#define MODE_WARMSTART 2 /* Command: B_SYSFKT */
#define MODE_ZYKL_STATUS_STOP 3 /* Command: B_SYSFKT */
#define MODE_FWVERSION 4 /* Command: B_SYSFKT */
#define MODE_GET_PROJ_WERTE_HW 5 /* Command: B_SYSFKT */
#define MODE_GET_PROJ_WERTE_SW 6 /* Command: B_SYSFKT */
#define MODE_SHOW_DYN_SYSSTAT 7 /* Command: B_SYSFKT */
#define MODE_SETTIME 9 /* not implemented yet */
#define MODE_SET_DEVICE_DATA 9 /* not implemented yet */
#define MODE_MODUL_RCS 11 /* Command: B_SYSFKT */
#define MODE_MODUL_LIB 12 /* Command: B_SYSFKT */
#define MODE_MODUL_MCL 13 /* Command: B_SYSFKT */
#define MODE_MODUL_LIB 12 /* Command: B_SYSFKT */
#define MODE_MODUL_MCL 13 /* Command: B_SYSFKT */
#define MODE_DISTRIBUTOR_DRIVER 14 /* Command: B_SYSFKT ->function 1 = insert */
#define MODE_PRINT_DRIVER 15 /* Command: B_SYSFKT */
#define MODE_GET_RCS_ERROR 16 /* Command: B_SYSFKT */
#define MODE_PRINT_DEVICE 1 /* NO mode, only for MENU.H */
#define MODE_PRINT_DEVICE_DRIVER 2 /* NO mode, only for MENU.H */
#define MODE_START_STOP_STAT 0 /* Command: B_TASKFKT */
#define MODE_START_STOP 1 /* Command: B_TASKFKT */
#define MODE_TASK_VERSION 2 /* Command: B_TASKFKT */
#define MODE_ZYKL_STATUS 3 /* Command: B_TASKFKT */
#define MODE_SHOW_FUELLST 4 /* Command: B_TASKFKT */
#define MODE_SHOW_TIMER 5 /* Command: B_TASKFKT */
#define MODE_DIAG_MEM_READ_SINGLE 0x0 /* Command: B_DIAGNOSE */
#define MODE_DIAG_MEM_WRITE_SINGLE 0x1 /* Command: B_DIAGNOSE */
#define MODE_DIAG_IO_READ_SINGLE 0x2 /* Command: B_STRUKTFKT */
#define MODE_DIAG_IO_WRITE_SINGLE 0x3 /* Command: B_STRUKTFKT */
#define MODE_DIAG_ZYKL 0x10 /* Command: B_STRUKTFKT */
#define MODE_DIAG_MEM_READ_ZYKL 0x10 /* Command: B_STRUKTFKT */
#define MODE_DIAG_MEM_WRITE_ZYKL 0x11 /* Command: B_STRUKTFKT */
#define MODE_DIAG_IO_READ_ZYKL 0x12 /* Command: B_STRUKTFKT */
#define MODE_DIAG_IO_WRITE_ZYKL 0x13 /* Command: B_STRUKTFKT */
#define MODE_ZYKL_TASK_STRUK 0 /* Command: B_STRUKTFKT */
#define MODE_INIT_INFO_STRUK 1 /* Command: B_STRUKTFKT */
#define MODE_WRITE_STRUK 2 /* Command: B_STRUKTFKT */
#define MODE_START_TRACE 0 /* Command: B_TRACE */
#define MODE_DEL_TRACE_PUF 1 /* Command: B_TRACE */
#define MODE_UPLOAD_BINAER 0 /* Command: B_LOADFKT */
#define MODE_DOWNLOAD_BINAER 1 /* Command: B_LOADFKT */
#define MODE_UPLOAD_DBM 2 /* Command: B_LOADFKT */
#define MODE_DOWNLOAD_DBM 3 /* Command: B_LOADFKT */
#define MODE_DEL_FLASH 4 /* Command: B_LOADFKT */
#define MODE_GET_FLASH_DIR 5 /* Command: B_LOADFKT */
#define MODE_URLADEN 6 /* Command: B_LOADFKT */
#define MODE_LONG_BINLOAD 7 /* Command: B_LOADFKT */
#define MODE_FREE_DRIVER 8 /* Command: B_LOADFKT */
#define MODE_RESET_DEVICE 10 /* Command: B_LOADFKT */
/* ------------------------------------------------------------------------------------ */
#ifdef _cplusplus
}
#endif
#endif
// ======== eof 'RcsDef.h' ========
...@@ -30,14 +30,6 @@ ...@@ -30,14 +30,6 @@
#include <sys/file.h> #include <sys/file.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h" #include "rt_io_pb_locals.h"
#include "pwr.h" #include "pwr.h"
...@@ -47,7 +39,6 @@ ...@@ -47,7 +39,6 @@
#include "rt_io_bus.h" #include "rt_io_bus.h"
#include "rt_io_msg.h" #include "rt_io_msg.h"
#include "rt_errh.h" #include "rt_errh.h"
#include "rt_io_profiboard.h"
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Convert ai from rawvalue to actualvalue. Convert ai from rawvalue to actualvalue.
......
...@@ -28,15 +28,6 @@ ...@@ -28,15 +28,6 @@
#include <sys/file.h> #include <sys/file.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h" #include "rt_io_pb_locals.h"
#include "pwr.h" #include "pwr.h"
...@@ -46,7 +37,6 @@ ...@@ -46,7 +37,6 @@
#include "rt_io_bus.h" #include "rt_io_bus.h"
#include "rt_io_msg.h" #include "rt_io_msg.h"
#include "rt_errh.h" #include "rt_errh.h"
#include "rt_io_profiboard.h"
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
......
...@@ -28,15 +28,6 @@ ...@@ -28,15 +28,6 @@
#include <sys/file.h> #include <sys/file.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h" #include "rt_io_pb_locals.h"
#include "pwr.h" #include "pwr.h"
...@@ -46,7 +37,6 @@ ...@@ -46,7 +37,6 @@
#include "rt_io_bus.h" #include "rt_io_bus.h"
#include "rt_io_msg.h" #include "rt_io_msg.h"
#include "rt_errh.h" #include "rt_errh.h"
#include "rt_io_profiboard.h"
#define IO_CONVMASK_ALL 0xFFFF #define IO_CONVMASK_ALL 0xFFFF
......
...@@ -28,15 +28,6 @@ ...@@ -28,15 +28,6 @@
#include <sys/file.h> #include <sys/file.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h" #include "rt_io_pb_locals.h"
#include "pwr.h" #include "pwr.h"
...@@ -46,7 +37,6 @@ ...@@ -46,7 +37,6 @@
#include "rt_io_bus.h" #include "rt_io_bus.h"
#include "rt_io_msg.h" #include "rt_io_msg.h"
#include "rt_errh.h" #include "rt_errh.h"
#include "rt_io_profiboard.h"
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
......
...@@ -27,15 +27,6 @@ ...@@ -27,15 +27,6 @@
#include <sys/file.h> #include <sys/file.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h" #include "rt_io_pb_locals.h"
#include "pwr.h" #include "pwr.h"
...@@ -316,20 +307,12 @@ static pwr_tStatus IoRackRead ( ...@@ -316,20 +307,12 @@ static pwr_tStatus IoRackRead (
{ {
pwr_sClass_Pb_Profiboard *mp; pwr_sClass_Pb_Profiboard *mp;
pwr_sClass_Pb_DP_Slave *sp; pwr_sClass_Pb_DP_Slave *sp;
T_PROFI_DEVICE_HANDLE *hDevice;
pwr_tUInt16 sts;
pwr_tUInt16 data_len;
hDevice = (T_PROFI_DEVICE_HANDLE *) ap->Local;
sp = (pwr_sClass_Pb_DP_Slave *) rp->op; sp = (pwr_sClass_Pb_DP_Slave *) rp->op;
mp = (pwr_sClass_Pb_Profiboard *) ap->op; mp = (pwr_sClass_Pb_Profiboard *) ap->op;
if (sp->Status == PB__NORMAL && mp->Status == PB__NORMAL && sp->DisableSlave != 1 && mp->DisableBus != 1) { /* The reading of the process image is now performed at the agent level,
this eliminates the need for board specific code at the rack level. */
data_len = sp->BytesOfInput;
sts = profi_get_data(hDevice, ID_DP_SLAVE_IO_IMAGE, sp->OffsetInputs, &data_len, &sp->Inputs );
}
if (sp->DisableSlave != 1 && mp->DisableBus != 1) { if (sp->DisableSlave != 1 && mp->DisableBus != 1) {
...@@ -368,26 +351,12 @@ static pwr_tStatus IoRackWrite ( ...@@ -368,26 +351,12 @@ static pwr_tStatus IoRackWrite (
{ {
pwr_sClass_Pb_Profiboard *mp; pwr_sClass_Pb_Profiboard *mp;
pwr_sClass_Pb_DP_Slave *sp; pwr_sClass_Pb_DP_Slave *sp;
T_PROFI_DEVICE_HANDLE *hDevice;
pwr_tUInt16 sts;
hDevice = (T_PROFI_DEVICE_HANDLE *) ap->Local;
sp = (pwr_sClass_Pb_DP_Slave *) rp->op; sp = (pwr_sClass_Pb_DP_Slave *) rp->op;
mp = (pwr_sClass_Pb_Profiboard *) ap->op; mp = (pwr_sClass_Pb_Profiboard *) ap->op;
// Write the whole I/O output area from local area /* The writing of the process image is now performed at the agent level,
this eliminates the need for board specific code at the rack level. */
if ((sp->Status == PB__NORMAL || sp->Status == PB__NOCONN) &&
mp->Status == PB__NORMAL && (sp->DisableSlave != 1) && (mp->DisableBus != 1)) {
if (sp->BytesOfOutput > 0) {
sts = profi_set_data(hDevice, ID_DP_SLAVE_IO_IMAGE, sp->OffsetOutputs, sp->BytesOfOutput, &sp->Outputs);
if (sts != E_OK) sp->ErrorCount++;
}
}
if (sp->DisableSlave == 1 || mp->DisableBus == 1) sp->Status = PB__DISABLED; if (sp->DisableSlave == 1 || mp->DisableBus == 1) sp->Status = PB__DISABLED;
......
/*
* Proview $Id$
* Copyright (C) 2008 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* rt_io_m_pb_hilscher.c -- Proview agent for the Hilscher CIF 50-PB
* Profibus DP board.
*/
/* Enable this define to spam the Proview log with diagnostic messages
from the slaves (this is probably a bad idea). */
/* #define SLAVE_DIAG_VERBOSE */
/* Enable this define to permit the agent to write to the board's flash in
order to remove the SyCon database. */
#define FLASH_WRITE_ENABLE
/* A note on assertions: There are some asserts in the code, most of these
are only used during initialization to verify that we do not write outside
our buffers or provide the Hilscher API with messages that would be too long.
The asserts may be disabled completely by using the NDEBUG macro, defined
in assert.h (man assert(3)). I would, however, recommend against that. */
/*
The code refers to some documents provided by Hilscher, the documents are:
CIFLinux_en.pdf: found in cif2620.tbz, the Linux version of the Hilscher
driver and API.
dpm_pie.pdf: found on the system software disc that comes with the board.
*/
#define BOARD_INIT_ERROR -1
#pragma pack(1)
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include "cif_user.h"
#include "rcs_user.h"
#include "dpm_user.h"
#include "rt_io_pb_locals.h"
#include "pwr.h"
#include "co_cdh.h"
#include "pwr_baseclasses.h"
#include "pwr_profibusclasses.h"
#include "rt_io_base.h"
#include "rt_io_bus.h"
#include "rt_io_msg.h"
#include "rt_errh.h"
#include "rt_io_agent_init.h"
#include "rt_pb_msg.h"
typedef struct {
/* Board number. */
unsigned short dev_number;
/* Number of occupied bytes in the input area of the dual port ram. */
unsigned short input_size;
/* Number of occupied bytes in the output area of the dual port ram. */
unsigned short output_size;
/* Message counter for communicating with the Profibus board,
(pre-)incremented before sending each message, the value is then
sent with the message. This message counter is optional. */
unsigned char cif_msgcnt;
/* Watchdog counter, used by DevTriggerWatchDog() as explained on page
58 of CIFLinux_en.pdf. */
unsigned short watchdog;
} io_sAgentLocal;
/* Prototypes for functions exported to Proview. */
static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent *ap);
static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent *ap);
static pwr_tStatus IoAgentWrite(io_tCtx ctx, io_sAgent *ap);
static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent *ap);
#ifdef FLASH_WRITE_ENABLE
/*** Structures for board flashing. ***/
/* Start segment of the database, shall be 8 for
CIF30-DPM, CIF104-DPM, COM-DPM, COM-PB, CIF104-PB and CIF 50-PB.
Shall be 0 for CIF 30-PB and CIF 60-PB. */
typedef struct {
/* Used to terminate the table, se to 1 for every entry but the
last (dummy entry), which should be 0. */
unsigned char entry;
/* The DEVINFO struct for this board. */
DEVINFO info;
/* Start segment of the database for this board. */
unsigned char db_startsegment;
/* A human readable name for this board. Max 99 characters! */
unsigned char board_name[100];
} boards;
/* Table of known boards, consists of four fields according to the board type.
The last entry must be a null termination (entry == 0).
*/
boards known_boards[] = {
{ 1, { 8, 50, 66, { 'C', 'I', 'F'} }, 8, "Hilscher CIF 50-PB" },
{ 0 }
};
#endif /* FLASH_WRITE_ENABLE */
/* Initializes Profibus DP interface on the CIF board referred to by local.
DRV_NO_ERROR is returned upon success. */
static short
dpm_init_master(io_sAgentLocal *local, pwr_sClass_Pb_Hilscher *op,
io_sAgent *ap)
{
short rv;
DPM_PLC_PARAMETER prm;
/* Clears struct. */
memset(&prm, 0, sizeof(prm));
/* Defines standard parameters. */
prm.bMode = DPM_SET_MODE_BUFFERED_HOST_CONTROLLED;
prm.bCycleTime = 0;
prm.bFormat = DPM_FORMAT_SWAP;
/* Sets the timeout (in milliseconds) for the watchdog supervising the
Profibus DP board. After this amount of time has passed without
any data exchange with the host, the board will be reset which will
eventually make the watchdogs in the slaves time out (normally resulting
in all outputs being cleared). A zero value will disable the watchdog
functionality altogether. */
prm.usWatchDogTime = op->StallTime;
prm.bRedundancy = 0;
prm.bSlStateMethod = DPM_SL_STATE_NOT_SYCHRONOUS;
prm.bEnableBits.biIdentNumberActive = 0;
prm.bEnableBits.biHighPriorHandshake = 0;
/* 0x7505 in LE */
*((unsigned char *) &(prm.usIdentNumber)) = 0x75;
*(((unsigned char *) &(prm.usIdentNumber)) + 1) = 0x05;
/* Writes parameters to the board local->dev_number, task 2, size is
* hardcoded to 16 as specified in dpm_pie.pdf, page 9. */
if ((rv = DevPutTaskParameter(local->dev_number, 2,
16, &prm)) != DRV_NO_ERROR) {
errh_Error("Profibus DP Master %s - "
" DevPutTaskParameter() failed with return code %d",
ap->Name, rv);
return rv;
}
/* Resets board to put new master parameters into effect. */
if ((rv = DevReset(local->dev_number, WARMSTART, 8000)) != DRV_NO_ERROR) {
errh_Error("Profibus DP Master %s - "
" DevReset() failed with return code %d",
ap->Name, rv);
return rv;
}
return rv;
}
/* Opens and initializes the board referred to by local. Upon success
* DRV_NO_ERROR will be returned. */
static short
dpm_init(io_sAgentLocal *local, io_sAgent *ap)
{
short rv;
if ((rv = DevOpenDriver()) != DRV_NO_ERROR) {
errh_Error("Profibus DP Master %s - "
" DevOpenDriver() failed with return code %d",
ap->Name, rv);
return rv;
} else if ((rv = DevInitBoard(local->dev_number)) != DRV_NO_ERROR) {
errh_Error("Profibus DP Master %s - "
" DevInitBoard() failed with return code %d",
ap->Name, rv);
return rv;
}
return DRV_NO_ERROR;
}
/* Closes the board referred to by local. Upon success DRV_NO_ERROR will
be returned. */
static short
dpm_exit(io_sAgentLocal *local, io_sAgent *ap)
{
short rv;
short rv_ret = DRV_NO_ERROR;
if ((rv = DevExitBoard(local->dev_number)) != DRV_NO_ERROR) {
errh_Error("Profibus DP Master %s - "
" DevExitBoard() failed with return code %d",
ap->Name, rv);
rv_ret = rv;
}
if ((rv = DevCloseDriver()) != DRV_NO_ERROR) {
errh_Error("Profibus DP Master %s - "
" DevCloseDriver() failed with return code %d",
ap->Name, rv);
rv_ret = rv;
}
return rv_ret;
}
/* Returns the number of bytes required to represent the inputs of card
(Profibus module) cp. Based on the IoRackInit() method of
rt_io_m_pb_dp_slave.c. */
static short
module_cnt_inputs(io_sCard *cp)
{
short input_counter = 0;
int latent_input_count = 0;
pwr_tCid cid;
io_sChannel *chanp;
int i;
pwr_tInt32 chan_size;
pwr_sClass_ChanDi *chan_di;
pwr_sClass_ChanAi *chan_ai;
pwr_sClass_ChanAit *chan_ait;
pwr_sClass_ChanIi *chan_ii;
/* From v4.1.3 we can have subclasses, find the super class */
for (cid = cp->Class; ODD(gdh_GetSuperClass(cid, &cid, cp->Objid));)
;
if (cid == pwr_cClass_Pb_Module) {
/* New style configuring (from v4.1.3) with Pb_Module objects or
subclass. Loop all channels in the module and set channel size and
offset. */
for (i = 0; i < cp->ChanListSize; ++i) {
chanp = &cp->chanlist[i];
if (is_diag(&chanp->ChanAref)) {
chanp->udata |= PB_UDATA_DIAG;
if (chanp->ChanClass != pwr_cClass_ChanIi)
errh_Error("Diagnostic channel class, card %s", cp->Name);
continue;
}
if (chanp->ChanClass != pwr_cClass_ChanDi) {
input_counter += latent_input_count;
latent_input_count = 0;
}
switch (chanp->ChanClass) {
case pwr_cClass_ChanDi:
chan_di = (pwr_sClass_ChanDi *) chanp->cop;
if (chan_di->Number == 0) {
input_counter += latent_input_count;
latent_input_count = 0;
}
if (chan_di->Number == 0)
latent_input_count = GetChanSize(chan_di->Representation);
break;
case pwr_cClass_ChanAi:
chan_ai = (pwr_sClass_ChanAi *) chanp->cop;
chan_size = GetChanSize(chan_ai->Representation);
input_counter += chan_size;
break;
case pwr_cClass_ChanAit:
chan_ait = (pwr_sClass_ChanAit *) chanp->cop;
chan_size = GetChanSize(chan_ait->Representation);
input_counter += chan_size;
break;
case pwr_cClass_ChanIi:
chan_ii = (pwr_sClass_ChanIi *) chanp->cop;
chan_size = GetChanSize(chan_ii->Representation);
input_counter += chan_size;
break;
}
}
}
return (input_counter + latent_input_count);
}
/* Returns the number of bytes required to represent the outputs of card
(Profibus module) cp. Based on the IoRackInit() method of
rt_io_m_pb_dp_slave.c. */
static short
module_cnt_outputs(io_sCard *cp)
{
short output_counter = 0;
int latent_output_count = 0;
pwr_tCid cid;
io_sChannel *chanp;
int i;
pwr_tInt32 chan_size;
pwr_sClass_ChanDo *chan_do;
pwr_sClass_ChanAo *chan_ao;
pwr_sClass_ChanIo *chan_io;
/* From v4.1.3 we can have subclasses, find the super class */
for (cid = cp->Class; ODD(gdh_GetSuperClass(cid, &cid, cp->Objid));)
;
if (cid == pwr_cClass_Pb_Module) {
/* New style configuring (from v4.1.3) with Pb_Module objects or
subclass. Loop all channels in the module and set channel size and
offset. */
for (i=0; i<cp->ChanListSize; i++) {
chanp = &cp->chanlist[i];
if(is_diag(&chanp->ChanAref)) {
chanp->udata |= PB_UDATA_DIAG;
if (chanp->ChanClass != pwr_cClass_ChanIi)
errh_Error("Diagnostic channel class, card %s", cp->Name);
continue;
}
if (chanp->ChanClass != pwr_cClass_ChanDo) {
output_counter += latent_output_count;
latent_output_count = 0;
}
switch (chanp->ChanClass) {
case pwr_cClass_ChanDo:
chan_do = (pwr_sClass_ChanDo *) chanp->cop;
if (chan_do->Number == 0) {
output_counter += latent_output_count;
latent_output_count = 0;
}
chan_size = GetChanSize(chan_do->Representation);
if (chan_do->Number == 0)
latent_output_count = GetChanSize(chan_do->Representation);
break;
case pwr_cClass_ChanAo:
chan_ao = (pwr_sClass_ChanAo *) chanp->cop;
chan_size = GetChanSize(chan_ao->Representation);
output_counter += chan_size;
break;
case pwr_cClass_ChanIo:
chan_io = (pwr_sClass_ChanIo *) chanp->cop;
chan_size = GetChanSize(chan_io->Representation);
output_counter += chan_size;
break;
}
}
}
return (output_counter + latent_output_count);
}
/* Builds a struct for IO area allocation for the modules attached
to the slave op. The starting offset is derived from the local struct of
ap. The address table will be written to the buffer provided in add_tab.
add_tab will also have its length field updated. Not more than add_tab_len
bytes will be written to add_tab.
The function will also set up the required fields in op so that Proview
may perform IO operations using the IoAgentRead() and IoAgentWrite() functions
in this module. */
static void
dpm_set_add_tab(pwr_sClass_Pb_DP_Slave *op, io_sAgent *ap, io_sRack *rp,
DPM_SL_PRM_ADD_TAB *add_tab, int add_tab_len)
{
io_sCard *cardp;
short input_counter;
short output_counter;
io_sRack *sl;
/* A minimal address table consists of one word of length counter + two
bytes of input and output counters. */
assert(add_tab_len >= 4);
/* Handles for the number of bytes in the board's dual port memory that the
slaves/modules have occupied so far. */
unsigned short *input_size;
unsigned short *output_size;
input_size = (unsigned short *) &((io_sAgentLocal *) ap->Local)->input_size;
output_size =
(unsigned short *) &((io_sAgentLocal *) ap->Local)->output_size;
/* This lets Proview find the IO-area for this module (in this case it is
actually handled at the agent level, thus in this file). The offsets
are known at this time, while the number of IO-bytes are calculated below,
the latter still needs to be initialized to zero. */
op->OffsetInputs = *input_size;
op->OffsetOutputs = *output_size;
op->BytesOfInput = 0;
op->BytesOfOutput = 0;
/* Finds our rack (slave). */
for (sl = rp;
sl != NULL && ((pwr_sClass_Pb_DP_Slave *) sl->op)->SlaveAddress
!= op->SlaveAddress;
sl = sl->next)
;
if (sl == NULL
|| ((pwr_sClass_Pb_DP_Slave *) sl->op)->SlaveAddress
!= op->SlaveAddress) {
errh_Error("Profibus DP Master %s - "
" Can't find rack for slave %d",
ap->Name, op->SlaveAddress);
return;
}
/* Iterates through the cards (modules in Profibus terminology) of
the current rack, counting the length of the input area as we go. */
for (cardp = sl->cardlist; cardp; cardp = cardp->next) {
/* Gets the size of the input area for this module. */
input_counter = module_cnt_inputs(cardp);
/* Saves the length of this module's input area. */
op->BytesOfInput += input_counter;
/* Only modules with and input or output area are required to
have an entry in the add tab. */
if (input_counter > 0) {
assert(add_tab->bInput_Count + 4 < add_tab_len);
/* The MSB tells the Hilscher board whether to treat the address
as a byte (set) or word (unset) offset
(see dpm_pie.pdf, page 45). */
add_tab->ausEA_Offset[add_tab->bInput_Count++]
= *input_size | EA_OFFSET_BYTE;
*input_size += input_counter;
}
}
/* Now process the output areas. */
for (cardp = sl->cardlist; cardp; cardp = cardp->next) {
/* Gets the size of the output area for this module. */
output_counter = module_cnt_outputs(cardp);
/* Saves the length of this module's input area. */
op->BytesOfOutput += output_counter;
/* Only modules with and input or output area are required to
have an entry in the add tab. */
if (output_counter > 0) {
assert(add_tab->bInput_Count + add_tab->bOutput_Count + 4
< add_tab_len);
/* The MSB tells the Hilscher board whether to treat the address
as a byte (set) or word (unset) offset
(see dpm_pie.pdf, page 45). */
/* The input offsets precedes the output offsets. */
add_tab->ausEA_Offset[
add_tab->bInput_Count + add_tab->bOutput_Count++]
= *output_size | EA_OFFSET_BYTE;
*output_size += output_counter;
}
}
assert(add_tab->bInput_Count + add_tab->bOutput_Count <= MAX_EA_OFFSET_LEN);
/* Updates the length of the add_tab struct. */
add_tab->usAdd_Tab_Len = sizeof(add_tab->usAdd_Tab_Len)
+ sizeof(add_tab->bInput_Count) + sizeof(add_tab->bOutput_Count)
+ 2 * add_tab->bInput_Count + 2 * add_tab->bOutput_Count;
}
/* Writes instructions for reflashing the board to the error log. */
static void
flashing_disabled_warning(io_sAgent *ap)
{
errh_Error("Profibus DP Master %s - DDLM Download: this board",
ap->Name);
errh_Error("appears to be set for offline configuration. To make");
errh_Error("the board usable in Proview, delete the configuration");
errh_Error("database from the board's flash. This can be done");
errh_Error("with the tool cif50_rmdb, alternatively the profibus");
errh_Error("agent may be recompiled with flashing support.");
}
/* Produces human readable log entries based on the f-flag (error state) of the
message passed in msg. */
static void
dpm_ddlm_answer_msg_print_error(RCS_MESSAGE *msg, io_sAgent *ap)
{
char *s;
if (msg == NULL)
return;
switch (msg->a) {
case DDLM_Download:
switch (msg->f) {
case 0:
return;
case CON_NO:
s = "master not in offline configuration mode. Delete"
" the data base within the DEVICE, else the DEVICE is not"
" able to execute the download of the dataset file";
break;
case CON_IV:
s = "parameter fault in request. Please check the"
" downloaded parameter in your request message. The"
" Siemens master chip has denied the bus parameter data"
" set.";
break;
case CON_TO:
s = "timeout. If Start and End_Seq messaging is used a"
" message timeout occurred during the sequenced download.";
break;
case CON_NI:
s = "area_code unknown. Please check the area code"
" of the message in its limits.";
break;
case CON_EA:
s = "overstep of the maximum buffer length of 1000"
" bytes per dataset file.";
break;
case CON_IP:
s = "faulty parameter detected. The configured"
" data_control time is set to zero. This is not allowed.";
break;
case CON_SE:
s = "sequence error. End_seq was called without"
" Start_seq or the area_code is different in the download"
" message in comparison to the Start_seq area_code";
break;
case CON_DI:
s = "data incomplete or faulty. The check routine for the"
" downloaded parameter file detected inconsistencies";
break;
default:
return;
}
errh_Info("Profibus DP Master %s - DDLM Download: %s", ap->Name, s);
/* Provides extended instructions if the board's flash is configured for
offline configuration. */
if (msg->f == CON_NO)
flashing_disabled_warning(ap);
break;
case DDLM_Slave_Diag:
switch (msg->f) {
case 0:
return;
case CON_NA:
s = "no response of the station";
break;
case CON_DS:
s = "master not into the logical network in token ring";
break;
case TASK_F_DEVICE_ADR:
s = "Remote Address in request service out of range";
break;
default:
return;
}
errh_Info("Profibus DP Master %s - Station %d - DDLM Slave Diag: %s",
ap->Name, ((RCS_MESSAGETELEGRAM_10 *) msg)->device_adr, s);
break;
default:
return;
}
}
/* Performs a DDLM download, used to configure the master or
slave bus parameters. The agent's local struct is passed in local, the
destination address is passed in address, 0-125 to set slave bus parameters
or 127 to set master bus parameters. The bus parameters are read from
the buffer prmdata and shall be of length prmlen. DRV_NO_ERROR is returned
if successful. */
static short
dpm_ddlm_download(io_sAgentLocal *local, unsigned char address,
unsigned int prmlen, void *prmdata, io_sAgent *ap)
{
short rv;
int got_response = 0;
RCS_MESSAGE msg, rcv_msg;
DDLM_DOWNLOAD_REQUEST *download = (DDLM_DOWNLOAD_REQUEST *) &(msg.d[0]);
/* Clears struct. */
memset(&msg, 0, sizeof(msg));
memset(&rcv_msg, 0, sizeof(rcv_msg));
/* Defines message header. */
msg.rx = 3;
msg.tx = 16;
msg.ln = prmlen + 4;
msg.nr = ++local->cif_msgcnt;
msg.a = 0;
msg.f = 0;
msg.b = DDLM_Download;
msg.e = 0;
/* Defines service header. */
download->bReq_Add = 0;
download->bArea_Code = address;
download->usAdd_Offset = 0;
/* PRM data starts at d[4] in the message according to
dpm_pie.pdf, page 43. */
assert(prmlen <= 240);
memcpy(&(msg.d[4]), prmdata, prmlen);
if ((rv = DevPutMessage(local->dev_number, (MSG_STRUC *) &msg, 5000))
!= DRV_NO_ERROR) {
errh_Error("Profibus DP Master %s - DDLM_Download - DevPutMessage()"
" returned %d", ap->Name, rv);
return rv;
}
/* Checks confirmation message. */
while (!got_response) {
if ((rv = DevGetMessage(local->dev_number, sizeof(rcv_msg),
(MSG_STRUC *) &rcv_msg, 5000)) != DRV_NO_ERROR) {
errh_Error("Profibus DP Master %s - DDLM_Download - DevGetMessage()"
" returned %d", ap->Name, rv);
return rv;
} else if (rcv_msg.nr != local->cif_msgcnt
|| rcv_msg.rx != 16
|| rcv_msg.tx != 3
|| rcv_msg.a != DDLM_Download) {
/* Discards all messages prior to our response. */
memset(&rcv_msg, 0, sizeof(rcv_msg));
continue;
} else if (rcv_msg.f != 0) {
dpm_ddlm_answer_msg_print_error(&rcv_msg, ap);
return rcv_msg.f;
} else {
got_response = 1;
}
}
return rv;
}
/* Configures the master bus parameters of the board referred to by
local, the struct containing the parameters should be passed in op. */
static short
dpm_download_master_prm(io_sAgentLocal *local, pwr_sClass_Pb_Hilscher *op,
io_sAgent *ap)
{
DPM_BUS_DP prm;
/* Clears struct. */
memset(&prm, 0, sizeof(prm));
/* Defines Profibus DP bus parameters, these are described briefly
in dpm_pie.pdf, page 41. */
prm.usBus_Para_Len = 32;
/* The master's address is hardcoded to 0. */
prm.bFDL_Add = 0;
prm.bBaudrate = ((op->BaudRate == 500) ? (DP_BAUD_500)
: (op->BaudRate == 1500) ? (DP_BAUD_1500)
: (op->BaudRate == 3000) ? (DP_BAUD_3000)
: (op->BaudRate == 6000) ? (DP_BAUD_6000)
: (op->BaudRate == 12000) ? (DP_BAUD_12000)
: (DP_BAUD_1500));
prm.usTSL = op->Tsl;
prm.usMin_TSDR = op->MinTsdr;
prm.usMax_TSDR = op->MaxTsdr;
prm.bTQUI = op->Tqui;
prm.bTSET = op->Tset;
prm.ulTTR = op->Ttr;
prm.bG = op->G;
prm.bHSA = op->Hsa;
prm.bMax_Retry_Limit = op->MaxRetryLimit;
prm.Bp_Flag.bError_Action_Flag = ((op->BpFlag) ? (1) : (0));
prm.usMin_Slave_Intervall = op->MinSlaveInterval;
prm.usPoll_Timeout = op->PollTimeout;
prm.usData_Control_Time = op->DataControlTime;
prm.bAlarm_Max = 0;
prm.bMax_User_Global_Control = 1;
/* The length of the total message is 35 according to dpm_pie.pdf,
page 43. The service header accounts for 4 of these, thus we set
the length to 31 here. */
return dpm_ddlm_download(local, 127, 31, &prm, ap);
}
/* Configures the bus parameters for one slave. The agent's local struct
is passed in local. op holds the slave to configure, the corresponding
agent pointer and rack pointer must be passed in ap and rp respectively.
DRV_NO_ERROR will be returned upon success. */
static short
dpm_download_slave_prm(io_sAgentLocal *local, pwr_sClass_Pb_DP_Slave *op,
io_sAgent *ap, io_sRack *rp)
{
unsigned char buf[DPM_MAX_LEN_DATA_UNIT];
unsigned int bufcnt = 0;
/* DPM_SL_PRM_HEADER starts at offset 4 in the data buffer according
to dpm_pie.pdf, page 45 -- however, since the first 4 bytes are
occupied by the service header, which we'll fill in later, we'll
define the offset to be 0. */
DPM_SL_PRM_HEADER *hdr = (DPM_SL_PRM_HEADER *) &buf[0];
DPM_SL_PRM_PRM_DATA *prm = (DPM_SL_PRM_PRM_DATA *) &buf[16];
DPM_SL_PRM_CFG_DATA *cfg;
DPM_SL_PRM_ADD_TAB *add_tab;
DPM_SL_PRM_USR_DATA *usr;
/* Clears buffer. */
memset(&buf, 0, sizeof(buf));
/* Defines prm header. */
hdr->Sl_Flag.biExtra_Alarm_SAP = 0;
hdr->Sl_Flag.biDPV1_Data_Types = 0;
hdr->Sl_Flag.biDPV1_Supported = 0;
hdr->Sl_Flag.biPublisher_Enable = 0;
hdr->Sl_Flag.biFail_Safe = 0;
hdr->Sl_Flag.biNew_Prm = 0;
hdr->Sl_Flag.biActive = 1;
hdr->bSlave_Typ = 0;
bufcnt = 16;
/* Defines prm data */
prm->usPrmDataLen = 7 + sizeof(prm->usPrmDataLen);
prm->Station_Status.bWD_On = 1;
prm->Station_Status.bFreeze_Req = 0;
prm->Station_Status.bSync_Req = 0;
prm->Station_Status.bUnLock_Req = 0;
prm->Station_Status.bLock_Req = 1;
prm->bWD_Fact_1 = op->WdFact1;
prm->bWD_Fact_2 = op->WdFact2;
prm->bMin_Tsdr = 0;
/* Ident number in LE */
prm->usIdent_Number = swap16(op->PNOIdent);
prm->bGroup_Ident = op->GroupIdent;
bufcnt += prm->usPrmDataLen;
/* Defines user prm data. */
prm->usPrmDataLen += op->PrmUserDataLen;
assert(bufcnt + op->PrmUserDataLen + 2 <= DPM_MAX_LEN_DATA_UNIT);
memcpy(&buf[bufcnt], op->PrmUserData, op->PrmUserDataLen);
bufcnt += op->PrmUserDataLen;
/* Defines cfg data */
cfg = (DPM_SL_PRM_CFG_DATA *) &buf[bufcnt];
/* Note that the cfg data length is part of the cfg data in Proview,
by skipping these two bytes and writing the op->ConfigDataLen
field to the usCfg_Data_Len of DPM_SL_PRM_CFG_DATA we avoid some
endianness issues. */
cfg->usCfg_Data_Len = op->ConfigDataLen - 2 + sizeof(cfg->usCfg_Data_Len);
assert(bufcnt + cfg->usCfg_Data_Len + 2 <= DPM_MAX_LEN_DATA_UNIT);
memcpy(cfg->abCfg_Data, op->ConfigData + 2, op->ConfigDataLen - 2);
bufcnt += cfg->usCfg_Data_Len;
/* Defines address table. */
add_tab = (DPM_SL_PRM_ADD_TAB *) &buf[bufcnt];
/* dpm_set_add_tab is also responsible for updating the length of the
table, so no need to worry about it here :). */
dpm_set_add_tab(op, ap, rp, add_tab, DPM_MAX_LEN_DATA_UNIT - bufcnt);
/* Take the length of the address table into account when filling our
local buffer. */
bufcnt += add_tab->usAdd_Tab_Len;
assert(bufcnt + 2 <= DPM_MAX_LEN_DATA_UNIT);
/* We will leave the slave user data empty. */
usr = (DPM_SL_PRM_USR_DATA *) &buf[bufcnt];
usr->usSlave_Usr_Data_Len = sizeof(usr->usSlave_Usr_Data_Len);
bufcnt += usr->usSlave_Usr_Data_Len;
/* The length of the whole PRM set is now known, so we can
fill in that field in the header. */
hdr->usSlaveParaLen = bufcnt;
assert(bufcnt <= DPM_MAX_LEN_DATA_UNIT);
return dpm_ddlm_download(local, op->SlaveAddress, bufcnt, buf, ap);
}
/* Requests diagnostics from the slave address, attached to the
board referred to by local. The function will return DRV_NO_ERROR if
the request was sent without error, however, it tells us nothing
about whether any diagnostics data was sent back. */
static short
dpm_req_slave_diag(io_sAgentLocal *local, unsigned char address, io_sAgent *ap)
{
short rv;
RCS_MESSAGETELEGRAM_10 msg;
/* Clears struct. */
memset(&msg, 0, sizeof(msg));
/* Defines message header. */
msg.rx = 3;
msg.tx = 16;
msg.ln = 8;
msg.nr = ++local->cif_msgcnt;
msg.a = 0;
msg.f = 0;
msg.b = DDLM_Slave_Diag;
msg.e = 0;
/* Defines extended message header. */
msg.device_adr = address;
msg.data_area = 0;
msg.data_adr = 0;
msg.data_idx = 0;
msg.data_cnt = 0;
msg.data_type = TASK_TDT_STRING;
msg.function = TASK_TFC_READ;
/* Requests diagnostic data from slave. */
if ((rv = DevPutMessage(local->dev_number, (MSG_STRUC *) &msg, 0))
!= DRV_NO_ERROR) {
errh_Info("Profibus DP Master %s - DDLM_Slave_Diag - DevPutMessage()"
" returned %d", ap->Name, rv);
return rv;
}
return DRV_NO_ERROR;
}
/* Checks if we have any pending messages and processes them. This allows us
to gather diagnostics data asynchronously. The desired agent's local
struct is passed via local and the associated rack list (Profibus slaves) is
passed in slave_list. */
static void
dpm_update_slave_diag(io_sAgentLocal *local, io_sRack *slave_list,
io_sAgent *ap)
{
short rv;
RCS_MESSAGETELEGRAM_10 rcv_msg;
pwr_sClass_Pb_DP_Slave *sp;
io_sRack *sl;
/* Clears struct. */
memset(&rcv_msg, 0, sizeof(rcv_msg));
/* Gets pending diagnostic messages, discards all other messages. */
while ((rv = DevGetMessage(local->dev_number, sizeof(rcv_msg),
(MSG_STRUC *) &rcv_msg, 0)) == DRV_NO_ERROR) {
if (rcv_msg.rx != 16 || rcv_msg.tx != 3
|| rcv_msg.a != DDLM_Slave_Diag) {
/* Discards received message. */
memset(&rcv_msg, 0, sizeof(rcv_msg));
continue;
} else if (rcv_msg.f != 0) {
dpm_ddlm_answer_msg_print_error((RCS_MESSAGE *) &rcv_msg, ap);
/* Discards received message. */
memset(&rcv_msg, 0, sizeof(rcv_msg));
continue;
} else {
/*** Updates Proview's structs with the acquired diagnostics. ***/
/* Finds our slave. */
for (sl = slave_list; sl != NULL; sl = sl->next) {
sp = (pwr_sClass_Pb_DP_Slave *) sl->op;
if (sp->SlaveAddress == rcv_msg.device_adr)
break;
}
/* The slave from which we were to read diagnostic data could not
be found -- abort. */
if (sp->SlaveAddress != rcv_msg.device_adr) {
errh_Error("Profibus DP Master %s - Received diagnostic message"
" from unknown slave %d", ap->Name, rcv_msg.device_adr);
return;
}
/* Copies the diagnostic data into slave struct. */
sp->StationStatus1 = rcv_msg.d[0];
sp->StationStatus2 = rcv_msg.d[1];
sp->StationStatus3 = rcv_msg.d[2];
sp->BytesOfDiag = rcv_msg.data_cnt - 6;
/* Makes sure we don't overflow the slave's diagnostics buffer. */
if (sp->BytesOfDiag > sizeof(sp->Diag))
sp->BytesOfDiag = sizeof(sp->Diag);
memcpy(sp->Diag, rcv_msg.d + 6, sp->BytesOfDiag);
/* Updates the slave's status */
if (!(sp->StationStatus1 & ~pwr_mPbStationStatus1Mask_ExternalDiag)
&& !(sp->StationStatus2
& ~(pwr_mPbStationStatus2Mask_Default |
pwr_mPbStationStatus2Mask_ResponseMonitoringOn))) {
sp->Status = PB__NORMAL;
} else if (sp->StationStatus1
& pwr_mPbStationStatus1Mask_NonExistent) {
sp->Status = PB__NOCONN;
} else if ((sp->StationStatus1
& (pwr_mPbStationStatus1Mask_ConfigFault
| pwr_mPbStationStatus1Mask_ParamFault))
|| (sp->StationStatus2
& pwr_mPbStationStatus2Mask_NewParamsRequested)) {
sp->Status = PB__CONFIGERR;
} else if (sp->StationStatus1
& pwr_mPbStationStatus1Mask_MasterLock) {
sp->Status = PB__MASTERLOCK;
} else { /* if (sp->StationStatus1
& pwr_mPbStationStatus1Mask_NotReady) */
sp->Status = PB__NOTREADY;
}
}
}
}
/* Prints diagnostics info diag in human readable form if the macro
SLAVE_DIAG_VERBOSE is defined. */
static void
dpm_print_diag(io_sAgent *ap, DPM_DIAGNOSTICS *diag)
{
char *s;
if (diag->tError.bErr_Event == 0) {
return;
} else if (diag->tError.bErr_Rem_Adr == 255) {
switch (diag->tError.bErr_Event) {
case TASK_F_NO_USR_TASK: s = "usr task not found"; break;
case TASK_F_NO_GLOBAL_DATA: s = "no global entry in data base"; break;
case TASK_F_NO_FDL: s = "fdl task not found"; break;
case TASK_F_NO_PLC: s = "plc task not found"; break;
case TASK_F_NO_BUS_DP: s = "no bus parameters"; break;
case TASK_F_INVALID_BUS_DP: s = "bus parameters faulty"; break;
case TASK_F_NO_SL_TAB: s = "no slave data sets"; break;
case TASK_F_INVALID_SL_TAB: s = "slave data set faulty"; break;
case TASK_F_REM_ADR_DOUBLE: s = "double station addr detected"; break;
case TASK_F_A_OFFSET_MAX: s = "maximum output offset reached"; break;
case TASK_F_E_OFFSET_MAX: s = "maximum input offset reached"; break;
case TASK_F_A_OVERLAP: s = "overlap in output area"; break;
case TASK_F_E_OVERLAP: s = "overlap in input area"; break;
case TASK_F_DPM_UNKNOWN_MODE: s = "warmstart with unknown mode"; break;
case TASK_F_RAM_OVERRUN: s = "extended ram exceeded"; break;
case TASK_F_SL_PRM_FAULT: s = "slave data set faulty"; break;
case TASK_F_WATCHDOG: s = "user watchdog failure"; break;
case TASK_F_NO_DATA_ACK: s = "mode0 no acknowledge"; break;
case TASK_F_AUTO_CLEAR: s = "auto clear activated"; break;
case TASK_F_FATAL_ASIC_ERROR: s = "fatal error occurred"; break;
case TASK_F_UNKNOWN_EVENT: s = "unknown event detected"; break;
case TASK_F_SEGMENT_CNT: s = "no segments to communicate"; break;
default: return;
}
errh_Info("Profibus DP Master %s - %s", ap->Name, s);
return;
} else {
switch (diag->tError.bErr_Event) {
case CON_NA: s = "no reaction of the remote station"; break;
case CON_DS: s = "local FDL not in logical token ring"; break;
case CON_RS: s = "master request not supported by the slave"; break;
case CON_NR: s = "no response data"; break;
default: return;
}
#ifdef SLAVE_DIAG_VERBOSE
errh_Info("Profibus DP Master %s - Station %d - %s",
ap->Name, diag->tError.bErr_Rem_Adr, s);
#endif /* SLAVE_DIAG_VERBOSE */
return;
}
}
#ifdef FLASH_WRITE_ENABLE
/*** Functions for board flashing. ***/
/* Tries to find the db_startsegment for the board referred to by local.
If the board was found in the database, the function returns DRV_NO_ERROR
and the startsegment will be written to what db_startsegment points to. */
static short
dpm_check_board_type(io_sAgentLocal *local, io_sAgent *ap,
unsigned char *db_startsegment)
{
short rv;
DEVINFO info;
int i;
assert(DRV_NO_ERROR == 0);
/* Gets device information from the board. */
if ((rv = DevGetInfo(local->dev_number, GET_DEV_INFO, sizeof(info), &info))
!= DRV_NO_ERROR) {
errh_Error(
"Profibus DP Master %s - Error %d while checking board type.",
ap->Name, rv);
return rv;
}
errh_Info("Profibus DP Master %s -"
" Selected board %d has the following device info:",
ap->Name, local->dev_number);
errh_Info("Device DPM size: %d", info.bDpmSize);
errh_Info("Device type: %d", info.bDevType);
errh_Info("Device model: %d", info.bDevModel);
errh_Info("Device identification: %.3s", info.abDevIdentifier);
/* Looks for an entry matching our board. */
for (i = 0; known_boards[i].entry != 0; ++i)
if (memcmp(&known_boards[i].info, &info, sizeof(info)) == 0)
break;
if (known_boards[i].entry == 0) {
/* Board was not found in table. */
errh_Error("Profibus DP Master %s - Unknown board.", ap->Name);
errh_Error("To add support for this board, look up its database start");
errh_Error("segment in DPM_PIE.PDF, page 33 and add an entry to the");
errh_Error("known_boards table in rt_io_m_pb_hilscher.c.");
errh_Error("The following entry may be inserted into the known_boards");
errh_Error("table to enable flashing for this board. Replace");
errh_Error("<db start segment> and <board name> with data found");
errh_Error("in the above mentioned documentation.");
errh_Error("{ 1, { %d, %d, %d, { '%c', '%c', '%c'} }, "
"<db start segment>, \"<board name>\" },",
info.bDpmSize, info.bDevType, info.bDevModel,
info.abDevIdentifier[0],
info.abDevIdentifier[1],
info.abDevIdentifier[2]);
return BOARD_INIT_ERROR;
}
/* Board was found in table. */
errh_Info("Board known:");
errh_Info("Name: %s", known_boards[i].board_name);
errh_Info("Start segment of database: %d",
known_boards[i].db_startsegment);
*db_startsegment = known_boards[i].db_startsegment;
return DRV_NO_ERROR;
}
/* Deletes the "PROFIBUS" protocol settings database from the card referred
to by local, this procedure is described on page 32 -- 33 in dpm_pie.pdf. */
static short
dpm_delete_flash_prmdb(io_sAgentLocal *local, io_sAgent *ap)
{
unsigned char db_startsegment;
int s = 3;
int got_response = 0;
short rv;
RCS_MESSAGE msg;
/* Gets start segment of database. */
if ((rv = dpm_check_board_type(local, ap, &db_startsegment))
!= DRV_NO_ERROR)
return rv;
/* Clears struct. */
memset(&msg, 0, sizeof(msg));
/* Defines message header. */
msg.rx = 0; /* receiver = RCS-Task */
msg.tx = 16; /* transmitter = user at HOST */
msg.ln = 2;
msg.nr = ++local->cif_msgcnt;
msg.a = 0; /* no answer */
msg.f = 0; /* no error */
msg.b = 6; /* command = data base access */
msg.e = 0; /* extension, not used */
/* Defines delete database request. */
msg.d[0] = 4; /* mode = delete data base */
msg.d[1] = db_startsegment;
errh_Info("Profibus DP Master %s - Sending delete database request...",
ap->Name);
/* Sends delete database request. */
if ((rv = DevPutMessage(local->dev_number, (MSG_STRUC *) &msg, 5000))
!= DRV_NO_ERROR) {
errh_Error("Profibus DP Master %s -"
" DevPutMessage failed with return code %d", ap->Name, rv);
return rv;
}
/* Waits for controller to update flash. */
errh_Info("Profibus DP Master %s -"
" Delete db request sent. Waiting %d seconds...", ap->Name, s);
while ((s = sleep(s)))
;
/* Clears struct. */
memset(&msg, 0, sizeof(msg));
/* Gets response message. */
while (!got_response) {
if ((rv = DevGetMessage(local->dev_number, sizeof(msg),
(MSG_STRUC *) &msg, 10000)) != DRV_NO_ERROR) {
errh_Error("Profibus DP Master %s -"
" DevGetMessage failed with return code %d\n",
ap->Name, rv);
return rv;
} else if (msg.nr != local->cif_msgcnt || msg.rx != 16 || msg.tx != 0
|| msg.a != 6) {
/* Discards all messages prior to our response. */
memset(&msg, 0, sizeof(msg));
continue;
} else {
if (msg.f != 0)
errh_Error("Profibus DP Master %s -"
" Delete db confirmation message f-flag set to %d",
ap->Name, msg.f);
else
errh_Info("Profibus DP Master %s -"
" Delete database confirmation message received.",
ap->Name);
got_response = 1;
}
}
return rv;
}
#endif /* FLASH_WRITE_ENABLE */
/* From cif_dev.h in the linux driver package. */
#define RUN_FLAG 0x40
#define READY_FLAG 0x80
/* Wrapper for dpm_init_master(), takes care of checking for (and optionally
removing) the sycon database if present. */
static short
dpm_init_master_check_sycon_db(io_sAgentLocal *local,
pwr_sClass_Pb_Hilscher *op, io_sAgent *ap)
{
short rv;
DRIVERINFO di;
assert(DRV_NO_ERROR == 0);
/* Initializes DP Master. */
if ((rv = dpm_init_master(local, op, ap)) != DRV_NO_ERROR) {
return rv;
} else if ((rv = DevGetInfo(local->dev_number, GET_DRIVER_INFO,
sizeof(di), &di)) != DRV_NO_ERROR) {
errh_Error("Profibus DP Master %s -"
" DevGetInfo failed with return code %d", ap->Name, rv);
return rv;
} else if ((di.bHostFlags & (READY_FLAG | RUN_FLAG))
== (READY_FLAG | RUN_FLAG)) {
/* RUN and RDY bits set */
errh_Info("Profibus DP Master %s - Hostflags: 0x%X",
ap->Name, di.bHostFlags);
errh_Info("Device is configured by SyCon.");
#ifdef FLASH_WRITE_ENABLE
errh_Info("Deleting SyCon database from board's flash.");
if ((rv = dpm_delete_flash_prmdb(local, ap)) != DRV_NO_ERROR) {
return rv;
} else {
/* Reinitializes DP Master. */
rv = dpm_init_master(local, op, ap);
}
#else /* FLASH_WRITE_ENABLE */
errh_Info("Flash writing is not enabled, ");
flashing_disabled_warning(ap);
return BOARD_INIT_ERROR;
#endif /* FLASH_WRITE_ENABLE */
}
return rv;
}
/*----------------------------------------------------------------------------*\
Init method for the Pb_Hilscher agent
\*----------------------------------------------------------------------------*/
static pwr_tStatus
IoAgentInit(io_tCtx ctx, io_sAgent *ap)
{
pwr_sClass_Pb_Hilscher *op;
pwr_tStatus status;
io_sAgentLocal *local;
char ok;
pwr_tObjid slave_objid;
pwr_tClassId slave_class;
pwr_sClass_Pb_DP_Slave *sop;
char name[196];
struct timespec rqtp = {0, 20000000}; /* 20 ms */
int retry;
/* Allocates area for local data structure */
ap->Local = calloc(1, sizeof(io_sAgentLocal));
if (!ap->Local) {
errh_Error("ERROR config Profibus DP Master %s - %s",
ap->Name, "calloc");
return IO__ERRINIDEVICE;
}
/* Handles for easy access to local variables. */
local = (io_sAgentLocal *) ap->Local;
op = (pwr_sClass_Pb_Hilscher *) ap->op;
op->Status = PB__NOTINIT;
/* Initializes interface. */
if (ctx->Node->Restarts > 0) {
nanosleep(&rqtp, NULL);
}
errh_Info("Initializing interface for Profibus DP Master %s", ap->Name);
/* Initializes local struct. */
local->dev_number = op->BusNumber - 1;
local->input_size = 0;
local->output_size = 0;
local->cif_msgcnt = 0;
local->watchdog = 0;
/* Initializes Profibus driver API. */
if (dpm_init(local, ap) != DRV_NO_ERROR) {
/* Cannot open driver */
op->Status = PB__INITFAIL;
errh_Error("ERROR config Profibus DP Master %s - %s",
ap->Name, "open device");
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
/* If this is not the Profibus I/O process, return */
if ((op->Process & io_mProcess_Profibus)
&& (ctx->Process != io_mProcess_Profibus)) {
op->Status = PB__NOTINIT;
errh_Info("Init template I/O agent for Profibus DP Master %s, %d",
ap->Name, ctx->Process );
return IO__SUCCESS;
}
if (ctx->Node->Restarts > 0) {
errh_Info("Warm restart - Skipping config of Profibus DP Master %s",
ap->Name);
op->Status = PB__NORMAL;
return IO__SUCCESS;
}
errh_Info("Config of Profibus DP Master %s", ap->Name);
if (op->DisableBus != 1) {
ok = FALSE;
if (ctx->Node->Restarts == 0) {
retry = 0;
while (!ok) {
op->Status = PB__NOTINIT;
/* Sets DP master parameters and checks for sycon database. */
if (dpm_init_master_check_sycon_db(local, op, ap)
!= DRV_NO_ERROR) {
op->Status = PB__INITFAIL;
errh_Error("ERROR config Profibus DP Master %s - %s",
ap->Name, "dp init master");
return IO__ERRINIDEVICE;
}
/* Loops through all slaves (traverse agent's children)
and initializes them. */
op->NumberSlaves = 0;
status = gdh_GetChild(ap->Objid, &slave_objid);
while (ODD(status)) {
status = gdh_GetObjectClass(slave_objid, &slave_class);
status = gdh_ObjidToPointer(slave_objid,
(pwr_tAddress *) &sop);
status = gdh_ObjidToName(slave_objid, (char *) &name,
sizeof(name), cdh_mNName);
errh_Info("Download Profibus DP Slave config - %s", name);
/* Calculates IO offsets and configures the slave. */
if (dpm_download_slave_prm(local, sop, ap, ap->racklist)
!= DRV_NO_ERROR) {
errh_Error("ERROR Init Profibus DP slave %s", name);
}
errh_Info("Profibus DP slave %d: in offs %d, input size %d,"
" out offs %d, out size %d",
sop->SlaveAddress,
sop->OffsetInputs, sop->BytesOfInput,
sop->OffsetOutputs, sop->BytesOfOutput);
op->NumberSlaves++;
status = gdh_GetNextSibling(slave_objid, &slave_objid);
}
/* Downloads the DP bus parameters -- this initiates the
cyclic data exchange. */
if (dpm_download_master_prm(local, op, ap) != DRV_NO_ERROR) {
op->Status = PB__INITFAIL;
errh_Error("ERROR config Profibus DP Master %s - %s",
ap->Name, "dp download bus");
return IO__ERRINIDEVICE;
}
ok = TRUE;
} /* End - While !ok */
} /* End - Initialization only if not restart */
} else
op->Status = PB__DISABLED;
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Read method for the Pb_Hilscher agent
\*----------------------------------------------------------------------------*/
static pwr_tStatus
IoAgentRead(io_tCtx ctx, io_sAgent *ap)
{
pwr_sClass_Pb_Hilscher *mp;
pwr_sClass_Pb_DP_Slave *sp;
io_sAgentLocal *local;
io_sRack *slave_list;
pwr_sClass_Pb_Hilscher *op;
unsigned short rv;
int i;
DPM_DIAGNOSTICS diag;
/* Handle for local data structure. */
local = (io_sAgentLocal *) ap->Local;
/*** Data exchange code goes here: ***/
/* Iterates over the slaves on the bus and reads process data from their
respective addresses. This is really the responsibility of the rack level,
however, keeping this code here enables us to confine all the Profibus
board specific code at the agent level. */
for (slave_list = ap->racklist; slave_list != NULL;
slave_list = slave_list->next) {
sp = (pwr_sClass_Pb_DP_Slave *) slave_list->op;
mp = (pwr_sClass_Pb_Hilscher *) ap->op;
if (sp->Status == PB__NORMAL && mp->Status == PB__NORMAL
&& sp->DisableSlave != 1 && mp->DisableBus != 1) {
/* Triggers the board's watchdog. */
DevTriggerWatchDog(local->dev_number, WATCHDOG_START,
&local->watchdog);
/* Reads process image from the slave. */
rv = DevExchangeIO(local->dev_number,
0, 0, NULL,
sp->OffsetInputs, sp->BytesOfInput, sp->Inputs,
100);
}
}
/*** Diagnostics collecting code goes here: ***/
local = (io_sAgentLocal *) ap->Local;
op = (pwr_sClass_Pb_Hilscher *) ap->op;
/* If everything is fine we should be in state OPERATE.
Make a poll to see if there are diagnostics, the answer also tells us
if there are any hardware faults. */
if ((op->Process & io_mProcess_Profibus)
&& (ctx->Process != io_mProcess_Profibus))
return IO__SUCCESS;
if (op->DisableBus == 1)
return IO__SUCCESS;
/* Reads the protocol states and checks for errors. */
DevGetTaskState(local->dev_number, 2, 64, &diag);
/* Checks if master is in state OPERATE. */
switch (diag.bDPM_state) {
case OPERATE:
if (op->Status != PB__NORMAL) {
op->Status = PB__NORMAL;
errh_Info("Profibus DP Master %s - Mode changed to OPERATE",
ap->Name);
}
break;
case CLEAR:
if (op->Status != PB__CLEARED) {
op->Status = PB__CLEARED;
errh_Info("Profibus DP Master %s - Mode changed to CLEAR",
ap->Name);
}
break;
case STOP:
if (op->Status != PB__STOPPED) {
op->Status = PB__STOPPED;
errh_Info("Profibus DP Master %s - Mode changed to STOP", ap->Name);
}
break;
case OFFLINE:
if (op->Status != PB__NOTINIT) {
errh_Info("Profibus DP Master %s - Mode changed to OFFLINE",
ap->Name);
op->Status = PB__NOTINIT;
}
break;
default:
errh_Info("Profibus DP Master %s - Unknown mode", ap->Name);
}
/* Outputs some bus related diagnostics (using errh_Info()). */
dpm_print_diag(ap, &diag);
/* Checks if there are any new diagnostics data that we should read from
any of our slaves. */
for (i = 0; i <= 127; ++i) {
/* The abSl_diag data structure is described on page 22 in
dpm_pie.pdf. */
if (diag.abSl_diag[i >> 3] & (1 << (i & 7))) {
/* Request diagnostics from slaves with unread diagnostic data. */
dpm_req_slave_diag(local, i, ap);
}
}
/* The above code requests diagnostics from the slaves
with new diagnostic data. It does not seem to work reliably in
some circumstances though. E.g. if a slave is disconnected and reconnected
before its watchdog times out the diagnostics would not be updated. The
following code covers that case, it is a bit ugly, but works. */
for (slave_list = ap->racklist; slave_list != NULL;
slave_list = slave_list->next) {
sp = (pwr_sClass_Pb_DP_Slave *) slave_list->op;
/* The abSl_state has the same layout as the abSl_diag bitmap. */
if (sp->StationStatus1 & pwr_mPbStationStatus1Mask_NonExistent &&
diag.abSl_state[sp->SlaveAddress >> 3]
& (1 << (sp->SlaveAddress & 7)))
dpm_req_slave_diag(local, sp->SlaveAddress, ap);
}
/* Collects requested slave diagnostics. */
dpm_update_slave_diag(local, ap->racklist, ap);
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Write method for the Pb_Hilscher agent
\*----------------------------------------------------------------------------*/
static pwr_tStatus
IoAgentWrite(io_tCtx ctx, io_sAgent *ap)
{
pwr_sClass_Pb_Hilscher *mp;
pwr_sClass_Pb_DP_Slave *sp;
io_sAgentLocal *local;
io_sRack *slave_list;
/* Handle for local data structure. */
local = (io_sAgentLocal *) ap->Local;
/* Iterates over the slaves on the bus and writes process data to their
respective addresses. This is really the rack level's responsibility,
however, keeping this code here enables us to confine all the Profibus
board specific code at the agent level. */
for (slave_list = ap->racklist; slave_list != NULL;
slave_list = slave_list->next) {
sp = (pwr_sClass_Pb_DP_Slave *) slave_list->op;
mp = (pwr_sClass_Pb_Hilscher *) ap->op;
if ((sp->Status == PB__NORMAL || sp->Status == PB__NOCONN)
&& mp->Status == PB__NORMAL
&& (sp->DisableSlave != 1) && (mp->DisableBus != 1)) {
if (sp->BytesOfOutput > 0) {
/* Trigger the board's watchdog. */
DevTriggerWatchDog(local->dev_number, WATCHDOG_START,
&local->watchdog);
/* Writes process image to the slave. */
if (DevExchangeIO(local->dev_number,
sp->OffsetOutputs, sp->BytesOfOutput, sp->Outputs,
0, 0, NULL,
100)
!= DRV_NO_ERROR)
sp->ErrorCount++;
}
}
}
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus
IoAgentClose(io_tCtx ctx, io_sAgent *ap)
{
io_sAgentLocal *local;
local = (io_sAgentLocal *) ap->Local;
dpm_exit(local, ap);
free(local);
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Hilscher) = {
pwr_BindIoMethod(IoAgentInit),
pwr_BindIoMethod(IoAgentRead),
pwr_BindIoMethod(IoAgentWrite),
pwr_BindIoMethod(IoAgentClose),
pwr_NullMethod
};
...@@ -27,16 +27,6 @@ ...@@ -27,16 +27,6 @@
#include <sys/file.h> #include <sys/file.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h" #include "rt_io_pb_locals.h"
#include "pwr.h" #include "pwr.h"
...@@ -46,7 +36,6 @@ ...@@ -46,7 +36,6 @@
#include "rt_io_bus.h" #include "rt_io_bus.h"
#include "rt_io_msg.h" #include "rt_io_msg.h"
#include "rt_errh.h" #include "rt_errh.h"
#include "rt_io_profiboard.h"
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
......
...@@ -25,15 +25,6 @@ ...@@ -25,15 +25,6 @@
#include <sys/file.h> #include <sys/file.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h" #include "rt_io_pb_locals.h"
#include "pwr.h" #include "pwr.h"
...@@ -43,7 +34,6 @@ ...@@ -43,7 +34,6 @@
#include "rt_io_bus.h" #include "rt_io_bus.h"
#include "rt_io_msg.h" #include "rt_io_msg.h"
#include "rt_errh.h" #include "rt_errh.h"
#include "rt_io_profiboard.h"
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
......
...@@ -27,15 +27,6 @@ ...@@ -27,15 +27,6 @@
#include <sys/file.h> #include <sys/file.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h" #include "rt_io_pb_locals.h"
#include "pwr.h" #include "pwr.h"
...@@ -45,7 +36,6 @@ ...@@ -45,7 +36,6 @@
#include "rt_io_bus.h" #include "rt_io_bus.h"
#include "rt_io_msg.h" #include "rt_io_msg.h"
#include "rt_errh.h" #include "rt_errh.h"
#include "rt_io_profiboard.h"
#include "rt_pb_msg.h" #include "rt_pb_msg.h"
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
......
...@@ -54,6 +54,17 @@ ...@@ -54,6 +54,17 @@
#include "rt_io_profiboard.h" #include "rt_io_profiboard.h"
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;
int hDpsBoardDevice; // Handle for DP-Slave Output-Data device
} io_sAgentLocal;
#define DP_MAX_SERVICE_RETRY 10 #define DP_MAX_SERVICE_RETRY 10
...@@ -807,10 +818,32 @@ static pwr_tStatus IoAgentRead ( ...@@ -807,10 +818,32 @@ static pwr_tStatus IoAgentRead (
T_PROFI_SERVICE_DESCR con_ind_sdb; T_PROFI_SERVICE_DESCR con_ind_sdb;
T_DP_GET_SLAVE_DIAG_CON FAR *get_slave_diag_con_ptr; T_DP_GET_SLAVE_DIAG_CON FAR *get_slave_diag_con_ptr;
pwr_sClass_Pb_Profiboard *mp;
pwr_sClass_Pb_DP_Slave *sp;
pwr_tUInt16 data_len;
io_sRack *slave_list;
hDevice = (T_PROFI_DEVICE_HANDLE *) ap->Local; hDevice = (T_PROFI_DEVICE_HANDLE *) ap->Local;
local = (io_sAgentLocal *) ap->Local; local = (io_sAgentLocal *) ap->Local;
op = (pwr_sClass_Pb_Profiboard *) ap->op; op = (pwr_sClass_Pb_Profiboard *) ap->op;
/* Iterate over the slaves. */
for (slave_list = ap->racklist; slave_list != NULL;
slave_list = slave_list->next) {
sp = (pwr_sClass_Pb_DP_Slave *) slave_list->op;
mp = (pwr_sClass_Pb_Profiboard *) ap->op;
/* Read process data. */
if (sp->Status == PB__NORMAL && mp->Status == PB__NORMAL && sp->DisableSlave != 1 && mp->DisableBus != 1) {
data_len = sp->BytesOfInput;
sts = profi_get_data(hDevice, ID_DP_SLAVE_IO_IMAGE, sp->OffsetInputs, &data_len, &sp->Inputs );
}
}
/* If everything is fine we should be in state OPERATE /* If everything is fine we should be in state OPERATE
Make a poll to see if there are diagnostics, the answer also tell us Make a poll to see if there are diagnostics, the answer also tell us
if there are any hardware faults. In that case, make a reset and a new init. */ if there are any hardware faults. In that case, make a reset and a new init. */
...@@ -1003,6 +1036,37 @@ static pwr_tStatus IoAgentWrite ( ...@@ -1003,6 +1036,37 @@ static pwr_tStatus IoAgentWrite (
io_sAgent *ap io_sAgent *ap
) )
{ {
T_PROFI_DEVICE_HANDLE *hDevice;
pwr_tUInt16 sts;
pwr_sClass_Pb_Profiboard *mp;
pwr_sClass_Pb_DP_Slave *sp;
io_sRack *slave_list;
hDevice = (T_PROFI_DEVICE_HANDLE *) ap->Local;
/* Iterate over the slaves. */
for (slave_list = ap->racklist; slave_list != NULL;
slave_list = slave_list->next) {
sp = (pwr_sClass_Pb_DP_Slave *) slave_list->op;
mp = (pwr_sClass_Pb_Profiboard *) ap->op;
// Write the whole I/O output area from local area
if ((sp->Status == PB__NORMAL || sp->Status == PB__NOCONN) &&
mp->Status == PB__NORMAL && (sp->DisableSlave != 1) && (mp->DisableBus != 1)) {
if (sp->BytesOfOutput > 0) {
sts = profi_set_data(hDevice, ID_DP_SLAVE_IO_IMAGE, sp->OffsetOutputs, sp->BytesOfOutput, &sp->Outputs);
if (sts != E_OK) sp->ErrorCount++;
}
}
}
return IO__SUCCESS; return IO__SUCCESS;
} }
......
...@@ -53,16 +53,7 @@ ...@@ -53,16 +53,7 @@
#define PB_UDATA_DIAG 1 #define PB_UDATA_DIAG 1
typedef struct { /* io_sAgentLocal now lives in the respective agent modules. */
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;
int hDpsBoardDevice; // Handle for DP-Slave Output-Data device
} io_sAgentLocal;
typedef struct { typedef struct {
int initialized; int initialized;
......
Pb_Profiboard Pb_Profiboard
Pb_Hilscher
Pb_DP_Slave Pb_DP_Slave
Pb_Module Pb_Module
Pb_Di Pb_Di
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
* Proview $Id: rt_pb_gsd.h,v 1.8 2008-10-31 12:51:29 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass ave, Cambridge, MA 02139, USA.
*/
#ifndef rt_pn_gsdml_h
#define rt_pn_gsdml_h
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
class pn_gsdml;
class gsdml_Valuelist;
typedef struct {
char name[32];
pwr_tCid cid;
} gsdml_sModuleClass;
typedef char gsdml_tString80[80];
typedef char gsdml_tString1024[1024];
typedef char gsdml_tString512[512];
typedef char gsdml_tString[80];
typedef char *gsdml_tAllocatedString;
typedef char gsdml_tNormalizedString[80];
typedef char gsdml_tToken[80];
typedef char gsdml_tTokenList[80];
typedef struct {
char str[160];
gsdml_Valuelist *list;
} gsdml_tValueList;
typedef char gsdml_tEnum[80];
typedef char gsdml_tId[80];
typedef char gsdml_tIdT[256];
typedef struct {
gsdml_tIdT ref;
void *p;
} gsdml_tRefIdT;
typedef struct {
char ref[80];
void *p;
} gsdml_tRefId;
typedef int gsdml_tInteger;
typedef unsigned char gsdml_tUnsigned8;
typedef unsigned short gsdml_tUnsigned16;
typedef unsigned int gsdml_tUnsigned32;
typedef unsigned short gsdml_tUnsigned16hex;
typedef unsigned int gsdml_tUnsigned32hex;
typedef unsigned int gsdml_tBoolean;
typedef char gsdml_tSignedOrFloatValueList[160];
typedef enum {
gsdml_eType_,
gsdml_eType_Boolean,
gsdml_eType_Integer,
gsdml_eType_String,
gsdml_eType_AllocatedString,
gsdml_eType_NormalizedString,
gsdml_eType_Token,
gsdml_eType_Id,
gsdml_eType_IdT,
gsdml_eType_RefId,
gsdml_eType_RefIdT,
gsdml_eType_Unsigned8,
gsdml_eType_Unsigned16,
gsdml_eType_Unsigned32,
gsdml_eType_Unsigned16hex,
gsdml_eType_Unsigned32hex,
gsdml_eType_ValueList,
gsdml_eType_SignedOrFloatValueList,
gsdml_eType_TokenList,
gsdml_eType_Enum,
gsdml_eType__
} gsdml_eType;
typedef enum {
gsdml_eValueDataType_,
gsdml_eValueDataType_Bit,
gsdml_eValueDataType_BitArea,
gsdml_eValueDataType_Integer8,
gsdml_eValueDataType_Integer16,
gsdml_eValueDataType_Integer32,
gsdml_eValueDataType_Integer64,
gsdml_eValueDataType_Unsigned8,
gsdml_eValueDataType_Unsigned16,
gsdml_eValueDataType_Unsigned32,
gsdml_eValueDataType_Unsigned64,
gsdml_eValueDataType_Float32,
gsdml_eValueDataType_Float64,
gsdml_eValueDataType_Date,
gsdml_eValueDataType_TimeOfDayWithDate,
gsdml_eValueDataType_TimeOfDayWithoutDate,
gsdml_eValueDataType_TimeDiffWithDate,
gsdml_eValueDataType_TimeDiffWithoutDate,
gsdml_eValueDataType_NetworkTime,
gsdml_eValueDataType_NetworkTimeDiff,
gsdml_eValueDataType_VisibleString,
gsdml_eValueDataType_OctetString,
gsdml_eValueDataType__
} gsdml_eValueDataType;
typedef enum {
gsdml_eTag_,
gsdml_eTag_xml,
gsdml_eTag_ISO15745Profile,
gsdml_eTag_ProfileHeader,
gsdml_eTag_ProfileIdentification,
gsdml_eTag_ProfileRevision,
gsdml_eTag_ProfileName,
gsdml_eTag_ProfileSource,
gsdml_eTag_ProfileClassID,
gsdml_eTag_ISO15745Reference,
gsdml_eTag_ISO15745Part,
gsdml_eTag_ISO15745Edition,
gsdml_eTag_ProfileTechnology,
gsdml_eTag_ProfileBody,
gsdml_eTag_DeviceIdentity,
gsdml_eTag_InfoText,
gsdml_eTag_VendorName,
gsdml_eTag_DeviceFunction,
gsdml_eTag_Family,
gsdml_eTag_ApplicationProcess,
gsdml_eTag_DeviceAccessPointList,
gsdml_eTag_DeviceAccessPointItem,
gsdml_eTag_ModuleInfo,
gsdml_eTag_Name,
gsdml_eTag_OrderNumber,
gsdml_eTag_HardwareRelease,
gsdml_eTag_SoftwareRelease,
gsdml_eTag_SubslotList,
gsdml_eTag_SubslotItem,
gsdml_eTag_IOConfigData,
gsdml_eTag_UseableModules,
gsdml_eTag_ModuleItemRef,
gsdml_eTag_VirtualSubmoduleList,
gsdml_eTag_VirtualSubmoduleItem,
gsdml_eTag_IOData,
gsdml_eTag_Input,
gsdml_eTag_Output,
gsdml_eTag_DataItem,
gsdml_eTag_BitDataItem,
gsdml_eTag_RecordDataList,
gsdml_eTag_ParameterRecordDataItem,
gsdml_eTag_Const,
gsdml_eTag_Ref,
gsdml_eTag_F_ParameterRecordDataItem,
gsdml_eTag_F_Check_iPar,
gsdml_eTag_F_SIL,
gsdml_eTag_F_CRC_Length,
gsdml_eTag_F_Block_ID,
gsdml_eTag_F_Par_Version,
gsdml_eTag_F_Source_Add,
gsdml_eTag_F_Dest_Add,
gsdml_eTag_F_WD_Time,
gsdml_eTag_F_Par_CRC,
gsdml_eTag_F_iPar_CRC,
gsdml_eTag_Graphics,
gsdml_eTag_GraphicItemRef,
gsdml_eTag_IsochroneMode,
gsdml_eTag_SystemDefinedSubmoduleList,
gsdml_eTag_InterfaceSubmoduleItem,
gsdml_eTag_General,
gsdml_eTag_DCP_FlashOnceSignalUnit,
gsdml_eTag_RT_Class3Properties,
gsdml_eTag_SynchronisationMode,
gsdml_eTag_ApplicationRelations,
gsdml_eTag_TimingProperties,
gsdml_eTag_RT_Class3TimingProperties,
gsdml_eTag_MediaRedundancy,
gsdml_eTag_PortSubmoduleItem,
gsdml_eTag_UseableSubmodules,
gsdml_eTag_SubmoduleItemRef,
gsdml_eTag_SlotList,
gsdml_eTag_SlotItem,
gsdml_eTag_SlotGroups,
gsdml_eTag_SlotGroup,
gsdml_eTag_ModuleList,
gsdml_eTag_ModuleItem,
gsdml_eTag_SubmoduleList,
gsdml_eTag_ValueList,
gsdml_eTag_ValueItem,
gsdml_eTag_Help,
gsdml_eTag_Assignments,
gsdml_eTag_Assign,
gsdml_eTag_ChannelDiagList,
gsdml_eTag_ChannelDiagItem,
gsdml_eTag_ProfileChannelDiagItem,
gsdml_eTag_ExtChannelDiagList,
gsdml_eTag_ExtChannelDiagItem,
gsdml_eTag_ExtChannelAddValue,
gsdml_eTag_UnitDiagTypeList,
gsdml_eTag_UnitDiagTypeItem,
gsdml_eTag_GraphicsList,
gsdml_eTag_GraphicItem,
gsdml_eTag_Embedded,
gsdml_eTag_CategoryList,
gsdml_eTag_CategoryItem,
gsdml_eTag_ExternalTextList,
gsdml_eTag_PrimaryLanguage,
gsdml_eTag_Language,
gsdml_eTag_Text,
gsdml_eTag__
} gsdml_eTag;
#define VL_END 0xffffffff
class gsdml_ValuelistValue {
public:
gsdml_ValuelistValue( unsigned int v) : value1(v), is_range(false) {}
gsdml_ValuelistValue( unsigned int v1, unsigned int v2) : value1(v1), value2(v2), is_range(true) {}
unsigned int value1;
unsigned int value2;
bool is_range;
};
class gsdml_Valuelist {
public:
gsdml_Valuelist( char *str);
vector<gsdml_ValuelistValue> value;
unsigned int status;
void sort();
int parse( char *str);
bool in_list( unsigned int);
unsigned int sts() { return status;}
};
class gsdml_ValuelistIterator {
public:
gsdml_ValuelistIterator( gsdml_Valuelist *vl) : valuelist(vl), current_value(0),
initiated(false) {}
gsdml_Valuelist *valuelist;
unsigned int next();
unsigned int begin();
unsigned int end() { return VL_END;}
unsigned int current_value;
unsigned int current_idx;
bool initiated;
};
#define VLS_END 0xefffffff
class gsdml_SValuelistValue {
public:
gsdml_SValuelistValue( int v) : value1(v), is_range(false) {}
gsdml_SValuelistValue( int v1, int v2) : value1(v1), value2(v2), is_range(true) {}
int value1;
int value2;
bool is_range;
};
class gsdml_SValuelist {
public:
gsdml_SValuelist( char *str);
vector<gsdml_SValuelistValue> value;
unsigned int status;
void sort();
int parse( char *str);
bool in_list( int);
unsigned int sts() { return status;}
};
class gsdml_SValuelistIterator {
public:
gsdml_SValuelistIterator( gsdml_SValuelist *vl) : valuelist(vl), current_value(0),
initiated(false) {}
gsdml_SValuelist *valuelist;
int next();
int begin();
int end() { return VL_END;}
int current_value;
unsigned int current_idx;
bool initiated;
};
class gsdml_FValuelistValue {
public:
gsdml_FValuelistValue( double v) : value1(v), is_range(false) {}
gsdml_FValuelistValue( double v1, double v2) : value1(v1), value2(v2), is_range(true) {}
double value1;
double value2;
bool is_range;
};
class gsdml_FValuelist {
public:
gsdml_FValuelist( char *str);
vector<gsdml_FValuelistValue> value;
unsigned int status;
void sort();
int parse( char *str);
bool in_list( double val);
unsigned int sts() { return status;}
};
typedef struct {
gsdml_tString80 Version;
gsdml_tString80 Encoding;
} gsdml_sXml;
class gsdml_Xml {
public:
gsdml_Xml( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sXml Body;
pn_gsdml *gsdml;
};
typedef struct {
gsdml_tString80 ProfileIdentification;
gsdml_tString80 ProfileRevision;
gsdml_tString80 ProfileName;
gsdml_tString80 ProfileSource;
gsdml_tString80 ProfileClassID;
gsdml_tInteger ISO15745Part;
gsdml_tInteger ISO15745Edition;
gsdml_tString80 ProfileTechnology;
} gsdml_sProfileHeader;
class gsdml_ProfileHeader {
public:
gsdml_ProfileHeader( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sProfileHeader Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16hex VendorID;
gsdml_tUnsigned16hex DeviceID;
gsdml_tRefIdT InfoText;
gsdml_tToken VendorName;
} gsdml_sDeviceIdentity;
class gsdml_DeviceIdentity {
public:
gsdml_DeviceIdentity( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sDeviceIdentity Body;
pn_gsdml *gsdml;
void build();
void print( int ind);
};
typedef struct {
gsdml_tString80 MainFamily;
gsdml_tString80 ProductFamily;
} gsdml_sDeviceFunction;
class gsdml_DeviceFunction {
public:
gsdml_DeviceFunction( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sDeviceFunction Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tRefIdT CategoryRef;
gsdml_tRefIdT SubCategory1Ref;
gsdml_tRefIdT Name;
gsdml_tRefIdT InfoText;
gsdml_tToken VendorName;
gsdml_tToken OrderNumber;
gsdml_tToken HardwareRelease;
gsdml_tToken SoftwareRelease;
gsdml_tString MainFamily;
gsdml_tString ProductFamily;
} gsdml_sModuleInfo;
class gsdml_ModuleInfo {
public:
gsdml_ModuleInfo( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sModuleInfo Body;
pn_gsdml *gsdml;
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 SubslotNumber;
gsdml_tRefId TextId;
} gsdml_sSubslotItem;
class gsdml_SubslotItem {
public:
gsdml_SubslotItem( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sSubslotItem Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_SubslotList {
public:
gsdml_SubslotList( pn_gsdml *g) : gsdml(g) {}
~gsdml_SubslotList();
vector<gsdml_SubslotItem *> SubslotItem;
pn_gsdml *gsdml;
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 MaxInputLength;
gsdml_tUnsigned16 MaxOutputLength;
gsdml_tUnsigned16 MaxDataLength;
} gsdml_sIOConfigData;
class gsdml_IOConfigData {
public:
gsdml_IOConfigData( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sIOConfigData Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tRefId ModuleItemTarget;
gsdml_tValueList AllowedInSlots;
gsdml_tValueList UsedInSlots;
gsdml_tValueList FixedInSlots;
} gsdml_sModuleItemRef;
class gsdml_ModuleItemRef {
public:
gsdml_ModuleItemRef( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sModuleItemRef Body;
pn_gsdml *gsdml;
~gsdml_ModuleItemRef();
void build();
void print( int ind);
};
class gsdml_UseableModules {
public:
gsdml_UseableModules( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_ModuleItemRef *> ModuleItemRef;
pn_gsdml *gsdml;
~gsdml_UseableModules();
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned8 BitOffset;
gsdml_tRefIdT TextId;
} gsdml_sBitDataItem;
class gsdml_BitDataItem {
public:
gsdml_BitDataItem( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sBitDataItem Body;
pn_gsdml *gsdml;
void build();
void print( int ind);
};
typedef struct {
gsdml_tEnum DataType;
gsdml_tUnsigned16 Length;
gsdml_tBoolean UseAsBits;
gsdml_tRefIdT TextId;
} gsdml_sDataItem;
class gsdml_DataItem {
public:
gsdml_DataItem( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sDataItem Body;
vector<gsdml_BitDataItem *> BitDataItem;
~gsdml_DataItem();
pn_gsdml *gsdml;
void build();
void print( int ind);
};
typedef struct {
gsdml_tEnum Consistency;
} gsdml_sInput;
class gsdml_Input {
public:
gsdml_Input( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sInput Body;
vector<gsdml_DataItem *> DataItem;
~gsdml_Input();
pn_gsdml *gsdml;
void build();
void print( int ind);
};
typedef struct {
gsdml_tEnum Consistency;
} gsdml_sOutput;
class gsdml_Output {
public:
gsdml_Output( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sOutput Body;
vector<gsdml_DataItem *> DataItem;
pn_gsdml *gsdml;
~gsdml_Output();
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned8 IOPS_Length;
gsdml_tUnsigned8 IOCS_Length;
gsdml_tUnsigned8 F_IO_StructureDescVersion;
gsdml_tUnsigned32 F_IO_StructureDescCRC;
} gsdml_sIOData;
class gsdml_IOData {
public:
gsdml_IOData( pn_gsdml *g) : Input(0), Output(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sIOData Body;
gsdml_Input *Input;
gsdml_Output *Output;
pn_gsdml *gsdml;
~gsdml_IOData();
void build();
void print( int ind);
};
typedef struct {
gsdml_tRefId ValueItemTarget;
gsdml_tUnsigned32 ByteOffset;
gsdml_tInteger BitOffset;
gsdml_tInteger BitLength;
gsdml_tEnum DataType;
gsdml_tString DefaultValue;
gsdml_tSignedOrFloatValueList AllowedValues;
gsdml_tBoolean Changeable;
gsdml_tBoolean Visible;
gsdml_tRefIdT TextId;
gsdml_tUnsigned16 Length;
} gsdml_sRef;
class gsdml_Ref {
public:
gsdml_Ref( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sRef Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tUnsigned32 ByteOffset;
gsdml_tString1024 Data;
} gsdml_sConst;
class gsdml_Const {
public:
gsdml_Const( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sConst Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 Index;
gsdml_tUnsigned32 Length;
gsdml_tUnsigned16 TransferSequence;
gsdml_tRefIdT Name;
} gsdml_sParameterRecordDataItem;
class gsdml_ParameterRecordDataItem {
public:
gsdml_ParameterRecordDataItem( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sParameterRecordDataItem Body;
vector<gsdml_Const *> Const;
vector<gsdml_Ref *> Ref;
pn_gsdml *gsdml;
~gsdml_ParameterRecordDataItem();
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 F_ParamDescCRC;
gsdml_tUnsigned16 Index;
gsdml_tUnsigned16 TransferSequence;
gsdml_tEnum F_Check_iPar_DefaultValue;
gsdml_tString F_Check_iPar_AllowedValues;
gsdml_tBoolean F_Check_iPar_Visible;
gsdml_tBoolean F_Check_iPar_Changeable;
gsdml_tEnum F_SIL_DefaultValue;
gsdml_tString F_SIL_AllowedValues;
gsdml_tBoolean F_SIL_Visible;
gsdml_tBoolean F_SIL_Changeable;
gsdml_tEnum F_CRC_Length_DefaultValue;
gsdml_tString F_CRC_Length_AllowedValues;
gsdml_tBoolean F_CRC_Length_Visible;
gsdml_tBoolean F_CRC_Length_Changeable;
gsdml_tInteger F_Block_ID_DefaultValue;
gsdml_tValueList F_Block_ID_AllowedValues;
gsdml_tBoolean F_Block_ID_Visible;
gsdml_tBoolean F_Block_ID_Changeable;
gsdml_tInteger F_Par_Version_DefaultValue;
gsdml_tValueList F_Par_Version_AllowedValues;
gsdml_tBoolean F_Par_Version_Visible;
gsdml_tBoolean F_Par_Version_Changeable;
gsdml_tUnsigned16 F_Source_Add_DefaultValue;
gsdml_tValueList F_Source_Add_AllowedValues;
gsdml_tBoolean F_Source_Add_Visible;
gsdml_tBoolean F_Source_Add_Changeable;
gsdml_tUnsigned16 F_Dest_Add_DefaultValue;
gsdml_tValueList F_Dest_Add_AllowedValues;
gsdml_tBoolean F_Dest_Add_Visible;
gsdml_tBoolean F_Dest_Add_Changeable;
gsdml_tUnsigned16 F_WD_Time_DefaultValue;
gsdml_tValueList F_WD_Time_AllowedValues;
gsdml_tBoolean F_WD_Time_Visible;
gsdml_tBoolean F_WD_Time_Changeable;
gsdml_tUnsigned16 F_Par_CRC_DefaultValue;
gsdml_tValueList F_Par_CRC_AllowedValues;
gsdml_tBoolean F_Par_CRC_Visible;
gsdml_tBoolean F_Par_CRC_Changeable;
gsdml_tUnsigned32 F_iPar_CRC_DefaultValue;
gsdml_tValueList F_iPar_CRC_AllowedValues;
gsdml_tBoolean F_iPar_CRC_Visible;
gsdml_tBoolean F_iPar_CRC_Changeable;
} gsdml_sF_ParameterRecordDataItem;
class gsdml_F_ParameterRecordDataItem {
public:
gsdml_F_ParameterRecordDataItem( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sF_ParameterRecordDataItem Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_RecordDataList {
public:
gsdml_RecordDataList( pn_gsdml *g) : F_ParameterRecordDataItem(0), gsdml(g) {}
vector<gsdml_ParameterRecordDataItem *> ParameterRecordDataItem;
gsdml_F_ParameterRecordDataItem *F_ParameterRecordDataItem;
pn_gsdml *gsdml;
~gsdml_RecordDataList();
void build();
void print( int ind);
};
typedef struct {
gsdml_tEnum Type;
gsdml_tRefId GraphicItemTarget;
} gsdml_sGraphicItemRef;
class gsdml_GraphicItemRef {
public:
gsdml_GraphicItemRef( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sGraphicItemRef Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_Graphics {
public:
gsdml_Graphics( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_GraphicItemRef *> GraphicItemRef;
pn_gsdml *gsdml;
~gsdml_Graphics();
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 T_DC_Base;
gsdml_tUnsigned16 T_DC_Min;
gsdml_tUnsigned16 T_DC_Max;
gsdml_tUnsigned32 T_IO_Base;
gsdml_tUnsigned32 T_IO_InputMin;
gsdml_tUnsigned32 T_IO_OutputMin;
gsdml_tBoolean IsochroneModeRequired;
} gsdml_sIsochroneMode;
class gsdml_IsochroneMode {
public:
gsdml_IsochroneMode( pn_gsdml *g) : gsdml(g) { memset( &Body, 0, sizeof(Body));}
gsdml_sIsochroneMode Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tId ID;
gsdml_tUnsigned32hex SubmoduleIdentNumber;
gsdml_tUnsigned32 API;
gsdml_tValueList FixedInSubslots;
gsdml_tBoolean PROFIsafeSupported;
gsdml_tValueList Writeable_IM_Records;
gsdml_tUnsigned32 Max_iParameterSize;
gsdml_tUnsigned16 SubsysModuleDirIndex;
} gsdml_sVirtualSubmoduleItem;
class gsdml_VirtualSubmoduleItem {
public:
gsdml_VirtualSubmoduleItem( pn_gsdml *g) : IOData(0), RecordDataList(0), ModuleInfo(0),
Graphics(0), IsochroneMode(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sVirtualSubmoduleItem Body;
gsdml_IOData *IOData;
gsdml_RecordDataList *RecordDataList;
gsdml_ModuleInfo *ModuleInfo;
gsdml_Graphics *Graphics;
gsdml_IsochroneMode *IsochroneMode;
pn_gsdml *gsdml;
~gsdml_VirtualSubmoduleItem();
void build();
void print( int ind);
};
class gsdml_VirtualSubmoduleList {
public:
gsdml_VirtualSubmoduleList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_VirtualSubmoduleItem *> VirtualSubmoduleItem;
pn_gsdml *gsdml;
~gsdml_VirtualSubmoduleList();
void build();
void print( int ind);
};
typedef struct {
gsdml_tRefIdT TextId;
} gsdml_sDCP_FlashOnceSignalUnit;
class gsdml_DCP_FlashOnceSignalUnit {
public:
gsdml_DCP_FlashOnceSignalUnit( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sDCP_FlashOnceSignalUnit Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_General {
public:
gsdml_General( pn_gsdml *g) : DCP_FlashOnceSignalUnit(0), gsdml(g) {}
gsdml_DCP_FlashOnceSignalUnit *DCP_FlashOnceSignalUnit;
pn_gsdml *gsdml;
~gsdml_General();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 MaxBridgeDelay;
gsdml_tUnsigned16 MaxNumberIR_FrameData;
} gsdml_sRT_Class3Properties;
class gsdml_RT_Class3Properties {
public:
gsdml_RT_Class3Properties( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sRT_Class3Properties Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tEnum SupportedRole;
gsdml_tUnsigned16 MaxLocalJitter;
gsdml_tUnsigned16 T_PLL_MAX;
gsdml_tTokenList SupportedSyncProtocols;
} gsdml_sSynchronisationMode;
class gsdml_SynchronisationMode {
public:
gsdml_SynchronisationMode( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sSynchronisationMode Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tValueList SendClock;
gsdml_tValueList ReductionRatio;
gsdml_tValueList ReductionRatioPow2;
gsdml_tValueList ReductionRatioNonPow2;
} gsdml_sTimingProperties;
class gsdml_TimingProperties {
public:
gsdml_TimingProperties( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sTimingProperties Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tValueList SendClock;
gsdml_tValueList ReductionRatio;
gsdml_tValueList ReductionRatioPow2;
gsdml_tValueList ReductionRatioNonPow2;
} gsdml_sRT_Class3TimingProperties;
class gsdml_RT_Class3TimingProperties {
public:
gsdml_RT_Class3TimingProperties( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sRT_Class3TimingProperties Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 NumberOfAdditionalInputCR;
gsdml_tUnsigned16 NumberOfAdditionalOutputCR;
gsdml_tUnsigned16 NumberOfAdditionalMulticastProviderCR;
gsdml_tUnsigned16 NumberOfMulticastConsumerCR;
gsdml_tUnsigned16 PullModuleAlarmSupported;
} gsdml_sInterfaceSubmoduleItem_ApplicationRelations;
class gsdml_InterfaceSubmoduleItem_ApplicationRelations {
public:
gsdml_InterfaceSubmoduleItem_ApplicationRelations( pn_gsdml *g) : TimingProperties(0), RT_Class3TimingProperties(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sInterfaceSubmoduleItem_ApplicationRelations Body;
gsdml_TimingProperties *TimingProperties;
gsdml_RT_Class3TimingProperties *RT_Class3TimingProperties;
pn_gsdml *gsdml;
~gsdml_InterfaceSubmoduleItem_ApplicationRelations();
void print( int ind);
};
typedef struct {
gsdml_tBoolean RT_MediaRedundancySupported;
gsdml_tTokenList SupportedRole;
} gsdml_sMediaRedundancy;
class gsdml_MediaRedundancy {
public:
gsdml_MediaRedundancy( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sMediaRedundancy Body;
pn_gsdml *gsdml;
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 SubslotNumber;
gsdml_tRefId TextId;
gsdml_tEnum SupportedRT_Class;
gsdml_tTokenList SupportedRT_Classes;
gsdml_tBoolean IsochroneModeSupported;
gsdml_tTokenList IsochroneModeInRT_Classes;
gsdml_tUnsigned32hex SubmoduleIdentNumber;
gsdml_tTokenList SupportedProtocols;
gsdml_tTokenList SupportedMibs;
gsdml_tBoolean NetworkComponentDiagnosisSupported;
gsdml_tBoolean DCP_HelloSupported;
gsdml_tBoolean PTP_BoundarySupported;
gsdml_tBoolean DCP_BoundarySupported;
} gsdml_sInterfaceSubmoduleItem;
class gsdml_InterfaceSubmoduleItem {
public:
gsdml_InterfaceSubmoduleItem( pn_gsdml *g) : General(0), RecordDataList(0), RT_Class3Properties(0), SynchronisationMode(0),
ApplicationRelations(0), MediaRedundancy(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sInterfaceSubmoduleItem Body;
gsdml_General *General;
gsdml_RecordDataList *RecordDataList;
gsdml_RT_Class3Properties *RT_Class3Properties;
gsdml_SynchronisationMode *SynchronisationMode;
gsdml_InterfaceSubmoduleItem_ApplicationRelations *ApplicationRelations;
gsdml_MediaRedundancy *MediaRedundancy;
pn_gsdml *gsdml;
~gsdml_InterfaceSubmoduleItem();
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 SubslotNumber;
gsdml_tRefId TextId;
gsdml_tEnum MAUType;
gsdml_tValueList MAUTypes;
gsdml_tValueList FiberOpticTypes;
gsdml_tUnsigned16 MaxPortTxDelay;
gsdml_tUnsigned16 MaxPortRxDelay;
gsdml_tUnsigned32 SubmoduleIdentNumber;
gsdml_tBoolean PortDeactivationSupported;
gsdml_tEnum LinkStateDiagnosisCapability;
gsdml_tBoolean PowerBudgetControlSupported;
gsdml_tBoolean SupportsRingportConfig;
gsdml_tBoolean IsDefaultRingport;
} gsdml_sPortSubmoduleItem;
class gsdml_PortSubmoduleItem {
public:
gsdml_PortSubmoduleItem( pn_gsdml *g) : RecordDataList(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sPortSubmoduleItem Body;
gsdml_RecordDataList *RecordDataList;
pn_gsdml *gsdml;
~gsdml_PortSubmoduleItem();
void build();
void print( int ind);
};
class gsdml_SystemDefinedSubmoduleList {
public:
gsdml_SystemDefinedSubmoduleList( pn_gsdml *g) : gsdml(g) {}
gsdml_InterfaceSubmoduleItem *InterfaceSubmoduleItem;
vector<gsdml_PortSubmoduleItem *> PortSubmoduleItem;
pn_gsdml *gsdml;
~gsdml_SystemDefinedSubmoduleList();
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 AR_BlockVersion;
gsdml_tUnsigned16 IOCR_BlockVersion;
gsdml_tUnsigned16 AlarmCR_BlockVersion;
gsdml_tUnsigned16 SubmoduleDataBlockVersion;;
} gsdml_sDeviceAccessPointItem_ApplicationRelations;
class gsdml_DeviceAccessPointItem_ApplicationRelations {
public:
gsdml_DeviceAccessPointItem_ApplicationRelations( pn_gsdml *g) : TimingProperties(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sDeviceAccessPointItem_ApplicationRelations Body;
gsdml_TimingProperties *TimingProperties;
pn_gsdml *gsdml;
~gsdml_DeviceAccessPointItem_ApplicationRelations();
void print( int ind);
};
typedef struct {
gsdml_tRefId SubmoduleItemTarget;
gsdml_tValueList AllowedInSubslots;
gsdml_tValueList UsedInSubslots;
gsdml_tValueList FixedInSubslots;
} gsdml_sSubmoduleItemRef;
class gsdml_SubmoduleItemRef {
public:
gsdml_SubmoduleItemRef( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sSubmoduleItemRef Body;
pn_gsdml *gsdml;
void build();
void print( int ind);
};
class gsdml_UseableSubmodules {
public:
gsdml_UseableSubmodules( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_SubmoduleItemRef *> SubmoduleItemRef;
pn_gsdml *gsdml;
~gsdml_UseableSubmodules();
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 SlotNumber;
gsdml_tRefId TextId;
} gsdml_sSlotItem;
class gsdml_SlotItem {
public:
gsdml_SlotItem( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sSlotItem Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_SlotList {
public:
gsdml_SlotList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_SlotItem *> SlotItem;
pn_gsdml *gsdml;
~gsdml_SlotList();
void build();
void print( int ind);
};
typedef struct {
gsdml_tValueList SlotList;
gsdml_tRefId Name;
gsdml_tRefId InfoText;
} gsdml_sSlotGroup;
class gsdml_SlotGroup {
public:
gsdml_SlotGroup( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sSlotGroup Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_SlotGroups {
public:
gsdml_SlotGroups( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_SlotGroup *> SlotGroup;
pn_gsdml *gsdml;
~gsdml_SlotGroups();
void print( int ind);
};
typedef struct {
gsdml_tId ID;
gsdml_tValueList PhysicalSlots;
gsdml_tUnsigned32hex ModuleIdentNumber;
gsdml_tUnsigned16 MinDeviceInterval;
gsdml_tNormalizedString ImplementationType;
gsdml_tString DNS_CompatibleName;
gsdml_tBoolean ExtendedAddressAssignmentSupported;
gsdml_tTokenList AddressAssignment;
gsdml_tValueList AllowedInSlots;
gsdml_tValueList FixedInSlots;
gsdml_tUnsigned16 ObjectUUID_LocalIndex;
gsdml_tString RequiredSchemaVersion;
gsdml_tBoolean MultipleWriteSupported;
gsdml_tBoolean IOXS_Required;
gsdml_tValueList PhysicalSubslots;
gsdml_tUnsigned16 RemoteApplicationTimeout;
gsdml_tUnsigned32 MaxSupportedRecordSize;
gsdml_tUnsigned32 PowerOnToCommReady;
gsdml_tBoolean ParameterizationSpeedSupported;
gsdml_tBoolean NameOfStationNotTransferable;
} gsdml_sDeviceAccessPointItem;
class gsdml_DeviceAccessPointItem {
public:
gsdml_DeviceAccessPointItem( pn_gsdml *g) : ModuleInfo(0), SubslotList(0), IOConfigData(0), UseableModules(0),
VirtualSubmoduleList(0), SystemDefinedSubmoduleList(0), Graphics(0), ApplicationRelations(0),
UseableSubmodules(0), SlotList(0), SlotGroups(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sDeviceAccessPointItem Body;
gsdml_ModuleInfo *ModuleInfo;
gsdml_SubslotList *SubslotList;
gsdml_IOConfigData *IOConfigData;
gsdml_UseableModules *UseableModules;
gsdml_VirtualSubmoduleList *VirtualSubmoduleList;
gsdml_SystemDefinedSubmoduleList *SystemDefinedSubmoduleList;
gsdml_Graphics *Graphics;
gsdml_DeviceAccessPointItem_ApplicationRelations *ApplicationRelations;
gsdml_UseableSubmodules *UseableSubmodules;
gsdml_SlotList *SlotList;
gsdml_SlotGroups *SlotGroups;
pn_gsdml *gsdml;
~gsdml_DeviceAccessPointItem();
void build();
void print( int ind);
};
class gsdml_DeviceAccessPointList {
public:
gsdml_DeviceAccessPointList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_DeviceAccessPointItem *> DeviceAccessPointItem;
pn_gsdml *gsdml;
~gsdml_DeviceAccessPointList();
void build();
void print( int ind);
};
typedef struct {
gsdml_tId ID;
gsdml_tUnsigned32hex ModuleIdentNumber;
gsdml_tString RequiredSchemaVersion;
gsdml_tValueList PhysicalSubslots;
} gsdml_sModuleItem;
class gsdml_ModuleItem {
public:
gsdml_ModuleItem( pn_gsdml *g) : ModuleInfo(0), SubslotList(0), VirtualSubmoduleList(0),
SystemDefinedSubmoduleList(0), UseableSubmodules(0), Graphics(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sModuleItem Body;
gsdml_ModuleInfo *ModuleInfo;
gsdml_SubslotList *SubslotList;
gsdml_VirtualSubmoduleList *VirtualSubmoduleList;
gsdml_SystemDefinedSubmoduleList *SystemDefinedSubmoduleList;
gsdml_UseableSubmodules *UseableSubmodules;
gsdml_Graphics *Graphics;
pn_gsdml *gsdml;
~gsdml_ModuleItem();
void build();
void print( int ind);
};
class gsdml_ModuleList {
public:
gsdml_ModuleList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_ModuleItem *> ModuleItem;
pn_gsdml *gsdml;
~gsdml_ModuleList();
void build();
void print( int ind);
};
class gsdml_SubmoduleList {
public:
gsdml_SubmoduleList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_VirtualSubmoduleItem *> SubmoduleItem;
pn_gsdml *gsdml;
~gsdml_SubmoduleList();
void print( int ind);
};
typedef struct {
gsdml_tString Content;
gsdml_tRefIdT TextId;
} gsdml_sAssign;
class gsdml_Assign {
public:
gsdml_Assign( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sAssign Body;
pn_gsdml *gsdml;
void build();
void print( int ind);
};
class gsdml_Assignments {
public:
gsdml_Assignments( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_Assign *> Assign;
pn_gsdml *gsdml;
~gsdml_Assignments();
void print( int ind);
};
typedef struct {
gsdml_tId ID;
gsdml_tRefIdT Help;
} gsdml_sValueItem;
class gsdml_ValueItem {
public:
gsdml_ValueItem( pn_gsdml *g) : Assignments(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sValueItem Body;
gsdml_Assignments *Assignments;
pn_gsdml *gsdml;
~gsdml_ValueItem();
void build();
void print( int ind);
};
class gsdml_ValueList {
public:
gsdml_ValueList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_ValueItem *> ValueItem;
pn_gsdml *gsdml;
~gsdml_ValueList();
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned8 Id;
gsdml_tEnum DataType;
gsdml_tUnsigned16 Length;
} gsdml_sExtChannelAddValue_DataItem;
class gsdml_ExtChannelAddValue_DataItem {
public:
gsdml_ExtChannelAddValue_DataItem( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sExtChannelAddValue_DataItem Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_ExtChannelAddValue {
public:
gsdml_ExtChannelAddValue( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_ExtChannelAddValue_DataItem *> DataItem;
pn_gsdml *gsdml;
~gsdml_ExtChannelAddValue();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 ErrorType;
gsdml_tTokenList MaintenanceAlarmState;
gsdml_tUnsigned32 API;
gsdml_tRefId Name;
gsdml_tRefId Help;
} gsdml_sExtChannelDiagItem;
class gsdml_ExtChannelDiagItem {
public:
gsdml_ExtChannelDiagItem( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sExtChannelDiagItem Body;
vector<gsdml_ExtChannelAddValue *> ExtChannelAddValue;
pn_gsdml *gsdml;
~gsdml_ExtChannelDiagItem();
void print( int ind);
};
class gsdml_ExtChannelDiagList {
public:
gsdml_ExtChannelDiagList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_ExtChannelDiagItem *> ExtChannelDiagItem;
pn_gsdml *gsdml;
~gsdml_ExtChannelDiagList();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 ErrorType;
gsdml_tTokenList MaintenanceAlarmState;
gsdml_tUnsigned32 API;
gsdml_tRefId Name;
gsdml_tRefId Help;
} gsdml_sChannelDiagItem;
class gsdml_ChannelDiagItem {
public:
gsdml_ChannelDiagItem( pn_gsdml *g) : ExtChannelDiagList(0), gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sChannelDiagItem Body;
gsdml_ExtChannelDiagList *ExtChannelDiagList;
pn_gsdml *gsdml;
~gsdml_ChannelDiagItem();
void build();
void print( int ind);
};
class gsdml_ChannelDiagList {
public:
gsdml_ChannelDiagList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_ChannelDiagItem *> ChannelDiagItem;
pn_gsdml *gsdml;
~gsdml_ChannelDiagList();
void build();
void print( int ind);
};
typedef struct {
gsdml_tUnsigned16 UserStructureIdentifier;
gsdml_tUnsigned32 API;
} gsdml_sUnitDiagTypeItem;
class gsdml_UnitDiagTypeItem {
public:
gsdml_UnitDiagTypeItem( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sUnitDiagTypeItem Body;
vector<gsdml_Ref *> Ref;
pn_gsdml *gsdml;
~gsdml_UnitDiagTypeItem();
void print( int ind);
};
class gsdml_UnitDiagTypeList {
public:
gsdml_UnitDiagTypeList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_UnitDiagTypeItem *> UnitDiagTypeItem;
pn_gsdml *gsdml;
~gsdml_UnitDiagTypeList();
void print( int ind);
};
typedef struct {
gsdml_tId ID;
gsdml_tString GraphicFile;
gsdml_tString Embedded;
} gsdml_sGraphicItem;
class gsdml_GraphicItem {
public:
gsdml_GraphicItem( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sGraphicItem Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_GraphicsList {
public:
gsdml_GraphicsList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_GraphicItem *> GraphicItem;
pn_gsdml *gsdml;
~gsdml_GraphicsList();
void print( int ind);
};
typedef struct {
gsdml_tId ID;
gsdml_tRefIdT TextId;
gsdml_tRefId InfoText;
} gsdml_sCategoryItem;
class gsdml_CategoryItem {
public:
gsdml_CategoryItem( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sCategoryItem Body;
pn_gsdml *gsdml;
void print( int ind);
};
class gsdml_CategoryList {
public:
gsdml_CategoryList( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_CategoryItem *> CategoryItem;
pn_gsdml *gsdml;
~gsdml_CategoryList();
void print( int ind);
};
typedef struct {
gsdml_tIdT TextId;
gsdml_tAllocatedString Value;
} gsdml_sText;
class gsdml_Text {
public:
gsdml_Text( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sText Body;
pn_gsdml *gsdml;
~gsdml_Text();
void print( int ind);
};
class gsdml_PrimaryLanguage {
public:
gsdml_PrimaryLanguage( pn_gsdml *g) : gsdml(g) {}
vector<gsdml_Text *> Text;
pn_gsdml *gsdml;
~gsdml_PrimaryLanguage();
void print( int ind);
};
typedef struct {
gsdml_tEnum xml_lang;
} gsdml_sLanguage;
class gsdml_Language {
public:
gsdml_Language( pn_gsdml *g) : gsdml(g)
{ memset( &Body, 0, sizeof(Body));}
gsdml_sLanguage Body;
vector<gsdml_Text *> Text;
pn_gsdml *gsdml;
~gsdml_Language();
void print( int ind);
};
class gsdml_ExternalTextList {
public:
gsdml_ExternalTextList( pn_gsdml *g) : gsdml(g) {}
gsdml_PrimaryLanguage *PrimaryLanguage;
vector<gsdml_Language *> Language;
pn_gsdml *gsdml;
~gsdml_ExternalTextList();
void print( int ind);
};
class gsdml_ApplicationProcess {
public:
gsdml_ApplicationProcess( pn_gsdml *g) : DeviceAccessPointList(0), ModuleList(0), SubmoduleList(0),
ValueList(0), ChannelDiagList(0), UnitDiagTypeList(0), GraphicsList(0), CategoryList(0), gsdml(g) {}
gsdml_DeviceAccessPointList *DeviceAccessPointList;
gsdml_ModuleList *ModuleList;
gsdml_SubmoduleList *SubmoduleList;
gsdml_ValueList *ValueList;
gsdml_ChannelDiagList *ChannelDiagList;
gsdml_UnitDiagTypeList *UnitDiagTypeList;
gsdml_GraphicsList *GraphicsList;
gsdml_CategoryList *CategoryList;
gsdml_ExternalTextList *ExternalTextList;
pn_gsdml *gsdml;
~gsdml_ApplicationProcess();
void build();
void print( int ind);
};
class pn_gsdml {
public:
pn_gsdml();
~pn_gsdml();
ifstream fp;
int logglevel;
bool first_token;
unsigned int state;
int line_cnt;
int char_cnt;
bool in_comment;
char c;
char c_f;
char c_ff;
void *c_sts;
void *c_f_sts;
void *c_ff_sts;
char current_tag[256];
char current_attribute_name[256];
char current_attribute_value[4096];
char current_tag_value[256];
unsigned int current_tag_idx;
unsigned int current_attribute_name_idx;
unsigned int current_attribute_value_idx;
unsigned int current_tag_value_idx;
int suppress_msg;
gsdml_eTag tag_stack[100];
unsigned int tag_stack_cnt;
void *object_stack[100];
gsdml_eTag object_stack_id[100];
unsigned int object_stack_cnt;
void *current_body;
unsigned int current_body_size;
char current_lang[10];
int byte_order;
gsdml_sModuleClass *module_classlist;
pwr_tFileName gsdmlfile;
gsdml_Xml *xml;
gsdml_ProfileHeader *ProfileHeader;
gsdml_DeviceIdentity *DeviceIdentity;
gsdml_DeviceFunction *DeviceFunction;
gsdml_ApplicationProcess *ApplicationProcess;
int read( const char *filename);
int tag( const char *name);
int metatag( const char *name);
int tag_end( const char *name);
int metatag_end( const char *name);
int tag_value( const char *value);
int tag_attribute( const char *name, const char *value);
int tag_stack_push( gsdml_eTag id);
int tag_stack_pull( gsdml_eTag id);
int object_stack_push( void *o, gsdml_eTag id);
int object_stack_pull( gsdml_eTag id);
void set_language( const char *lang);
static int ostring_to_data( unsigned char **data, const char *str, int size, int *rsize);
static int data_to_ostring( unsigned char *data, int size, char *str, int strsize);
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,
unsigned int size, char *str);
void set_classes( gsdml_sModuleClass *mclist) { module_classlist = mclist;}
int set_par_record_default( unsigned char *data, int size,
gsdml_ParameterRecordDataItem *par_record);
void *next_token();
bool is_space( const char c);
int find_tag( const char *name, int *idx);
int find_tag( gsdml_eTag id, int *idx);
int find_tag_attribute( const char *name, gsdml_eTag id, gsdml_eTag pid, int *idx);
void error_message_line( const char *msg);
void error_message( const char *format, const char *value);
gsdml_eTag get_tag_stack();
gsdml_eTag get_tag_stack( int p);
void *get_object_stack( gsdml_eTag id);
void *get_object_stack( int p, gsdml_eTag id);
int string_to_value( gsdml_eType type, unsigned int size, const char *str, void *buf);
int set_default_values( gsdml_eTag id, void *data, unsigned int size);
void *object_factory( gsdml_eTag id);
void *find_value_ref( char *ref);
void *find_module_ref( char *ref);
void *find_submodule_ref( char *ref);
void *find_category_ref( char *ref);
void *find_text_ref( char *ref);
void *find_graphic_ref( char *ref);
void gsdml_print();
void build();
};
#endif
/*
* Proview $Id: rt_pn_gsdml_attr.cpp,v 1.6 2008-10-31 12:51:29 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
/* rt_pn_gsdml_attr.cpp -- Display gsd attributes */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include "co_cdh.h"
#include "co_time.h"
#include "co_dcli.h"
#include "co_wow.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "glow.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "flow_msg.h"
#include "rt_pb_msg.h"
#include "rt_pn_gsdml_attr.h"
#include "rt_pn_gsdml_attrnav.h"
// Static member variables
char GsdmlAttr::value_recall[30][160];
void GsdmlAttr::gsdmlattr_message( void *attr, char severity, const char *message)
{
((GsdmlAttr *)attr)->message( severity, message);
}
void GsdmlAttr::gsdmlattr_change_value_cb( void *attr_ctx)
{
GsdmlAttr *attr = (GsdmlAttr *) attr_ctx;
attr->change_value();
}
//
// Callbackfunctions from menu entries
//
void GsdmlAttr::activate_exit()
{
if ( close_cb) {
if ( attrnav->is_modified()) {
wow->DisplayQuestion( (void *)this, "Apply",
"Do you want to apply changes",
cmd_close_apply_cb, cmd_close_no_cb, 0);
}
else
(close_cb)( parent_ctx);
}
else
delete this;
}
void GsdmlAttr::activate_help()
{
int sts;
if ( help_cb)
sts = (help_cb)( parent_ctx, "pn_device_editor /helpfile=\"$pwr_exe/profibus_xtthelp.dat\"");
}
void GsdmlAttr::activate_copy()
{
ItemPnSlot *item;
int sts;
sts = attrnav->get_select( (ItemPn **) &item);
if ( EVEN(sts)) {
message('E', "Select a module");
return;
}
if ( item->type != attrnav_eItemType_PnSlot) {
message('E', "Only slots can be copied");
return;
}
attrnav->dev_data.copy_slot( item->slotdata->slot_idx);
message('I', "Slot copied");
}
void GsdmlAttr::activate_cut()
{
ItemPnSlot *item;
int sts;
sts = attrnav->get_select( (ItemPn **) &item);
if ( EVEN(sts)) {
message('E', "Select a slot");
return;
}
if ( item->type != attrnav_eItemType_PnSlot) {
message('E', "Only slots can be cut");
return;
}
attrnav->dev_data.cut_slot( item->slotdata->slot_idx);
attrnav->redraw();
}
void GsdmlAttr::activate_paste()
{
ItemPnSlot *item;
int sts;
sts = attrnav->get_select( (ItemPn **) &item);
if ( EVEN(sts)) {
message('E', "Select a slot");
return;
}
if ( item->type != attrnav_eItemType_PnSlot) {
message('E', "Select a slot");
return;
}
attrnav->dev_data.paste_slot( item->slotdata->slot_idx);
attrnav->redraw();
}
void GsdmlAttr::activate_viewio( int set)
{
attrnav->set_viewio( set);
}
void GsdmlAttr::activate_zoom_in()
{
double zoom_factor;
attrnav->get_zoom( &zoom_factor);
if ( zoom_factor > 40)
return;
attrnav->zoom( 1.18);
}
void GsdmlAttr::activate_zoom_out()
{
double zoom_factor;
attrnav->get_zoom( &zoom_factor);
if ( zoom_factor < 15)
return;
attrnav->zoom( 1.0 / 1.18);
}
void GsdmlAttr::activate_zoom_reset()
{
attrnav->unzoom();
}
void GsdmlAttr::activate_print()
{
char filename[80] = "pwrp_tmp:wnav.ps";
char cmd[200];
int sts;
dcli_translate_filename( filename, filename);
attrnav->print( filename);
sprintf( cmd, "wb_gre_print.sh %s", filename);
sts = system( cmd);
}
void GsdmlAttr::activate_cmd_ok()
{
int sts;
attrnav->save( data_filename);
if ( save_cb) {
sts = (save_cb)( parent_ctx);
if ( EVEN(sts))
message( 'E', "Error saving profibus data");
else
attrnav->set_modified(0);
}
}
void GsdmlAttr::cmd_close_apply_cb( void *ctx, void *data)
{
GsdmlAttr *attr = (GsdmlAttr *)ctx;
int sts;
attr->attrnav->save( attr->data_filename);
if ( attr->save_cb) {
sts = (attr->save_cb)( attr->parent_ctx);
if ( EVEN(sts))
attr->message( 'E', "Error saving profibus data");
else
(attr->close_cb)( attr->parent_ctx);
}
}
void GsdmlAttr::cmd_close_no_cb( void *ctx, void *data)
{
GsdmlAttr *attr = (GsdmlAttr *)ctx;
(attr->close_cb)( attr->parent_ctx);
}
void GsdmlAttr::activate_cmd_ca()
{
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
(close_cb)( parent_ctx);
}
}
GsdmlAttr::~GsdmlAttr()
{
}
GsdmlAttr::GsdmlAttr( void *a_parent_ctx,
void *a_object,
pn_gsdml *a_gsdml,
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)
{
dcli_translate_filename( data_filename, a_data_filename);
}
/*
* Proview $Id$
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#ifndef rt_pn_gsdml_attr_h
#define rt_pn_gsdml_attr_h
/* rt_pn_gsdml_attr.h -- Profinet gsdml attribute editor */
#include "rt_pn_gsdml.h"
#include "rt_pn_gsdml_data.h"
typedef struct {
void *value;
char name[80];
int type;
int size;
double minlimit;
double maxlimit;
int noedit;
int multiline;
int mask;
} attr_sItem;
class GsdmlAttrNav;
class CoWow;
class GsdmlAttr {
public:
void *parent_ctx;
char name[80];
pn_gsdml *gsdml;
int edit_mode;
GsdmlAttrNav *attrnav;
int input_open;
void *object;
void (*close_cb) (void *);
int (*save_cb) (void *);
int (*help_cb) (void *, const char *);
void *client_data;
int recall_idx;
static char value_recall[30][160];
int value_current_recall;
pwr_tFileName data_filename;
CoWow *wow;
GsdmlAttr( void *a_parent_ctx,
void *a_object,
pn_gsdml *a_gsdml,
int a_edit_mode,
const char *a_data_filename);
virtual ~GsdmlAttr();
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();
void activate_copy();
void activate_cut();
void activate_paste();
void activate_print();
void activate_viewio( int set);
void activate_zoom_in();
void activate_zoom_out();
void activate_zoom_reset();
void activate_cmd_ok();
void activate_cmd_ca();
static void gsdmlattr_message( void *attr, char severity, const char *message);
static void gsdmlattr_change_value_cb( void *attr_ctx);
static void cmd_close_apply_cb( void *ctx, void *data);
static void cmd_close_no_cb( void *ctx, void *data);
};
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
* Proview $Id: rt_pn_gsdml_attrnav.h,v 1.5 2008-10-31 12:51:30 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#ifndef rt_pn_gsdml_attrnav_h
#define rt_pn_gsdml_attrnav_h
/* rt_pn_gsdml_attrnav.h -- Profibus gsd configurator navigator */
#if defined __cplusplus
extern "C" {
#endif
#ifndef pwr_h
# include "pwr.h"
#endif
#ifndef flow_h
#include "flow.h"
#endif
#ifndef glow_h
#include "glow.h"
#endif
#ifndef flow_browctx_h
#include "flow_browapi.h"
#endif
#ifndef glow_growctx_h
#include "glow_growctx.h"
#endif
#ifndef glow_growapi_h
#include "glow_growapi.h"
#endif
#ifndef rt_pn_gsdml_atttr_h
#include "rt_pn_gsdml_attr.h"
#endif
#ifndef rt_pn_gsdml_data_h
#include "rt_pn_gsdml_data.h"
#endif
typedef enum {
attrnav_eItemType_PnBase,
attrnav_eItemType_PnEnumValue,
attrnav_eItemType_PnDevice,
attrnav_eItemType_PnNetwork,
attrnav_eItemType_PnDeviceInfo,
attrnav_eItemType_PnDAP,
attrnav_eItemType_PnInterfaceSubmodule,
attrnav_eItemType_PnPortSubmodule,
attrnav_eItemType_PnSlot,
attrnav_eItemType_PnSubslot,
attrnav_eItemType_PnModuleInfo,
attrnav_eItemType_PnModuleType,
attrnav_eItemType_PnParRecord,
attrnav_eItemType_PnParValue,
attrnav_eItemType_PnParEnum,
attrnav_eItemType_PnParEnumBit,
attrnav_eItemType_PnModuleClass,
attrnav_eItemType_PnIOData,
attrnav_eItemType_PnInput,
attrnav_eItemType_PnOutput,
attrnav_eItemType_PnDataItem,
attrnav_eItemType_PnBitDataItem,
attrnav_eItemType_PnEnumByteOrder,
attrnav_eItemType_PnEnumTimeRatio
} attrnav_eItemType;
typedef enum {
attrnav_mOpen_All = ~0,
attrnav_mOpen_Children = 1 << 0,
attrnav_mOpen_Attributes = 1 << 1
} attrnav_mOpen;
class ItemPn;
//! Class for handling of brow.
class GsdmlAttrNavBrow {
public:
GsdmlAttrNavBrow( BrowCtx *brow_ctx, void *xn) : ctx(brow_ctx), attrnav(xn) {};
~GsdmlAttrNavBrow();
BrowCtx *ctx;
void *attrnav;
brow_tNodeClass nc_object;
brow_tNodeClass nc_attr;
brow_tNodeClass nc_attr_multiline;
brow_tNodeClass nc_table;
brow_tNodeClass nc_header;
brow_tNodeClass nc_table_header;
brow_tNodeClass nc_enum;
flow_sAnnotPixmap *pixmap_leaf;
flow_sAnnotPixmap *pixmap_map;
flow_sAnnotPixmap *pixmap_openmap;
flow_sAnnotPixmap *pixmap_attr;
flow_sAnnotPixmap *pixmap_attrarray;
flow_sAnnotPixmap *pixmap_attrenum;
void free_pixmaps();
void allocate_pixmaps();
void create_nodeclasses();
void brow_setup();
};
class CoWow;
class CoWowTimer;
//! The navigation area of the attribute editor.
class GsdmlAttrNav {
public:
void *parent_ctx;
pn_gsdml *gsdml;
char name[80];
GsdmlAttrNavBrow *brow;
attr_sItem *itemlist;
int item_cnt;
int edit_mode;
int trace_started;
void (*message_cb)( void *, char, const char *);
void (*change_value_cb)( void *);
CoWow *wow;
CoWowTimer *trace_timerid;
unsigned int device_num;
gsdml_DeviceAccessPointItem *device_item;
int device_confirm_active;
int modified;
GsdmlDeviceData dev_data;
int device_read;
int viewio;
unsigned int time_ratio;
GsdmlAttrNav(
void *xn_parent_ctx,
const char *xn_name,
pn_gsdml *xn_gsd,
int xn_edit_mode,
pwr_tStatus *status);
virtual ~GsdmlAttrNav();
virtual void set_inputfocus() {}
void start_trace( pwr_tObjid Objid, char *object_str);
int set_attr_value( char *value_str);
int check_attr_value( char **value);
int get_select( pwr_sAttrRef *attrref, int *is_attr);
void message( char sev, const char *text);
void force_trace_scan();
int object_attr();
void print( char *filename);
int get_select( ItemPn **item);
void zoom( double zoom_factor);
void unzoom();
void get_zoom( double *zoom_factor);
void set_modified( int value) { modified = value;}
int is_modified() { return modified;}
int save( const char *filename);
int open( const char *filename);
void redraw();
void set_viewio( int set) { viewio = set;}
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);
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, char *value_str,
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);
static int brow_cb( FlowCtx *ctx, flow_tEvent event);
static void device_changed_ok( void *ctx, void *data);
static void device_changed_cancel( void *ctx, void *data);
};
class ItemPn {
public:
ItemPn() : parent(0) {}
attrnav_eItemType type;
brow_tNode node;
char name[120];
int parent;
virtual ~ItemPn() {}
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y) { return 1;}
virtual int close( GsdmlAttrNav *attrnav, double x, double y);
virtual int scan( GsdmlAttrNav *attrnav, void *p) { return 1;}
virtual void update( GsdmlAttrNav *attrnav) {}
virtual void value_changed( GsdmlAttrNav *attrnav, char *value_str) {}
};
//! Item for a normal attribute.
class ItemPnBase : public ItemPn {
public:
ItemPnBase( GsdmlAttrNav *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);
void *value_p;
char old_value[80];
int first_scan;
int type_id;
int size;
double min_limit;
double max_limit;
int noedit;
int subgraph;
virtual int scan( GsdmlAttrNav *attrnav, void *p);
virtual void value_changed( GsdmlAttrNav *attrnav, char *value_str);
};
//! Item for an enum attribute.
class ItemPnEnumValue : public ItemPn {
public:
ItemPnEnumValue( GsdmlAttrNav *attrnav, const char *item_name, int item_num,
int item_type_id,
void *attr_value_p, brow_tNode dest, flow_eDest dest_code);
int num;
int type_id;
void *value_p;
int old_value;
int first_scan;
int scan( GsdmlAttrNav *attrnav, void *p);
};
//! Item for a device.
class ItemPnDevice : public ItemPn {
public:
ItemPnDevice( GsdmlAttrNav *attrnav, const char *item_name,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnDevice() {}
int old_value;
int first_scan;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
int scan( GsdmlAttrNav *attrnav, void *p);
};
//! Item for a slot.
class ItemPnSlot : public ItemPn {
public:
ItemPnSlot( GsdmlAttrNav *attrnav, const char *item_name, GsdmlSlotData *item_slotdata,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnSlot() {}
GsdmlSlotData *slotdata;
int old_value;
int first_scan;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
int scan( GsdmlAttrNav *attrnav, void *p);
};
//! Item for a subslot.
class ItemPnSubslot : public ItemPn {
public:
ItemPnSubslot( GsdmlAttrNav *attrnav, const char *item_name, GsdmlSubslotData *item_subslotdata,
gsdml_VirtualSubmoduleItem *item_virtualsubmodule,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnSubslot() {}
GsdmlSubslotData *subslotdata;
gsdml_VirtualSubmoduleItem *virtualsubmodule;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for the DeviceAccessPoint, slot 0
class ItemPnDAP : public ItemPn {
public:
ItemPnDAP( GsdmlAttrNav *attrnav, const char *item_name, GsdmlSlotData *item_slotdata,
brow_tNode dest, flow_eDest dest_code);
GsdmlSlotData *slotdata;
virtual ~ItemPnDAP() {}
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for Network settings
class ItemPnNetwork : public ItemPn {
public:
ItemPnNetwork( GsdmlAttrNav *attrnav, const char *item_name,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnNetwork() {}
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for Network settings
class ItemPnDeviceInfo : public ItemPn {
public:
ItemPnDeviceInfo( GsdmlAttrNav *attrnav, const char *item_name,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnDeviceInfo() {}
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for an InterfaceSubmoduleItem
class ItemPnInterfaceSubmodule : public ItemPn {
public:
ItemPnInterfaceSubmodule( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_InterfaceSubmoduleItem *item_ii,
GsdmlSubslotData *item_subslotdata,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnInterfaceSubmodule() {}
gsdml_InterfaceSubmoduleItem *ii;
GsdmlSubslotData *subslotdata;
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for a PortSubmoduleItem
class ItemPnPortSubmodule : public ItemPn {
public:
ItemPnPortSubmodule( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_PortSubmoduleItem *item_pi,
GsdmlSubslotData *item_subslotdata,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnPortSubmodule() {}
gsdml_PortSubmoduleItem *pi;
GsdmlSubslotData *subslotdata;
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for a moduleinfo.
class ItemPnModuleInfo : public ItemPn {
public:
ItemPnModuleInfo( GsdmlAttrNav *attrnav, const char *item_name, gsdml_ModuleInfo *item_info,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnModuleInfo() {}
gsdml_ModuleInfo *info;
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for module type selection.
class ItemPnModuleType : public ItemPn {
public:
ItemPnModuleType( GsdmlAttrNav *attrnav, const char *item_name, int item_slot_number,
int item_slot_idx, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnModuleType() {}
int slot_number;
int slot_idx;
int old_value;
int first_scan;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
int scan( GsdmlAttrNav *attrnav, void *p);
};
//! Item for module type selection.
class ItemPnParRecord : public ItemPn {
public:
ItemPnParRecord( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_ParameterRecordDataItem *item_par_record,
GsdmlDataRecord *item_datarecord, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnParRecord() {}
gsdml_ParameterRecordDataItem *par_record;
GsdmlDataRecord *datarecord;
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for module type selection.
class ItemPnParValue : public ItemPn {
public:
ItemPnParValue( GsdmlAttrNav *attrnav, const char *item_name, gsdml_Ref *item_value_ref,
gsdml_eValueDataType item_datatype, unsigned char *item_data,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnParValue() {}
gsdml_Ref *value_ref;
gsdml_eValueDataType datatype;
unsigned char *data;
unsigned int byte_offset;
unsigned int size;
int first_scan;
char old_value[80];
int noedit;
int scan( GsdmlAttrNav *attrnav, void *p);
void value_changed( GsdmlAttrNav *attrnav, char *value_str);
};
class ParEnumValue {
public:
ParEnumValue() {}
unsigned int value;
char text[160];
};
//! Item for module type selection.
class ItemPnParEnum : public ItemPn {
public:
ItemPnParEnum( GsdmlAttrNav *attrnav, const char *item_name, gsdml_Ref *item_value_ref,
gsdml_eValueDataType item_datatype, unsigned char *item_data,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnParEnum() {}
gsdml_Ref *value_ref;
gsdml_eValueDataType datatype;
unsigned char *data;
unsigned int byte_offset;
unsigned int bit_offset;
unsigned int bit_length;
vector<ParEnumValue> values;
unsigned int mask;
unsigned int old_value;
int first_scan;
int noedit;
virtual int open_children( GsdmlAttrNav *attrnav, double x, double y);
int scan( GsdmlAttrNav *attrnav, void *p);
};
//! Item for module type selection.
class ItemPnParEnumBit : public ItemPn {
public:
ItemPnParEnumBit( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_eValueDataType item_datatype,
unsigned char *item_data, unsigned int item_byte_offset,
unsigned int item_value, unsigned int item_mask,
int item_noedit, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnParEnumBit() {}
gsdml_Assign *assign;
gsdml_eValueDataType datatype;
unsigned char *data;
unsigned int byte_offset;
unsigned int value;
unsigned int mask;
int first_scan;
unsigned int old_value;
int noedit;
int scan( GsdmlAttrNav *attrnav, void *p);
void update( GsdmlAttrNav *attrnav);
};
//! Item for a IOData.
class ItemPnIOData : public ItemPn {
public:
ItemPnIOData( GsdmlAttrNav *attrnav, const char *item_name, gsdml_IOData *item_iodata,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnIOData() {}
gsdml_IOData *iodata;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for a Input.
class ItemPnInput : public ItemPn {
public:
ItemPnInput( GsdmlAttrNav *attrnav, const char *item_name, gsdml_Input *item_input,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnInput() {}
gsdml_Input *input;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for a Output.
class ItemPnOutput : public ItemPn {
public:
ItemPnOutput( GsdmlAttrNav *attrnav, const char *item_name, gsdml_Output *item_output,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnOutput() {}
gsdml_Output *output;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for a DataItem.
class ItemPnDataItem : public ItemPn {
public:
ItemPnDataItem( GsdmlAttrNav *attrnav, const char *item_name, gsdml_DataItem *item_dataitem,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnDataItem() {}
gsdml_DataItem *dataitem;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for a BitDataItem.
class ItemPnBitDataItem : public ItemPn {
public:
ItemPnBitDataItem( GsdmlAttrNav *attrnav, const char *item_name, gsdml_BitDataItem *item_bitdataitem,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnBitDataItem() {}
gsdml_BitDataItem *bitdataitem;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
};
//! Item for module class selection.
class ItemPnModuleClass : public ItemPn {
public:
ItemPnModuleClass( GsdmlAttrNav *attrnav, const char *item_name, GsdmlSlotData *item_slotdata,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnModuleClass() {}
GsdmlSlotData *slotdata;
int old_value;
int first_scan;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
int scan( GsdmlAttrNav *attrnav, void *p);
};
//! Item for slave byte order.
class ItemPnEnumByteOrder : public ItemPnBase {
public:
ItemPnEnumByteOrder( GsdmlAttrNav *attrnav, const char *item_name, const char *attr,
int attr_type, int attr_size, void *attr_value_p, int attr_noedit,
brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnEnumByteOrder() {}
int old_value;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
int scan( GsdmlAttrNav *attrnav, void *p);
};
//! Item for time ratio.
class ItemPnEnumTimeRatio : public ItemPn {
public:
ItemPnEnumTimeRatio( GsdmlAttrNav *attrnav, const char *item_name,
gsdml_InterfaceSubmoduleItem *item_interfacesubmodule,
void *attr_value_p, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemPnEnumTimeRatio() {}
gsdml_InterfaceSubmoduleItem *interfacesubmodule;
void *value_p;
int first_scan;
int old_value;
int open_children( GsdmlAttrNav *attrnav, double x, double y);
int scan( GsdmlAttrNav *attrnav, void *p);
};
/*@}*/
#if defined __cplusplus
}
#endif
#endif
/*
* Proview $Id$
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
/* rt_pn_gsdml_data.cpp -- Profinet configurator data file */
#include "glow_std.h"
#include <vector>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "co_dcli.h"
#include "co_xml_parser.h"
#include "rt_pb_msg.h"
#include "rt_pn_gsdml_data.h"
typedef enum {
gsdmldata_eTag_,
gsdmldata_eTag_PnDevice,
gsdmldata_eTag_NetworkSettings,
gsdmldata_eTag_Slot,
gsdmldata_eTag_Subslot,
gsdmldata_eTag_DataRecord,
gsdmldata_eTag_IOCR,
gsdmldata_eTag_ChannelDiag,
gsdmldata_eTag__
} gsdmldata_eTag;
GsdmlSlotData *GsdmlDeviceData::paste_slotdata = 0;
int GsdmlChannelDiag::print( ofstream& fp)
{
fp <<
" <ChannelDiag ErrorType=\"" << error_type << "\"" << endl <<
" Name=\"" << name << "\"" << endl <<
" Help=\"" << help << "\" />" << endl;
return 1;
}
int GsdmlDataRecord::print( ofstream& fp)
{
char str[1024];
co_xml_parser::data_to_ostring( data, data_length, str, sizeof(str));
fp <<
" <DataRecord Index=\"" << index << "\"" << endl <<
" TransferSequence=\"" << transfer_sequence << "\"" << endl <<
" DataLength=\"" << data_length << "\"" << endl <<
" Data=\"" << str << "\" />" << endl;
return 1;
}
int GsdmlSubslotData::print( ofstream& fp)
{
fp <<
" <Subslot SubslotNumber=\"" << subslot_number << "\" >" << endl;
for ( unsigned int i = 0; i < data_record.size(); i++) {
data_record[i]->print( fp);
}
fp <<
" </Subslot>" << endl;
return 1;
}
int GsdmlSlotData::print( ofstream& fp)
{
fp <<
" <Slot ModuleEnumNumber=\"" << module_enum_number << "\"" << endl <<
" ModuleClass=\"" << module_class << "\"" << endl <<
" ModuleText=\"" << module_text << "\"" << endl <<
" SlotNumber=\"" << slot_number << "\" >" << endl;
for ( unsigned int i = 0; i < subslot_data.size(); i++) {
subslot_data[i]->print( fp);
}
fp <<
" </Slot>" << endl;
return 1;
}
int GsdmlIOCRData::print( ofstream& fp)
{
fp <<
" <IOCR Type=\"" << type << "\"" << endl <<
" Properties=\"" << properties << "\"" << endl <<
" SendClockFactor=\"" << send_clock_factor << "\"" << endl <<
" ReductionRatio=\"" << reduction_ratio << "\"" << endl <<
" API=\"" << api << "\" />" << endl;
return 1;
}
int GsdmlDeviceData::print( const char *filename)
{
pwr_tFileName fname;
ofstream fp;
char *gsdmlfile_p;
// Print name of gsdmlfile, not path
if ( (gsdmlfile_p = strrchr(gsdmlfile, '/')))
gsdmlfile_p++;
else
gsdmlfile_p = gsdmlfile;
dcli_translate_filename( fname, filename);
fp.open( fname);
fp <<
"<PnDevice GsdmlFile=\"" << gsdmlfile_p << "\"" << endl <<
" DeviceNumber=\"" << device_num << "\"" << endl <<
" DeviceText=\"" << device_text << "\"" << endl <<
" VendorId=\"" << vendor_id << "\"" << endl <<
" DeviceId=\"" << device_id << "\"" << endl <<
" Version=\"" << version << "\"" << endl <<
" ByteOrder=\"" << byte_order << "\">" << endl <<
" <NetworkSettings " << endl <<
" DeviceName=\"" << device_name << "\"" << endl <<
" IP_Address=\"" << ip_address << "\"" << endl <<
" SubnetMask=\"" << subnet_mask << "\"" << endl <<
" MAC_Address=\"" << mac_address << "\" />" << endl;
for ( unsigned int i = 0; i < slot_data.size(); i++) {
slot_data[i]->print( fp);
}
for ( unsigned int i = 0; i < iocr_data.size(); i++) {
iocr_data[i]->print( fp);
}
for ( unsigned int i = 0; i < channel_diag.size(); i++) {
channel_diag[i]->print( fp);
}
fp <<
"</PnDevice>" << endl;
fp.close();
return PB__SUCCESS;
}
int GsdmlDeviceData::read( const char *filename)
{
int sts;
GsdmlDataReader *reader = new GsdmlDataReader( this);
co_xml_parser *xml_parser = new co_xml_parser( reader);
sts = xml_parser->read( filename);
delete xml_parser;
delete reader;
return sts;
}
int GsdmlDeviceData::copy_slot( unsigned int slot_idx)
{
if ( slot_idx >= slot_data.size())
return 0;
if ( paste_slotdata)
delete paste_slotdata;
paste_slotdata = new GsdmlSlotData( *slot_data[slot_idx]);
return PB__SUCCESS;
}
int GsdmlDeviceData::cut_slot( unsigned int slot_idx)
{
if ( slot_idx >= slot_data.size())
return 0;
unsigned int tmp_slot_idx;
unsigned int tmp_slot_number;
unsigned int prev_slot_idx = slot_data[slot_idx]->slot_idx;
unsigned int prev_slot_number = slot_data[slot_idx]->slot_number;
delete slot_data[slot_idx];
for ( unsigned int i = slot_idx; i < slot_data.size() - 1; i++) {
tmp_slot_idx = slot_data[i+1]->slot_idx;
tmp_slot_number = slot_data[i+1]->slot_number;
slot_data[i] = slot_data[i+1];
slot_data[i]->slot_idx = prev_slot_idx;
slot_data[i]->slot_number = prev_slot_number;
prev_slot_idx = tmp_slot_idx;
prev_slot_number = tmp_slot_number;
}
slot_data[slot_data.size()-1] = new GsdmlSlotData();
slot_data[slot_data.size()-1]->slot_idx = prev_slot_idx;
slot_data[slot_data.size()-1]->slot_number = prev_slot_number;
return PB__SUCCESS;
}
int GsdmlDeviceData::paste_slot( unsigned int slot_idx)
{
if ( slot_idx >= slot_data.size())
return 0;
if ( !paste_slotdata)
return 0;
unsigned int tmp_slot_idx;
unsigned int tmp_slot_number;
unsigned int prev_slot_idx = slot_data[slot_data.size()-1]->slot_idx;
unsigned int prev_slot_number = slot_data[slot_data.size()-1]->slot_number;
delete slot_data[slot_data.size()-1];
for ( unsigned int i = slot_data.size()-1; i > slot_idx; i--) {
tmp_slot_idx = slot_data[i-1]->slot_idx;
tmp_slot_number = slot_data[i-1]->slot_number;
slot_data[i] = slot_data[i-1];
slot_data[i]->slot_idx = prev_slot_idx;
slot_data[i]->slot_number = prev_slot_number;
prev_slot_idx = tmp_slot_idx;
prev_slot_number = tmp_slot_number;
}
slot_data[slot_idx] = new GsdmlSlotData(*paste_slotdata);
slot_data[slot_idx]->slot_idx = prev_slot_idx;
slot_data[slot_idx]->slot_number = prev_slot_number;
return PB__SUCCESS;
}
int GsdmlDataReader::tag_name_to_id( const char *name, unsigned int *id)
{
if ( strcmp( name, "PnDevice") == 0)
*id = gsdmldata_eTag_PnDevice;
else if ( strcmp( name, "NetworkSettings") == 0)
*id = gsdmldata_eTag_NetworkSettings;
else if ( strcmp( name, "Slot") == 0)
*id = gsdmldata_eTag_Slot;
else if ( strcmp( name, "Subslot") == 0)
*id = gsdmldata_eTag_Subslot;
else if ( strcmp( name, "DataRecord") == 0)
*id = gsdmldata_eTag_DataRecord;
else if ( strcmp( name, "IOCR") == 0)
*id = gsdmldata_eTag_IOCR;
else if ( strcmp( name, "ChannelDiag") == 0)
*id = gsdmldata_eTag_ChannelDiag;
else
return 0;
return 1;
}
int GsdmlDataReader::tag( const char *name)
{
if ( tag_name_to_id( name, &current_tag))
tag_stack_push( current_tag);
else {
printf( "XML-Parser: Unknown tag: %s\n", name);
return 0;
}
switch ( current_tag) {
case gsdmldata_eTag_Slot: {
GsdmlSlotData *sd = new GsdmlSlotData();
data->slot_data.push_back( sd);
object_stack_push( sd, current_tag);
break;
}
case gsdmldata_eTag_Subslot: {
GsdmlSlotData *sd = (GsdmlSlotData *) get_object_stack( gsdmldata_eTag_Slot);
if ( !sd) {
printf( "XML-Parser: Subslot outside slot");
break;
}
GsdmlSubslotData *ssd = new GsdmlSubslotData();
sd->subslot_data.push_back( ssd);
object_stack_push( ssd, current_tag);
break;
}
case gsdmldata_eTag_DataRecord: {
GsdmlSubslotData *ssd = (GsdmlSubslotData *) get_object_stack( gsdmldata_eTag_Subslot);
if ( !ssd) {
printf( "XML-Parser: RecordData outside subslot");
break;
}
GsdmlDataRecord *dr = new GsdmlDataRecord();
ssd->data_record.push_back( dr);
object_stack_push( dr, current_tag);
break;
}
case gsdmldata_eTag_IOCR: {
GsdmlIOCRData *iod = new GsdmlIOCRData();
data->iocr_data.push_back( iod);
object_stack_push( iod, current_tag);
break;
}
case gsdmldata_eTag_ChannelDiag: {
GsdmlChannelDiag *cd = new GsdmlChannelDiag();
data->channel_diag.push_back( cd);
object_stack_push( cd, current_tag);
break;
}
default: ;
}
return 1;
}
int GsdmlDataReader::metatag( const char *name)
{
return 1;
}
int GsdmlDataReader::tag_end( const char *name)
{
unsigned int id;
if ( tag_name_to_id( name, &id))
tag_stack_pull( id);
else {
printf( "XML-Parser: Tag/EndTag mismach: %s\n", name);
return 0;
}
switch( id) {
case gsdmldata_eTag_Slot:
object_stack_pull( id);
break;
case gsdmldata_eTag_Subslot:
object_stack_pull( id);
break;
case gsdmldata_eTag_DataRecord:
object_stack_pull( id);
break;
case gsdmldata_eTag_IOCR:
object_stack_pull( id);
break;
default: ;
}
return 1;
}
int GsdmlDataReader::metatag_end( const char *name)
{
return 1;
}
int GsdmlDataReader::tag_value( const char *name)
{
return 1;
}
int GsdmlDataReader::tag_attribute( const char *name, const char *value)
{
switch ( current_tag) {
case gsdmldata_eTag_PnDevice:
if ( strcmp( name, "GsdmlFile") == 0) {
// Check that the GSDML file is not changed
char *gsdmlfile_p;
// Print name of gsdmlfile, not path
if ( (gsdmlfile_p = strrchr(data->gsdmlfile, '/')))
gsdmlfile_p++;
else
gsdmlfile_p = data->gsdmlfile;
if ( strcmp( value, gsdmlfile_p) != 0)
return PB__GSDMLFILEMISMATCH;
}
else if ( strcmp( name, "DeviceText") == 0)
strncpy( data->device_text, value, sizeof(data->device_text));
else if ( strcmp( name, "DeviceNumber") == 0)
sscanf( value, "%d", &data->device_num);
else if ( strcmp( name, "VendorId") == 0)
sscanf( value, "%hu", &data->vendor_id);
else if ( strcmp( name, "DeviceId") == 0)
sscanf( value, "%hu", &data->device_id);
else if ( strcmp( name, "Version") == 0)
strncpy( data->version, value, sizeof(data->version));
else if ( strcmp( name, "ByteOrder") == 0)
sscanf( value, "%d", &data->byte_order);
break;
case gsdmldata_eTag_NetworkSettings:
if ( strcmp( name, "DeviceName") == 0)
strncpy( data->device_name, value, sizeof(data->device_name));
else if ( strcmp( name, "IP_Address") == 0)
strncpy( data->ip_address, value, sizeof(data->ip_address));
else if ( strcmp( name, "SubnetMask") == 0)
strncpy( data->subnet_mask, value, sizeof(data->subnet_mask));
else if ( strcmp( name, "MAC_Address") == 0)
strncpy( data->mac_address, value, sizeof(data->mac_address));
break;
case gsdmldata_eTag_Slot: {
GsdmlSlotData *sd = (GsdmlSlotData *) get_object_stack( current_tag);
if ( strcmp( name, "ModuleEnumNumber") == 0)
sscanf( value, "%d", &sd->module_enum_number);
else if ( strcmp( name, "ModuleClass") == 0)
sscanf( value, "%u", &sd->module_class);
else if ( strcmp( name, "ModuleText") == 0)
strncpy( sd->module_text, value, sizeof(sd->module_text));
else if ( strcmp( name, "SlotNumber") == 0)
sscanf( value, "%u", &sd->slot_number);
break;
}
case gsdmldata_eTag_Subslot: {
GsdmlSubslotData *sd = (GsdmlSubslotData *) get_object_stack( current_tag);
if ( strcmp( name, "SubslotNumber") == 0)
sscanf( value, "%u", &sd->subslot_number);
break;
}
case gsdmldata_eTag_DataRecord: {
GsdmlDataRecord *dr = (GsdmlDataRecord *) get_object_stack( current_tag);
if ( strcmp( name, "DataLength") == 0)
sscanf( value, "%u", &dr->data_length);
else if ( strcmp( name, "Index") == 0)
sscanf( value, "%hu", &dr->index);
else if ( strcmp( name, "TransferSequence") == 0)
sscanf( value, "%hu", &dr->transfer_sequence);
else if ( strcmp( name, "Data") == 0) {
int len;
co_xml_parser::ostring_to_data( &dr->data, value, dr->data_length, &len);
}
break;
}
case gsdmldata_eTag_IOCR: {
GsdmlIOCRData *iod = (GsdmlIOCRData *) get_object_stack( current_tag);
if ( strcmp( name, "Type") == 0)
sscanf( value, "%hu", &iod->type);
else if ( strcmp( name, "Properties") == 0)
sscanf( value, "%u", &iod->properties);
else if ( strcmp( name, "SendClockFactor") == 0)
sscanf( value, "%hu", &iod->send_clock_factor);
else if ( strcmp( name, "ReductionRatio") == 0)
sscanf( value, "%hu", &iod->reduction_ratio);
else if ( strcmp( name, "API") == 0)
sscanf( value, "%u", &iod->api);
break;
}
case gsdmldata_eTag_ChannelDiag: {
GsdmlChannelDiag *cd = (GsdmlChannelDiag *) get_object_stack( current_tag);
if ( strcmp( name, "ErrorType") == 0)
sscanf( value, "%hu", &cd->error_type);
else if ( strcmp( name, "Name") == 0)
strncpy( cd->name, value, sizeof(cd->name));
else if ( strcmp( name, "Help") == 0)
strncpy( cd->help, value, sizeof(cd->help));
break;
}
default: ;
}
return 1;
}
/*
* Proview $Id$
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#ifndef rt_pn_gsdml_data_h
#define rt_pn_gsdml_data_h
/* rt_pn_gsdml_data.h -- Profinet configurator data file. */
#include "co_xml_parser.h"
class GsdmlDataRecord {
public:
GsdmlDataRecord() : record_idx(0), data(0), data_length(0), index(0), transfer_sequence(0) {}
unsigned int record_idx;
unsigned char *data;
unsigned int data_length;
unsigned short index;
unsigned short transfer_sequence;
~GsdmlDataRecord() {
if ( data)
free( data);
}
GsdmlDataRecord( const GsdmlDataRecord& x) : record_idx(x.record_idx), data(x.data),
data_length(x.data_length), index(x.index), transfer_sequence(x.transfer_sequence) {
if ( data) {
data = (unsigned char *) malloc( data_length);
memcpy( data, x.data, data_length);
}
}
int print( ofstream& fp);
};
class GsdmlIOCRData {
public:
GsdmlIOCRData() : type(0), properties(0), send_clock_factor(0), api(0) {}
unsigned short type;
unsigned int properties;
unsigned short send_clock_factor;
unsigned short reduction_ratio;
unsigned int api;
int print( ofstream& fp);
};
class GsdmlSubslotData {
public:
GsdmlSubslotData() : subslot_number(0), subslot_idx(0) {}
vector<GsdmlDataRecord *> data_record;
unsigned int subslot_number;
unsigned int subslot_idx;
~GsdmlSubslotData() {
for ( unsigned int i = 0; i < data_record.size(); i++)
delete data_record[i];
}
GsdmlSubslotData( const GsdmlSubslotData& x) : subslot_number(x.subslot_number),
subslot_idx(x.subslot_idx) {
for ( unsigned int i = 0; i < x.data_record.size(); i++) {
data_record.push_back( new GsdmlDataRecord(*x.data_record[i]));
}
}
int print( ofstream& fp);
};
class GsdmlSlotData {
public:
GsdmlSlotData() : module_enum_number(0), module_class(0), module_oid(pwr_cNOid),
slot_number(0), slot_idx(0)
{ module_text[0]=0;}
unsigned int module_enum_number;
pwr_tCid module_class;
pwr_tOid module_oid;
char module_text[160];
unsigned int slot_number;
unsigned int slot_idx;
vector<GsdmlSubslotData *> subslot_data;
~GsdmlSlotData() {
for ( unsigned int i = 0; i < subslot_data.size(); i++)
delete subslot_data[i];
}
void slot_reset() {
for ( unsigned int i = 0; i < subslot_data.size(); i++)
delete subslot_data[i];
subslot_data.clear();
}
GsdmlSlotData( const GsdmlSlotData& x) : module_enum_number(x.module_enum_number),
module_class(x.module_class), module_oid(pwr_cNObjid), slot_number(x.slot_number),
slot_idx(x.slot_idx) {
for ( unsigned int i = 0; i < x.subslot_data.size(); i++) {
subslot_data.push_back( new GsdmlSubslotData(*x.subslot_data[i]));
}
}
int print( ofstream& fp);
};
class GsdmlChannelDiag {
public:
GsdmlChannelDiag() : error_type(0) {
strcpy( name, ""); strcpy( help, "");
}
unsigned short error_type;
char name[200];
char help[256];
int print( ofstream& fp);
};
class GsdmlDeviceData {
public:
GsdmlDeviceData()
{ device_name[0]=0; ip_address[0]=0; subnet_mask[0]=0; mac_address[0]=0;
device_text[0]=0; version[0]=0; gsdmlfile[0]=0;}
char device_name[80];
char ip_address[20];
char subnet_mask[20];
char mac_address[20];
int device_num;
char device_text[160];
unsigned short vendor_id;
unsigned short device_id;
char version[20];
int byte_order;
pwr_tFileName gsdmlfile;
vector<GsdmlSlotData *> slot_data;
vector<GsdmlIOCRData *> iocr_data;
static GsdmlSlotData *paste_slotdata;
vector<GsdmlChannelDiag *> channel_diag;
~GsdmlDeviceData() { device_reset();}
void device_reset() {
for ( unsigned int i = 0; i < slot_data.size(); i++)
delete slot_data[i];
slot_data.clear();
for ( unsigned int i = 0; i < iocr_data.size(); i++)
delete iocr_data[i];
iocr_data.clear();
}
void channel_diag_reset() {
for ( unsigned int i = 0; i < channel_diag.size(); i++)
delete channel_diag[i];
channel_diag.clear();
}
int print( const char *filename);
int read( const char *filename);
int copy_slot( unsigned int slot_idx);
int cut_slot( unsigned int slot_idx);
int paste_slot( unsigned int slot_idx);
};
class GsdmlDataReader : public co_xml_interpreter {
public:
GsdmlDataReader( GsdmlDeviceData *d) : data(d) {}
int tag( const char *name);
int metatag( const char *name);
int tag_end( const char *name);
int metatag_end( const char *name);
int tag_value( const char *value);
int tag_attribute( const char *name, const char *value);
int tag_name_to_id( const char *name, unsigned int *id);
unsigned int current_tag;
GsdmlDeviceData *data;
};
#endif
/*
* Proview $Id: wb_c_pb_dp_slave_gtk.cpp,v 1.1 2007-01-04 08:44:14 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
/* wb_c_pb_dp_slave_gtk.c -- work bench methods of the Pb_DP_Slave class. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <vector>
#include <map>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_profibusclasses.h"
#include <gtk/gtk.h>
#include "wb_env.h"
#include "flow.h"
#include "flow_ctx.h"
#include "flow_api.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "co_msg.h"
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_wow.h"
#include "co_xhelp_gtk.h"
#include "rt_pn_gsdml.h"
#include "rt_pn_gsdml_attr_gtk.h"
#include "wb_c_pndevice.h"
#include "wb_pwrs.h"
#include "wb_ldh_msg.h"
#include "wb_ldh.h"
#include "wb_pwrb_msg.h"
#include "rt_pb_msg.h"
#include "wb_wnav.h"
using namespace std;
char *id_to_string( pwr_tOid oid)
{
unsigned char vid[4];
static char str[40];
memcpy( &vid, &oid.vid, sizeof(vid));
sprintf( str, "%3.3u_%3.3u_%3.3u_%3.3u_%8.8x", vid[3], vid[2], vid[1], vid[0], oid.oix);
return str;
}
static pwr_tStatus Configure (
ldh_sMenuCall *ip
)
{
pwr_tStatus sts;
device_sCtx *ctx;
pwr_tFileName datafile;
sprintf( datafile, "$pwrp_load/pwr_pn_%s.xml", id_to_string( ip->Pointed.Objid));
sts = pndevice_create_ctx( ip->PointedSession, ip->Pointed, ip->wnav, &ctx);
if ( EVEN(sts)) return sts;
ctx->attr = new GsdmlAttrGtk( CoXHelpGtk::get_widget(), ctx, 0, ctx->gsdml,
ctx->edit_mode, datafile);
ctx->attr->close_cb = pndevice_close_cb;
ctx->attr->save_cb = pndevice_save_cb;
ctx->attr->help_cb = pndevice_help_cb;
if ( ODD(sts))
sts = pndevice_init( ctx);
if ( EVEN(sts)) {
ctx->attr->wow->DisplayError( "Configuration load error",
"Configuration load error\nCheck configuration data");
}
return 1;
}
static pwr_tStatus ConfigureFilter (
ldh_sMenuCall *ip
)
{
#if 0
char *gsd;
int size;
int sts;
sts = ldh_GetObjectPar( ip->PointedSession, ip->Pointed.Objid, "RtBody",
"GSDfile", &gsd, &size);
if ( EVEN(sts)) return sts;
if ( strcmp( gsd, "") == 0) {
free( gsd);
return 0;
}
free( gsd);
#endif
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindMethods(PnDevice) = {
pwr_BindMethod(Configure),
pwr_BindMethod(ConfigureFilter),
pwr_NullMethod
};
/*
* Proview $Id$
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
/* wb_c_pndevice.c -- work bench methods of the PnDevice class. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <vector>
#include <map>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_profibusclasses.h"
#include "wb_env.h"
#include "flow.h"
#include "flow_ctx.h"
#include "flow_api.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "co_msg.h"
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_wow.h"
#include "co_msgwindow.h"
#include "co_xhelp.h"
#include "rt_pn_gsdml.h"
#include "rt_pn_gsdml_attr.h"
#include "rt_pn_gsdml_attrnav.h"
#include "wb_c_pndevice.h"
#include "wb_pwrs.h"
#include "wb_ldh_msg.h"
#include "wb_ldh.h"
#include "wb_pwrb_msg.h"
#include "rt_pb_msg.h"
#include "wb_wnav.h"
using namespace std;
class ChanItem {
public:
ChanItem() : subslot_number(0), representation(0), number(0), use_as_bit(0), cid(0) {}
unsigned int subslot_number;
unsigned int representation;
unsigned int number;
unsigned int use_as_bit;
pwr_tCid cid;
char description[80];
};
static int pndevice_add_channels( device_sCtx *ctx, gsdml_VirtualSubmoduleItem *vi, int subslot_number,
vector<ChanItem>& input_vect, vector<ChanItem>& output_vect);
static int pndevice_check_io( device_sCtx *ctx, gsdml_VirtualSubmoduleList *vsl,
vector<ChanItem>& input_vect, vector<ChanItem>& output_vect);
/*----------------------------------------------------------------------------*\
Configure the slave from gsd file.
\*----------------------------------------------------------------------------*/
static void get_subcid( ldh_tSession ldhses, pwr_tCid cid, vector<pwr_tCid>& v)
{
pwr_tCid subcid;
pwr_tStatus sts;
for ( sts = ldh_GetSubClass( ldhses, cid, pwr_cNCid, &subcid);
ODD(sts);
sts = ldh_GetSubClass( ldhses, cid, subcid, &subcid)) {
v.push_back( subcid);
get_subcid( ldhses, subcid, v);
}
}
int pndevice_help_cb( void *sctx, const char *text)
{
pwr_tCmd cmd;
device_sCtx *ctx = (device_sCtx *)sctx;
strcpy( cmd, "help ");
strcat( cmd, text);
return ((WNav *)ctx->editor_ctx)->command( cmd);
}
void pndevice_close_cb( void *sctx)
{
device_sCtx *ctx = (device_sCtx *)sctx;
delete ctx->attr;
delete ctx->gsdml;
free( (char *)ctx);
}
int pndevice_save_cb( void *sctx)
{
device_sCtx *ctx = (device_sCtx *)sctx;
pwr_tStatus sts;
pwr_tOName name;
int size;
pwr_tOid oid;
// Syntax check
if ( ctx->attr->attrnav->device_num == 0) {
MsgWindow::message( 'E', "Device type not selected");
return PB__SYNTAX;
}
for ( unsigned int i = 1; i < ctx->attr->attrnav->dev_data.slot_data.size(); i++) {
if ( ctx->attr->attrnav->dev_data.slot_data[i]->module_enum_number == 0 &&
ctx->attr->attrnav->dev_data.slot_data[i]->module_class != 0) {
// Module class selected but not module type
char msg[20];
sprintf( msg, "Slot %d", i);
MsgWindow::message( 'E', "Module type not selected, ", msg);
}
if ( ctx->attr->attrnav->dev_data.slot_data[i]->module_class == 0 &&
ctx->attr->attrnav->dev_data.slot_data[i]->module_enum_number != 0) {
// Module type selected but not module class
char msg[20];
sprintf( msg, "Slot %d", i);
MsgWindow::message( 'E', "Module class not selected, ", msg);
}
}
// Save configuration
((WNav *)ctx->editor_ctx)->set_nodraw();
sts = ldh_ObjidToName(ctx->ldhses, ctx->aref.Objid,
ldh_eName_Hierarchy, name, sizeof(name), &size);
if ( EVEN(sts)) goto return_now;
// Do a temporary rename all module object to avoid name collisions
for ( sts = ldh_GetChild( ctx->ldhses, ctx->aref.Objid, &oid);
ODD(sts);
sts = ldh_GetNextSibling( ctx->ldhses, oid, &oid)) {
sts = ldh_ObjidToName( ctx->ldhses, oid, cdh_mName_object, name,
sizeof(name), &size);
if ( EVEN(sts)) goto return_now;
strcat( name, "__tmp");
sts = ldh_ChangeObjectName( ctx->ldhses, oid, name);
if ( EVEN(sts)) goto return_now;
}
for ( unsigned int i = 1; i < ctx->attr->attrnav->dev_data.slot_data.size(); i++) {
GsdmlSlotData *slot = ctx->attr->attrnav->dev_data.slot_data[i];
pwr_tCid cid;
pwr_tOid prev;
pwr_tObjName mname;
int found = 0;
sprintf( mname, "M%d", slot->slot_idx);
if ( cdh_ObjidIsNotNull( slot->module_oid)) {
// Find module object
sts = ldh_GetObjectClass( ctx->ldhses, slot->module_oid, &cid);
if ( ODD(sts)) {
if ( cid == slot->module_class) {
// Module object found and class is ok
found = 1;
// Check if name is changed
sts = ldh_ObjidToName( ctx->ldhses, slot->module_oid, cdh_mName_object, name,
sizeof(name), &size);
if ( EVEN(sts)) goto return_now;
if ( strcmp( name, mname) != 0) {
// Change name
sts = ldh_ChangeObjectName( ctx->ldhses, slot->module_oid, mname);
if ( EVEN(sts)) goto return_now;
}
// Check that sibling position is right
sts = ldh_GetPreviousSibling( ctx->ldhses, slot->module_oid, &prev);
if ( i == 0) {
// Should be first sibling
if ( ODD(sts)) {
// Move to first sibling
sts = ldh_MoveObject( ctx->ldhses, slot->module_oid, ctx->aref.Objid, ldh_eDest_IntoFirst);
}
}
else {
if ( (ODD(sts) &&
cdh_ObjidIsNotEqual( ctx->attr->attrnav->dev_data.slot_data[i-1]->module_oid, prev)) ||
EVEN(sts)) {
// Move to next to i-1
sts = ldh_MoveObject( ctx->ldhses, slot->module_oid,
ctx->attr->attrnav->dev_data.slot_data[i-1]->module_oid,
ldh_eDest_After);
}
}
}
else {
// New class, delete current object
sts = ldh_DeleteObjectTree( ctx->ldhses, slot->module_oid, 0);
}
}
}
if ( !found && slot->module_class != pwr_cNCid) {
// Create a new module object
if ( i == 1)
sts = ldh_CreateObject( ctx->ldhses, &slot->module_oid, mname, slot->module_class,
ctx->aref.Objid, ldh_eDest_IntoFirst);
else
sts = ldh_CreateObject( ctx->ldhses, &slot->module_oid, mname, slot->module_class,
ctx->attr->attrnav->dev_data.slot_data[i-1]->module_oid,
ldh_eDest_After);
if ( EVEN(sts)) {
printf( "Error creating module object, %d\n", sts);
sts = 0;
goto return_now;
}
}
}
// Remove modules that wasn't configured any more
pwr_tOid moid[100];
int mcnt;
int found;
mcnt = 0;
for ( sts = ldh_GetChild( ctx->ldhses, ctx->aref.Objid, &oid);
ODD(sts);
sts = ldh_GetNextSibling( ctx->ldhses, oid, &oid)) {
found = 0;
for ( unsigned int i = 0; i < ctx->attr->attrnav->dev_data.slot_data.size(); i++) {
if ( cdh_ObjidIsEqual( ctx->attr->attrnav->dev_data.slot_data[i]->module_oid, oid)) {
found = 1;
break;
}
}
if ( !found) {
moid[mcnt++] = oid;
if ( mcnt > (int) (sizeof(moid)/sizeof(moid[0])))
break;
}
}
for ( int i = 0; i < mcnt; i++)
sts = ldh_DeleteObjectTree( ctx->ldhses, moid[i], 0);
for ( unsigned int i = 0; i < ctx->attr->attrnav->dev_data.slot_data.size(); i++) {
GsdmlSlotData *slot = ctx->attr->attrnav->dev_data.slot_data[i];
if ( i == 0) {
vector<ChanItem> input_vect;
vector<ChanItem> output_vect;
sts = pndevice_check_io( ctx, ctx->attr->attrnav->device_item->VirtualSubmoduleList,
input_vect, output_vect);
if ( sts == PB__CREATECHAN) {
char msg[20];
sprintf( msg, "Slot %d", i);
MsgWindow::message( 'W', "Unexpected datatype, channel not created, ", msg);
}
}
else {
if ( slot->module_class == pwr_cClass_PnModule) {
vector<ChanItem> input_vect;
vector<ChanItem> output_vect;
gsdml_UseableModules *um = ctx->gsdml->ApplicationProcess->DeviceAccessPointList->
DeviceAccessPointItem[ctx->attr->attrnav->device_num-1]->UseableModules;
if ( !um)
continue;
gsdml_ModuleItem *mi = (gsdml_ModuleItem *)um->
ModuleItemRef[slot->module_enum_number-1]->Body.ModuleItemTarget.p;
sts = pndevice_check_io( ctx, mi->VirtualSubmoduleList, input_vect, output_vect);
if ( sts == PB__CREATECHAN) {
char msg[20];
sprintf( msg, "Slot %d", i);
MsgWindow::message( 'W', "Unexpected datatype, channel not created, ", msg);
}
// Create the channels
if ( EVEN(ldh_GetChild( ctx->ldhses, slot->module_oid, &oid))) {
unsigned int chan_cnt = 0;
for ( unsigned int j = 0; j < input_vect.size(); j++) {
char name[80];
sprintf( name, "Ch%02u", chan_cnt++);
sts = ldh_CreateObject( ctx->ldhses, &oid, name, input_vect[j].cid,
slot->module_oid, ldh_eDest_IntoLast);
if ( EVEN(sts)) goto return_now;
pwr_tAttrRef aaref;
pwr_tAttrRef chanaref = cdh_ObjidToAref( oid);
// Set Representation
pwr_tEnum representation = input_vect[j].representation;
sts = ldh_ArefANameToAref( ctx->ldhses, &chanaref, "Representation", &aaref);
if ( EVEN(sts)) goto return_now;
sts = ldh_WriteAttribute( ctx->ldhses, &aaref, &representation, sizeof(representation));
if ( EVEN(sts)) goto return_now;
// Set Number
pwr_tUInt16 number = input_vect[j].number;
sts = ldh_ArefANameToAref( ctx->ldhses, &chanaref, "Number", &aaref);
if ( EVEN(sts)) goto return_now;
sts = ldh_WriteAttribute( ctx->ldhses, &aaref, &number, sizeof(number));
if ( EVEN(sts)) goto return_now;
// Set Description
pwr_tString80 description;
strncpy( description, input_vect[j].description, sizeof(description));
sts = ldh_ArefANameToAref( ctx->ldhses, &chanaref, "Description", &aaref);
if ( EVEN(sts)) goto return_now;
sts = ldh_WriteAttribute( ctx->ldhses, &aaref, description, sizeof(description));
if ( EVEN(sts)) goto return_now;
}
for ( unsigned int j = 0; j < output_vect.size(); j++) {
char name[80];
sprintf( name, "Ch%02u", chan_cnt++);
sts = ldh_CreateObject( ctx->ldhses, &oid, name, output_vect[j].cid,
slot->module_oid, ldh_eDest_IntoLast);
if ( EVEN(sts)) goto return_now;
pwr_tAttrRef aaref;
pwr_tAttrRef chanaref = cdh_ObjidToAref( oid);
// Set Representation
pwr_tEnum representation = output_vect[j].representation;
sts = ldh_ArefANameToAref( ctx->ldhses, &chanaref, "Representation", &aaref);
if ( EVEN(sts)) goto return_now;
sts = ldh_WriteAttribute( ctx->ldhses, &aaref, &representation, sizeof(representation));
if ( EVEN(sts)) goto return_now;
// Set Number
pwr_tUInt16 number = output_vect[j].number;
sts = ldh_ArefANameToAref( ctx->ldhses, &chanaref, "Number", &aaref);
if ( EVEN(sts)) goto return_now;
sts = ldh_WriteAttribute( ctx->ldhses, &aaref, &number, sizeof(number));
if ( EVEN(sts)) goto return_now;
// Set Description
pwr_tString80 description;
strncpy( description, output_vect[j].description, sizeof(description));
sts = ldh_ArefANameToAref( ctx->ldhses, &chanaref, "Description", &aaref);
if ( EVEN(sts)) goto return_now;
sts = ldh_WriteAttribute( ctx->ldhses, &aaref, description, sizeof(description));
if ( EVEN(sts)) goto return_now;
}
}
}
else {
// Remove existing channels
vector<pwr_tOid> chanvect;
pwr_tCid cid;
for ( sts = ldh_GetChild( ctx->ldhses, slot->module_oid, &oid);
ODD(sts);
sts = ldh_GetNextSibling( ctx->ldhses, oid, &oid)) {
sts = ldh_GetObjectClass( ctx->ldhses, oid, &cid);
if ( EVEN(sts)) goto return_now;
switch ( cid) {
case pwr_cClass_ChanDi:
case pwr_cClass_ChanDo:
case pwr_cClass_ChanAi:
case pwr_cClass_ChanAo:
case pwr_cClass_ChanIi:
case pwr_cClass_ChanIo:
chanvect.push_back( oid);
break;
default: ;
}
}
for ( unsigned int i = 0; i < chanvect.size(); i++) {
sts = ldh_DeleteObject( ctx->ldhses, chanvect[i]);
if ( EVEN(sts)) goto return_now;
}
}
}
}
sts = PWRB__SUCCESS;
return_now:
((WNav *)ctx->editor_ctx)->reset_nodraw();
return sts;
}
static int pndevice_check_io( device_sCtx *ctx, gsdml_VirtualSubmoduleList *vsl,
vector<ChanItem>& input_vect, vector<ChanItem>& output_vect)
{
int sts;
if ( vsl) {
unsigned int subslot_number = 0;
for ( unsigned int i = 0; i < vsl->VirtualSubmoduleItem.size(); i++) {
if ( strcmp( vsl->VirtualSubmoduleItem[i]->Body.FixedInSubslots.str, "") == 0) {
// FixedInSubslots not supplied, default subslot number is 1
if ( vsl->VirtualSubmoduleItem.size() == 1)
subslot_number = 1;
else
subslot_number++;
sts = pndevice_add_channels( ctx, vsl->VirtualSubmoduleItem[i], subslot_number,
input_vect, output_vect);
if ( EVEN(sts)) return sts;
}
else {
// FixedInSubslots supplied, create channels for all fixed subslots
gsdml_Valuelist *vl = new gsdml_Valuelist( vsl->
VirtualSubmoduleItem[i]->Body.FixedInSubslots.str);
gsdml_ValuelistIterator iter( vl);
for ( unsigned int j = iter.begin(); j != iter.end(); j = iter.next()) {
subslot_number = j;
sts = pndevice_add_channels( ctx, vsl->VirtualSubmoduleItem[i], subslot_number,
input_vect, output_vect);
if (EVEN(sts)) {
delete vl;
return sts;
}
}
delete vl;
}
}
}
return PB__SUCCESS;
}
static int pndevice_add_channels( device_sCtx *ctx, gsdml_VirtualSubmoduleItem *vi, int subslot_number,
vector<ChanItem>& input_vect, vector<ChanItem>& output_vect)
{
// Find input data
if ( vi->IOData && vi->IOData->Input) {
for ( unsigned int i = 0;
i < vi->IOData->Input->DataItem.size();
i++) {
gsdml_DataItem *di = vi->IOData->Input->DataItem[i];
gsdml_eValueDataType datatype;
ctx->attr->attrnav->gsdml->string_to_value_datatype( di->Body.DataType, &datatype);
if ( !di->Body.UseAsBits) {
unsigned int representation;
int invalid_type = 0;
switch ( datatype) {
case gsdml_eValueDataType_Integer8:
representation = pwr_eDataRepEnum_Int8;
break;
case gsdml_eValueDataType_Unsigned8:
representation = pwr_eDataRepEnum_UInt8;
break;
case gsdml_eValueDataType_Integer16:
representation = pwr_eDataRepEnum_Int16;
break;
case gsdml_eValueDataType_Unsigned16:
representation = pwr_eDataRepEnum_UInt16;
break;
case gsdml_eValueDataType_Integer32:
representation = pwr_eDataRepEnum_Int32;
break;
case gsdml_eValueDataType_Unsigned32:
representation = pwr_eDataRepEnum_UInt32;
break;
case gsdml_eValueDataType_Integer64:
representation = pwr_eDataRepEnum_Int64;
break;
case gsdml_eValueDataType_Unsigned64:
representation = pwr_eDataRepEnum_UInt64;
break;
case gsdml_eValueDataType_Float32:
representation = pwr_eDataRepEnum_Float32;
break;
case gsdml_eValueDataType_Float64:
representation = pwr_eDataRepEnum_Float64;
break;
default:
invalid_type = 1;
}
if ( invalid_type)
return PB__CREATECHAN;
ChanItem ci;
ci.subslot_number = subslot_number;
ci.number = 0;
ci.representation = representation;
ci.use_as_bit = 0;
ci.cid = pwr_cClass_ChanAi;
strncpy( ci.description, (char *)di->Body.TextId.p, sizeof(ci.description));
ci.description[sizeof(ci.description)-1] = 0;
input_vect.push_back( ci);
}
else {
// Use as bits
unsigned int bits;
unsigned int representation;
switch ( datatype) {
case gsdml_eValueDataType_Integer8:
case gsdml_eValueDataType_Unsigned8:
representation = pwr_eDataRepEnum_Bit8;
bits = 8;
break;
case gsdml_eValueDataType_Integer16:
case gsdml_eValueDataType_Unsigned16:
representation = pwr_eDataRepEnum_Bit16;
bits = 16;
break;
case gsdml_eValueDataType_Integer32:
case gsdml_eValueDataType_Unsigned32:
representation = pwr_eDataRepEnum_Bit32;
bits = 32;
break;
case gsdml_eValueDataType_Integer64:
case gsdml_eValueDataType_Unsigned64:
representation = pwr_eDataRepEnum_Bit64;
bits = 64;
break;
default:
bits = 0;
}
if ( di->BitDataItem.size() == 0) {
// Add all bits
for ( unsigned int j = 0; j < bits; j++) {
// Add Channel
ChanItem ci;
ci.subslot_number = subslot_number;
ci.number = j;
ci.representation = representation;
ci.use_as_bit = 1;
ci.cid = pwr_cClass_ChanDi;
strncpy( ci.description, (char *)di->Body.TextId.p, sizeof(ci.description));
ci.description[sizeof(ci.description)-2] = 0;
input_vect.push_back( ci);
}
}
else {
for ( unsigned int j = 0; j < di->BitDataItem.size(); j++) {
// Add channel
ChanItem ci;
ci.subslot_number = subslot_number;
ci.number = di->BitDataItem[j]->Body.BitOffset;
ci.representation = representation;
ci.use_as_bit = 1;
ci.cid = pwr_cClass_ChanDi;
strncpy( ci.description, (char *)di->BitDataItem[j]->Body.TextId.p, sizeof(ci.description));
ci.description[sizeof(ci.description)-2] = 0;
input_vect.push_back( ci);
}
}
}
}
}
// Find output data
if ( vi->IOData && vi->IOData->Output) {
for ( unsigned int i = 0;
i < vi->IOData->Output->DataItem.size();
i++) {
gsdml_DataItem *di = vi->IOData->Output->DataItem[i];
gsdml_eValueDataType datatype;
ctx->attr->attrnav->gsdml->string_to_value_datatype( di->Body.DataType, &datatype);
if ( !di->Body.UseAsBits) {
unsigned int representation;
int invalid_type = 0;
switch ( datatype) {
case gsdml_eValueDataType_Integer8:
representation = pwr_eDataRepEnum_Int8;
break;
case gsdml_eValueDataType_Unsigned8:
representation = pwr_eDataRepEnum_UInt8;
break;
case gsdml_eValueDataType_Integer16:
representation = pwr_eDataRepEnum_Int16;
break;
case gsdml_eValueDataType_Unsigned16:
representation = pwr_eDataRepEnum_UInt16;
break;
case gsdml_eValueDataType_Integer32:
representation = pwr_eDataRepEnum_Int32;
break;
case gsdml_eValueDataType_Unsigned32:
representation = pwr_eDataRepEnum_UInt32;
break;
case gsdml_eValueDataType_Integer64:
representation = pwr_eDataRepEnum_Int64;
break;
case gsdml_eValueDataType_Unsigned64:
representation = pwr_eDataRepEnum_UInt64;
break;
case gsdml_eValueDataType_Float32:
representation = pwr_eDataRepEnum_Float32;
break;
case gsdml_eValueDataType_Float64:
representation = pwr_eDataRepEnum_Float64;
break;
default:
invalid_type = 1;
}
if ( invalid_type) {
printf("GSDML-Error, Invalid type, unable to create channel\n");
return 0;
}
ChanItem ci;
ci.subslot_number = subslot_number;
ci.number = 0;
ci.representation = representation;
ci.use_as_bit = 0;
ci.cid = pwr_cClass_ChanAo;
strncpy( ci.description, (char *)di->Body.TextId.p, sizeof(ci.description));
ci.description[sizeof(ci.description)-2] = 0;
output_vect.push_back( ci);
}
else {
// Use as bits
unsigned int bits;
unsigned int representation;
switch ( datatype) {
case gsdml_eValueDataType_Integer8:
case gsdml_eValueDataType_Unsigned8:
representation = pwr_eDataRepEnum_Bit8;
bits = 8;
break;
case gsdml_eValueDataType_Integer16:
case gsdml_eValueDataType_Unsigned16:
representation = pwr_eDataRepEnum_Bit16;
bits = 16;
break;
case gsdml_eValueDataType_Integer32:
case gsdml_eValueDataType_Unsigned32:
representation = pwr_eDataRepEnum_Bit32;
bits = 32;
break;
case gsdml_eValueDataType_Integer64:
case gsdml_eValueDataType_Unsigned64:
representation = pwr_eDataRepEnum_Bit64;
bits = 64;
break;
default:
bits = 0;
}
if ( di->BitDataItem.size() == 0) {
// Add all bits
for ( unsigned int j = 0; j < bits; j++) {
// Add Channel
ChanItem ci;
ci.subslot_number = subslot_number;
ci.number = j;
ci.representation = representation;
ci.use_as_bit = 1;
ci.cid = pwr_cClass_ChanDo;
strncpy( ci.description, (char *)di->Body.TextId.p, sizeof(ci.description));
ci.description[sizeof(ci.description)-2] = 0;
output_vect.push_back( ci);
}
}
else {
for ( unsigned int j = 0; j < di->BitDataItem.size(); j++) {
// Add channel
ChanItem ci;
ci.subslot_number = subslot_number;
ci.number = di->BitDataItem[j]->Body.BitOffset;
ci.representation = representation;
ci.use_as_bit = 1;
ci.cid = pwr_cClass_ChanDo;
strncpy( ci.description, (char *)di->BitDataItem[j]->Body.TextId.p, sizeof(ci.description));
ci.description[sizeof(ci.description)-2] = 0;
output_vect.push_back( ci);
}
}
}
}
}
return PB__SUCCESS;
}
pwr_tStatus pndevice_create_ctx( ldh_tSession ldhses, pwr_tAttrRef aref,
void *editor_ctx, device_sCtx **ctxp)
{
pwr_tOName name;
char *gsdmlfile;
int size;
int sts;
pwr_tFileName fname;
ldh_sSessInfo Info;
vector<pwr_tCid> mcv;
sts = ldh_GetSessionInfo( ldhses, &Info);
sts = ldh_ObjidToName( ldhses, aref.Objid,
ldh_eName_Hierarchy, name, sizeof(name), &size);
if ( EVEN(sts)) return sts;
sts = ldh_GetObjectPar( ldhses, aref.Objid, "RtBody",
"GSDMLfile", &gsdmlfile, &size);
if ( EVEN(sts)) return sts;
if ( strcmp( gsdmlfile, "") == 0) {
free( gsdmlfile);
return PB__GSDATTR;
}
device_sCtx *ctx = (device_sCtx *) calloc( 1, sizeof(device_sCtx));
ctx->ldhses = ldhses;
ctx->aref = aref;
ctx->editor_ctx = editor_ctx;
ctx->edit_mode = (ODD(sts) && Info.Access == ldh_eAccess_ReadWrite) &&
ldh_LocalObject( ldhses, aref.Objid);
get_subcid( ctx->ldhses, pwr_cClass_PnModule, mcv);
ctx->mc = (gsdml_sModuleClass *) calloc( mcv.size() + 2, sizeof(gsdml_sModuleClass));
ctx->mc[0].cid = pwr_cClass_PnModule;
sts = ldh_ObjidToName( ctx->ldhses, cdh_ClassIdToObjid(ctx->mc[0].cid), cdh_mName_object,
ctx->mc[0].name, sizeof(ctx->mc[0].name), &size);
if ( EVEN(sts)) return sts;
for ( int i = 1; i <= (int) mcv.size(); i++) {
ctx->mc[i].cid = mcv[i-1];
sts = ldh_ObjidToName( ctx->ldhses, cdh_ClassIdToObjid(ctx->mc[i].cid), cdh_mName_object,
ctx->mc[i].name, sizeof(ctx->mc[0].name), &size);
if ( EVEN(sts)) return sts;
}
if ( strchr( gsdmlfile, '/') == 0) {
strcpy( fname, "$pwrp_exe/");
strcat( fname, gsdmlfile);
}
else
strcpy( fname, gsdmlfile);
free( gsdmlfile);
ctx->gsdml = new pn_gsdml();
sts = ctx->gsdml->read( fname);
if ( EVEN(sts))
return sts;
ctx->gsdml->build();
ctx->gsdml->set_classes( ctx->mc);
*ctxp = ctx;
return 1;
}
pwr_tStatus pndevice_init( device_sCtx *ctx)
{
pwr_tObjName module_name;
pwr_tOid module_oid;
int corrupt = 0;
unsigned int idx;
pwr_tStatus sts;
int size;
// Identify module objects
for ( sts = ldh_GetChild( ctx->ldhses, ctx->aref.Objid, &module_oid);
ODD(sts);
sts = ldh_GetNextSibling( ctx->ldhses, module_oid, &module_oid)) {
sts = ldh_ObjidToName( ctx->ldhses, module_oid, cdh_mName_object, module_name,
sizeof(module_name), &size);
if ( EVEN(sts)) return sts;
if ( !(sscanf( module_name, "M%d", &idx) == 1)) {
corrupt = 1;
continue;
}
if ( idx >= ctx->attr->attrnav->dev_data.slot_data.size()) {
corrupt = 1;
continue;
}
ctx->attr->attrnav->dev_data.slot_data[idx]->module_oid = module_oid;
}
if ( corrupt) {
ctx->attr->wow->DisplayError( "Configuration corrupt",
"Configuration of module objects doesn't match device configuration");
}
return 1;
}
/*
* Proview $Id$
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#ifndef wb_c_pndevice_h
#define wb_c_pndevice_h
/* wb_c_pndevice.h -- Profinet gsdml configure method */
typedef struct {
pn_gsdml *gsdml;
GsdmlAttr *attr;
ldh_tSession ldhses;
pwr_tAttrRef aref;
gsdml_sModuleClass *mc;
void *editor_ctx;
int edit_mode;
} device_sCtx;
pwr_tStatus pndevice_create_ctx( ldh_tSession ldhses, pwr_tAttrRef aref,
void *editor_ctx, device_sCtx **ctxp);
pwr_tStatus pndevice_init( device_sCtx *ctx);
int pndevice_help_cb( void *sctx, const char *text);
void pndevice_close_cb( void *sctx);
int pndevice_save_cb( void *sctx);
#endif
Pb_DP_Slave Pb_DP_Slave
PnDevice
\ No newline at end of file
Volume Profibus $ClassVolume 0.0.250.7 Volume Profibus $ClassVolume 0.0.250.7
Body SysBody 05-SEP-2005 17:51:40.00 Body SysBody 05-SEP-2005 17:51:40.00
Attr NextOix = "_X109" Attr NextOix = "_X161"
Attr NextCix = "_X14" Attr NextCix = "_X18"
Attr NextTix[0] = "_X7" Attr NextTix[0] = "_X7"
EndBody EndBody
Object Type $TypeHier 55 16-JAN-2006 10:07:43.21 Object Type $TypeHier 55 16-JAN-2006 10:07:43.21
...@@ -1969,5 +1969,727 @@ Volume Profibus $ClassVolume 0.0.250.7 ...@@ -1969,5 +1969,727 @@ Volume Profibus $ClassVolume 0.0.250.7
EndObject EndObject
EndObject EndObject
EndObject EndObject
!/**
! @Author Ferdinand Hauck
! @Version 1.0
! @Group IO
! @Summary Configures a Hilscher CIF 50-PB (Profibus DP master board)
! Configuresa Hilscher CIF 50-PB (Profibus DP master board).
! Available on GNU/Linux. The object should be named Px, where x is
! the number of the device, e.g. P1. It should in theory be possible
! to run up to four Hilscher Profibus DP master boards in parallel per
! system.
! This class is based on the Softing Profiboard class by Claes Jurstrand.
!*/
Object Pb_Hilscher $ClassDef 14 09-DEC-2008 13:19:56.59
Body SysBody 09-DEC-2008 13:19:32.10
Attr Editor = 0
Attr Method = 1
Attr Flags = 4176
EndBody
Object RtBody $ObjBodyDef 1 09-DEC-2008 13:20:25.79
Body SysBody 09-DEC-2008 13:26:35.55
Attr StructName = "Pb_Hilscher"
Attr NextAix = "_X53"
EndBody
!/**
! Text description of the object (comment).
!*/
Object Description $Attribute 27 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Defines the Proview process that will handle I/O for the bus.
! 1 for the PLC process (default).
!*/
Object Process $Attribute 28 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "Process"
Attr TypeRef = "pwrb:Type-IoProcessMask"
EndBody
EndObject
!/**
! Defines which of the PLC threads that will handle I/O for the bus (if Process = 1).
!*/
Object ThreadObject $Attribute 29 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "ThreadObject"
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
!/**
! Indicates the current state of the bus in runtime. Updated by the I/O-handler.
! PB__NOTINIT : Bus is not initialized.
! PB__INITFAIL : Bus failed to be initialized.
! PB__DISABLED : Bus is disabled, no I/O-handling will be performed.
! PB__STOPPED : Bus is in stopped mode.
! PB__CLEARED : Bus is in cleared mode.
! PB__NORMAL : Bus is in operating mode (this should be the normal state when running).
!*/
Object Status $Attribute 30 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "Status"
Attr Flags = 3072
Attr TypeRef = "pwrs:Type-$Status"
EndBody
EndObject
!/**
! Flag that disables the initialization of the bus, if initialized turns off I/O-handling.
!*/
Object DisableBus $Attribute 31 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "DisableBus"
Attr Flags = 3072
Attr TypeRef = "pwrs:Type-$UInt8"
EndBody
EndObject
!/**
! Number of configured slaves in the bus. Updated by the I/O-handler.
!*/
Object NumberSlaves $Attribute 32 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "NumberSlaves"
Attr Flags = 3072
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
!/**
! Number of the bus. This value is independent for different agent
! classes, so if you mix boards from different vendors, the agent
! objects for the cards will share BusNumber in some cases.
! It should be possible to attach up to four Hilscher Profibus DP
! master boards to each system.
!*/
Object BusNumber $Attribute 33 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "BusNumber"
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
!/**
! Baud rate for the bus in Kbit/s. Possible values are 500, 1500, 3000, 6000, 12000.
! Note that the values for some of the following attributes are depending on the
! baud rate.
!*/
Object BaudRate $Attribute 37 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "BaudRate"
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
!/**
! Watchdog timer for write supervision in the master card. This watchdog is
! activated at the first write operation after initialization. If the timer later
! elapses without a write operation, the master card will reset itself, and the bus
! will stop, leaving all slaves to stall when their own stall time elapses.
! A value of 0 will disable the board's watchdog functionality altogether.
! Range 0..65535 ms
!*/
Object StallTime $Attribute 38 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "StallTime"
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
!/**
! Slot time, the maximum time a master station must wait for a transaction response.
! Range 37..16383 Bit Times.
! Recommended values for each baud rate:
! 500 kbit/s - 200
! 1500 kbit/s - 300
! 3000 kbit/s - 400
! 6000 kbit/s - 600
! 12000 kbit/s - 1000
!*/
Object Tsl $Attribute 39 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "Tsl"
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
!/**
! Minimum station delay time for responder, the period of time which may elapse before
! the responder can send the response frame. Range 11..1023 Bit Times.
! Recommended values for each baud rate:
! 500 kbit/s - 11
! 1500 kbit/s - 11
! 3000 kbit/s - 11
! 6000 kbit/s - 11
! 12000 kbit/s - 11
!*/
Object MinTsdr $Attribute 40 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "MinTsdr"
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
!/**
! Maximum station delay time for responder, the responder has to send the response frame
! before this time is elapsed. Range 37..2^16-1 Bit Times.
! Recommended values for each baud rate:
! 500 kbit/s - 100
! 1500 kbit/s - 150
! 3000 kbit/s - 250
! 6000 kbit/s - 450
! 12000 kbit/s - 800
!*/
Object MaxTsdr $Attribute 41 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "MaxTsdr"
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
!/**
! Quiet time, the period of time which a transmitting station must wait after the end of a frame
! before enabling its receiver. It is significant when using repeaters. Range 0..493 Bit Times.
! Recommended values for each baud rate:
! 500 kbit/s - 0
! 1500 kbit/s - 0
! 3000 kbit/s - 3
! 6000 kbit/s - 6
! 12000 kbit/s - 9
!*/
Object Tqui $Attribute 42 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "Tqui"
Attr TypeRef = "pwrs:Type-$UInt8"
EndBody
EndObject
!/**
! Setup time, the time between the occurrence of an interrupt request and the necessary request
! action is performed. Range 1..494-Tqui BitTimes.
! Recommended values for each baud rate:
! 500 kbit/s - 1
! 1500 kbit/s - 1
! 3000 kbit/s - 4
! 6000 kbit/s - 8
! 12000 kbit/s - 16
!*/
Object Tset $Attribute 43 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "Tset"
Attr TypeRef = "pwrs:Type-$UInt8"
EndBody
EndObject
!/**
! Target rotation time, the anticipated time for one token rotation on the bus, including
! allowances for high and low priority transactions and GAP maintenance.
! Range 256..2^24-1 Bit Times.
! The value is irrelevant in Profibus DP operations.
!*/
Object Ttr $Attribute 44 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "Ttr"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Gap update factor, defines the number of token rotations between GAP maintenance cycles.
! Range 1..100.
! Recommended values for each baud rate:
! 500 kbit/s - 1
! 1500 kbit/s - 10
! 3000 kbit/s - 10
! 6000 kbit/s - 10
! 12000 kbit/s - 10
!*/
Object G $Attribute 45 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "G"
Attr TypeRef = "pwrs:Type-$UInt8"
EndBody
EndObject
!/**
! Highest station address. Range 1..126.
!*/
Object Hsa $Attribute 46 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "Hsa"
Attr TypeRef = "pwrs:Type-$UInt8"
EndBody
EndObject
!/**
! Maximum retry limit, indicates how often FDL has to repeat the request frame when no response
! or acknowledge frame is receive from the recognized station within the slot time. Range 0..7.
! Recommended values for each baud rate:
! 500 kbit/s - 1
! 1500 kbit/s - 1
! 3000 kbit/s - 2
! 6000 kbit/s - 3
! 12000 kbit/s - 4
!*/
Object MaxRetryLimit $Attribute 47 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "MaxRetryLimit"
Attr TypeRef = "pwrs:Type-$UInt8"
EndBody
EndObject
!/**
! Bus parameter flag. Should not be changed from the default value.
!*/
Object BpFlag $Attribute 48 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "BpFlag"
Attr TypeRef = "pwrs:Type-$UInt8"
EndBody
EndObject
!/**
! Data exchange cycle time in 100 us. Should not be changed from the default value.
!*/
Object MinSlaveInterval $Attribute 49 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "MinSlaveInterval"
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
!/**
! Watchdog timer for Master to Master communication.
!*/
Object PollTimeout $Attribute 50 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "PollTimeout"
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
!/**
! Control interval for global control status reports of the DP master.
!*/
Object DataControlTime $Attribute 51 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "DataControlTime"
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
!/**
! Area for receiving diagnostic data from the master. Not implemented yet.
!*/
Object Diag $Attribute 52 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:19:32.10
Attr PgmName = "Diag"
Attr Flags = 3074
Attr Elements = 256
Attr TypeRef = "pwrs:Type-$UInt8"
EndBody
EndObject
EndObject
Object IoMethods $RtMethod 110 09-DEC-2008 13:19:32.10
Object IoAgentInit $Method 111 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:20:59.19
Attr MethodName = "Pb_Hilscher-IoAgentInit"
EndBody
EndObject
Object IoAgentClose $Method 112 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:21:12.28
Attr MethodName = "Pb_Hilscher-IoAgentClose"
EndBody
EndObject
Object IoAgentRead $Method 113 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:21:25.05
Attr MethodName = "Pb_Hilscher-IoAgentRead"
EndBody
EndObject
Object IoAgentWrite $Method 114 09-DEC-2008 13:19:32.10
Body SysBody 09-DEC-2008 13:21:42.78
Attr MethodName = "Pb_Hilscher-IoAgentWrite"
EndBody
EndObject
EndObject
Object Template Pb_Hilscher 2151383040 01-JAN-1970 01:00:00.00
Body RtBody 09-DEC-2008 13:24:06.12
Attr Process = 1
Attr BusNumber = 1
Attr BaudRate = 12000
Attr StallTime = 3000
Attr Tsl = 1000
Attr MinTsdr = 11
Attr MaxTsdr = 800
Attr Tqui = 9
Attr Tset = 16
Attr Ttr = 300000
Attr G = 10
Attr Hsa = 126
Attr MaxRetryLimit = 4
Attr MinSlaveInterval = 1
Attr PollTimeout = 1000
Attr DataControlTime = 100
EndBody
EndObject
EndObject
Object PnControllerSoftingPNAK $ClassDef 15 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr Editor = 0
Attr Method = 1
Attr Flags = 4176
EndBody
Object RtBody $ObjBodyDef 1 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr StructName = "Pb_Profiboard"
Attr NextAix = "_X57"
EndBody
Object Description $Attribute 53 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object Process $Attribute 54 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Process"
Attr TypeRef = "pwrb:Type-IoProcessMask"
EndBody
EndObject
Object ThreadObject $Attribute 55 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "ThreadObject"
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
Object Status $Attribute 56 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Status"
Attr Flags = 3072
Attr TypeRef = "pwrs:Type-$Status"
EndBody
EndObject
EndObject
Object IoMethods $RtMethod 116 21-APR-2009 13:41:08.17
Object IoAgentInit $Method 117 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnControllerSoftingPNAK-IoAgentInit"
EndBody
EndObject
Object IoAgentClose $Method 118 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnControllerSoftingPNAK-IoAgentClose"
EndBody
EndObject
Object IoAgentRead $Method 119 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnControllerSoftingPNAK-IoAgentRead"
EndBody
EndObject
Object IoAgentWrite $Method 120 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnControllerSoftingPNAK-IoAgentWrite"
EndBody
EndObject
Object IoAgentSwap $Method 121 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnControllerSoftingPNAK-IoAgentSwap"
EndBody
EndObject
EndObject
Object Template PnControllerSoftingPNAK 2151645184 01-JAN-1970 01:00:00.00
Body RtBody 01-JAN-1970 01:00:00.00
EndBody
EndObject
EndObject
Object PnDevice $ClassDef 16 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr Editor = 0
Attr Method = 1
Attr Flags = 8272
EndBody
Object RtBody $ObjBodyDef 1 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr StructName = "PnDevice"
Attr NextAix = "_X97"
EndBody
Object Description $Attribute 87 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object Specification $Attribute 88 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Specification"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object DataSheet $Attribute 89 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "DataSheet"
Attr TypeRef = "pwrs:Type-$URL"
EndBody
EndObject
Object GSDMLfile $Attribute 90 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "GSDMLfile"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object Status $Attribute 91 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Status"
Attr Flags = 3072
Attr TypeRef = "pwrs:Type-$Status"
EndBody
EndObject
Object Process $Attribute 92 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Process"
Attr TypeRef = "pwrb:Type-IoProcessMask"
EndBody
EndObject
Object ThreadObject $Attribute 93 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "ThreadObject"
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
Object ErrorCount $Attribute 94 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "ErrorCount"
Attr Flags = 3072
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
Object ErrorSoftLimit $Attribute 95 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "ErrorSoftLimit"
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
Object ErrorHardLimit $Attribute 96 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "ErrorHardLimit"
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
EndObject
Object ConfiguratorPosnn $Menu 122 21-APR-2009 13:41:08.17
Object Pointed $Menu 123 21-APR-2009 13:41:08.17
Object ConfigureDevice $MenuButton 124 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ConfigureDevice"
Attr MethodName = "PnDevice-Configure"
Attr FilterName = "PnDevice-ConfigureFilter"
EndBody
EndObject
EndObject
EndObject
Object ConfiguratorPoscn $Menu 125 21-APR-2009 13:41:08.17
Object Pointed $Menu 126 21-APR-2009 13:41:08.17
Object ConfigureDevice $MenuButton 127 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ConfigureDevice"
Attr MethodName = "PnDevice-Configure"
Attr FilterName = "PnDevice-ConfigureFilter"
EndBody
EndObject
EndObject
EndObject
Object ConfiguratorPosos $Menu 128 21-APR-2009 13:41:08.17
Object Pointed $Menu 129 21-APR-2009 13:41:08.17
Object ConfigureDevice $MenuButton 130 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ConfigureDevice"
Attr MethodName = "PnDevice-Configure"
Attr FilterName = "PnDevice-ConfigureFilter"
EndBody
EndObject
EndObject
EndObject
Object ConfiguratorPoson $Menu 131 21-APR-2009 13:41:08.17
Object Pointed $Menu 132 21-APR-2009 13:41:08.17
Object ConfigureDevice $MenuButton 133 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ConfigureDevice"
Attr MethodName = "PnDevice-Configure"
Attr FilterName = "PnDevice-ConfigureFilter"
EndBody
EndObject
Object ConnectThread $MenuButton 134 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "Connect PlcThread"
Attr MethodName = "$Objid-Connect"
Attr MethodArguments[0] = "ThreadObject"
Attr MethodArguments[1] = "PlcThread"
Attr FilterName = "$Objid-IsOkConnect"
Attr FilterArguments[0] = "ThreadObject"
Attr FilterArguments[1] = "PlcThread"
EndBody
EndObject
EndObject
EndObject
Object NavigatorPosnn $Menu 135 21-APR-2009 13:41:08.17
Object Pointed $Menu 136 21-APR-2009 13:41:08.17
Object ConfigureDevice $MenuButton 137 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ConfigureDevice"
Attr MethodName = "PnDevice-Configure"
Attr FilterName = "PnDevice-ConfigureFilter"
EndBody
EndObject
EndObject
EndObject
Object NavigatorPoscn $Menu 138 21-APR-2009 13:41:08.17
Object Pointed $Menu 139 21-APR-2009 13:41:08.17
Object ConfigureDevice $MenuButton 140 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ConfigureDevice"
Attr MethodName = "PnDevice-Configure"
Attr FilterName = "PnDevice-ConfigureFilter"
EndBody
EndObject
EndObject
EndObject
Object NavigatorPosos $Menu 141 21-APR-2009 13:41:08.17
Object Pointed $Menu 142 21-APR-2009 13:41:08.17
Object ConfigureDevice $MenuButton 143 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ConfigureDevice"
Attr MethodName = "PnDevice-Configure"
Attr FilterName = "PnDevice-ConfigureFilter"
EndBody
EndObject
EndObject
EndObject
Object NavigatorPoson $Menu 144 21-APR-2009 13:41:08.17
Object Pointed $Menu 145 21-APR-2009 13:41:08.17
Object ConfigureDevice $MenuButton 146 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ConfigureDevice"
Attr MethodName = "PnDevice-Configure"
Attr FilterName = "PnDevice-ConfigureFilter"
EndBody
EndObject
EndObject
EndObject
Object RtXtt $RtMenu 147 21-APR-2009 13:41:08.17
Object ShowConfiguration $MenuButton 148 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "ShowConfiguration"
Attr MethodName = "PnDevice-ShowConfiguration"
EndBody
EndObject
EndObject
Object IoMethods $RtMethod 149 21-APR-2009 13:41:08.17
Object IoRackInit $Method 150 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnDevice-IoRackInit"
EndBody
EndObject
Object IoRackClose $Method 151 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnDevice-IoRackClose"
EndBody
EndObject
Object IoRackRead $Method 152 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnDevice-IoRackRead"
EndBody
EndObject
Object IoRackWrite $Method 153 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnDevice-IoRackWrite"
EndBody
EndObject
EndObject
Object Template PnDevice 2151907328 01-JAN-1970 01:00:00.00
Body RtBody 01-JAN-1970 01:00:00.00
EndBody
EndObject
EndObject
Object PnModule $ClassDef 17 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr Editor = 0
Attr Method = 0
Attr Flags = 16464
EndBody
Object RtBody $ObjBodyDef 1 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr StructName = "PnModule"
Attr NextAix = "_X22"
EndBody
Object Description $Attribute 15 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object Specification $Attribute 16 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Specification"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object ModuleName $Attribute 17 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "ModuleName"
Attr TypeRef = "pwrs:Type-$String40"
EndBody
EndObject
Object Process $Attribute 18 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Process"
Attr TypeRef = "pwrb:Type-IoProcessMask"
EndBody
EndObject
Object ThreadObject $Attribute 19 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "ThreadObject"
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
Object Status $Attribute 20 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "Status"
Attr TypeRef = "pwrs:Type-$Status"
EndBody
EndObject
Object DataSheet $Attribute 21 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr PgmName = "DataSheet"
Attr TypeRef = "pwrs:Type-$URL"
EndBody
EndObject
EndObject
Object ConfiguratorPoson $Menu 154 21-APR-2009 13:41:08.17
Object Pointed $Menu 155 21-APR-2009 13:41:08.17
Object ConnectThread $MenuButton 156 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr ButtonName = "Connect PlcThread"
Attr MethodName = "$Objid-Connect"
Attr MethodArguments[0] = "ThreadObject"
Attr MethodArguments[1] = "PlcThread"
Attr FilterName = "$Objid-IsOkConnect"
Attr FilterArguments[0] = "ThreadObject"
Attr FilterArguments[1] = "PlcThread"
EndBody
EndObject
EndObject
EndObject
Object IoMethods $RtMethod 157 21-APR-2009 13:41:08.17
Object IoCardInit $Method 158 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnModule-IoCardInit"
EndBody
EndObject
Object IoCardClose $Method 159 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnModule-IoCardClose"
EndBody
EndObject
Object IoCardRead $Method 160 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnModule-IoCardRead"
EndBody
EndObject
Object IoCardWrite $Method 161 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr MethodName = "PnModule-IoCardWrite"
EndBody
EndObject
EndObject
Object Template PnModule 2152169472 01-JAN-1970 01:00:00.00
Body RtBody 01-JAN-1970 01:00:00.00
EndBody
EndObject
EndObject
EndObject EndObject
EndVolume EndVolume
/*
* Proview $Id$
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* co_xml_parser.cpp -- Parse xml file */
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include "co_dcli.h"
#include "co_dcli_msg.h"
#include "co_xml_parser.h"
typedef enum {
xml_eState_Init = 1 << 0,
xml_eState_Tag = 1 << 1,
xml_eState_MetaTag = 1 << 2,
xml_eState_TagNameFound = 1 << 3,
xml_eState_TagName = 1 << 4,
xml_eState_Attribute = 1 << 5,
xml_eState_AttributeName = 1 << 6,
xml_eState_AttributeNameFound = 1 << 7,
xml_eState_AttributeValue = 1 << 8,
xml_eState_AttributeValueFound = 1 << 9,
xml_eState_TagValue = 1 << 10,
xml_eState_TagValueFound = 1 << 11,
xml_eState_EndTag = 1 << 12
} xml_eState;
co_xml_parser::co_xml_parser( co_xml_interpreter *i) :
interpreter(i),logglevel(0), first_token(true),
state( xml_eState_Init), line_cnt(1),
char_cnt(0), in_comment(false), c(0), c_f(0), c_ff(0), c_sts(0), c_f_sts(0),
c_ff_sts((void *)1), current_tag_idx(0), current_attribute_name_idx(0),
current_attribute_value_idx(0), current_tag_value_idx(0)
{
interpreter->parser = this;
}
void *co_xml_parser::next_token()
{
char t;
void *sts;
if ( first_token) {
first_token = false;
c_sts = fp.get(c);
if ( !c_sts) return c_sts;
c_f_sts = fp.get(c_f);
if ( c_f_sts)
c_ff_sts = fp.get(c_ff);
}
else {
if ( c_ff_sts)
sts = fp.get(t);
c = c_f;
c_sts = c_f_sts;
c_f = c_ff;
c_f_sts = c_ff_sts;
if ( c_ff_sts)
c_ff_sts = sts;
if ( sts)
c_ff = t;
}
if ( c_sts) {
if ( c == '\n') {
line_cnt++;
char_cnt = 1;
}
else
char_cnt++;
}
return c_sts;
}
void co_xml_parser::error_message_line( const char *msg)
{
printf( "** XML-parser error, %s, line %d, %d\n", msg, line_cnt, char_cnt);
}
void co_xml_parser::error_message( const char *format, const char *value)
{
printf( "** XML-parser error, ");
printf( format, value);
printf( "\n");
}
bool co_xml_parser::is_space( const char c)
{
return c == ' ' || c == ' ' || c == '\n' || c == '\r';
}
int co_xml_parser::read( const char *filename)
{
int sts;
fp.open( filename);
if ( !fp)
return DCLI__NOFILE;
while ( next_token()) {
if ( in_comment) {
if ( c == '-' && c_f == '-' && c_ff == '>') {
// End of comment
in_comment = false;
next_token();
next_token();
continue;
}
else
continue;
}
//
// State MetaTag
//
if ( state & xml_eState_MetaTag) {
if ( !(state & xml_eState_TagNameFound)) {
if ( is_space(c))
continue;
else {
// Start of tag name
state |= xml_eState_TagName;
state |= xml_eState_TagNameFound;
current_tag_idx = 0;
current_tag[current_tag_idx++] = c;
}
}
else {
if ( state & xml_eState_TagName) {
if ( is_space(c)) {
// End of tag name
current_tag[current_tag_idx] = 0;
state &= ~xml_eState_TagName;
sts = interpreter->metatag( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
else if ( c == '?' && c_f == '>') {
// End of meta tag
next_token();
current_tag[current_tag_idx] = 0;
if ( state & xml_eState_AttributeName ||
state & xml_eState_AttributeValue)
error_message_line( "Syntax error");
state &= ~xml_eState_TagName;
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_MetaTag;
sts = interpreter->metatag( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
else {
// Next tag character
if ( current_tag_idx >= sizeof(current_tag) - 1)
error_message_line( "Buffer to small");
else
current_tag[current_tag_idx++] = c;
}
}
else {
if ( is_space(c) && !(state & xml_eState_AttributeValue))
continue;
else if ( c == '?' && c_f == '>') {
// End of meta tag
next_token();
if ( state & xml_eState_AttributeName ||
state & xml_eState_AttributeValue)
error_message_line( "Syntax error");
state &= ~xml_eState_AttributeNameFound;
state &= ~xml_eState_AttributeValueFound;
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_MetaTag;
sts = interpreter->metatag_end( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
else {
if ( !(state & xml_eState_AttributeNameFound)) {
// Start of attribute name
state |= xml_eState_Attribute;
state |= xml_eState_AttributeName;
state |= xml_eState_AttributeNameFound;
current_attribute_name_idx = 0;
current_attribute_name[current_attribute_name_idx++] = c;
}
else if ( state & xml_eState_AttributeName) {
if ( is_space(c)) {
// End of attribute name
current_attribute_name[current_attribute_name_idx] = 0;
state &= ~xml_eState_AttributeName;
}
else if ( c == '=') {
// End of attribute name
current_attribute_name[current_attribute_name_idx] = 0;
state &= ~xml_eState_AttributeName;
}
else {
// Next char of attribute name
if ( current_attribute_name_idx >= sizeof(current_attribute_name) - 1)
error_message_line( "Buffer to small");
else
current_attribute_name[current_attribute_name_idx++] = c;
}
}
else if ( state & xml_eState_AttributeNameFound) {
if ( !(state & xml_eState_AttributeValueFound)) {
if ( c == '\"') {
// Start of attribute value
state |= xml_eState_AttributeValue;
state |= xml_eState_AttributeValueFound;
current_attribute_value_idx = 0;
}
else
continue;
}
else if ( state & xml_eState_AttributeValue) {
if ( c == '\\' && c_f == '\"') {
// '"' sign in string
if ( current_attribute_value_idx >= sizeof(current_attribute_value) - 1)
error_message_line( "Buffer to small");
else
current_attribute_value[current_attribute_value_idx++] = c_f;
next_token();
}
else if ( c == '\"') {
// End of attribute value
current_attribute_value[current_attribute_value_idx] = 0;
state &= ~xml_eState_AttributeValue;
state &= ~xml_eState_Attribute;
state &= ~xml_eState_AttributeNameFound;
state &= ~xml_eState_AttributeValueFound;
sts = interpreter->tag_attribute( current_attribute_name, current_attribute_value);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
else {
// Next char in attribute value
if ( current_attribute_value_idx >= sizeof(current_attribute_value) - 1)
error_message_line( "Buffer to small");
else
current_attribute_value[current_attribute_value_idx++] = c;
}
}
}
}
}
}
}
//
// State Tag
//
else if ( state & xml_eState_Tag) {
if ( !(state & xml_eState_TagNameFound)) {
if ( is_space(c))
continue;
else {
// Start of tag name
state |= xml_eState_TagName;
state |= xml_eState_TagNameFound;
current_tag_idx = 0;
current_tag[current_tag_idx++] = c;
}
}
else {
if ( state & xml_eState_TagName) {
if ( is_space(c)) {
// End of tag name
current_tag[current_tag_idx] = 0;
state &= ~xml_eState_TagName;
sts = interpreter->tag( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
else if ( c == '/' && c_f == '>') {
// End of tag
next_token();
current_tag[current_tag_idx] = 0;
sts = interpreter->tag( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
sts = interpreter->tag_end( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
if ( state & xml_eState_AttributeName ||
state & xml_eState_AttributeValue)
error_message_line( "Syntax error");
state &= ~xml_eState_TagName;
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_Tag;
}
else if ( c == '>') {
// End of tag
current_tag[current_tag_idx] = 0;
if ( state & xml_eState_AttributeName ||
state & xml_eState_AttributeValue)
error_message_line( "Syntax error");
state &= ~xml_eState_TagName;
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_Tag;
state |= xml_eState_TagValue;
current_tag_value_idx = 0;
sts = interpreter->tag( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
else {
// Next tag character
if ( current_tag_idx >= sizeof(current_tag) - 1)
error_message_line( "Buffer to small");
else
current_tag[current_tag_idx++] = c;
}
}
else {
if ( is_space(c) && !(state & xml_eState_AttributeValue))
continue;
else if ( c == '/' && c_f == '>') {
// End of tag
next_token();
if ( state & xml_eState_AttributeName)
error_message_line( "Syntax error");
else if ( state & xml_eState_AttributeValue) {
// Next char in attribute value
if ( current_attribute_value_idx >= sizeof(current_attribute_value) - 1)
error_message_line( "Buffer to small");
else
current_attribute_value[current_attribute_value_idx++] = c;
continue;
}
sts = interpreter->tag_end( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
state &= ~xml_eState_AttributeNameFound;
state &= ~xml_eState_AttributeValueFound;
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_Tag;
suppress_msg = 0;
}
else if ( c == '>') {
// End of tag
if ( state & xml_eState_AttributeName)
error_message_line( "Syntax error");
else if ( state & xml_eState_AttributeValue) {
// Next char in attribute value
if ( current_attribute_value_idx >= sizeof(current_attribute_value) - 1) {
if ( !suppress_msg) {
error_message_line( "Buffer size to small, value cut off");
suppress_msg = 1;
}
}
else
current_attribute_value[current_attribute_value_idx++] = c;
continue;
}
state &= ~xml_eState_AttributeNameFound;
state &= ~xml_eState_AttributeValueFound;
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_Tag;
suppress_msg = 0;
}
else {
if ( !(state & xml_eState_AttributeNameFound)) {
// Start of attribute name
state |= xml_eState_Attribute;
state |= xml_eState_AttributeName;
state |= xml_eState_AttributeNameFound;
current_attribute_name_idx = 0;
current_attribute_name[current_attribute_name_idx++] = c;
}
else if ( state & xml_eState_AttributeName) {
if ( is_space(c)) {
// End of attribute name
current_attribute_name[current_attribute_name_idx] = 0;
state &= ~xml_eState_AttributeName;
}
else if ( c == '=') {
// End of attribute name
current_attribute_name[current_attribute_name_idx] = 0;
state &= ~xml_eState_AttributeName;
}
else {
// Next char of attribute name
if ( current_attribute_name_idx >= sizeof(current_attribute_name) - 1)
error_message_line( "Buffer size to small");
else
current_attribute_name[current_attribute_name_idx++] = c;
}
}
else if ( state & xml_eState_AttributeNameFound) {
if ( !(state & xml_eState_AttributeValueFound)) {
if ( c == '\"') {
// Start of attribute value
state |= xml_eState_AttributeValue;
state |= xml_eState_AttributeValueFound;
current_attribute_value_idx = 0;
}
else
continue;
}
else if ( state & xml_eState_AttributeValue) {
if ( c == '\\' && c_f == '\"') {
// '"' sign in string
if ( current_attribute_value_idx >= sizeof(current_attribute_value) - 1) {
if ( !suppress_msg) {
error_message_line( "Buffer size to small, value cut off");
suppress_msg = 1;
}
}
else
current_attribute_value[current_attribute_value_idx++] = c_f;
next_token();
}
else if ( c == '\"') {
// End of attribute value
current_attribute_value[current_attribute_value_idx] = 0;
state &= ~xml_eState_AttributeValue;
state &= ~xml_eState_Attribute;
state &= ~xml_eState_AttributeNameFound;
state &= ~xml_eState_AttributeValueFound;
suppress_msg = 0;
sts = interpreter->tag_attribute( current_attribute_name, current_attribute_value);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
else {
// Next char in attribute value
if ( current_attribute_value_idx >= sizeof(current_attribute_value) - 1) {
if ( !suppress_msg) {
error_message_line( "Buffer size to small, value cut off");
suppress_msg = 1;
}
}
else
current_attribute_value[current_attribute_value_idx++] = c;
}
}
}
}
}
}
}
//
// State TagValue
//
else if ( state & xml_eState_TagValue) {
if ( c == '<' && c_f == '!' && c_ff == '-' && !(state & xml_eState_AttributeValue)) {
in_comment = true;
next_token();
next_token();
}
else if ( c == '<' && c_f == '/') {
// Start of EndTag
next_token();
current_tag_value[current_tag_value_idx] = 0;
if ( state & xml_eState_TagValueFound) {
sts = interpreter->tag_value( current_tag_value);
if ( EVEN(sts)) {
fp.close();
return sts;
}
state &= ~xml_eState_TagValueFound;
}
state &= ~xml_eState_TagValue;
state |= xml_eState_EndTag;
current_tag_idx = 0;
}
else if ( c == '<' && !(state & xml_eState_TagValueFound)) {
// New tag, no value found
state &= ~xml_eState_TagValue;
state |= xml_eState_Tag;
current_tag_idx = 0;
}
else {
if ( !is_space(c))
state |= xml_eState_TagValueFound;
if ( current_tag_value_idx >= sizeof(current_tag_value) - 1)
error_message_line( "Buffer to small");
else
current_tag_value[current_tag_value_idx++] = c;
}
}
//
// State EndTag
//
else if ( state & xml_eState_EndTag) {
if ( !(state & xml_eState_TagNameFound)) {
if ( is_space(c))
continue;
else {
// Start of tag name
state |= xml_eState_TagName;
state |= xml_eState_TagNameFound;
current_tag_idx = 0;
current_tag[current_tag_idx++] = c;
}
}
else {
if ( state & xml_eState_TagName) {
if ( is_space(c)) {
// End of tag name
current_tag[current_tag_idx] = 0;
state &= ~xml_eState_TagName;
sts = interpreter->tag_end( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
else if ( c == '>') {
// End of tag
current_tag[current_tag_idx] = 0;
state &= ~xml_eState_TagName;
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_EndTag;
sts = interpreter->tag_end( current_tag);
if ( EVEN(sts)) {
fp.close();
return sts;
}
}
else {
// Next tag character
if ( current_tag_idx >= sizeof(current_tag) - 1)
error_message_line( "Buffer to small");
else
current_tag[current_tag_idx++] = c;
}
}
else {
if ( is_space(c))
continue;
else if ( c == '>') {
// End of tag
state &= ~xml_eState_TagNameFound;
state &= ~xml_eState_EndTag;
}
}
}
}
else if ( state & xml_eState_Init) {
if ( c == '<' && c_f == '?') {
state |= xml_eState_MetaTag;
current_tag_idx = 0;
next_token();
}
else if ( c == '<' && c_f == '!' && c_ff == '-') {
in_comment = true;
next_token();
next_token();
}
else if ( c == '<' && c_f == '/') {
state |= xml_eState_EndTag;
current_tag_idx = 0;
next_token();
}
else if ( c == '<') {
state |= xml_eState_Tag;
current_tag_idx = 0;
}
}
}
fp.close();
return DCLI__SUCCESS;
}
//
// Convert binary data to octet string
//
int co_xml_parser::data_to_ostring( unsigned char *data, int size, char *str, int strsize)
{
int len = 0;
for ( int i = 0; i < size; i++) {
if ( i == size - 1) {
if ( len + 5 >= strsize)
return 0;
len += sprintf( &str[i*5], "0x%02hhx", data[i]);
}
else {
if ( len + 4 >= strsize)
return 0;
len += sprintf( &str[i*5], "0x%02hhx,", data[i]);
}
}
return 1;
}
//
// Convert octet string to binary
//
int co_xml_parser::ostring_to_data( unsigned char **data, const char *str, int size, int *rsize)
{
char valstr[40];
int valcnt;
unsigned int val;
const char *s, *t;
int sts;
*data = (unsigned char *) calloc( 1, size);
t = str;
valcnt = 0;
for ( s = str;; s++) {
if ( valcnt > size) {
printf( "** Size error");
break;
}
if ( *s == ',' || *s == 0) {
strncpy( valstr, t, s - t);
valstr[s - t] = 0;
dcli_remove_blank( valstr, valstr);
if ( valstr[0] == '0' && valstr[1] == 'x')
sts = sscanf( &valstr[2], "%x", &val);
else
sts = sscanf( valstr, "%d", &val);
*(*data + valcnt++) = (unsigned char) val;
if ( sts != 1)
error_message( "Syntax error in octet string, %s", str);
t = s+1;
}
if ( *s == 0)
break;
}
if ( rsize)
*rsize = valcnt;
return 1;
}
int co_xml_interpreter::tag_stack_push( unsigned int id)
{
if ( tag_stack_cnt >= sizeof(tag_stack)/sizeof(tag_stack[0]) - 1) {
parser->error_message_line( "Tag stack overflow");
return 0;
}
tag_stack[tag_stack_cnt++] = id;
return 1;
}
int co_xml_interpreter::tag_stack_pull( unsigned int id)
{
if ( tag_stack_cnt < 1 || tag_stack[tag_stack_cnt - 1] != id) {
parser->error_message_line( "Tag stack missmatch");
return 0;
}
tag_stack_cnt--;
return 1;
}
int co_xml_interpreter::object_stack_push( void *o, unsigned int id)
{
if ( object_stack_cnt >= sizeof(object_stack)/sizeof(object_stack[0]) - 1) {
parser->error_message_line( "Object stack overflow");
return 0;
}
object_stack_id[object_stack_cnt] = id;
object_stack[object_stack_cnt++] = o;
return 1;
}
int co_xml_interpreter::object_stack_pull( unsigned int id)
{
if ( id != object_stack_id[object_stack_cnt-1] ||
object_stack_cnt == 0) {
parser->error_message_line( "Object stack pull mismatch");
return 0;
}
object_stack_cnt--;
return 1;
}
unsigned int co_xml_interpreter::get_tag_stack()
{
if ( tag_stack_cnt)
return tag_stack[tag_stack_cnt-1];
else
return 0;
}
unsigned int co_xml_interpreter::get_tag_stack( int p)
{
if ( p <= (int)tag_stack_cnt - 1)
return tag_stack[tag_stack_cnt- 1 - p];
else
return 0;
}
void *co_xml_interpreter::get_object_stack( unsigned int id)
{
if ( object_stack_cnt) {
if ( object_stack_id[object_stack_cnt-1] == id)
return object_stack[object_stack_cnt-1];
}
return 0;
}
void *co_xml_interpreter::get_object_stack( int p, unsigned int id)
{
if ( p <= (int)object_stack_cnt - 1) {
if ( object_stack_id[object_stack_cnt-1-p] == id)
return object_stack[object_stack_cnt- 1 - p];
}
return 0;
}
/*
* Proview $Id$
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef co_xml_parser_h
#define co_xml_parser_h
#include <iostream>
#include <fstream>
using namespace std;
class co_xml_parser;
class co_xml_interpreter {
public:
co_xml_interpreter() : tag_stack_cnt(0), object_stack_cnt(0) {}
virtual int tag( const char *name) { return 0;}
virtual int metatag( const char *name) { return 0;}
virtual int tag_end( const char *name) { return 0;}
virtual int metatag_end( const char *name) { return 0;}
virtual int tag_value( const char *value) { return 0;}
virtual int tag_attribute( const char *name, const char *value) { return 0;}
int tag_stack_push( unsigned int id);
int tag_stack_pull( unsigned int id);
int object_stack_push( void *o, unsigned int id);
int object_stack_pull( unsigned int id);
unsigned int get_tag_stack();
unsigned int get_tag_stack( int p);
void *get_object_stack( unsigned int id);
void *get_object_stack( int p, unsigned int id);
co_xml_parser *parser;
unsigned int tag_stack[100];
unsigned int tag_stack_cnt;
void *object_stack[100];
unsigned int object_stack_id[100];
unsigned int object_stack_cnt;
};
class co_xml_parser {
public:
co_xml_parser( co_xml_interpreter *i);
~co_xml_parser() {}
co_xml_interpreter *interpreter;
ifstream fp;
int logglevel;
bool first_token;
unsigned int state;
int line_cnt;
int char_cnt;
bool in_comment;
char c;
char c_f;
char c_ff;
void *c_sts;
void *c_f_sts;
void *c_ff_sts;
char current_tag[256];
char current_attribute_name[256];
char current_attribute_value[4096];
char current_tag_value[256];
unsigned int current_tag_idx;
unsigned int current_attribute_name_idx;
unsigned int current_attribute_value_idx;
unsigned int current_tag_value_idx;
int suppress_msg;
int read( const char *filename);
static int ostring_to_data( unsigned char **data, const char *str, int size, int *rsize);
static int data_to_ostring( unsigned char *data, int size, char *str, int strsize);
void *next_token();
bool is_space( const char c);
void error_message_line( const char *msg);
static void error_message( const char *format, const char *value);
};
#endif
...@@ -41,6 +41,12 @@ configerr <Configuration error> /error ...@@ -41,6 +41,12 @@ configerr <Configuration error> /error
masterlock <Slave is locked by other master> /error masterlock <Slave is locked by other master> /error
notready <Not ready> /warning notready <Not ready> /warning
gsdattr <Gsdfile attibute is empty> /error gsdattr <Gsdfile attibute is empty> /error
nyi <Not yet implemented> /error
syntax <Conversion syntax error> /error
gsdmlfile <Unable to open GSDML file> /error
nodevice <No device selected> /error
createchan <Unable to create channel> /error
gsdmlfilemismatch <Gsdmlfile doesn't match original filename> /error
.end .end
/*
* Proview $Id: rt_io_m_ssab_aiup.c,v 1.4 2007-04-30 12:08:08 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_ssab_pid.c -- io methods for ssab cards. */
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include "pwr.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "rt_errh.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_ssaboxclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
#include "qbus_io.h"
#include "rt_io_m_ssab_locals.h"
#include "rt_io_bfbeth.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
#define init_mask 0x0001
#define inc3p_mask 0x0002
#define pos3p_mask 0x0004
#define ao_mask 0x0008
#define dyn_bias_mask 0x0010
#define stall_freeze_mask 0x0020
#define stall_cont_mask 0x0040
#define setup_req_mask 0x1000 // bit 12
#define act_dat_mask 0x2000 // bit 13
#define setup_mask 0x4000 // bit 14
#define dyn_mask 0x8000 // bit 15
#define typ_mask 0xf001 // bit 12, 13, 14, 15 + bit 1
typedef struct
{
unsigned short csr1;
unsigned short csr2;
}register_def;
typedef struct
{
float SetVal;
float BiasD;
float ForcVal;
short int Force;
short int IntOff;
} card_dyn;
typedef struct
{
float inc3pGain;
float MinTim;
float MaxTim;
float MaxInteg;
float AVcoeff[2];
float BVcoeff[2];
float OVcoeff[2];
short int PidAlg;
short int Inverse;
float PidGain;
float IntTime;
float DerTime;
float DerGain;
float BiasGain;
float MinOut;
float MaxOut;
float EndHys;
float PVcoeff[2];
float ErrSta;
float ErrSto;
float pos3pGain;
float ProcFiltTime;
float BiasFiltTime;
float PosFiltTime;
}card_par;
typedef struct
{
float PosVal;
float Acc;
float ProcVal;
float OutVal;
float ControlDiff;
short int EndMax;
short int EndMin;
float Bias;
float ScanTime;
}card_stat;
typedef struct
{
float Max; /* Max ingenjrsvrde */
float Min; /* Min ingenjrsvrde */
float RawMax; /* Rvrde vid Max (+- 30000) */
float RawMin; /* Rvrde vid Min (+- 30000) */
}card_range;
typedef struct {
unsigned short int Istat[2];
card_dyn Dyn;
card_par Par;
card_stat Stat;
card_range AoRange;
card_range ProcRange;
card_range BiasRange;
card_range PosRange;
pwr_sClass_PidX *objP;
unsigned int Address;
int Qbus_fp;
unsigned short dyn_ind;
unsigned short par_ind;
unsigned short stat_ind;
unsigned short ran_ind;
unsigned short init;
pwr_tTime ErrTime;
unsigned short Valid;
} io_sLocal;
void swap_word(unsigned int *out, unsigned int *in)
{
unsigned int result = 0;;
result = (*in << 16) & 0xFFFF0000;
result |= (*in >> 16) & 0x0000FFFF;
*out = result;
}
static int ssabpid_read(unsigned short index,
unsigned short *data,
io_sLocal *local) {
qbus_io_read rb;
qbus_io_write wb;
int sts;
wb.Address = local->Address;
wb.Data = index;
sts = write( local->Qbus_fp, &wb, sizeof(wb));
if (sts != -1) {
rb.Address = local->Address + 2;
sts = read( local->Qbus_fp, &rb, sizeof(rb));
*data = (unsigned short) rb.Data;
}
return sts;
}
static int ssabpid_write(unsigned short index,
unsigned short *data,
io_sLocal *local) {
qbus_io_write wb;
int sts;
wb.Address = local->Address;
wb.Data = index;
sts = write( local->Qbus_fp, &wb, sizeof(wb));
if (sts != -1) {
wb.Address = local->Address + 2;
wb.Data = *data;
sts = write( local->Qbus_fp, &wb, sizeof(wb));
}
return sts;
}
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_sClass_Ssab_PIDuP *op;
io_sLocal *local;
pwr_tStatus sts;
op = (pwr_sClass_Ssab_PIDuP *) cp->op;
local = calloc( 1, sizeof(*local));
cp->Local = local;
local->Address = op->RegAddress;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
errh_Info( "Init of pid card '%s'", cp->Name);
sts = gdh_ObjidToPointer(op->PidXCon, (void *) &local->objP);
if ( EVEN(sts)) {
errh_Error( "PID-card not properly connected, %s", cp->Name);
return IO__ERRDEVICE;
}
/* Calculate indexes in I/O-area */
local->dyn_ind = ((char *) &local->Dyn - (char *) local) / 2;
local->par_ind = ((char *) &local->Par - (char *) local) / 2;
local->stat_ind = ((char *) &local->Stat - (char *) local) / 2;
local->ran_ind = ((char *) &local->AoRange - (char *) local) / 2;
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
errh_Info( "IO closing pid card '%s'", cp->Name);
local = (io_sLocal *) cp->Local;
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_sClass_Ssab_PIDuP *op;
int sts, ii;
card_stat c_stat;
unsigned short *datap;
unsigned short diff;
pwr_tTime now;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ssab_PIDuP *) cp->op;
sts = ssabpid_read(0, &local->Istat[0], local);
if (sts != -1) {
sts = ssabpid_read(1, &local->Istat[1], local);
}
if (sts == -1) {
op->ErrorCount++;
local->Valid = 0;
} else local->Valid = 1;
diff = local->Istat[0] ^ local->Istat[1];
memset(&c_stat, 0, sizeof(c_stat));
if (local->Valid && (diff & act_dat_mask)) {
for (ii = local->stat_ind, datap = (unsigned short *) &c_stat; ii < local->ran_ind; ii++, datap++) {
sts = ssabpid_read(ii, datap, local);
if ( sts == -1) {
/* Increase error count and check error limits */
clock_gettime(CLOCK_REALTIME, &now);
if (op->ErrorCount > op->ErrorSoftLimit) {
/* Ignore if some time has expired */
if (now.tv_sec - local->ErrTime.tv_sec < 600)
op->ErrorCount++;
}
else
op->ErrorCount++;
local->ErrTime = now;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
continue;
}
}
/* Move data to PidX-object */
swap_word((unsigned int *) &local->objP->ProcVal, (unsigned int *) &c_stat.ProcVal);
swap_word((unsigned int *) &local->objP->PosVal, (unsigned int *) &c_stat.PosVal);
swap_word((unsigned int *) &local->objP->OutVal, (unsigned int *) &c_stat.OutVal);
swap_word((unsigned int *) &local->objP->ControlDiff, (unsigned int *) &c_stat.ControlDiff);
if (local->objP->BiasGain != 0) swap_word((unsigned int *) &local->objP->Bias, (unsigned int *) &c_stat.Bias);
local->objP->EndMin = c_stat.EndMin;
local->objP->EndMax = c_stat.EndMax;
// local->objP->ScanTime = c_stat.ScanTime;
local->Istat[0] ^= act_dat_mask;
}
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_sClass_Ssab_PIDuP *op;
int ii;
int sts;
pwr_tTime now;
unsigned short diff;
card_dyn c_dyn;
card_par c_par;
int paramc = 0;
int dynparc = 0;
unsigned short *datap;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ssab_PIDuP *) cp->op;
if (!local->Valid) return 1;
diff = local->Istat[0] ^ local->Istat[1];
if (diff & setup_req_mask) paramc = 1, dynparc = 1;
/* Check if static parameters has changed */
if ((local->objP->PidAlg != local->Par.PidAlg) ||
(local->objP->Inverse != local->Par.Inverse) ||
(local->objP->PidGain != local->Par.PidGain) ||
(local->objP->IntTime != local->Par.IntTime) ||
(local->objP->DerTime != local->Par.DerTime) ||
(local->objP->DerGain != local->Par.DerGain) ||
(local->objP->BiasGain != local->Par.BiasGain) ||
(local->objP->MinOut != local->Par.MinOut) ||
(local->objP->MaxOut != local->Par.MaxOut) ||
(local->objP->EndHys != local->Par.EndHys) ||
(local->objP->ProcFiltTime != local->Par.ProcFiltTime) ||
(local->objP->ProcMax != local->ProcRange.Max) ||
(local->objP->ProcMin != local->ProcRange.Min) ||
(local->objP->AoMax != local->AoRange.Max) ||
(local->objP->AoMin != local->AoRange.Min) ||
(local->Par.inc3pGain != local->objP->Inc3pGain) ||
(local->Par.MinTim != local->objP->MinTim) ||
(local->Par.MaxTim != local->objP->MaxTim) ||
(local->Par.MaxInteg != local->objP->MaxInteg)) paramc = 1;
/* Check if dynamic parameters has changed */
if ((local->objP->SetVal != local->Dyn.SetVal) ||
(local->objP->Bias != local->Dyn.BiasD) ||
(local->objP->ForcVal != local->Dyn.ForcVal) ||
(local->objP->IntOff != local->Dyn.IntOff) ||
(local->objP->Force != local->Dyn.Force)) dynparc = 1;
/* Move parameters to local */
if (paramc && ((diff & setup_mask) == 0)) {
local->Par.inc3pGain = local->objP->Inc3pGain;
local->Par.MinTim = local->objP->MinTim;
local->Par.MaxTim = local->objP->MaxTim;
local->Par.MaxInteg = local->objP->MaxInteg;
local->ProcRange.Max = local->objP->ProcMax;
local->ProcRange.Min = local->objP->ProcMin;
local->ProcRange.RawMax = local->objP->ProcRawMax;
local->ProcRange.RawMin = local->objP->ProcRawMin;
if (local->ProcRange.RawMax != local->ProcRange.RawMin) {
local->Par.AVcoeff[0] = (local->ProcRange.Max - local->ProcRange.Min) /
(local->ProcRange.RawMax - local->ProcRange.RawMin);
local->Par.AVcoeff[1] = local->ProcRange.Min -
local->ProcRange.RawMin * local->Par.AVcoeff[0];
}
local->BiasRange.Max = local->objP->BiasMax;
local->BiasRange.Min = local->objP->BiasMin;
local->BiasRange.RawMax = local->objP->BiasRawMax;
local->BiasRange.RawMin = local->objP->BiasRawMin;
if (local->BiasRange.RawMax != local->BiasRange.RawMin) {
local->Par.BVcoeff[0] = (local->BiasRange.Max - local->BiasRange.Min) /
(local->BiasRange.RawMax - local->BiasRange.RawMin);
local->Par.BVcoeff[1] = local->BiasRange.Min -
local->BiasRange.RawMin * local->Par.BVcoeff[0];
}
local->AoRange.Max = local->objP->AoMax;
local->AoRange.Min = local->objP->AoMin;
local->AoRange.RawMax = local->objP->AoRawMax;
local->AoRange.RawMin = local->objP->AoRawMin;
if (local->AoRange.Max != local->AoRange.Min)
{
local->Par.OVcoeff[0] = (local->AoRange.RawMax - local->AoRange.RawMin) /
(local->AoRange.Max - local->AoRange.Min);
local->Par.OVcoeff[1] = local->AoRange.RawMin -
local->AoRange.Min * local->Par.OVcoeff[0];
}
local->PosRange.Max = local->objP->PosMax;
local->PosRange.Min = local->objP->PosMin;
local->PosRange.RawMax = local->objP->PosRawMax;
local->PosRange.RawMin = local->objP->PosRawMin;
if (local->PosRange.RawMax != local->PosRange.RawMin) {
local->Par.PVcoeff[0] = (local->PosRange.Max - local->PosRange.Min) /
(local->PosRange.RawMax - local->PosRange.RawMin);
local->Par.PVcoeff[1] = local->PosRange.Min -
local->PosRange.RawMin * local->Par.PVcoeff[0];
}
local->Par.PidAlg = local->objP->PidAlg;
local->Par.Inverse = local->objP->Inverse;
local->Par.PidGain = local->objP->PidGain;
local->Par.IntTime = local->objP->IntTime;
local->Par.DerTime = local->objP->DerTime;
local->Par.DerGain = local->objP->DerGain;
local->Par.BiasGain = local->objP->BiasGain;
local->Par.MinOut = local->objP->MinOut;
local->Par.MaxOut = local->objP->MaxOut;
local->Par.EndHys = local->objP->EndHys;
local->Par.ErrSta = local->objP->ErrSta;
local->Par.ErrSto = local->objP->ErrSto;
local->Par.pos3pGain = local->objP->Pos3pGain;
local->Par.ProcFiltTime = local->objP->ProcFiltTime;
local->Par.BiasFiltTime = local->objP->BiasFiltTime;
local->Par.PosFiltTime = local->objP->PosFiltTime;
/* Write parameters to card */
c_par.PidAlg = local->Par.PidAlg;
c_par.Inverse = local->Par.Inverse;
swap_word((unsigned int *) &c_par.inc3pGain, (unsigned int *) &local->Par.inc3pGain);
swap_word((unsigned int *) &c_par.MinTim, (unsigned int *) &local->Par.MinTim);
swap_word((unsigned int *) &c_par.MaxTim, (unsigned int *) &local->Par.MaxTim);
swap_word((unsigned int *) &c_par.MaxInteg, (unsigned int *) &local->Par.MaxInteg);
swap_word((unsigned int *) &c_par.AVcoeff[0], (unsigned int *) &local->Par.AVcoeff[0]);
swap_word((unsigned int *) &c_par.AVcoeff[1], (unsigned int *) &local->Par.AVcoeff[1]);
swap_word((unsigned int *) &c_par.BVcoeff[0], (unsigned int *) &local->Par.BVcoeff[0]);
swap_word((unsigned int *) &c_par.BVcoeff[1], (unsigned int *) &local->Par.BVcoeff[1]);
swap_word((unsigned int *) &c_par.OVcoeff[0], (unsigned int *) &local->Par.OVcoeff[0]);
swap_word((unsigned int *) &c_par.OVcoeff[1], (unsigned int *) &local->Par.OVcoeff[1]);
swap_word((unsigned int *) &c_par.PidGain, (unsigned int *) &local->Par.PidGain);
swap_word((unsigned int *) &c_par.IntTime, (unsigned int *) &local->Par.IntTime);
swap_word((unsigned int *) &c_par.DerTime, (unsigned int *) &local->Par.DerTime);
swap_word((unsigned int *) &c_par.DerGain, (unsigned int *) &local->Par.DerGain);
swap_word((unsigned int *) &c_par.BiasGain, (unsigned int *) &local->Par.BiasGain);
swap_word((unsigned int *) &c_par.MinOut, (unsigned int *) &local->Par.MinOut);
swap_word((unsigned int *) &c_par.MaxOut, (unsigned int *) &local->Par.MaxOut);
swap_word((unsigned int *) &c_par.EndHys, (unsigned int *) &local->Par.EndHys);
swap_word((unsigned int *) &c_par.PVcoeff[0], (unsigned int *) &local->Par.PVcoeff[0]);
swap_word((unsigned int *) &c_par.PVcoeff[1], (unsigned int *) &local->Par.PVcoeff[1]);
swap_word((unsigned int *) &c_par.ErrSta, (unsigned int *) &local->Par.ErrSta);
swap_word((unsigned int *) &c_par.ErrSto, (unsigned int *) &local->Par.ErrSto);
swap_word((unsigned int *) &c_par.pos3pGain, (unsigned int *) &local->Par.pos3pGain);
swap_word((unsigned int *) &c_par.ProcFiltTime, (unsigned int *) &local->Par.ProcFiltTime);
swap_word((unsigned int *) &c_par.BiasFiltTime, (unsigned int *) &local->Par.BiasFiltTime);
swap_word((unsigned int *) &c_par.PosFiltTime, (unsigned int *) &local->Par.PosFiltTime);
for (ii = local->par_ind, datap = (unsigned short *)&c_par; ii < local->stat_ind; ii++, datap++) {
sts = ssabpid_write(ii, datap, local);
if ( sts == -1) {
/* Increase error count and check error limits */
clock_gettime(CLOCK_REALTIME, &now);
if (op->ErrorCount > op->ErrorSoftLimit) {
/* Ignore if some time has expired */
if (now.tv_sec - local->ErrTime.tv_sec < 600)
op->ErrorCount++;
}
else
op->ErrorCount++;
local->ErrTime = now;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
continue;
}
}
/* Update status word */
if ((diff & setup_req_mask) != 0) local->Istat[0] ^= setup_req_mask;
local->Istat[0] ^= setup_mask;
} /* End - if new parameters */
/* Send dynamic parameters ? */
if (dynparc && ((diff & dyn_mask) == 0)) {
/* Move parameters to local */
local->Dyn.SetVal = local->objP->SetVal;
local->Dyn.BiasD = local->objP->Bias;
local->Dyn.ForcVal = local->objP->ForcVal;
local->Dyn.IntOff = local->objP->IntOff;
local->Dyn.Force = local->objP->Force;
/* Write parameters to card */
swap_word((unsigned int *) &c_dyn.SetVal, (unsigned int *) &local->Dyn.SetVal);
swap_word((unsigned int *) &c_dyn.BiasD, (unsigned int *) &local->Dyn.BiasD);
swap_word((unsigned int *) &c_dyn.ForcVal, (unsigned int *) &local->Dyn.ForcVal);
c_dyn.Force = local->Dyn.Force;
c_dyn.IntOff = local->Dyn.IntOff;
for (ii = local->dyn_ind, datap = (unsigned short *)&c_dyn; ii < local->par_ind; ii++, datap++) {
sts = ssabpid_write(ii, datap, local);
if ( sts == -1) {
/* Increase error count and check error limits */
clock_gettime(CLOCK_REALTIME, &now);
if (op->ErrorCount > op->ErrorSoftLimit) {
/* Ignore if some time has expired */
if (now.tv_sec - local->ErrTime.tv_sec < 600)
op->ErrorCount++;
}
else
op->ErrorCount++;
local->ErrTime = now;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
continue;
}
}
/* Update status word */
local->Istat[0] ^= dyn_mask;
} /* End if nya dyn par */
/* Update status-word */
local->Istat[0] &= typ_mask;
local->Istat[0] |= ao_mask;
if (local->objP->UseInc3p) local->Istat[0] |= inc3p_mask;
if (local->objP->UsePos3p) local->Istat[0] |= pos3p_mask;
if (local->objP->UseDynBias) local->Istat[0] |= dyn_bias_mask;
if (local->objP->UseAo) local->Istat[0] |= stall_freeze_mask;
else local->Istat[0] |= stall_cont_mask;
datap = &local->Istat[0];
sts = ssabpid_write(0, datap, local);
if ( sts == -1)
op->ErrorCount++;
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Ssab_PIDuP) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
...@@ -5,6 +5,7 @@ Ssab_Di ...@@ -5,6 +5,7 @@ Ssab_Di
Ssab_Do Ssab_Do
Ssab_Co Ssab_Co
Ssab_RemoteRack Ssab_RemoteRack
Ssab_PIDuP
Di_DIX2 Di_DIX2
Do_HVDO32 Do_HVDO32
Ao_HVAO4 Ao_HVAO4
......
Volume SsabOx $ClassVolume 0.0.250.5 Volume SsabOx $ClassVolume 0.0.250.5
Body SysBody 01-JAN-1970 01:00:00.00 Body SysBody 01-JAN-1970 01:00:00.00
Attr NextOix = "_X162" Attr NextOix = "_X167"
Attr NextCix = "_X30" Attr NextCix = "_X31"
Attr NextTix[0] = "_X5" Attr NextTix[0] = "_X5"
EndBody EndBody
Object Type $TypeHier 138 30-DEC-2005 14:28:03.99 Object Type $TypeHier 138 30-DEC-2005 14:28:03.99
...@@ -4254,6 +4254,188 @@ Volume SsabOx $ClassVolume 0.0.250.5 ...@@ -4254,6 +4254,188 @@ Volume SsabOx $ClassVolume 0.0.250.5
EndObject EndObject
EndObject EndObject
EndObject EndObject
!/**
! @Version 1.0
! @Group IO,IO_PSS9000
! @Summary Configuration of a PID card PIDuP.
! Configuration of a PSS9000 PID card PIDuP.
!
! The PIDuP object is positioned below a SSAB_Rack object in the node configuration.
!
! @h2 Function
!
! The PIDuP-card is an autonomous PID-controller where the PID-algorithm runs
! in the micro-processor of the card. Proview only send setpoint-values to the
! card and the card itself calulates the control-value.
!
! @h2 Console
! The card has a terminal port that can be used to view the signal values of the card and to
! trace trouble. To use the terminal port you
! - connect the serial port of the computer to the terminal port of the card.
! - open a consol window on the screen of the computer from the popup menu of the background,
! menu item 'PSS Kort'.
! - view information and help with (Shift) '?'.
! - view the signal values of the card with 'R'.
! For more information about the console program, follow the link below.
!
! @b See hardware specification
! @link Datasheet ../dsh/ssab_pidup.pdf
! @Link Console program http://intern.oxelosund.ssab.se/pss/Hrdvara/PSS-kort-data.htm#AI32uP
!*/
Object Ssab_PIDuP $ClassDef 30 27-MAR-2009 13:34:16.63
Body SysBody 25-MAR-2009 10:38:54.30
Attr Editor = 0
Attr Method = 0
Attr Flags = 16464
EndBody
Object RtBody $ObjBodyDef 1 25-MAR-2009 10:39:31.96
Body SysBody 27-MAR-2009 13:34:30.21
Attr StructName = "Ssab_PIDuP"
Attr NextAix = "_X14"
EndBody
!/**
! Optional description.
!*/
Object Description $Attribute 11 25-MAR-2009 10:41:05.61
Body SysBody 25-MAR-2009 10:40:51.04
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Optional device name.
!*/
Object DevName $Attribute 10 25-MAR-2009 10:41:15.44
Body SysBody 25-MAR-2009 10:40:51.04
Attr PgmName = "DevName"
Attr TypeRef = "pwrs:Type-$String40"
EndBody
EndObject
!/**
! Error counter, incremented for every failed read or write operation of the card.
! When the error counter reaches ErrorSoftLimit, a message is sent to the console log.
! When it reaches ErrorHardLimit, all IO handling is aborted.
!*/
Object ErrorCount $Attribute 9 25-MAR-2009 10:41:21.76
Body SysBody 25-MAR-2009 10:40:51.04
Attr PgmName = "ErrorCount"
Attr Flags = 16
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Value of the error counter, when a message is sent to the console log.
!*/
Object ErrorSoftLimit $Attribute 8 25-MAR-2009 10:41:28.70
Body SysBody 25-MAR-2009 10:40:51.04
Attr PgmName = "ErrorSoftLimit"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Value of the error counter, when all IO handling is aborted.
!*/
Object ErrorHardLimit $Attribute 7 25-MAR-2009 10:41:35.61
Body SysBody 25-MAR-2009 10:40:51.04
Attr PgmName = "ErrorHardLimit"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! @Summary QBUS address of the card.
! QBUS address of the card.
! The value is set with address switches on the card.
! Typically addresses are:
!
! Card number Decimal address
! 1 4193024
! 2 4193028
! 3 4193032
! 4 4193036
!*/
Object RegAddress $Attribute 5 25-MAR-2009 10:41:55.11
Body SysBody 25-MAR-2009 10:40:51.04
Attr PgmName = "RegAddress"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Object identity of PidX-block that should be connected
! to this card.
!*/
Object PidXCon $Attribute 12 25-MAR-2009 10:47:49.69
Body SysBody 25-MAR-2009 10:48:12.80
Attr PgmName = "PidXCon"
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
!/**
! @Summary Process that handles the card. Plc(1), rt_io_comm(2) or application process(4).
! Process that handles the card.
!
! 1: The card is read by the plc process, and is handled by a specific
! thread in the plc, which is specified in the ThreadObject attribute.
! 2: The card is read by the rt_io_comm process.
! 4: The card is handled by an application program.
!*/
Object Process $Attribute 3 25-MAR-2009 10:42:14.10
Body SysBody 25-MAR-2009 10:40:51.04
Attr PgmName = "Process"
Attr TypeRef = "pwrb:Type-IoProcessMask"
EndBody
EndObject
!/**
! @Summary Plc thread that handles the card.
! The PlcThread object of the plc thread that handles the card.
! The card read to with the scantime of the thread.
!*/
Object ThreadObject $Attribute 13 25-MAR-2009 10:48:37.17
Body SysBody 25-MAR-2009 10:48:38.85
Attr PgmName = "ThreadObject"
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
!/**
! @Summary A URL to the data sheet for the equipment in this object.
! A URL to the data sheet for the equipment of this object.
! The data sheet can be displayed from the popup menu for this object.
!*/
Object DataSheet $Attribute 1 25-MAR-2009 10:44:41.26
Body SysBody 25-MAR-2009 10:40:51.04
Attr PgmName = "DataSheet"
Attr TypeRef = "pwrs:Type-$URL"
EndBody
EndObject
EndObject
Object IoMethods $RtMethod 163 25-MAR-2009 10:50:23.12
Object IoCardInit $Method 164 25-MAR-2009 10:52:00.36
Body SysBody 30-MAR-2009 13:49:05.19
Attr MethodName = "Ssab_PIDuP-IoCardInit"
EndBody
EndObject
Object IoCardRead $Method 165 25-MAR-2009 10:53:21.52
Body SysBody 30-MAR-2009 13:49:12.65
Attr MethodName = "Ssab_PIDuP-IoCardRead"
EndBody
EndObject
Object IoCardWrite $Method 166 25-MAR-2009 10:54:43.00
Body SysBody 30-MAR-2009 13:49:21.22
Attr MethodName = "Ssab_PIDuP-IoCardWrite"
EndBody
EndObject
Object IoCardClose $Method 167 25-MAR-2009 10:54:55.04
Body SysBody 30-MAR-2009 13:49:28.53
Attr MethodName = "Ssab_PIDuP-IoCardClose"
EndBody
EndObject
EndObject
Object Template Ssab_PIDuP 2155577344 01-JAN-1970 01:00:00.00
Body RtBody 02-APR-2009 08:35:02.91
Attr ErrorSoftLimit = 100
Attr ErrorHardLimit = 500
EndBody
EndObject
EndObject
Object Ai_AI32uP $ClassDef 16 30-DEC-2005 11:26:36.69 Object Ai_AI32uP $ClassDef 16 30-DEC-2005 11:26:36.69
Body SysBody 30-DEC-2005 11:26:36.69 Body SysBody 30-DEC-2005 11:26:36.69
Attr Editor = 0 Attr Editor = 0
...@@ -5802,525 +5984,140 @@ Volume SsabOx $ClassVolume 0.0.250.5 ...@@ -5802,525 +5984,140 @@ Volume SsabOx $ClassVolume 0.0.250.5
EndBody EndBody
EndObject EndObject
EndObject EndObject
Object PID_1uP $ClassDef 25 12-JAN-2006 07:29:56.01 !/**
Body SysBody 12-JAN-2006 07:29:56.01 ! @Version 1.0
! @Code ssabox_plc_pidx.c
! @Group Plc,PlcControl
! @Summary Implements the robust PID control algorithm
! Implements the robust PID control algorithm.
! @image orm_en1-141.gif
!
! Different PID strategies are implemented for
! incremental as well as positional form, see PidAlg
! below.
! The proportional respectively derivative term can be
! based either on process value or control deviation.
!
! The derivative term can be filtered by a first order
! lag filter.
! A feed forward signal, Bias, may be included in the
! algorithm.
!
! It is possible to switch the integration on/off.
! The control signal OutVal is checked against the limit
! values MinOut and MaxOut.
!
!*/
Object PidX $ClassDef 26 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr Editor = 0 Attr Editor = 0
Attr Method = 5 Attr Method = 6
Attr Flags = 2128 Attr Flags = 80
EndBody Attr PopEditor = 2
Object RtBody $ObjBodyDef 1 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr StructName = "PID_1uP"
Attr NextAix = "_X58"
EndBody
Object Description $Attribute 1 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object DevName $Attribute 2 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "DevName"
Attr TypeRef = "pwrs:Type-$String40"
EndBody
EndObject
Object ErrorCount $Attribute 3 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "ErrorCount"
Attr Flags = 1024
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
Object ErrorSoftLimit $Attribute 4 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "ErrorSoftLimit"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
Object ErrorHardLimit $Attribute 5 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "ErrorHardLimit"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
Object StallReact $Attribute 6 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "StallReact"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
Object RegAddress $Attribute 7 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "RegAddress"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
Object VectAddress $Attribute 8 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "VectAddress"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
Object Process $Attribute 9 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "Process"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
Object ThreadObject $Attribute 10 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "ThreadObject"
Attr TypeRef = "pwrs:Type-$Objid"
EndBody EndBody
EndObject Object RtBody $ObjBodyDef 1 12-JAN-2006 07:30:19.53
Object PidXCon $Intern 11 12-JAN-2006 07:29:56.01 Body SysBody 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:29:56.01 Attr StructName = "PidX"
Attr PgmName = "PidXCon" Attr NextAix = "_X62"
Attr TypeRef = "pwrs:Type-$Objid"
EndBody EndBody
EndObject !/**
Object SetVal $Attribute 12 12-JAN-2006 07:29:56.01 ! Specifies the set point value.
Body SysBody 12-JAN-2006 07:29:56.01 !*/
Object SetVal $Input 1 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "SetVal" Attr PgmName = "SetVal"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "SV"
EndBody EndBody
EndObject EndObject
Object BiasD $Attribute 13 12-JAN-2006 07:29:56.01 Object BiasD $Input 2 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:29:56.01 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "BiasD" Attr PgmName = "BiasD"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "BIS"
EndBody EndBody
EndObject EndObject
Object ForcVal $Attribute 14 12-JAN-2006 07:29:56.01 !/**
Body SysBody 12-JAN-2006 07:29:56.01 ! Specifies which value is to be used when Force is TRUE.
! When Force is TRUE OutVal is equal to ForcVal. This
! input is in general connected to the corresponding
! output of a Mode object.
!*/
Object ForcVal $Input 3 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ForcVal" Attr PgmName = "ForcVal"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "FOV"
EndBody EndBody
EndObject EndObject
Object Force $Attribute 15 12-JAN-2006 07:29:56.01 !/**
Body SysBody 12-JAN-2006 07:29:56.01 ! Specifies whether forced control is selected
! or not. FALSE means none;
!*/
Object Force $Input 4 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Force" Attr PgmName = "Force"
Attr Flags = 2048 Attr Flags = 8192
Attr TypeRef = "pwrs:Type-$Boolean" Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "for"
EndBody EndBody
EndObject EndObject
Object IntOff $Attribute 16 12-JAN-2006 07:29:56.01 !/**
Body SysBody 12-JAN-2006 07:29:56.01 ! Specifies whether to enable or disable the integration.
! FALSE means that the integration is on; TRUE switches
! the integration off.
!*/
Object IntOff $Input 5 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "IntOff" Attr PgmName = "IntOff"
Attr Flags = 2048 Attr Flags = 8192
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
Object Init $Attribute 17 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "Init"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Boolean" Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "iof"
EndBody EndBody
EndObject EndObject
Object PidAlg $Attribute 18 12-JAN-2006 07:29:56.01 !/**
Body SysBody 12-JAN-2006 07:29:56.01 ! Description.
Attr PgmName = "PidAlg" !*/
Attr Flags = 2048 Object Description $Intern 9 12-JAN-2006 07:30:19.53
Attr TypeRef = "pwrs:Type-$UInt32" Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
EndBody EndBody
EndObject EndObject
Object Inverse $Attribute 19 12-JAN-2006 07:29:56.01 !/**
Body SysBody 12-JAN-2006 07:29:56.01 ! Not used.
Attr PgmName = "Inverse" !*/
Attr Flags = 2048 Object Pid1uPCon $Intern 10 12-JAN-2006 07:30:19.53
Attr TypeRef = "pwrs:Type-$Boolean" Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Pid1uPCon"
Attr TypeRef = "pwrs:Type-$Objid"
Attr NiNaAnnot = 1
EndBody EndBody
EndObject EndObject
Object PidGain $Attribute 20 12-JAN-2006 07:29:56.01 !/**
Body SysBody 12-JAN-2006 07:29:56.01 ! Accumulated control error - in time form.
Attr PgmName = "PidGain" !*/
Attr Flags = 2048 Object Acc $Intern 11 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Acc"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
Object IntTime $Attribute 21 12-JAN-2006 07:29:56.01 !/**
Body SysBody 12-JAN-2006 07:29:56.01 ! The controller's control signal. The value is based
Attr PgmName = "IntTime" ! either on the algorithm's current result or a forced value.
Attr Flags = 2048 !*/
Attr TypeRef = "pwrs:Type-$Float32" Object OutVal $Intern 12 12-JAN-2006 07:30:19.53
EndBody Body SysBody 12-JAN-2006 07:30:19.53
EndObject Attr PgmName = "OutVal"
Object DerTime $Attribute 22 12-JAN-2006 07:29:56.01 Attr Flags = 1040
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "DerTime"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object DerGain $Attribute 23 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "DerGain"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object MinOut $Attribute 24 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "MinOut"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object MaxOut $Attribute 25 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "MaxOut"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object EndHys $Attribute 26 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "EndHys"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object BiasGain $Attribute 27 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "BiasGain"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object UseDynBias $Attribute 28 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "UseDynBias"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
Object ActMax $Attribute 29 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "ActMax"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object ActMin $Attribute 30 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "ActMin"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object ActRawMax $Attribute 31 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "ActRawMax"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
Object ActRawMin $Attribute 32 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "ActRawMin"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
Object BiasMax $Attribute 33 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "BiasMax"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object BiasMin $Attribute 34 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "BiasMin"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object BiasRawMax $Attribute 35 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "BiasRawMax"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
Object BiasRawMin $Attribute 36 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "BiasRawMin"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
Object UseAo $Attribute 37 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "UseAo"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
Object AoMax $Attribute 38 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "AoMax"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object AoMin $Attribute 39 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "AoMin"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object AoRawMax $Attribute 40 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "AoRawMax"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
Object AoRawMin $Attribute 41 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "AoRawMin"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
Object UsePos3p $Attribute 42 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "UsePos3p"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
Object PosMax $Attribute 43 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "PosMax"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object PosMin $Attribute 44 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "PosMin"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object PosRawMax $Attribute 45 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "PosRawMax"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
Object PosRawMin $Attribute 46 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "PosRawMin"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
Object ErrSta $Attribute 47 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "ErrSta"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object ErrSto $Attribute 48 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "ErrSto"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object Pos3pGain $Attribute 49 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "Pos3pGain"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object ProcFiltTime $Attribute 50 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "ProcFiltTime"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object BiasFiltTime $Attribute 51 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "BiasFiltTime"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object PosFiltTime $Attribute 52 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "PosFiltTime"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object UseInc3p $Attribute 53 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "UseInc3p"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
Object Inc3pGain $Attribute 54 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "Inc3pGain"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object MinTim $Attribute 55 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "MinTim"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object MaxTim $Attribute 56 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "MaxTim"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object MaxInteg $Attribute 57 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "MaxInteg"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
EndObject
Object DevBody $ObjBodyDef 2 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr NextAix = "_X2"
EndBody
Object PlcNode $Buffer 1 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr Flags = 2048
Attr Class = "pwrs:Class-$PlcNode"
EndBody
EndObject
EndObject
Object Template PID_1uP 2154266624 01-JAN-1970 01:00:00.00
Body RtBody 01-JAN-1970 01:00:00.00
EndBody
Body DevBody 01-JAN-1970 01:00:00.00
EndBody
EndObject
EndObject
Object PidX $ClassDef 26 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr Editor = 0
Attr Method = 6
Attr Flags = 80
Attr PopEditor = 2
EndBody
Object RtBody $ObjBodyDef 1 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr StructName = "PidX"
Attr NextAix = "_X62"
EndBody
Object SetVal $Input 1 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "SetVal"
Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "SV"
EndBody
EndObject
Object BiasD $Input 2 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "BiasD"
Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "BIS"
EndBody
EndObject
Object ForcVal $Input 3 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ForcVal"
Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "FOV"
EndBody
EndObject
Object Force $Input 4 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Force"
Attr Flags = 8192
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "for"
EndBody
EndObject
Object IntOff $Input 5 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "IntOff"
Attr Flags = 8192
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "iof"
EndBody
EndObject
Object PosVal $Output 6 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "PosVal"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "POS"
EndBody
EndObject
Object ProcVal $Output 7 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ProcVal"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "PV"
EndBody
EndObject
Object Bias $Output 8 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Bias"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "BIS"
EndBody
EndObject
Object Description $Intern 9 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object Pid1uPCon $Intern 10 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Pid1uPCon"
Attr TypeRef = "pwrs:Type-$Objid"
Attr NiNaAnnot = 1
EndBody
EndObject
Object Acc $Intern 11 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Acc"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object OutVal $Intern 12 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "OutVal"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Control error (= ProcVal - SetVal).
!*/
Object ControlDiff $Intern 13 12-JAN-2006 07:30:19.53 Object ControlDiff $Intern 13 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ControlDiff" Attr PgmName = "ControlDiff"
...@@ -6335,6 +6132,17 @@ Volume SsabOx $ClassVolume 0.0.250.5 ...@@ -6335,6 +6132,17 @@ Volume SsabOx $ClassVolume 0.0.250.5
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Specifies if OutVal at this scanning has been limited
! against any of the limit values in the interval {
! MinOut, MaxOut } or not. If a limitation is done
! against
!
! -- MinOut, then EndMin is set TRUE
! -- MaxOut, then EndMax is set TRUE
! else they are FALSE.
!
!*/
Object EndMax $Intern 15 12-JAN-2006 07:30:19.53 Object EndMax $Intern 15 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "EndMax" Attr PgmName = "EndMax"
...@@ -6342,6 +6150,17 @@ Volume SsabOx $ClassVolume 0.0.250.5 ...@@ -6342,6 +6150,17 @@ Volume SsabOx $ClassVolume 0.0.250.5
Attr TypeRef = "pwrs:Type-$Boolean" Attr TypeRef = "pwrs:Type-$Boolean"
EndBody EndBody
EndObject EndObject
!/**
! Specifies if OutVal at this scanning has been limited
! against any of the limit values in the interval {
! MinOut, MaxOut } or not. If a limitation is done
! against
!
! -- MinOut, then EndMin is set TRUE
! -- MaxOut, then EndMax is set TRUE
! else they are FALSE.
!
!*/
Object EndMin $Intern 16 12-JAN-2006 07:30:19.53 Object EndMin $Intern 16 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "EndMin" Attr PgmName = "EndMin"
...@@ -6349,276 +6168,584 @@ Volume SsabOx $ClassVolume 0.0.250.5 ...@@ -6349,276 +6168,584 @@ Volume SsabOx $ClassVolume 0.0.250.5
Attr TypeRef = "pwrs:Type-$Boolean" Attr TypeRef = "pwrs:Type-$Boolean"
EndBody EndBody
EndObject EndObject
!/**
! Request to initialize card, not implemented.
!*/
Object Init $Intern 17 12-JAN-2006 07:30:19.53 Object Init $Intern 17 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Init" Attr PgmName = "Init"
Attr TypeRef = "pwrs:Type-$Boolean" Attr TypeRef = "pwrs:Type-$Boolean"
EndBody EndBody
EndObject EndObject
!/**
! @Summary The PID control algorithm
! There are several variations of the PID control
! algorithm. PidAlg specifies the current choice. The
! possible values are as follows:
!
! 1 -- I Integral controller. Gain is not used.
!
! 3 -- I+P Integral controller with proportional
! control action. The P-term is based on the
! the process value.
!
! 6 -- P Proportional Controller.
!
! 7 -- PI Proportional Integral Controller. The
! P-term is based on the control error.
!
! 11 -- I+PD Integral controller with proportional
! derivative control action. Both the P- and
! D-term are based on the process value.
!
! 14 -- P+D Proportional Controller with derivative
! control action. P is based on the control error,
! D on the process value.
!
! 15 -- PI+D Proportional Integral Controller with
! derivative control action. P is based on
! the control error, D on the process value.
!
! 30 -- PD Proportional Derivative Controller. Both
! the P- and D-term are based on the control
! error.
!
! 31 -- PID Proportional Integral Derivative
! Controller. Both the P- and D-term are
! based on the control error.
!*/
Object PidAlg $Intern 18 12-JAN-2006 07:30:19.53 Object PidAlg $Intern 18 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 31-MAR-2009 14:29:29.84
Attr PgmName = "PidAlg" Attr PgmName = "PidAlg"
Attr TypeRef = "pwrs:Type-$UInt32" Attr TypeRef = "pwrb:Type-PidAlgEnum"
EndBody EndBody
EndObject EndObject
!/**
! Specifies whether the control action should be inverted
! or not. FALSE means that a spontaneous increasing
! process value, in a control with fixed set point, is
! met by an increasing control signal, i.e. reverse
! control action. TRUE is the normal case, where a
! spontaneous increasing process value is met by a
! decreasing control signal.
!*/
Object Inverse $Intern 19 12-JAN-2006 07:30:19.53 Object Inverse $Intern 19 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Inverse" Attr PgmName = "Inverse"
Attr TypeRef = "pwrs:Type-$Boolean" Attr TypeRef = "pwrs:Type-$Boolean"
EndBody EndBody
EndObject EndObject
!/**
! Specifies the proportional control factor; >= 0.
! The value may be changed in the more info form of the
! Pid object.
!*/
Object PidGain $Intern 20 12-JAN-2006 07:30:19.53 Object PidGain $Intern 20 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "PidGain" Attr PgmName = "PidGain"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Specifies the integral action time in seconds.
! The value may be changed in the more info form of the
! Pid object.
!*/
Object IntTime $Intern 21 12-JAN-2006 07:30:19.53 Object IntTime $Intern 21 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "IntTime" Attr PgmName = "IntTime"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Specifies the derivative time in seconds; see p. 3-258.
! Normally DerTime is greater than ScanTime and
! 1.0 <= DerGain < DerTime/ScanTime
!*/
Object DerTime $Intern 22 12-JAN-2006 07:30:19.53 Object DerTime $Intern 22 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "DerTime" Attr PgmName = "DerTime"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Factor to specify the first order lag filter used in
! filtering of the derivative contribution.
!
! 1.0 <= DerGain < DerTime/ScanTime, otherwise no filtering
!
! DerGain is normally in the size of 3 to 4.
! The value may be changed in the more info form of the
! Pid object.
!*/
Object DerGain $Intern 23 12-JAN-2006 07:30:19.53 Object DerGain $Intern 23 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "DerGain" Attr PgmName = "DerGain"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! The control signal OutVal
! is supposed to be in the interval { MinOut, MaxOut }.
! The EndMin /EndMax flags are used to signal if any
! limitation has occurred.
! If OutVal is greater than MaxOut or less than MinOut,
! OutVal is limited to the value at the end of the
! interval.
!
! If MinOut >= MaxOut no limitation will occur.
!*/
Object MinOut $Intern 24 12-JAN-2006 07:30:19.53 Object MinOut $Intern 24 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "MinOut" Attr PgmName = "MinOut"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! The control signal OutVal
! is supposed to be in the interval { MinOut, MaxOut }.
! The EndMin /EndMax flags are used to signal if any
! limitation has occurred.
! If OutVal is greater than MaxOut or less than MinOut,
! OutVal is limited to the value at the end of the
! interval.
!
! If MinOut >= MaxOut no limitation will occur.
!*/
Object MaxOut $Intern 25 12-JAN-2006 07:30:19.53 Object MaxOut $Intern 25 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "MaxOut" Attr PgmName = "MaxOut"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Specifies the hysteresis on MinOut and MaxOut in
! connection with the handling of EndMin/EndMax.
! @image orm_en1-144.gif
!*/
Object EndHys $Intern 26 12-JAN-2006 07:30:19.53 Object EndHys $Intern 26 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "EndHys" Attr PgmName = "EndHys"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Specifies the feed forward gain; this factor may be
! negative.
!
! The values may be changed in the more info form of the
! Pid object.
!*/
Object BiasGain $Intern 27 12-JAN-2006 07:30:19.53 Object BiasGain $Intern 27 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "BiasGain" Attr PgmName = "BiasGain"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! True if bias should be used.
!*/
Object UseDynBias $Intern 28 12-JAN-2006 07:30:19.53 Object UseDynBias $Intern 28 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "UseDynBias" Attr PgmName = "UseDynBias"
Attr TypeRef = "pwrs:Type-$Boolean" Attr TypeRef = "pwrs:Type-$Boolean"
EndBody EndBody
EndObject EndObject
!/**
! Engineering value representing maximum raw value
! of the process value.
!*/
Object ProcMax $Intern 29 12-JAN-2006 07:30:19.53 Object ProcMax $Intern 29 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ProcMax" Attr PgmName = "ProcMax"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Engineering value representing minimum raw value
! of the process value.
!*/
Object ProcMin $Intern 30 12-JAN-2006 07:30:19.53 Object ProcMin $Intern 30 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ProcMin" Attr PgmName = "ProcMin"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! The unit of the process value.
!*/
Object ProcValueUnit $Intern 31 12-JAN-2006 07:30:19.53 Object ProcValueUnit $Intern 31 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ProcValueUnit" Attr PgmName = "ProcValueUnit"
Attr TypeRef = "pwrs:Type-$String16" Attr TypeRef = "pwrs:Type-$String16"
EndBody EndBody
EndObject EndObject
!/**
! Filter time of the analog input of the process value.
!*/
Object ProcFiltTime $Intern 32 12-JAN-2006 07:30:19.53 Object ProcFiltTime $Intern 32 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ProcFiltTime" Attr PgmName = "ProcFiltTime"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Raw value representing the maximum value of the analog input
! of the process value. This is default 30000.
!*/
Object ProcRawMax $Intern 33 12-JAN-2006 07:30:19.53 Object ProcRawMax $Intern 33 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ProcRawMax" Attr PgmName = "ProcRawMax"
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Int32"
EndBody EndBody
EndObject EndObject
!/**
! Raw value representing the minimum value of the analog input
! of the process value. This is default 30000.
!*/
Object ProcRawMin $Intern 34 12-JAN-2006 07:30:19.53 Object ProcRawMin $Intern 34 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ProcRawMin" Attr PgmName = "ProcRawMin"
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Int32"
EndBody EndBody
EndObject EndObject
!/**
! Engineering value representing maximum raw value
! of the bias analog input.
!*/
Object BiasMax $Intern 35 12-JAN-2006 07:30:19.53 Object BiasMax $Intern 35 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "BiasMax" Attr PgmName = "BiasMax"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Engineering value representing minimum raw value
! of the bias analog input.
!*/
Object BiasMin $Intern 36 12-JAN-2006 07:30:19.53 Object BiasMin $Intern 36 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "BiasMin" Attr PgmName = "BiasMin"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! The unit of the bias value.
!*/
Object BiasValueUnit $Intern 37 12-JAN-2006 07:30:19.53 Object BiasValueUnit $Intern 37 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "BiasValueUnit" Attr PgmName = "BiasValueUnit"
Attr TypeRef = "pwrs:Type-$String16" Attr TypeRef = "pwrs:Type-$String16"
EndBody EndBody
EndObject EndObject
!/**
! Filter time of the analog input of the bias value.
!*/
Object BiasFiltTime $Intern 38 12-JAN-2006 07:30:19.53 Object BiasFiltTime $Intern 38 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "BiasFiltTime" Attr PgmName = "BiasFiltTime"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Raw value representing the maximum value of the analog input
! of the bias value. This is default 30000.
!*/
Object BiasRawMax $Intern 39 12-JAN-2006 07:30:19.53 Object BiasRawMax $Intern 39 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "BiasRawMax" Attr PgmName = "BiasRawMax"
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Int32"
EndBody EndBody
EndObject EndObject
!/**
! Raw value representing the minimum value of the analog input
! of the bias value. This is default 0.
!*/
Object BiasRawMin $Intern 40 12-JAN-2006 07:30:19.53 Object BiasRawMin $Intern 40 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "BiasRawMin" Attr PgmName = "BiasRawMin"
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Int32"
EndBody EndBody
EndObject EndObject
!/**
! Represents the stall action to be taken when there is no cyclic
! communication with the card. if TRUE the analog output of the
! control value will be held. If FALSE the PID-algorithm will
! continue calculating the control value.
!*/
Object UseAo $Intern 41 12-JAN-2006 07:30:19.53 Object UseAo $Intern 41 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "UseAo" Attr PgmName = "UseAo"
Attr TypeRef = "pwrs:Type-$Boolean" Attr TypeRef = "pwrs:Type-$Boolean"
EndBody EndBody
EndObject EndObject
!/**
! Engineering value representing maximum raw value
! of the control signal analog output.
!*/
Object AoMax $Intern 42 12-JAN-2006 07:30:19.53 Object AoMax $Intern 42 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "AoMax" Attr PgmName = "AoMax"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Engineering value representing minimum raw value
! of the control signal analog output.
!*/
Object AoMin $Intern 43 12-JAN-2006 07:30:19.53 Object AoMin $Intern 43 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "AoMin" Attr PgmName = "AoMin"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! The unit of the control value.
!*/
Object AoValueUnit $Intern 44 12-JAN-2006 07:30:19.53 Object AoValueUnit $Intern 44 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "AoValueUnit" Attr PgmName = "AoValueUnit"
Attr TypeRef = "pwrs:Type-$String16" Attr TypeRef = "pwrs:Type-$String16"
EndBody EndBody
EndObject EndObject
!/**
! Raw value representing the maximum value of the analog output
! of the control value. This is default 30000.
!*/
Object AoRawMax $Intern 45 12-JAN-2006 07:30:19.53 Object AoRawMax $Intern 45 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "AoRawMax" Attr PgmName = "AoRawMax"
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Int32"
EndBody EndBody
EndObject EndObject
!/**
! Raw value representing the minimum value of the analog output
! of the control value. This is default 0.
!*/
Object AoRawMin $Intern 46 12-JAN-2006 07:30:19.53 Object AoRawMin $Intern 46 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "AoRawMin" Attr PgmName = "AoRawMin"
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Int32"
EndBody EndBody
EndObject EndObject
!/**
! Positional 3-step controller with position feedback and
! dead zone. Positional is aimed at the input signal and
! the digit 3 on the fact that the output signals specify
! one of three distinct orders e.g. increase / decrease.
!
! If set to TRUE, the positional 3-step controller will be used.
!*/
Object UsePos3p $Intern 47 12-JAN-2006 07:30:19.53 Object UsePos3p $Intern 47 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "UsePos3p" Attr PgmName = "UsePos3p"
Attr TypeRef = "pwrs:Type-$Boolean" Attr TypeRef = "pwrs:Type-$Boolean"
EndBody EndBody
EndObject EndObject
!/**
! Engineering value representing maximum raw value
! of the position signal analog input.
!*/
Object PosMax $Intern 48 12-JAN-2006 07:30:19.53 Object PosMax $Intern 48 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "PosMax" Attr PgmName = "PosMax"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Engineering value representing minimum raw value
! of the position signal analog input.
!*/
Object PosMin $Intern 49 12-JAN-2006 07:30:19.53 Object PosMin $Intern 49 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "PosMin" Attr PgmName = "PosMin"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! The unit of the position signal.
!*/
Object PosValueUnit $Intern 50 12-JAN-2006 07:30:19.53 Object PosValueUnit $Intern 50 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "PosValueUnit" Attr PgmName = "PosValueUnit"
Attr TypeRef = "pwrs:Type-$String16" Attr TypeRef = "pwrs:Type-$String16"
EndBody EndBody
EndObject EndObject
!/**
! Filter time of the analog input of the position value.
!*/
Object PosFiltTime $Intern 51 12-JAN-2006 07:30:19.53 Object PosFiltTime $Intern 51 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "PosFiltTime" Attr PgmName = "PosFiltTime"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Raw value representing the maximum value of the analog input
! of the position signal. This is default 30000.
!*/
Object PosRawMax $Intern 52 12-JAN-2006 07:30:19.53 Object PosRawMax $Intern 52 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "PosRawMax" Attr PgmName = "PosRawMax"
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Int32"
EndBody EndBody
EndObject EndObject
!/**
! Raw value representing the minimum value of the analog input
! of the position signal. This is default 0.
!*/
Object PosRawMin $Intern 53 12-JAN-2006 07:30:19.53 Object PosRawMin $Intern 53 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "PosRawMin" Attr PgmName = "PosRawMin"
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Int32"
EndBody EndBody
EndObject EndObject
!/**
! Specifies the dead zone value which the control error
! has to exceed before an open- or close-signal will be
! set or started.
!
! The demand on the dead zone is 0 ErrSto ErrSta
! Open or Close is set when the absolute value of (OutVal(t)
! - Pos(t) ) is greater than ErrSta.
!
! Only used when UsePos3p is TRUE.
!*/
Object ErrSta $Intern 54 12-JAN-2006 07:30:19.53 Object ErrSta $Intern 54 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ErrSta" Attr PgmName = "ErrSta"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Specifies the dead zone value which the control error
! have to be below before an open- or close-signal will
! be reset or stopped.
! Open or Close is interrupted when the absolute value of
! (OutVal(t) - Post(t)) is less than ErrSto.
! The demand on the dead zone is 0 <= ErrSto <= ErrSta
!
! Only used when UsePos3p is TRUE.
!*/
Object ErrSto $Intern 55 12-JAN-2006 07:30:19.53 Object ErrSto $Intern 55 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ErrSto" Attr PgmName = "ErrSto"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Gain, in seconds, per control signal unit. The control
! signal is often in the range 0 - 100 %. Suppose it is
! possible to measure the running time, e.g. the time to
! drive a valve from completely open to completely
! closed. Then select Gain as running time divided by the
! range; ( here 100 - 0).
!
! Gain is only used in conjunction with timer control of
! the outputs.
!*/
Object Pos3pGain $Intern 56 12-JAN-2006 07:30:19.53 Object Pos3pGain $Intern 56 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Pos3pGain" Attr PgmName = "Pos3pGain"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Incremental 3-point output with dead zone. Incremental
! comes from the type of input and the digit 3 of the
! output, which can have three distinct values, e.g. open
! / close / 0 but also with the meaning of up / down / 0
! or right / left / 0 or increase / decrease / 0 etc. The
! outputs are time-proportional to the input.
!
! If set to TRUE, the positional 3-step controller will be used.
!*/
Object UseInc3p $Intern 57 12-JAN-2006 07:30:19.53 Object UseInc3p $Intern 57 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "UseInc3p" Attr PgmName = "UseInc3p"
Attr TypeRef = "pwrs:Type-$Boolean" Attr TypeRef = "pwrs:Type-$Boolean"
EndBody EndBody
EndObject EndObject
!/**
! Gain, in seconds, per control signal unit. Often the
! control signal is in the range 0 - 100 %. Suppose it is
! possible to measure the running time, for example, the
! time to drive a valve from completely open to
! running time / divided by the range; ( here 100 - 0).
!*/
Object Inc3pGain $Intern 58 12-JAN-2006 07:30:19.53 Object Inc3pGain $Intern 58 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Inc3pGain" Attr PgmName = "Inc3pGain"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! The dead zone in seconds; see the description above. If
! the absolute value of Acc is less than MinTim no output
! at all is set.
!
! Only used when UseInc3p is TRUE.
!*/
Object MinTim $Intern 59 12-JAN-2006 07:30:19.53 Object MinTim $Intern 59 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "MinTim" Attr PgmName = "MinTim"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! When the MaxTim, in seconds, has elapsed without any
! output signal Acc is set equal to 0.
!
! Only used when UseInc3p is TRUE.
!*/
Object MaxTim $Intern 60 12-JAN-2006 07:30:19.53 Object MaxTim $Intern 60 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "MaxTim" Attr PgmName = "MaxTim"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Unknown usage. Should be set to 1.0.
!*/
Object MaxInteg $Intern 61 12-JAN-2006 07:30:19.53 Object MaxInteg $Intern 61 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "MaxInteg" Attr PgmName = "MaxInteg"
Attr TypeRef = "pwrs:Type-$Float32" Attr TypeRef = "pwrs:Type-$Float32"
EndBody EndBody
EndObject EndObject
!/**
! Position, from card.
!*/
Object PosVal $Output 6 27-MAR-2009 16:11:46.22
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "PosVal"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "POS"
EndBody
EndObject
!/**
! Process value, from card.
!*/
Object ProcVal $Output 7 27-MAR-2009 16:11:48.43
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ProcVal"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "PV"
EndBody
EndObject
!/**
! Bias Value, from card.
!*/
Object Bias $Output 8 27-MAR-2009 16:11:49.77
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Bias"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "BIS"
EndBody
EndObject
EndObject EndObject
Object DevBody $ObjBodyDef 2 12-JAN-2006 07:30:19.53 Object DevBody $ObjBodyDef 2 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 12-JAN-2006 07:30:19.53
...@@ -6632,7 +6759,7 @@ Volume SsabOx $ClassVolume 0.0.250.5 ...@@ -6632,7 +6759,7 @@ Volume SsabOx $ClassVolume 0.0.250.5
EndObject EndObject
EndObject EndObject
Object GraphPlcNode $GraphPlcNode 148 12-JAN-2006 07:30:19.53 Object GraphPlcNode $GraphPlcNode 148 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53 Body SysBody 27-MAR-2009 16:05:51.62
Attr object_type = 11 Attr object_type = 11
Attr parameters[0] = 5 Attr parameters[0] = 5
Attr parameters[1] = 53 Attr parameters[1] = 53
...@@ -6654,7 +6781,29 @@ Volume SsabOx $ClassVolume 0.0.250.5 ...@@ -6654,7 +6781,29 @@ Volume SsabOx $ClassVolume 0.0.250.5
EndBody EndBody
EndObject EndObject
Object Template PidX 2154528768 01-JAN-1970 01:00:00.00 Object Template PidX 2154528768 01-JAN-1970 01:00:00.00
Body RtBody 01-JAN-1970 01:00:00.00 Body RtBody 31-MAR-2009 14:44:34.00
Attr PidAlg = 3
Attr Inverse = 1
Attr PidGain = 1.000000e+00
Attr IntTime = 1.200000e+02
Attr DerGain = 3.000000e+00
Attr MaxOut = 1.000000e+02
Attr BiasGain = 1.000000e+00
Attr ProcMax = 1.000000e+02
Attr ProcRawMax = 30000
Attr BiasMax = 1.000000e+02
Attr BiasRawMax = 30000
Attr AoMax = 1.000000e+02
Attr AoRawMax = 30000
Attr PosMax = 1.000000e+02
Attr PosRawMax = 30000
Attr ErrSta = 1.000000e+00
Attr ErrSto = 1.000000e+00
Attr Pos3pGain = 1.000000e+00
Attr Inc3pGain = 1.000000e+00
Attr MinTim = 1.000000e+00
Attr MaxTim = 1.000000e+00
Attr MaxInteg = 1.000000e+00
EndBody EndBody
Body DevBody 01-JAN-1970 01:00:00.00 Body DevBody 01-JAN-1970 01:00:00.00
EndBody EndBody
......
...@@ -264,6 +264,7 @@ palette NavigatorPalette ...@@ -264,6 +264,7 @@ palette NavigatorPalette
menu Masters menu Masters
{ {
class Pb_Profiboard class Pb_Profiboard
class Pb_Hilscher
} }
menu Slaves menu Slaves
{ {
......
...@@ -585,7 +585,7 @@ WNav::WNav( ...@@ -585,7 +585,7 @@ WNav::WNav(
layout_objid(pwr_cNObjid), search_last(pwr_cNObjid), search_compiled(0), layout_objid(pwr_cNObjid), search_last(pwr_cNObjid), search_compiled(0),
search_type(wnav_eSearchType_No), selection_owner(0), last_selected(0), search_type(wnav_eSearchType_No), selection_owner(0), last_selected(0),
displayed(0), scriptmode(0), dialog_width(0), dialog_height(0), displayed(0), scriptmode(0), dialog_width(0), dialog_height(0),
dialog_x(0), dialog_y(0), menu(0), admin_login(0) dialog_x(0), dialog_y(0), menu(0), admin_login(0), nodraw(0)
{ {
strcpy( name, xn_name); strcpy( name, xn_name);
...@@ -2749,6 +2749,9 @@ void WNav::ldh_refresh( pwr_tObjid new_open) ...@@ -2749,6 +2749,9 @@ void WNav::ldh_refresh( pwr_tObjid new_open)
if ( brow->type != wnav_eBrowType_Volume) if ( brow->type != wnav_eBrowType_Volume)
return; return;
if ( nodraw)
return;
// Store all open objects // Store all open objects
open_cnt = 0; open_cnt = 0;
......
...@@ -287,6 +287,7 @@ class WNav : public WUtility{ ...@@ -287,6 +287,7 @@ class WNav : public WUtility{
int init_help; int init_help;
CoWow *wow; CoWow *wow;
int admin_login; int admin_login;
int nodraw;
virtual void pop() {} virtual void pop() {}
virtual void set_inputfocus( int focus) {} virtual void set_inputfocus( int focus) {}
...@@ -416,6 +417,8 @@ class WNav : public WUtility{ ...@@ -416,6 +417,8 @@ class WNav : public WUtility{
int case_sensitive); int case_sensitive);
int display_objects( pwr_tCid *cidp, char *name, pwr_tObjid root, int display_objects( pwr_tCid *cidp, char *name, pwr_tObjid root,
int depth); int depth);
void set_nodraw() { nodraw = 1;}
void reset_nodraw() { nodraw = 0; refresh();}
}; };
int wnav_cut_segments ( int wnav_cut_segments (
......
...@@ -463,7 +463,7 @@ menu Components ...@@ -463,7 +463,7 @@ menu Components
subgraph FlowSensor pwr_exe:bcomp_flowsensor.pwsg 16 subgraph FlowSensor pwr_exe:bcomp_flowsensor.pwsg 16
subgraph FcPPO3MotorAggr pwr_exe:bcomp_basefcppo3motoraggr.pwsg 23 subgraph FcPPO3MotorAggr pwr_exe:bcomp_basefcppo3motoraggr.pwsg 23
subgraph FcPPO3FanAggr pwr_exe:bcomp_basefcppo3fanaggr.pwsg 71 subgraph FcPPO3FanAggr pwr_exe:bcomp_basefcppo3fanaggr.pwsg 71
subgraph FcPPO3umpAggr pwr_exe:bcomp_basefcppo3pumpaggr.pwsg 72 subgraph FcPPO3PumpAggr pwr_exe:bcomp_basefcppo3pumpaggr.pwsg 72
subgraph FcPPO5MotorAggr pwr_exe:bcomp_basefcppo5motoraggr.pwsg 23 subgraph FcPPO5MotorAggr pwr_exe:bcomp_basefcppo5motoraggr.pwsg 23
subgraph FcPPO5FanAggr pwr_exe:bcomp_basefcppo5fanaggr.pwsg 71 subgraph FcPPO5FanAggr pwr_exe:bcomp_basefcppo5fanaggr.pwsg 71
subgraph FcPPO5umpAggr pwr_exe:bcomp_basefcppo5pumpaggr.pwsg 72 subgraph FcPPO5umpAggr pwr_exe:bcomp_basefcppo5pumpaggr.pwsg 72
......
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