Commit cb2e67d1 authored by claes's avatar claes

Files moved from kernel

parent 8d99e20a
......@@ -2,8 +2,8 @@ ifndef link_rule_mk
link_rule_mk := 1
link = $(ld) $(elinkflags) $(domap) -o $(export_exe) \
$(export_obj) $(objects) $(rt_msg_objs) \
$(pwr_eobj)/rt_io_user.o -lpwr_rs \
$(export_obj) $(objects) $(rt_msg_eobjs) \
$(pwr_eobj)/rt_io_user.o \
-lpwr_rt -lpwr_co -lpwr_msg_dummy -lrpcsvc -lpthread -lm -lrt
endif
/*
* Proview $Id: rs_nmps_bck.c,v 1.4 2005-10-25 15:28:10 claes Exp $
* Proview $Id: rs_nmps_bck.c,v 1.5 2006-01-12 05:57:42 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -69,9 +69,8 @@
#include "rt_errh.h"
#include "rt_gdh_msg.h"
#include "rt_hash_msg.h"
#include "rs_nmps.h"
#include "nmps.h"
#include "rs_nmps_msg.h"
#include "rs_sutl.h"
#include "rt_qcom.h"
#include "rt_qcom_msg.h"
#include "rt_ini_event.h"
......@@ -1131,7 +1130,7 @@ static pwr_tStatus nmpsbck_open_file( bck_ctx bckctx)
for (;;)
{
if ( wait_some_time)
sutl_sleep( reopen_time);
time_Sleep( reopen_time);
else
wait_some_time = 1;
......@@ -1193,7 +1192,7 @@ static pwr_tStatus nmpsbck_open_file( bck_ctx bckctx)
for (;;)
{
if ( wait_some_time)
sutl_sleep( reopen_time);
time_Sleep( reopen_time);
else
wait_some_time = 1;
......@@ -2518,7 +2517,7 @@ int main()
#endif
// sutl_sleep( scantime);
// time_Sleep( scantime);
first_scan = 0;
}
......
......@@ -2,8 +2,8 @@ ifndef link_rule_mk
link_rule_mk := 1
link = $(ld) $(elinkflags) $(domap) -o $(export_exe) \
$(export_obj) $(objects) $(rt_msg_objs) \
$(pwr_eobj)/rt_io_user.o -lpwr_rs\
$(export_obj) $(objects) $(rt_msg_eobjs) \
$(pwr_eobj)/rt_io_user.o\
-lpwr_rt -lpwr_co -lpwr_msg_dummy -lrpcsvc -lpthread -lm -lrt
endif
/*
* Proview $Id: rs_nmps_mirror.c,v 1.3 2005-10-25 15:28:10 claes Exp $
* Proview $Id: rs_nmps_mirror.c,v 1.4 2006-01-12 05:57:42 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -71,9 +71,8 @@
#include "rt_errh.h"
#include "rt_gdh_msg.h"
#include "rt_hash_msg.h"
#include "rs_nmps.h"
#include "nmps.h"
#include "rs_nmps_msg.h"
#include "rs_sutl.h"
/*_Globala variabler______________________________________________________*/
......@@ -2113,7 +2112,7 @@ int main()
sts = nmps_cellmir_init( mirctx);
if (EVEN(sts)) LogAndExit( sts);
sutl_sleep( 5.0);
time_Sleep( 5.0);
scantime = mirctx->mirrorconfig->ScanTime;
for (;;)
{
......@@ -2136,7 +2135,7 @@ int main()
mirctx->mirrorconfig->LoopCount++;
sutl_sleep( scantime);
time_Sleep( scantime);
mirctx->first_scan = 0;
if ( mirctx->mirrorconfig->Initialize)
......
......@@ -2,8 +2,8 @@ ifndef link_rule_mk
link_rule_mk := 1
link = $(ld) $(elinkflags) $(domap) -o $(export_exe) \
$(export_obj) $(objects) $(rt_msg_objs) \
$(pwr_eobj)/rt_io_user.o -lpwr_rs\
$(export_obj) $(objects) $(rt_msg_eobjs) \
$(pwr_eobj)/rt_io_user.o -lpwr_nmps\
-lpwr_rt -lpwr_co -lpwr_msg_dummy -lrpcsvc -lpthread -lm -lrt
endif
/*
* Proview $Id: rs_nmps_trans.c,v 1.7 2005-10-25 15:28:10 claes Exp $
* Proview $Id: rs_nmps_trans.c,v 1.8 2006-01-12 05:57:43 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -64,7 +64,7 @@
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_nmpsclasses.h"
#include "pwr_ssabclasses.h"
#include "pwr_remoteclasses.h"
#include "co_cdh.h"
#include "co_time.h"
#include "rt_gdh.h"
......@@ -78,10 +78,8 @@
#include "rt_plc_utl.h"
#include "rt_gdh_msg.h"
#include "rt_hash_msg.h"
#include "rs_nmps_cnv.h"
#include "rs_sutl.h"
#include "nmps_cnv.h"
#include "rs_nmps_msg.h"
#include "rs_ssabutil.h"
/*_Globala variabler______________________________________________________*/
......@@ -327,6 +325,7 @@ static int nmpstrans_req_accept_detected( trans_ctx transctx,
nmpstrans_t_req_list *req_ptr);
static int nmpstrans_req_reset_detected( trans_ctx transctx,
nmpstrans_t_req_list *req_ptr);
static int ssabutil_lopnr_check( pwr_tInt32 lopnr);
int nmpstrans_check_checksum( int key)
......@@ -2864,3 +2863,51 @@ int main()
}
}
}
static pwr_tInt32 ssabutil_chksum_calculate( pwr_tInt32 value,
pwr_tInt16 *weights,
pwr_tInt16 num_figures)
{
pwr_tInt16 sum; /* Arbetsvariabel */
pwr_tInt16 *weightP; /* Pekar p vikter */
/* Berkna perkaren till entalssiffran */
weightP = weights + num_figures - 1;
/* Berkna den viktade summan av siffrorona i talet */
for (sum=0; num_figures>0; num_figures--) {
sum += (value % 10) * (*weightP--);
value /= 10 ;
}
/* Berkna skillnaden till nrmast hgre tiotal */
sum = ((sum/10) + 1)*10 - sum;
if (sum == 10) sum = 0;
return (sum);
}
static pwr_tInt32 ssabutil_chksum_lop( pwr_tInt32 lopnummer)
{
static pwr_tInt16 lop_fig_weights[6] = {1,7,3,1,7,3};
lopnummer=lopnummer*10 +
ssabutil_chksum_calculate( lopnummer, lop_fig_weights, 6);
return(lopnummer);
}
static int ssabutil_lopnr_check( pwr_tInt32 lopnr)
{
pwr_tInt32 tst_lopnr;
tst_lopnr = lopnr / 10;
tst_lopnr = ssabutil_chksum_lop( tst_lopnr);
if ( tst_lopnr != lopnr)
return 0;
else
return 1;
}
/*
* Proview $Id: nmps.h,v 1.1 2006-01-12 05:57:43 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.
*/
#define NMPS_CELL_SIZE 30 /* Number of dataobject in
NMpsCell och NMpsSelectCell */
#define NMPS_CELLMIR_SIZE 30 /* Number of dataobject in
NMpsMirrorCell */
#define MMPS_CELLMIR_ORIGCELL_SIZE 10 /* Size of the origcell-array
in NMpsMirrorCell */
#define NMPS_OPTYPE_EXTINSERT 0
#define NMPS_OPTYPE_EXTINSERT_IDX 1
#define NMPS_OPTYPE_EXTDELETE 2
#define NMPS_OPTYPE_EXTDELETE_IDX 3
#define NMPS_OPTYPE_EXTDELETE_OBJID 4
#define NMPS_OPTYPE_EXTSELECT_OBJID 5
#define NMPS_OPTYPE_EXTINSERTSELECT 6
#define NMPS_OPTYPE_EXTUNSELECT_OBJID 7
#define NMPS_OPTYPE_EXTMOVEFORW_OBJID 8
#define NMPS_OPTYPE_EXTMOVEBACKW_OBJID 9
#define NMPS_OPTYPE_EXTREMOVE_OBJID 10
#define NMPS_CELL_RELOADDONE 1
#define NMPS_CELL_INITIALIZED 2
#define NMPS_CELLFUNC_SINGELSELECT 1
#define NMPS_CELLFUNC_ONESELECT 2
#define NMPS_CELLFUNC_DELETE 4
#define NMPS_CELLFUNC_RESETDELETE 8
#define NMPS_CELLFUNC_BACKUP 16
#define NMPS_TRPFUNC_UNIT 1
#define NMPS_TRPFUNC_ALL 2
#define NMPS_TRPFUNC_ALLEMPTY 4
#define NMPS_TRPFUNC_TRIGGRESET 8
#define NMPS_TRPFUNC_SLOW 16
#define NMPS_TRPFUNC_LEVEL 32
/* Data structure for one dataobjekt in a NMpsCell and NMpsSelectCell */
typedef struct {
pwr_tFloat32 *DataP;
pwr_tObjid Data_ObjId;
pwr_tBoolean Data_Front;
pwr_tBoolean Data_Back;
gdh_tDlid Data_Dlid;
pwr_tBoolean Data_Select;
pwr_tBoolean Data_OldSelect;
} plc_t_DataInfo;
/* Data structure for the DLpointer and the objid in a Cell */
typedef struct {
pwr_tFloat32 *DataP;
pwr_tObjid Data_ObjId;
} plc_t_DataInfoBrief;
/* Data structure for one dataobjekt in a NMpsMirrorCell */
typedef struct {
pwr_tFloat32 *DataP;
pwr_tObjid Data_ObjId;
gdh_tDlid Data_Dlid;
} plc_t_DataInfoMirCell;
/* Data structure for the copyarea in a NMpsMirrorCell */
typedef struct {
plc_t_DataInfoMirCell datainfo[ NMPS_CELLMIR_SIZE];
} nmps_t_mircell_copyarea;
int nmps_RemoveData( pwr_tObjid objid);
int nmps_RemoveAndDeleteData( pwr_tObjid objid);
/*
* Proview $Id: nmps_appl.c,v 1.1 2006-01-12 05:57:43 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.
*/
/*************************************************************************
*
* PROGRAM rs_nmps_appl
*
* Modifierad
* 971002 Claes Sjfors Skapad
*
* Funktion: Applikationsgrnssnitt mot Nmps.
**************************************************************************/
/*_Include filer_________________________________________________________*/
#ifdef OS_VMS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include <libdef.h>
#include <starlet.h>
#include <lib$routines.h>
#endif
#ifdef OS_ELN
#include stdio
#include stdlib
#include string
#include math
#include float
#include libdef
#include lib$routines
#include starlet
#endif
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_nmpsclasses.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "rt_errh.h"
#include "rt_gdh_msg.h"
#include "rt_hash_msg.h"
#include "rs_nmps_msg.h"
#include "nmps.h"
#include "nmps_appl.h"
/* Global functions________________________________________________________*/
#define ODD(a) (((int)(a) & 1) != 0)
#define EVEN(a) (((int)(a) & 1) == 0)
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
#ifndef __ALPHA
#define abs(Dragon) ((Dragon) >= 0 ? (Dragon) : (-(Dragon)))
#endif
#define LogAndReturn( status1, status2) \
{\
errh_CErrLog(status1, errh_ErrArgMsg(status2), NULL);\
return status2;\
}
#define Log( status1, status2) \
{\
errh_CErrLog(status1, errh_ErrArgMsg(status2), NULL);\
}
#define NMPS_CELLBUFF_SIZE 1000 /* This must be >= the size of
the largest cell */
typedef struct nmpsappl_s_data_list {
pwr_tObjid objid;
pwr_tString80 name;
unsigned int possession;
pwr_tAddress object_ptr;
gdh_tDlid subid;
int remove;
int pending_remove;
struct nmpsappl_s_data_list *prev_ptr;
struct nmpsappl_s_data_list *next_ptr;
} nmpsappl_t_data_list;
typedef struct nmpsappl_s_basectx {
nmpsappl_t_cellist *cellist;
int cellist_count;
nmpsappl_t_ctx applctx_list;
int applctx_count;
nmpsappl_t_data_list *datalist;
} *nmpsappl_t_basectx;
/*_Globala variabler______________________________________________________*/
static nmpsappl_t_basectx nmpsappl_basectx = 0;
/*_Local functions________________________________________________________*/
static pwr_tStatus nmpsappl_data_db_create(
nmpsappl_t_data_list **data_list,
pwr_tObjid objid,
int options,
nmpsappl_t_data_list **datalist_ptr);
static pwr_tStatus nmpsappl_data_db_delete(
nmpsappl_t_data_list **data_list,
nmpsappl_t_data_list *data_ptr);
/****************************************************************************
* Name: nmpsappl_data_db_create()
*
* Type pwr_tStatus
*
* Type Parameter IOGF Description
*
* Description:
* Create an entry in the datalist for an objid.
*
**************************************************************************/
static pwr_tStatus nmpsappl_data_db_create(
nmpsappl_t_data_list **data_list,
pwr_tObjid objid,
int options,
nmpsappl_t_data_list **datalist_ptr)
{
nmpsappl_t_data_list *next_ptr;
pwr_tStatus sts;
char name[80];
pwr_sAttrRef attrref;
pwr_tAddress object_ptr;
gdh_tDlid subid;
/* Get a direct link to the original object */
memset( &attrref, 0, sizeof(attrref));
attrref.Objid = objid;
sts = gdh_DLRefObjectInfoAttrref( &attrref, &object_ptr, &subid);
if (EVEN(sts)) return sts;
if ( options & nmpsappl_mOption_NamePath)
sts = gdh_ObjidToName( objid, name, sizeof(name), cdh_mName_path);
else
sts = gdh_ObjidToName( objid, name, sizeof(name), cdh_mName_object);
if ( EVEN(sts)) return sts;
*datalist_ptr = calloc( 1, sizeof( nmpsappl_t_data_list));
if ( *datalist_ptr == 0) return NMPS__NOMEMORY;
(*datalist_ptr)->object_ptr = object_ptr;
(*datalist_ptr)->subid = subid;
(*datalist_ptr)->objid = objid;
strcpy( (*datalist_ptr)->name, name);
/* Insert first in list */
next_ptr = *data_list;
if ( next_ptr != NULL)
next_ptr->prev_ptr = *datalist_ptr;
(*datalist_ptr)->next_ptr = next_ptr;
*data_list = *datalist_ptr;
return NMPS__SUCCESS;
}
/****************************************************************************
* Name: nmpsappl_data_db_delete()
*
* Type pwr_tStatus
*
* Type Parameter IOGF Description
*
* Description:
* Delete an entry in the datalist.
*
**************************************************************************/
static pwr_tStatus nmpsappl_data_db_delete(
nmpsappl_t_data_list **data_list,
nmpsappl_t_data_list *data_ptr)
{
int sts;
sts = gdh_DLUnrefObjectInfo ( data_ptr->subid);
if ( data_ptr == *data_list)
{
/* Change the root */
*data_list = data_ptr->next_ptr;
if ( *data_list)
(*data_list)->prev_ptr = 0;
}
if ( data_ptr->prev_ptr )
data_ptr->prev_ptr->next_ptr = data_ptr->next_ptr;
if ( data_ptr->next_ptr )
data_ptr->next_ptr->prev_ptr = data_ptr->prev_ptr;
free( data_ptr);
return NMPS__SUCCESS;
}
/****************************************************************************
* Name: nmpsappl_cell_init()
*
* Type pwr_tStatus
*
* Type Parameter IOGF Description
*
* Description:
*
**************************************************************************/
static pwr_tStatus nmpsappl_cell_init(
char *cell_name,
pwr_tObjid *orig_objid,
void **orig_cell,
gdh_tSubid *orig_subid,
pwr_tClassId *orig_class)
{
pwr_sAttrRef attrref;
pwr_tStatus sts;
pwr_tObjid cell_objid;
sts = gdh_NameToObjid( cell_name, &cell_objid);
if ( EVEN(sts)) return NMPS__APPLCELL;
/* It might already have been stored */
memset( &attrref, 0, sizeof(attrref));
attrref.Objid = cell_objid;
sts = gdh_GetObjectClass ( attrref.Objid, orig_class);
if ( EVEN(sts)) return sts;
/* Link to object */
sts = gdh_DLRefObjectInfoAttrref( &attrref,
(pwr_tAddress *) orig_cell, orig_subid);
if (EVEN(sts)) return NMPS__APPLCELL;
return NMPS__SUCCESS;
}
pwr_tStatus nmpsappl_MirrorInit( pwr_tString80 *cell_array,
unsigned long options,
nmpsappl_t_ctx *ctx)
{
pwr_tString80 *cellname;
nmpsappl_t_basectx basectx;
nmpsappl_t_ctx applctx;
nmpsappl_t_cellist *cellist_ptr;
nmpsappl_t_cellist *c_ptr;
int found;
int sts;
int maxsize;
int i;
if ( nmpsappl_basectx == 0)
{
/* Base context is not yet created */
nmpsappl_basectx = calloc( 1, sizeof( *nmpsappl_basectx));
if (nmpsappl_basectx == 0)
return 0;
}
basectx = nmpsappl_basectx;
if ( basectx->applctx_count >= NMPSAPPL_APPLSESS_MAX)
return NMPS__APPLSESSMAX;
/* Create a context for this applikation call */
applctx = calloc( 1, sizeof( *applctx));
if ( applctx == 0)
return 0;
/* Insert applctx in basectx */
applctx->next = basectx->applctx_list;
basectx->applctx_list = applctx;
applctx->index = basectx->applctx_count;
applctx->index_mask = 1 << basectx->applctx_count;
basectx->applctx_count++;
*ctx = applctx;
/* Add cells to cellist */
cellname = cell_array;
while ( strcmp( (char *) cellname, "") != 0)
{
cdh_ToUpper( (char *) cellname, (char *) cellname);
/* Check if cell already is inserted */
cellist_ptr = basectx->cellist;
found = 0;
while ( cellist_ptr)
{
if ( strcmp( (char *) cellname, cellist_ptr->name) == 0)
{
found = 1;
break;
}
cellist_ptr = cellist_ptr->next;
}
if ( !found)
{
/* Insert cell last position in cellist */
cellist_ptr = calloc( 1, sizeof( nmpsappl_t_cellist));
strcpy( (char *) cellist_ptr->name, (char *) cellname);
sts = nmpsappl_cell_init( cellist_ptr->name,
&cellist_ptr->objid,
&cellist_ptr->object_ptr,
&cellist_ptr->subid,
&cellist_ptr->classid);
if (EVEN(sts)) return sts;
c_ptr = basectx->cellist;
if ( !c_ptr)
basectx->cellist = cellist_ptr;
else
{
while ( c_ptr->next)
c_ptr++;
c_ptr->next = cellist_ptr;
}
basectx->cellist_count++;
}
if ( applctx->cellist_count < NMPSAPPL_CELLIST_MAX )
{
applctx->cellist[ applctx->cellist_count] = cellist_ptr;
cellist_ptr->index_mask[ applctx->index] = 1 << applctx->cellist_count;
applctx->cellist_count++;
}
else
return NMPS__APPLCELLIST; /* Cellist to large */
cellname++;
}
/* Calculate the total size of the cell's in the list */
applctx->total_cellsize = 0;
for ( i = 0; i < applctx->cellist_count; i++)
{
cellist_ptr = applctx->cellist[i];
switch ( cellist_ptr->classid)
{
case pwr_cClass_NMpsCell:
case pwr_cClass_NMpsStoreCell:
maxsize =
((pwr_sClass_NMpsCell *) cellist_ptr->object_ptr)->MaxSize;
applctx->total_cellsize += maxsize;
cellist_ptr->tmp_size = sizeof( pwr_sClass_NMpsCell) -
sizeof( plc_t_DataInfo) * ( NMPS_CELL_SIZE - maxsize);
break;
case pwr_cClass_NMpsMirrorCell:
maxsize =
((pwr_sClass_NMpsMirrorCell *) cellist_ptr->object_ptr)->MaxSize;
applctx->total_cellsize += maxsize;
cellist_ptr->tmp_size = sizeof( pwr_sClass_NMpsMirrorCell) -
sizeof( plc_t_DataInfoMirCell) * ( NMPS_CELLMIR_SIZE - maxsize)-
sizeof( nmps_t_mircell_copyarea);
break;
}
cellist_ptr->tmp_cell = (void *) calloc( 1, cellist_ptr->tmp_size);
}
/* Allocate memory for the data objects array in applctx */
if ( options & nmpsappl_mOption_Remove)
/* Remove requires the dubbel size */
applctx->datainfo =
(nmpsappl_t_datainfo *) calloc( applctx->total_cellsize * 2,
sizeof(nmpsappl_t_datainfo));
else
applctx->datainfo =
(nmpsappl_t_datainfo *) calloc( applctx->total_cellsize,
sizeof(nmpsappl_t_datainfo));
applctx->options = options;
return NMPS__SUCCESS;
}
pwr_tStatus nmpsappl_Mirror( nmpsappl_t_ctx applctx,
int *data_count,
nmpsappl_t_datainfo **datainfo)
{
int i, j, k;
int found;
nmpsappl_t_cellist *cellist_ptr;
nmpsappl_t_data_list *data_ptr;
nmpsappl_t_data_list *data_next_ptr;
int sts;
/* Copy cell-objects into the temporary buffer, and hope that
we will not be interuppted by the plc-program */
for ( i = 0; i < applctx->cellist_count; i++)
{
cellist_ptr = applctx->cellist[i];
memcpy( cellist_ptr->tmp_cell, cellist_ptr->object_ptr,
cellist_ptr->tmp_size);
}
applctx->data_count = 0;
for ( k = 0; k < applctx->cellist_count; k++)
{
cellist_ptr = applctx->cellist[k];
switch ( cellist_ptr->classid)
{
case pwr_cClass_NMpsCell:
case pwr_cClass_NMpsStoreCell:
{
pwr_sClass_NMpsCell *object_ptr;
plc_t_DataInfo *data_block_ptr;
object_ptr = (pwr_sClass_NMpsCell *) cellist_ptr->tmp_cell;
if ( !(object_ptr->ReloadDone & NMPS_CELL_INITIALIZED))
continue;
data_block_ptr = (plc_t_DataInfo *) &object_ptr->Data1P;
if ( applctx->options & nmpsappl_mOption_ReverseOrder)
data_block_ptr += object_ptr->LastIndex - 1;
for ( i = 0; i < object_ptr->LastIndex; i++)
{
/* Check that objid is not already inserted */
found = 0;
for ( j = 0; j < applctx->data_count; j++)
{
if ( cdh_ObjidIsEqual( applctx->datainfo[j].objid,
data_block_ptr->Data_ObjId))
{
found = 1;
break;
}
}
if ( !found)
{
applctx->datainfo[applctx->data_count].objid =
data_block_ptr->Data_ObjId;
applctx->datainfo[applctx->data_count].front =
data_block_ptr->Data_Front;
applctx->datainfo[applctx->data_count].back =
data_block_ptr->Data_Back;
applctx->datainfo[applctx->data_count].select =
data_block_ptr->Data_Select;
applctx->datainfo[applctx->data_count].cell_mask =
cellist_ptr->index_mask[ applctx->index];
applctx->datainfo[applctx->data_count].removed = 0;
applctx->data_count++;
}
else
{
applctx->datainfo[applctx->data_count].front |=
data_block_ptr->Data_Front;
applctx->datainfo[applctx->data_count].back |=
data_block_ptr->Data_Back;
if ( data_block_ptr->Data_Select)
applctx->datainfo[applctx->data_count].select = 1;
applctx->datainfo[applctx->data_count].cell_mask |=
cellist_ptr->index_mask[ applctx->index];
}
if ( applctx->options & nmpsappl_mOption_ReverseOrder)
data_block_ptr--;
else
data_block_ptr++;
}
break;
}
case pwr_cClass_NMpsMirrorCell:
{
pwr_sClass_NMpsMirrorCell *object_ptr;
plc_t_DataInfoMirCell *data_block_ptr;
object_ptr = (pwr_sClass_NMpsMirrorCell *) cellist_ptr->tmp_cell;
data_block_ptr = (plc_t_DataInfoMirCell *) &object_ptr->Data1P;
for ( i = 0; i < object_ptr->LastIndex; i++)
{
/* Check that objid is not already inserted */
found = 0;
for ( j = 0; j < i; j++)
{
if ( cdh_ObjidIsEqual( applctx->datainfo[j].objid,
data_block_ptr->Data_ObjId))
{
found = 1;
break;
}
}
if ( !found)
{
applctx->datainfo[applctx->data_count].objid =
data_block_ptr->Data_ObjId;
applctx->datainfo[applctx->data_count].select = 0;
applctx->datainfo[applctx->data_count].front = 0;
applctx->datainfo[applctx->data_count].back = 0;
applctx->datainfo[applctx->data_count].cell_mask =
cellist_ptr->index_mask[ applctx->index];
applctx->datainfo[applctx->data_count].removed = 0;
applctx->data_count++;
}
else
{
applctx->datainfo[applctx->data_count].cell_mask |=
cellist_ptr->index_mask[ applctx->index];
}
data_block_ptr++;
}
break;
}
}
}
/* Insert new data-object in the data db, or find the old ones */
/* Set the remove flag for all the dataobjects of this applctx */
data_ptr = nmpsappl_basectx->datalist;
while( data_ptr)
{
if ( data_ptr->possession & applctx->index_mask)
data_ptr->remove = 1;
data_ptr = data_ptr->next_ptr;
}
for ( i = 0; i <applctx->data_count; i++)
{
/* Try to find the data-object */
found = 0;
data_ptr = nmpsappl_basectx->datalist;
while( data_ptr)
{
if ( cdh_ObjidIsEqual( applctx->datainfo[i].objid, data_ptr->objid))
{
if ( data_ptr->possession & applctx->index_mask)
{
/* It already belongs to this application session */
if ( data_ptr->pending_remove)
/* The object has reappleard */
data_ptr->pending_remove = 0;
applctx->datainfo[i].object_ptr = data_ptr->object_ptr;
data_ptr->remove = 0;
applctx->datainfo[i].newdata = 0;
}
else
{
/* A new object for this session, mark possession */
if ( data_ptr->pending_remove)
{
/* The object has reappleard from another session */
data_ptr->pending_remove = 0;
data_ptr->possession = 0;
}
data_ptr->possession |= applctx->index_mask;
applctx->datainfo[i].object_ptr = data_ptr->object_ptr;
applctx->datainfo[i].newdata = 1;
data_ptr->remove = 0;
/* Insert in new data list */
}
strcpy( applctx->datainfo[i].name, data_ptr->name);
found = 1;
break;
}
data_ptr = data_ptr->next_ptr;
}
if ( !found)
{
/* A new object, insert it into the data database */
sts = nmpsappl_data_db_create( &nmpsappl_basectx->datalist,
applctx->datainfo[i].objid, applctx->options,
&data_ptr);
if ( EVEN(sts)) return sts;
data_ptr->possession |= applctx->index_mask;
applctx->datainfo[i].object_ptr = data_ptr->object_ptr;
applctx->datainfo[i].newdata = 1;
strcpy( applctx->datainfo[i].name, data_ptr->name);
/* Insert in new data list */
}
}
/* Mark objects for remove that was previously possessed by this
session only */
data_ptr = nmpsappl_basectx->datalist;
while( data_ptr)
{
if ( data_ptr->remove &&
data_ptr->possession & applctx->index_mask)
{
if ( data_ptr->possession == applctx->index_mask &&
data_ptr->pending_remove)
{
/* Remove the object from the database */
data_next_ptr = data_ptr->next_ptr;
sts = nmpsappl_data_db_delete( &nmpsappl_basectx->datalist,
data_ptr);
if ( EVEN(sts)) return sts;
data_ptr = data_next_ptr;
continue;
}
else
{
/* Remove next scan */
if ( data_ptr->possession == applctx->index_mask)
data_ptr->pending_remove = 1;
else
data_ptr->possession &= ~applctx->index_mask;
if ( applctx->options & nmpsappl_mOption_Remove)
{
/* Add the removed to the list */
applctx->datainfo[applctx->data_count].objid =
data_ptr->objid;
applctx->datainfo[applctx->data_count].select = 0;
applctx->datainfo[applctx->data_count].front = 0;
applctx->datainfo[applctx->data_count].back = 0;
applctx->datainfo[applctx->data_count].cell_mask = 0;
applctx->datainfo[applctx->data_count].removed = 1;
applctx->datainfo[i].object_ptr = data_ptr->object_ptr;
applctx->datainfo[i].newdata = 0;
strcpy( applctx->datainfo[i].name, data_ptr->name);
applctx->data_count++;
}
}
}
data_ptr = data_ptr->next_ptr;
}
*datainfo = applctx->datainfo;
*data_count = applctx->data_count;
return NMPS__SUCCESS;
}
pwr_tStatus nmpsappl_RemoveData(
nmpsappl_t_ctx applctx,
pwr_tObjid objid)
{
int k;
nmpsappl_t_cellist *cellist_ptr;
for ( k = 0; k < applctx->cellist_count; k++)
{
cellist_ptr = applctx->cellist[k];
switch ( cellist_ptr->classid)
{
case pwr_cClass_NMpsCell:
case pwr_cClass_NMpsStoreCell:
{
pwr_sClass_NMpsCell *object_ptr;
object_ptr = (pwr_sClass_NMpsCell *) cellist_ptr->object_ptr;
object_ptr->ExternOpType = NMPS_OPTYPE_EXTDELETE_OBJID;
object_ptr->ExternObjId = objid;
object_ptr->ExternFlag = 1;
break;
}
default:
break;
}
}
return NMPS__SUCCESS;
}
pwr_tStatus nmpsappl_RemoveAndDeleteData(
nmpsappl_t_ctx applctx,
pwr_tObjid objid)
{
int sts, k;
nmpsappl_t_cellist *cellist_ptr;
for ( k = 0; k < applctx->cellist_count; k++)
{
cellist_ptr = applctx->cellist[k];
switch ( cellist_ptr->classid)
{
case pwr_cClass_NMpsCell:
case pwr_cClass_NMpsStoreCell:
{
pwr_sClass_NMpsCell *object_ptr;
object_ptr = (pwr_sClass_NMpsCell *) cellist_ptr->object_ptr;
object_ptr->ExternOpType = NMPS_OPTYPE_EXTDELETE_OBJID;
object_ptr->ExternObjId = objid;
object_ptr->ExternFlag = 1;
break;
}
default:
break;
}
}
sts = gdh_DeleteObject(objid);
if ( EVEN(sts)) return sts;
return NMPS__SUCCESS;
}
pwr_tStatus nmpsappl_SelectData(
nmpsappl_t_ctx applctx,
pwr_tObjid objid)
{
int k;
nmpsappl_t_cellist *cellist_ptr;
for ( k = 0; k < applctx->cellist_count; k++)
{
cellist_ptr = applctx->cellist[k];
switch ( cellist_ptr->classid)
{
case pwr_cClass_NMpsStoreCell:
{
pwr_sClass_NMpsCell *object_ptr;
object_ptr = (pwr_sClass_NMpsCell *) cellist_ptr->object_ptr;
object_ptr->ExternOpType = NMPS_OPTYPE_EXTSELECT_OBJID;
object_ptr->ExternObjId = objid;
object_ptr->ExternFlag = 1;
break;
}
default:
break;
}
}
return NMPS__SUCCESS;
}
pwr_tStatus nmpsappl_TransportData(
nmpsappl_t_ctx applctx,
pwr_tObjid objid,
unsigned int from_cell_mask,
unsigned int to_cell_mask)
{
int k;
unsigned int mask;
nmpsappl_t_cellist *cellist_ptr;
/* Check that to cell is not busy or full */
mask = 1;
for ( k = 0; k < applctx->cellist_count; k++, mask = mask << 1)
{
if (!( mask & to_cell_mask))
continue;
cellist_ptr = applctx->cellist[k];
switch ( cellist_ptr->classid)
{
case pwr_cClass_NMpsCell:
case pwr_cClass_NMpsStoreCell:
{
pwr_sClass_NMpsCell *object_ptr;
object_ptr = (pwr_sClass_NMpsCell *) cellist_ptr->object_ptr;
if ( object_ptr->ExternFlag)
return NMPS__CELLEXTERNBUSY;
if ( object_ptr->CellFull)
return NMPS__CELLFULL;
break;
}
default:
break;
}
break;
}
/* Remove data first */
mask = 1;
for ( k = 0; k < applctx->cellist_count; k++, mask = mask << 1)
{
if (!( mask & from_cell_mask))
continue;
cellist_ptr = applctx->cellist[k];
switch ( cellist_ptr->classid)
{
case pwr_cClass_NMpsCell:
case pwr_cClass_NMpsStoreCell:
{
pwr_sClass_NMpsCell *object_ptr;
object_ptr = (pwr_sClass_NMpsCell *) cellist_ptr->object_ptr;
if ( object_ptr->ExternFlag)
return NMPS__CELLEXTERNBUSY;
object_ptr->ExternOpType = NMPS_OPTYPE_EXTREMOVE_OBJID;
object_ptr->ExternObjId = objid;
object_ptr->ExternFlag = 1;
break;
}
default:
break;
}
}
/* Insert data */
mask = 1;
for ( k = 0; k < applctx->cellist_count; k++, mask = mask << 1)
{
if (!( mask & to_cell_mask))
continue;
cellist_ptr = applctx->cellist[k];
switch ( cellist_ptr->classid)
{
case pwr_cClass_NMpsCell:
case pwr_cClass_NMpsStoreCell:
{
pwr_sClass_NMpsCell *object_ptr;
object_ptr = (pwr_sClass_NMpsCell *) cellist_ptr->object_ptr;
if ( object_ptr->ExternFlag)
return NMPS__CELLEXTERNBUSY;
if ( object_ptr->CellFull)
return NMPS__CELLFULL;
object_ptr->ExternOpType = NMPS_OPTYPE_EXTINSERT;
object_ptr->ExternObjId = objid;
object_ptr->ExternFlag = 1;
break;
}
default:
break;
}
break;
}
return NMPS__SUCCESS;
}
pwr_tStatus nmpsappl_InsertData(
nmpsappl_t_ctx applctx,
pwr_tObjid objid,
unsigned int cell_mask)
{
int k;
unsigned int mask;
nmpsappl_t_cellist *cellist_ptr;
/* Insert data */
mask = 1;
for ( k = 0; k < applctx->cellist_count; k++, mask = mask << 1)
{
if (!( mask & cell_mask))
continue;
cellist_ptr = applctx->cellist[k];
switch ( cellist_ptr->classid)
{
case pwr_cClass_NMpsCell:
case pwr_cClass_NMpsStoreCell:
{
pwr_sClass_NMpsCell *object_ptr;
object_ptr = (pwr_sClass_NMpsCell *) cellist_ptr->object_ptr;
if ( object_ptr->ExternFlag)
return NMPS__CELLEXTERNBUSY;
object_ptr->ExternOpType = NMPS_OPTYPE_EXTINSERT;
object_ptr->ExternObjId = objid;
object_ptr->ExternFlag = 1;
break;
}
default:
break;
}
break;
}
return NMPS__SUCCESS;
}
pwr_tStatus nmpsappl_RemoveAndKeepData(
nmpsappl_t_ctx applctx,
pwr_tObjid objid,
unsigned int cell_mask)
{
int k;
unsigned int mask;
nmpsappl_t_cellist *cellist_ptr;
/* Remove data first */
mask = 1;
for ( k = 0; k < applctx->cellist_count; k++, mask = mask << 1)
{
if (!( mask & cell_mask))
continue;
cellist_ptr = applctx->cellist[k];
switch ( cellist_ptr->classid)
{
case pwr_cClass_NMpsCell:
case pwr_cClass_NMpsStoreCell:
{
pwr_sClass_NMpsCell *object_ptr;
object_ptr = (pwr_sClass_NMpsCell *) cellist_ptr->object_ptr;
if ( object_ptr->ExternFlag)
return NMPS__CELLEXTERNBUSY;
object_ptr->ExternOpType = NMPS_OPTYPE_EXTREMOVE_OBJID;
object_ptr->ExternObjId = objid;
object_ptr->ExternFlag = 1;
break;
}
default:
break;
}
}
return NMPS__SUCCESS;
}
/*
* Proview $Id: nmps_appl.h,v 1.1 2006-01-12 05:57:43 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 ra_nmps_appl_h
#define ra_nmps_appl_h
/* ra_nmps_appl.h -- <short description>
NMps API. */
#if defined __cplusplus
extern "C" {
#endif
#define NMPSAPPL_CELLIST_MAX 32 /* Max number of cells in a
appl_init call */
#define NMPSAPPL_APPLSESS_MAX 32 /* Max number of application
sessions */
#define nmpsappl_mOption_Remove (1 << 0)
#define nmpsappl_mOption_NamePath (1 << 1)
#define nmpsappl_mOption_ReverseOrder (1 << 2)
typedef struct nmpsappl_s_cellist {
pwr_tString80 name;
pwr_tObjid objid;
pwr_tAddress object_ptr;
gdh_tDlid subid;
pwr_tClassId classid;
unsigned long index_mask[NMPSAPPL_APPLSESS_MAX];
int tmp_size;
void *tmp_cell;
struct nmpsappl_s_cellist *next;
} nmpsappl_t_cellist;
typedef struct {
pwr_tObjid objid;
pwr_tString80 name;
pwr_tAddress object_ptr;
pwr_tBoolean select;
pwr_tBoolean front;
pwr_tBoolean back;
pwr_tBoolean newdata;
pwr_tBoolean removed;
unsigned long cell_mask;
} nmpsappl_t_datainfo;
typedef struct nmpsappl_s_ctx {
nmpsappl_t_cellist *cellist[NMPSAPPL_CELLIST_MAX];
unsigned long options;
int index;
unsigned long index_mask;
int cellist_count;
int total_cellsize;
int data_count;
nmpsappl_t_datainfo *datainfo;
struct nmpsappl_s_ctx *next;
} *nmpsappl_t_ctx;
pwr_tStatus nmpsappl_MirrorInit( pwr_tString80 *cell_array,
unsigned long options,
nmpsappl_t_ctx *ctx);
pwr_tStatus nmpsappl_Mirror( nmpsappl_t_ctx applctx,
int *data_count,
nmpsappl_t_datainfo **datainfo);
pwr_tStatus nmpsappl_RemoveData(
nmpsappl_t_ctx applctx,
pwr_tObjid objid);
pwr_tStatus nmpsappl_RemoveAndDeleteData(
nmpsappl_t_ctx applctx,
pwr_tObjid objid);
pwr_tStatus nmpsappl_SelectData(
nmpsappl_t_ctx applctx,
pwr_tObjid objid);
pwr_tStatus nmpsappl_TransportData(
nmpsappl_t_ctx applctx,
pwr_tObjid objid,
unsigned int from_cell_mask,
unsigned int to_cell_mask);
pwr_tStatus nmpsappl_InsertData(
nmpsappl_t_ctx applctx,
pwr_tObjid objid,
unsigned int cell_mask);
pwr_tStatus nmpsappl_RemoveAndKeepData(
nmpsappl_t_ctx applctx,
pwr_tObjid objid,
unsigned int cell_mask);
#if defined __cplusplus
}
#endif
#endif
/*
* Proview $Id: nmps_cnv.c,v 1.1 2006-01-12 05:57:43 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.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "pwr.h"
#include "pwr_class.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "rt_errh.h"
#include "pwr_nmpsclasses.h"
#include "nmps_cnv.h"
#include "rs_cnv_msg.h"
#include "co_dcli.h"
#define ODD(a) (((int)(a) & 1) != 0)
#define EVEN(a) (((int)(a) & 1) == 0)
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
#define CNV_CONVDEFTYPE_OBJ 0
#define CNV_CONVDEFTYPE_FILE 1
#define CNV_CONVDEFTYPE_CLASS 2
#define CNV_CONVDEF_SIZE 200
static int cnv_remove_blank( char *out_str, char *in_str);
static int cnv_string_to_partype( char *string,
int args,
char *third_arg,
cnv_eParType *type,
int *size,
char *format);
static int cnv_convtable_add( cnv_eParType to_type,
cnv_eParType from_type,
int to_offset,
int from_offset,
int to_size,
int from_size,
char *to_format,
char *from_format,
cnv_t_conv_table *conv_table,
int *conv_table_count);
static int cnv_convtable_compress( cnv_t_conv_table *conv_table,
int *conv_table_count);
static int cnv_read_line( char *line,
int maxsize,
FILE *file);
static int cnv_ReadConvTable( char *filename,
pwr_sClass_ConvDef **convdef);
static int cnv_GetConvTableFromClass(
pwr_tObjid class,
pwr_sClass_ConvDef **convdef);
int cnv_CreateConvTable(
pwr_sClass_ConvDef *to_convdef,
pwr_sClass_ConvDef *from_convdef,
cnv_t_conv_table *conv_table,
int *conv_table_count)
{
char out_str[5][80];
int nr;
int i, j;
cnv_eParType to_type[CNV_CONVDEF_SIZE];
int to_offset[CNV_CONVDEF_SIZE];
int to_size[CNV_CONVDEF_SIZE];
pwr_tString80 to_param[CNV_CONVDEF_SIZE];
pwr_tString80 to_format[CNV_CONVDEF_SIZE];
cnv_eParType from_type[CNV_CONVDEF_SIZE];
int from_offset[CNV_CONVDEF_SIZE];
int from_size[CNV_CONVDEF_SIZE];
pwr_tString80 from_param[CNV_CONVDEF_SIZE];
pwr_tString80 from_format[CNV_CONVDEF_SIZE];
int from_convdef_count;
int to_convdef_count;
char type_str[80];
int sts;
/* Search trough parameternames in the to convdef
and match them with the from convdef */
from_convdef_count = 0;
for ( i = 0; i < CNV_CONVDEF_SIZE; i++)
{
cnv_remove_blank( from_convdef->Param[i], from_convdef->Param[i]);
if ( from_convdef->Param[i][0] == 0 )
break;
if ( from_convdef->Param[i][0] == '!')
continue;
nr = dcli_parse( from_convdef->Param[i], " ", "", (char *)out_str,
sizeof( out_str) / sizeof( out_str[0]), sizeof( out_str[0]), 0);
if ( nr != 2 && nr != 3)
{
errh_CErrLog( CNV__SYNTAX, errh_ErrArgAF( from_convdef->Param[i]), NULL);
return CNV__SYNTAX;
}
/* First arg is type */
cdh_ToUpper( type_str, out_str[0]);
/* Second arg i parameter name */
cdh_ToUpper( from_param[ from_convdef_count], out_str[1]);
strcpy( from_format[ from_convdef_count], "");
sts = cnv_string_to_partype( type_str, nr, out_str[2],
&from_type[ from_convdef_count],
&from_size[ from_convdef_count],
from_format[ from_convdef_count]);
if ( EVEN(sts))
{
errh_CErrLog( sts, errh_ErrArgAF( to_convdef->Param[i]), NULL);
return sts;
}
if ( from_convdef_count == 0)
from_offset[ from_convdef_count] = 0;
else
from_offset[ from_convdef_count] =
from_offset[ from_convdef_count - 1] +
from_size[ from_convdef_count - 1];
from_convdef_count++;
}
to_convdef_count = 0;
for ( i = 0; i < CNV_CONVDEF_SIZE; i++)
{
cnv_remove_blank( to_convdef->Param[i], to_convdef->Param[i]);
if ( to_convdef->Param[i][0] == 0 )
break;
if ( to_convdef->Param[i][0] == '!')
continue;
nr = dcli_parse( to_convdef->Param[i], " ", "", (char *)out_str,
sizeof( out_str) / sizeof( out_str[0]), sizeof( out_str[0]), 0);
if ( nr != 2 && nr != 3)
{
errh_CErrLog( CNV__SYNTAX, errh_ErrArgAF( to_convdef->Param[i]), NULL);
return CNV__SYNTAX;
}
cdh_ToUpper( type_str, out_str[0]);
strcpy( to_format[ from_convdef_count], "");
sts = cnv_string_to_partype( type_str, nr, out_str[2],
&to_type[ to_convdef_count],
&to_size[ to_convdef_count],
to_format[ from_convdef_count]);
if ( EVEN(sts))
{
errh_CErrLog( sts, errh_ErrArgAF( to_convdef->Param[i]), NULL);
return sts;
}
cdh_ToUpper( to_param[ to_convdef_count], out_str[1]);
if ( to_convdef_count == 0)
to_offset[ to_convdef_count] = 0;
else
to_offset[ to_convdef_count] =
to_offset[ to_convdef_count - 1] +
to_size[ to_convdef_count - 1];
to_convdef_count++;
}
for ( i = 0; i < to_convdef_count; i++)
{
/* Find a match i from_convdef */
for ( j = 0; j < from_convdef_count; j++)
{
if ( !strcmp( to_param[i], from_param[j]))
{
/* Hit */
sts = cnv_convtable_add( to_type[i], from_type[j],
to_offset[i], from_offset[j],
to_size[i], from_size[j],
to_format[i], from_format[j],
conv_table, conv_table_count);
if ( EVEN(sts))
{
errh_CErrLog( sts, errh_ErrArgAF( to_param[i]), NULL);
return sts;
}
}
}
}
sts = cnv_convtable_compress( conv_table,
conv_table_count);
return CNV__SUCCESS;
}
static int cnv_convtable_add( cnv_eParType to_type,
cnv_eParType from_type,
int to_offset,
int from_offset,
int to_size,
int from_size,
char *to_format,
char *from_format,
cnv_t_conv_table *conv_table,
int *conv_table_count)
{
cnv_t_conv_item *conv_table_ptr;
conv_table_ptr = (cnv_t_conv_item *)conv_table + *conv_table_count;
if ( to_type == from_type)
{
conv_table_ptr->from = from_offset;
conv_table_ptr->to = to_offset;
conv_table_ptr->size = to_size;
conv_table_ptr->type = cnv_eConvType_memcpy;
}
else if ( from_type == cnv_eParType_Char &&
to_type == cnv_eParType_String)
{
conv_table_ptr->from = from_offset;
conv_table_ptr->to = to_offset;
conv_table_ptr->size = to_size;
conv_table_ptr->type = cnv_eConvType_CharToString;
}
else if ( from_type == cnv_eParType_Int16 &&
to_type == cnv_eParType_Int32)
{
conv_table_ptr->from = from_offset;
conv_table_ptr->to = to_offset;
conv_table_ptr->size = 0;
conv_table_ptr->type = cnv_eConvType_Int16ToInt32;
}
else if ( from_type == cnv_eParType_Int32 &&
to_type == cnv_eParType_Float32)
{
conv_table_ptr->from = from_offset;
conv_table_ptr->to = to_offset;
conv_table_ptr->size = 0;
conv_table_ptr->type = cnv_eConvType_Int32ToFloat32;
}
else if ( from_type == cnv_eParType_Int32 &&
to_type == cnv_eParType_Int16)
{
conv_table_ptr->from = from_offset;
conv_table_ptr->to = to_offset;
conv_table_ptr->size = 0;
conv_table_ptr->type = cnv_eConvType_Int32ToInt16;
}
else if ( from_type == cnv_eParType_Int32 &&
to_type == cnv_eParType_String)
{
conv_table_ptr->from = from_offset;
conv_table_ptr->to = to_offset;
conv_table_ptr->size = to_size;
conv_table_ptr->type = cnv_eConvType_Int32ToString;
}
else if ( from_type == cnv_eParType_Int32 &&
to_type == cnv_eParType_Ascii)
{
conv_table_ptr->from = from_offset;
conv_table_ptr->to = to_offset;
conv_table_ptr->size = to_size;
conv_table_ptr->type = cnv_eConvType_Int32ToAscii;
}
else if ( from_type == cnv_eParType_Float32 &&
to_type == cnv_eParType_Int32)
{
conv_table_ptr->from = from_offset;
conv_table_ptr->to = to_offset;
conv_table_ptr->size = 0;
conv_table_ptr->type = cnv_eConvType_Float32ToInt32;
}
else if ( from_type == cnv_eParType_Float32 &&
to_type == cnv_eParType_String)
{
conv_table_ptr->from = from_offset;
conv_table_ptr->to = to_offset;
conv_table_ptr->size = to_size;
conv_table_ptr->type = cnv_eConvType_Float32ToString;
strcpy( conv_table_ptr->format, from_format);
}
else if ( from_type == cnv_eParType_Float32 &&
to_type == cnv_eParType_Ascii)
{
conv_table_ptr->from = from_offset;
conv_table_ptr->to = to_offset;
conv_table_ptr->size = to_size;
conv_table_ptr->type = cnv_eConvType_Float32ToAscii;
strcpy( conv_table_ptr->format, from_format);
}
else if ( from_type == cnv_eParType_String &&
to_type == cnv_eParType_Int32)
{
conv_table_ptr->from = from_offset;
conv_table_ptr->to = to_offset;
conv_table_ptr->size = from_size;
conv_table_ptr->type = cnv_eConvType_StringToInt32;
}
else if ( from_type == cnv_eParType_String &&
to_type == cnv_eParType_Float32)
{
conv_table_ptr->from = from_offset;
conv_table_ptr->to = to_offset;
conv_table_ptr->size = from_size;
conv_table_ptr->type = cnv_eConvType_StringToFloat32;
}
else if ( from_type == cnv_eParType_Ascii &&
to_type == cnv_eParType_Int32)
{
conv_table_ptr->from = from_offset;
conv_table_ptr->to = to_offset;
conv_table_ptr->size = from_size;
conv_table_ptr->type = cnv_eConvType_AsciiToInt32;
}
else if ( from_type == cnv_eParType_Ascii &&
to_type == cnv_eParType_Float32)
{
conv_table_ptr->from = from_offset;
conv_table_ptr->to = to_offset;
conv_table_ptr->size = from_size;
conv_table_ptr->type = cnv_eConvType_AsciiToFloat32;
}
else if ( (from_type == cnv_eParType_Time &&
to_type == cnv_eParType_Binary &&
to_size == sizeof(pwr_tTime)) ||
(from_type == cnv_eParType_Binary &&
to_type == cnv_eParType_Time &&
from_size == sizeof(pwr_tTime)))
{
conv_table_ptr->from = from_offset;
conv_table_ptr->to = to_offset;
conv_table_ptr->size = to_size;
conv_table_ptr->type = cnv_eConvType_memcpy;
}
else
return CNV__CONVTYPE;
(*conv_table_count)++;
return CNV__SUCCESS;
}
int cnv_ConvertData(
cnv_t_conv_table *conv_table,
int conv_table_count,
char *from_data,
char *to_data)
{
cnv_t_conv_item *conv_item;
int i;
char tmpstr[1000];
conv_item = (cnv_t_conv_item *) conv_table;
for ( i = 0; i < conv_table_count; i++)
{
switch( conv_item->type)
{
case cnv_eConvType_memcpy:
memcpy( to_data + conv_item->to, from_data + conv_item->from,
conv_item->size);
break;
case cnv_eConvType_CharToString:
memcpy( to_data + conv_item->to, from_data + conv_item->from, 1);
memset( to_data + conv_item->to + 1, 0, 1);
break;
case cnv_eConvType_Int16ToInt32:
* (pwr_tInt32 *) (to_data + conv_item->to) =
* (pwr_tInt16 *) (from_data + conv_item->from);
break;
case cnv_eConvType_Int32ToFloat32:
* (pwr_tFloat32 *) (to_data + conv_item->to) =
* (pwr_tInt32 *) (from_data + conv_item->from);
break;
case cnv_eConvType_Int32ToInt16:
* (pwr_tInt16 *) (to_data + conv_item->to) =
* (pwr_tInt32 *) (from_data + conv_item->from);
break;
case cnv_eConvType_Int32ToString:
sprintf( to_data + conv_item->to, "%d",
* (pwr_tInt32 *) (from_data + conv_item->from));
break;
case cnv_eConvType_Int32ToAscii:
sprintf( tmpstr, "%*d",
conv_item->size,
* (pwr_tInt32 *) (from_data + conv_item->from));
memcpy( to_data + conv_item->to, tmpstr, conv_item->size);
break;
case cnv_eConvType_Float32ToInt32:
* (pwr_tInt32 *) (to_data + conv_item->to) =
* (pwr_tFloat32 *) (from_data + conv_item->from);
break;
case cnv_eConvType_Float32ToString:
sprintf( to_data + conv_item->to, conv_item->format,
* (pwr_tFloat32 *) (from_data + conv_item->from));
break;
case cnv_eConvType_Float32ToAscii:
if ( conv_item->format[0] != 0)
sprintf( tmpstr, conv_item->format,
* (pwr_tFloat32 *) (from_data + conv_item->from));
else
sprintf( tmpstr, "%*f",
conv_item->size,
* (pwr_tFloat32 *) (from_data + conv_item->from));
memcpy( to_data + conv_item->to, tmpstr, conv_item->size);
break;
case cnv_eConvType_StringToInt32:
sscanf( from_data + conv_item->from, "%d",
(pwr_tInt32 *) (to_data + conv_item->to));
break;
case cnv_eConvType_StringToFloat32:
sscanf( from_data + conv_item->from, "%f",
(pwr_tFloat32 *) (to_data + conv_item->to));
break;
case cnv_eConvType_AsciiToInt32:
strncpy( tmpstr, from_data + conv_item->from,
conv_item->size);
tmpstr[ conv_item->size] = 0;
sscanf( tmpstr, "%d",
(pwr_tInt32 *) (to_data + conv_item->to));
break;
case cnv_eConvType_AsciiToFloat32:
strncpy( tmpstr, from_data + conv_item->from,
conv_item->size);
tmpstr[ conv_item->size] = 0;
sscanf( tmpstr, "%f",
(pwr_tFloat32 *) (to_data + conv_item->to));
break;
}
conv_item++;
}
return CNV__SUCCESS;
}
static int cnv_remove_blank( char *out_str, char *in_str)
{
char *s;
s = in_str;
/* Find first not blank */
while ( *s)
{
if ( !(*s == 9 || *s == 32))
break;
s++;
}
strcpy( out_str, s);
/* Remove at end */
s = out_str + strlen(out_str);
s--;
while( s >= out_str)
{
if ( !(*s == 9 || *s == 32))
break;
s--;
}
s++;
*s = 0;
return CNV__SUCCESS;
}
static int cnv_string_to_partype( char *string,
int args,
char *third_arg,
cnv_eParType *type,
int *size,
char *format)
{
int nr;
if ( !strcmp( string, "CHAR"))
{
*type = cnv_eParType_Char;
*size = 1;
}
else if ( !strcmp( string, "BOOLEAN"))
{
*type = cnv_eParType_Boolean;
*size = 4;
}
else if ( !strcmp( string, "INT8"))
{
*type = cnv_eParType_Int8;
*size = 1;
}
else if ( !strcmp( string, "UINT8"))
{
*type = cnv_eParType_UInt8;
*size = 1;
}
else if ( !strcmp( string, "INT16"))
{
*type = cnv_eParType_Int16;
*size = 2;
}
else if ( !strcmp( string, "UINT16"))
{
*type = cnv_eParType_UInt16;
*size = 2;
}
else if ( !strcmp( string, "INT32"))
{
*type = cnv_eParType_Int32;
*size = 4;
}
else if ( !strcmp( string, "UINT32"))
{
*type = cnv_eParType_UInt32;
*size = 4;
}
else if ( !strcmp( string, "FLOAT32"))
{
/* Format may be given as an argument */
if ( args == 3)
strcpy( format, third_arg);
*type = cnv_eParType_Float32;
*size = 4;
}
else if ( !strcmp( string, "FLOAT64"))
{
*type = cnv_eParType_Float64;
*size = 8;
}
else if ( !strcmp( string, "STRING"))
{
/* Size should be given as an argument */
/* Third arg is size */
if ( args != 3)
return CNV__SYNTAX;
nr = sscanf( third_arg, "%d", size);
if ( nr != 1)
return CNV__SYNTAX;
*type = cnv_eParType_String;
}
else if ( !strcmp( string, "ASCII"))
{
/* Size should be given as an argument */
/* Third arg is size */
if ( args != 3)
return CNV__SYNTAX;
nr = sscanf( third_arg, "%d", size);
if ( nr != 1)
return CNV__SYNTAX;
*type = cnv_eParType_Ascii;
}
else if ( !strcmp( string, "BINARY"))
{
/* Size should be given as an argument */
if ( args != 3)
return CNV__SYNTAX;
nr = sscanf( third_arg, "%d", size);
if ( nr != 1)
return CNV__SYNTAX;
*type = cnv_eParType_Binary;
}
else if ( !strcmp( string, "UNKNOWN"))
{
/* Size should be given as an argument */
if ( args != 3)
return CNV__SYNTAX;
nr = sscanf( third_arg, "%d", size);
if ( nr != 1)
return CNV__SYNTAX;
*type = cnv_eParType_Unknown;
}
else if ( !strcmp( string, "TIME"))
{
*type = cnv_eParType_Time;
*size = 8;
}
else
return CNV__NOPARTYPE;
return CNV__SUCCESS;
}
static int cnv_convtable_compress( cnv_t_conv_table *conv_table,
int *conv_table_count)
{
cnv_t_conv_item *conv_table_ptr;
cnv_t_conv_item previous;
cnv_t_conv_item *current_ptr;
int new_count;
int i;
int compress;
new_count = 1;
current_ptr = (cnv_t_conv_item *) conv_table;
conv_table_ptr = (cnv_t_conv_item *) conv_table + 1;
memcpy( &previous, conv_table, sizeof(previous));
for ( i = 1; i < *conv_table_count; i++)
{
compress = 0;
if ( current_ptr->type == cnv_eConvType_memcpy &&
conv_table_ptr->type == cnv_eConvType_memcpy &&
conv_table_ptr->to ==
(previous.to + previous.size) &&
conv_table_ptr->from ==
(previous.from + previous.size))
{
compress = 1;
}
if ( compress)
{
/* Compress these */
current_ptr->size += conv_table_ptr->size;
}
else
{
current_ptr++;
memcpy( current_ptr, conv_table_ptr, sizeof(*current_ptr));
new_count++;
}
memcpy( &previous, conv_table_ptr, sizeof(previous));
conv_table_ptr++;
}
*conv_table_count = new_count;
return CNV__SUCCESS;
}
static int cnv_GetConvTableFromClass(
pwr_tObjid class,
pwr_sClass_ConvDef **convdef)
{
pwr_tClassId class_class;
pwr_tObjid objid;
pwr_tObjid rtbody_objid;
char name[80];
pwr_sParInfo parinfo;
char *attrname;
int add_size;
int size;
char type[32];
int i, j;
pwr_tStatus sts;
int param_size;
/* Is this a ClassDef object ? */
sts = gdh_GetObjectClass ( class, &class_class);
if ( EVEN(sts)) return sts;
if ( class_class != pwr_eClass_ClassDef)
return CNV__CLASS;
*convdef = calloc( 1, sizeof( **convdef));
if ( *convdef == 0)
return CNV__NOMEMORY;
/* Get the attributes under RtBody */
sts = gdh_ObjidToName ( class, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
strcat( name, "-RtBody");
sts = gdh_NameToObjid ( name, &rtbody_objid);
if ( EVEN(sts)) return CNV__CLASS;
param_size = sizeof((*convdef)->Param)/sizeof((*convdef)->Param[0]);
i = 0;
sts = gdh_GetChild( rtbody_objid, &objid);
while (ODD(sts))
{
if ( i >= param_size)
break;
sts = gdh_ObjidToName ( objid, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
attrname = strrchr( name, '-');
if ( attrname == 0)
attrname = name;
else
attrname++;
sts = gdh_GetObjectInfo ( name, &parinfo, sizeof(parinfo));
if ( EVEN(sts)) return sts;
add_size = 0;
switch( parinfo.Type)
{
case pwr_eType_Boolean:
strcpy( type, "Boolean");
break;
case pwr_eType_Float32:
strcpy( type, "Float32");
break;
case pwr_eType_Float64:
strcpy( type, "Float64");
break;
case pwr_eType_Char:
strcpy( type, "Char");
break;
case pwr_eType_Int8:
strcpy( type, "Int8");
break;
case pwr_eType_Int16:
strcpy( type, "Int16");
break;
case pwr_eType_Int32:
strcpy( type, "Int32");
break;
case pwr_eType_UInt8:
strcpy( type, "UInt8");
break;
case pwr_eType_UInt16:
strcpy( type, "UInt16");
break;
case pwr_eType_UInt32:
strcpy( type, "UInt32");
break;
case pwr_eType_String:
strcpy( type, "String");
add_size = 1;
break;
case pwr_eType_Text:
strcpy( type, "String");
add_size = 1;
break;
case pwr_eType_Time:
case pwr_eType_DeltaTime:
strcpy( type, "Time");
break;
default:
strcpy( type, "Binary");
add_size = 1;
break;
}
if (!( parinfo.Flags & PWR_MASK_ARRAY ))
{
strcpy( (*convdef)->Param[i], type);
strcat( (*convdef)->Param[i], " ");
strcat( (*convdef)->Param[i], attrname);
if ( add_size)
{
size = parinfo.Size;
sprintf( (*convdef)->Param[i]+strlen((*convdef)->Param[i]),
" %d", size);
}
i++;
}
else
{
for( j = 0; j < (int) parinfo.Elements; j++)
{
if ( i >= param_size)
break;
strcpy( (*convdef)->Param[i], type);
strcat( (*convdef)->Param[i], " ");
strcat( (*convdef)->Param[i], attrname);
sprintf( (*convdef)->Param[i]+strlen((*convdef)->Param[i]),
"[%d]", j);
if ( add_size)
{
size = parinfo.Size/parinfo.Elements;
sprintf( (*convdef)->Param[i]+strlen((*convdef)->Param[i]),
" %d", size);
}
i++;
}
}
sts = gdh_GetNextSibling ( objid, &objid);
}
return CNV__SUCCESS;
}
static int cnv_ReadConvTable( char *filename,
pwr_sClass_ConvDef **convdef)
{
FILE *infile;
char line[80];
int i;
int sts;
infile = fopen( filename, "r");
if ( !infile)
{
errh_CErrLog( CNV__NOFILE, errh_ErrArgAF( filename), NULL);
return CNV__NOFILE;
}
*convdef = calloc( 1, sizeof( **convdef));
if ( *convdef == 0)
return CNV__NOMEMORY;
i = 0;
while( ODD( sts = cnv_read_line( line, sizeof(line), infile)))
{
cnv_remove_blank( line, line);
if ( line[0] == '!')
continue;
if ( i >= CNV_CONVDEF_SIZE)
return CNV__FILESIZE;
strcpy( (*convdef)->Param[i], line);
i++;
}
fclose( infile);
return CNV__SUCCESS;
}
/*************************************************************************
*
* Name: dtt_read_line()
*
* Type void
*
* Type Parameter IOGF Description
*
* Description:
* Read a line for a file.
*
**************************************************************************/
static int cnv_read_line( char *line,
int maxsize,
FILE *file)
{
char *s;
if (fgets( line, maxsize, file) == NULL)
return 0;
s = strchr( line, 10);
if ( s != 0)
*s = 0;
return CNV__SUCCESS;
}
int cvn_ConvInit(
pwr_tInt32 ToConvdefType,
pwr_tObjid ToConvdef,
char *ToConvdefFile,
pwr_tInt32 FromConvdefType,
pwr_tObjid FromConvdef,
char *FromConvdefFile,
pwr_tInt32 *ConvTableSize,
pwr_tInt32 AllocConvTable,
char **ConvTable)
{
cnv_t_conv_table *conv_table;
int conv_table_count;
int i;
int sts;
int log = 1;
pwr_sClass_ConvDef *to_convdef_ptr;
pwr_sClass_ConvDef *from_convdef_ptr;
if ( ToConvdefType == CNV_CONVDEFTYPE_OBJ)
{
/* Get pointer to ConvDef object */
sts = gdh_ObjidToPointer ( ToConvdef, (pwr_tAddress *) &to_convdef_ptr);
if ( EVEN(sts))
{
errh_CErrLog( CNV__CONVDEFOBJECT, errh_ErrArgMsg(sts), NULL);
*ConvTableSize = 0;
return CNV__CONVDEFOBJECT;
}
}
else if ( ToConvdefType == CNV_CONVDEFTYPE_FILE)
{
sts = cnv_ReadConvTable( ToConvdefFile, &to_convdef_ptr);
if ( EVEN(sts))
{
errh_CErrLog( CNV__CONVDEFFILE, errh_ErrArgMsg(sts), NULL);
*ConvTableSize = 0;
return CNV__CONVDEFFILE;
}
}
else if ( ToConvdefType == CNV_CONVDEFTYPE_CLASS)
{
sts = cnv_GetConvTableFromClass( ToConvdef, &to_convdef_ptr);
if ( EVEN(sts))
{
errh_CErrLog( CNV__CONVDEFCLASS, errh_ErrArgMsg(sts), NULL);
*ConvTableSize = 0;
return CNV__CONVDEFCLASS;
}
}
else
{
errh_CErrLog( CNV__CONVDEFTYPE, NULL);
*ConvTableSize = 0;
return CNV__CONVDEFTYPE;
}
if ( FromConvdefType == CNV_CONVDEFTYPE_OBJ)
{
/* Get pointer to ConvDef object */
sts = gdh_ObjidToPointer ( FromConvdef,
(pwr_tAddress *) &from_convdef_ptr);
if ( EVEN(sts))
{
errh_CErrLog( CNV__CONVDEFOBJECT, errh_ErrArgMsg(sts), NULL);
*ConvTableSize = 0;
return CNV__CONVDEFOBJECT;
}
}
else if ( FromConvdefType == CNV_CONVDEFTYPE_FILE)
{
sts = cnv_ReadConvTable( FromConvdefFile, &from_convdef_ptr);
if ( EVEN(sts))
{
errh_CErrLog( CNV__CONVDEFFILE, errh_ErrArgMsg(sts), NULL);
*ConvTableSize = 0;
return CNV__CONVDEFFILE;
}
}
else if ( FromConvdefType == CNV_CONVDEFTYPE_CLASS)
{
sts = cnv_GetConvTableFromClass( FromConvdef, &from_convdef_ptr);
if ( EVEN(sts))
{
errh_CErrLog( CNV__CONVDEFCLASS, errh_ErrArgMsg(sts), NULL);
*ConvTableSize = 0;
return CNV__CONVDEFCLASS;
}
}
else
{
errh_CErrLog( CNV__CONVDEFTYPE, NULL);
*ConvTableSize = 0;
return CNV__CONVDEFTYPE;
}
conv_table_count = 0;
if ( AllocConvTable)
{
/* Allocate space for the conversion table */
conv_table = calloc( 1, sizeof( *conv_table));
if ( !conv_table)
{
errh_CErrLog( CNV__NOMEMORY, NULL);
*ConvTableSize = 0;
return CNV__NOMEMORY;
}
}
else
/* The user has already allocated space */
conv_table = (cnv_t_conv_table *) ConvTable;
sts = cnv_CreateConvTable( to_convdef_ptr, from_convdef_ptr,
conv_table, &conv_table_count);
if ( EVEN(sts))
{
*ConvTableSize = 0;
return sts;
}
if ( AllocConvTable)
/* Return the address of the conversion table */
*ConvTable = (char *) conv_table;
*ConvTableSize = conv_table_count;
if ( log)
{
printf( "nr from to size type\n");
for ( i = 0; i < conv_table_count; i++)
{
printf( "%d %d %d %d %d\n", i,
(* conv_table)[i].from,
(* conv_table)[i].to,
(* conv_table)[i].size,
(* conv_table)[i].type);
}
}
return CNV__SUCCESS;
}
/*
* Proview $Id: nmps_cnv.h,v 1.1 2006-01-12 05:57:43 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.
*/
typedef enum {
cnv_eConvType_memcpy,
cnv_eConvType_CharToString,
cnv_eConvType_Int16ToInt32,
cnv_eConvType_Int32ToInt16,
cnv_eConvType_Int32ToFloat32,
cnv_eConvType_Int32ToString,
cnv_eConvType_Int32ToAscii,
cnv_eConvType_Float32ToInt32,
cnv_eConvType_Float32ToString,
cnv_eConvType_Float32ToAscii,
cnv_eConvType_StringToInt32,
cnv_eConvType_StringToFloat32,
cnv_eConvType_AsciiToInt32,
cnv_eConvType_AsciiToFloat32
} cnv_eConvType;
typedef enum {
cnv_eParType__ = 0,
cnv_eParType_Char,
cnv_eParType_Boolean,
cnv_eParType_Int8,
cnv_eParType_UInt8,
cnv_eParType_Int16,
cnv_eParType_UInt16,
cnv_eParType_Int32,
cnv_eParType_UInt32,
cnv_eParType_Float32,
cnv_eParType_Float64,
cnv_eParType_String,
cnv_eParType_Ascii,
cnv_eParType_Binary,
cnv_eParType_Unknown,
cnv_eParType_Time,
cnv_eParType_
} cnv_eParType;
typedef struct {
int from;
int to;
int size;
cnv_eConvType type;
char format[20];
} cnv_t_conv_item;
#define CNV_CONV_TABLE_SIZE 200
typedef cnv_t_conv_item cnv_t_conv_table [CNV_CONV_TABLE_SIZE];
int cnv_ConvertData(
cnv_t_conv_table *conv_table,
int conv_table_count,
char *from_data,
char *to_data);
int cvn_ConvInit(
pwr_tInt32 ToConvdefType,
pwr_tObjid ToConvdef,
char *ToConvdefFile,
pwr_tInt32 FromConvdefType,
pwr_tObjid FromConvdef,
char *FromConvdefFile,
pwr_tInt32 *ConvTableSize,
pwr_tInt32 AllocConvTable,
char **ConvTable);
/*
* Proview $Id: nmps_plc.c,v 1.1 2006-01-12 05:57:43 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.
*/
#if defined(OS_VMS) || defined(OS_LYNX) || defined(OS_LINUX)
#include <stdio.h>
#include <float.h>
#include <string.h>
#endif
#ifdef OS_ELN
#include stdio
#include float
#include string
#endif
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_nmpsclasses.h"
#include "rt_gdh.h"
#include "rt_plc.h"
#include "nmps.h"
#define ODD(a) (((int)(a) & 1) != 0)
#define EVEN(a) (((int)(a) & 1) == 0)
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
#ifndef __ALPHA
#define abs(Dragon) ((Dragon) >= 0 ? (Dragon) : (-(Dragon)))
#endif
#define NMPS_OPTYPE_FRONT 0
#define NMPS_OPTYPE_BACK 1
#define NMPS_OPTYPE_UNIT 2
#define NMPS_OPTYPE_FORWARD_FRONT 3
#define NMPS_OPTYPE_FORWARD_BACK 4
#define NMPS_OPTYPE_FORWARD_UNIT 5
#define NMPS_OPTYPE_REVERSE_FRONT 6
#define NMPS_OPTYPE_REVERSE_BACK 7
#define NMPS_OPTYPE_REVERSE_UNIT 8
/* NMPS RUTINER */
/* NMpsCell
*/
void NMpsCell_init_time(object)
pwr_sClass_NMpsCell *object;
{
pwr_sAttrRef attrref;
plc_t_DataInfo *data_index;
int i, sts;
/* Get new object pointers at restart av plc program */
data_index = (plc_t_DataInfo *) &object->Data1P;
for ( i = 1; i <= object->LastIndex; i++)
{
attrref.Objid = data_index->Data_ObjId;
attrref.Offset = 0;
attrref.Size = 4;
attrref.Flags.b.Indirect = 0;
sts = gdh_DLRefObjectInfoAttrref ( &attrref,
(pwr_tAddress *) &data_index->DataP, &data_index->Data_Dlid);
data_index++;
}
if ( object->LastIndex)
{
data_index = (plc_t_DataInfo *) &object->Data1P;
data_index += object->LastIndex - 1;
memcpy( &object->DataLP, data_index, sizeof( *data_index));
memcpy( &object->DataLastP, data_index, sizeof( *data_index));
}
object->InitTime = 0;
object->ReloadDone |= NMPS_CELL_INITIALIZED;
}
void NMpsCell_init(object)
pwr_sClass_NMpsCell *object;
{
plc_t_DataInfo *data_index;
int i;
if ( !(object->Function & NMPS_CELLFUNC_BACKUP))
NMpsCell_init_time( object);
else
{
/* Backup, reset all nonvalid pointers */
data_index = (plc_t_DataInfo *) &object->Data1P;
for ( i = 1; i <= object->LastIndex; i++)
{
data_index->DataP = NULL;
data_index++;
}
if ( object->LastIndex)
{
object->DataLP = NULL;
object->DataLastP = NULL;
}
object->InitTime = 1;
}
}
/**
@aref nmpscell NMpsCell
*/
void NMpsCell_exec(
plc_sThread *tp,
pwr_sClass_NMpsCell *object)
{
int i, sts;
plc_t_DataInfo *data_max;
plc_t_DataInfo *data_last;
plc_t_DataInfo *data_index;
plc_t_DataInfo data_tmp;
int size;
pwr_sAttrRef extern_attrref;
gdh_tDlid data_dlid;
unsigned long *data_pointer;
int reloaddone;
#if defined OS_LINUX
plc_t_DataInfo cpy_buf[NMPS_CELL_SIZE];
#endif
if ( object->InitTime)
{
if ( !(object->ReloadDone & NMPS_CELL_RELOADDONE))
return;
else
{
NMpsCell_init_time( object);
object->ReloadDone &= ~NMPS_CELL_RELOADDONE;
}
}
if ( object->FrontNew) object->FrontNew = 0;
if ( object->RearNew) object->RearNew = 0;
if ( object->MaxSize > NMPS_CELL_SIZE)
object->MaxSize = NMPS_CELL_SIZE;
if ( object->ResetObjectP)
{
if ( *object->ResetObjectP)
{
data_index = (plc_t_DataInfo *) &object->Data1P;
for ( i = 1; i <= object->LastIndex; i++)
{
sts = gdh_DLUnrefObjectInfo( data_index->Data_Dlid);
if ( object->Function & NMPS_CELLFUNC_RESETDELETE)
sts = gdh_DeleteObject( data_index->Data_ObjId);
data_index++;
}
reloaddone = object->ReloadDone;
memset( &object->CellFull, 0, sizeof(pwr_sClass_NMpsCell) -
((unsigned long)(&object->CellFull) -
(unsigned long)object));
object->ReloadDone = reloaddone;
if (object->Function & NMPS_CELLFUNC_BACKUP) object->BackupNow = 1;
}
}
if ( object->ExternFlag)
{
/* Insert new object in Front position */
switch( object->ExternOpType)
{
case NMPS_OPTYPE_EXTINSERT:
object->ExternIndex = 1;
case NMPS_OPTYPE_EXTINSERT_IDX:
/* Direct link to extern objid */
if ( object->CellFull)
object->ExternStatus = 2; /* Felkod !!! */
else if ( object->ExternIndex > object->LastIndex + 1)
object->ExternStatus = 2; /* Felkod !!! */
else
{
extern_attrref.Objid = object->ExternObjId;
extern_attrref.Offset = 0;
extern_attrref.Size = 4;
extern_attrref.Flags.b.Indirect = 0;
object->ExternStatus = gdh_DLRefObjectInfoAttrref (
&extern_attrref,
(pwr_tAddress *) &data_pointer, &data_dlid);
}
if ( ODD( object->ExternStatus))
{
object->ExternFlag = 0;
data_index = (plc_t_DataInfo *) &object->Data1P;
data_index += object->ExternIndex - 1;
if ( object->LastIndex >= object->ExternIndex)
{
#if defined OS_LINUX
memcpy( &cpy_buf, data_index,
(object->LastIndex - object->ExternIndex + 1)
* sizeof ( *data_max));
memcpy( (char *) data_index + sizeof( *data_max), cpy_buf,
(object->LastIndex - object->ExternIndex + 1)
* sizeof ( *data_max));
#else
memcpy( (char *) data_index + sizeof( *data_max),
data_index,
(object->LastIndex - object->ExternIndex + 1)
* sizeof ( *data_max));
#endif
}
data_index->DataP = (pwr_tFloat32 *) data_pointer;
data_index->Data_ObjId = object->ExternObjId;
data_index->Data_Front = 1;
data_index->Data_Back = 1;
data_index->Data_Dlid = data_dlid;
object->LastIndex++;
if ( object->LastIndex == object->MaxSize)
object->CellFull = 1;
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex - 1;
memcpy( &object->DataLP, data_last,
sizeof( *data_last));
memcpy( &object->DataLastP, data_last,
sizeof( *data_last));
if ( object->ExternOpType == NMPS_OPTYPE_EXTINSERT)
object->FrontNew = 1;
}
else
object->ExternFlag = 0;
break;
case NMPS_OPTYPE_EXTDELETE_OBJID:
case NMPS_OPTYPE_EXTREMOVE_OBJID:
data_index = (plc_t_DataInfo *) &object->Data1P;
for ( object->ExternIndex = 1;
object->ExternIndex <= object->LastIndex;
object->ExternIndex++)
{
if ( !memcmp( &data_index->Data_ObjId, &object->ExternObjId,
sizeof(pwr_tObjid)))
break;
data_index++;
}
if ( memcmp( &data_index->Data_ObjId, &object->ExternObjId,
sizeof(pwr_tObjid)))
{
object->ExternStatus = 2; /* Felkod !!! */
object->ExternFlag = 0;
break;
}
case NMPS_OPTYPE_EXTDELETE:
if ( object->ExternOpType == NMPS_OPTYPE_EXTDELETE)
object->ExternIndex = 1;
case NMPS_OPTYPE_EXTDELETE_IDX:
if ( object->ExternIndex > object->LastIndex)
{
object->ExternStatus = 2; /* Felkod !!! */
object->ExternFlag = 0;
break;
}
object->ExternFlag = 0;
data_index = (plc_t_DataInfo *) &object->Data1P;
data_index += object->ExternIndex - 1;
sts = gdh_DLUnrefObjectInfo( data_index->Data_Dlid);
if ( object->Function & NMPS_CELLFUNC_DELETE &&
object->ExternOpType != NMPS_OPTYPE_EXTREMOVE_OBJID)
sts = gdh_DeleteObject( data_index->Data_ObjId);
if ( object->ExternIndex < object->LastIndex)
{
size = (object->LastIndex - object->ExternIndex)
* sizeof ( *data_max);
#if defined OS_LINUX
memcpy( &cpy_buf, (char *) data_index + sizeof( *data_max), size);
memcpy( data_index, &cpy_buf, size);
#else
memcpy( data_index, (char *) data_index + sizeof( *data_max),
size);
#endif
}
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex - 1;
memset( data_last, 0, sizeof( *data_last));
object->CellFull = 0;
object->LastIndex--;
object->ExternFlag = 0;
if ( object->LastIndex > 0 )
{
data_last--;
memcpy( &object->DataLP, data_last,
sizeof( *data_last));
memcpy( &object->DataLastP, data_last,
sizeof( *data_last));
}
else
{
memset( &object->DataLP, 0, sizeof( *data_last));
memset( &object->DataLastP, 0, sizeof( *data_last));
}
object->ExternStatus = 1; /* Felkod Success!!! */
break;
case NMPS_OPTYPE_EXTMOVEFORW_OBJID:
data_index = (plc_t_DataInfo *) &object->Data1P;
for ( object->ExternIndex = 1;
object->ExternIndex <= object->LastIndex;
object->ExternIndex++)
{
if ( !memcmp( &data_index->Data_ObjId, &object->ExternObjId,
sizeof(pwr_tObjid)))
break;
data_index++;
}
if ( memcmp( &data_index->Data_ObjId, &object->ExternObjId,
sizeof(pwr_tObjid)))
{
object->ExternStatus = 2; /* Felkod !!! */
object->ExternFlag = 0;
break;
}
if ( object->ExternIndex >= object->LastIndex)
{
object->ExternStatus = 2; /* Felkod !!! */
object->ExternFlag = 0;
break;
}
data_index = (plc_t_DataInfo *) &object->Data1P;
data_index += object->ExternIndex - 1;
if ( !(data_index->Data_Front && data_index->Data_Back))
{
object->ExternStatus = 2; /* Felkod !!! */
object->ExternFlag = 0;
break;
}
memcpy( &data_tmp, data_index+1, sizeof( *data_index));
memcpy( data_index+1, data_index, sizeof( *data_index));
memcpy( data_index, &data_tmp, sizeof( *data_index));
object->ExternFlag = 0;
if ( object->ExternIndex == object->LastIndex -1)
{
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex - 1;
memcpy( &object->DataLP, data_last,
sizeof( *data_last));
memcpy( &object->DataLastP, data_last,
sizeof( *data_last));
}
object->ExternStatus = 1; /* Felkod Success!!! */
break;
case NMPS_OPTYPE_EXTMOVEBACKW_OBJID:
data_index = (plc_t_DataInfo *) &object->Data1P;
for ( object->ExternIndex = 1;
object->ExternIndex <= object->LastIndex;
object->ExternIndex++)
{
if ( !memcmp( &data_index->Data_ObjId, &object->ExternObjId,
sizeof(pwr_tObjid)))
break;
data_index++;
}
if ( memcmp( &data_index->Data_ObjId, &object->ExternObjId,
sizeof(pwr_tObjid)))
{
object->ExternStatus = 2; /* Felkod !!! */
object->ExternFlag = 0;
break;
}
if ( object->ExternIndex <= 1)
{
object->ExternStatus = 2; /* Felkod !!! */
object->ExternFlag = 0;
break;
}
data_index = (plc_t_DataInfo *) &object->Data1P;
data_index += object->ExternIndex - 1;
if ( !(data_index->Data_Front && data_index->Data_Back))
{
object->ExternStatus = 2; /* Felkod !!! */
object->ExternFlag = 0;
break;
}
memcpy( &data_tmp, data_index-1, sizeof( *data_index));
memcpy( data_index-1, data_index, sizeof( *data_index));
memcpy( data_index, &data_tmp, sizeof( *data_index));
object->ExternFlag = 0;
if ( object->ExternIndex == object->LastIndex)
{
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex - 1;
memcpy( &object->DataLP, data_last,
sizeof( *data_last));
memcpy( &object->DataLastP, data_last,
sizeof( *data_last));
}
object->ExternStatus = 1; /* Felkod Success!!! */
break;
}
if (object->Function & NMPS_CELLFUNC_BACKUP) object->BackupNow = 1;
}
if ( object->InFlag)
{
/* Insert new object in Front position */
switch( object->InOpType)
{
case NMPS_OPTYPE_FORWARD_FRONT:
/* Insert at front of object front of data */
if ( object->CellFull) return;
if ( object->LastIndex > 0)
{
#if defined OS_LINUX
memcpy( &cpy_buf, &object->Data1P,
object->LastIndex * sizeof ( *data_max));
memcpy( &object->Data2P, &cpy_buf,
object->LastIndex * sizeof ( *data_max));
#else
memcpy( &object->Data2P, &object->Data1P,
object->LastIndex * sizeof ( *data_max));
#endif
}
object->Data1P = object->InPointer;
object->Data1_ObjId = object->InObjId;
object->Data1_Front = 1;
object->Data1_Back = 0;
object->InFlag = 0;
object->Data1_Dlid = object->InDlid;
object->FrontNew = 1;
object->LastIndex++;
if ( object->LastIndex == object->MaxSize)
object->CellFull = 1;
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex - 1;
memcpy( &object->DataLP, data_last, sizeof( *data_last));
memcpy( &object->DataLastP, data_last, sizeof( *data_last));
break;
case NMPS_OPTYPE_FORWARD_BACK:
if ( memcmp( &object->Data1_ObjId, &object->InObjId,
sizeof(pwr_tObjid)))
{
/* This it not the correct object */
object->InFlag = 0;
return;
}
object->Data1_Back = 1;
if ( object->LastIndex == 1)
{
object->DataL_Back = 1;
object->DataLast_Back = 1;
}
object->InFlag = 0;
break;
case NMPS_OPTYPE_FORWARD_UNIT:
if ( object->CellFull) return;
if ( object->LastIndex > 0)
{
#if defined OS_LINUX
memcpy( &cpy_buf, &object->Data1P,
object->LastIndex * sizeof ( *data_max));
memcpy( &object->Data2P, &cpy_buf,
object->LastIndex * sizeof ( *data_max));
#else
memcpy( &object->Data2P, &object->Data1P,
object->LastIndex * sizeof ( *data_max));
#endif
}
object->Data1P = object->InPointer;
object->Data1_ObjId = object->InObjId;
object->Data1_Front = 1;
object->Data1_Back = 1;
object->Data1_Dlid = object->InDlid;
object->InFlag = 0;
object->FrontNew = 1;
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex;
memcpy( &object->DataLP, data_last, sizeof( *data_last));
memcpy( &object->DataLastP, data_last, sizeof( *data_last));
object->LastIndex++;
if ( object->LastIndex == object->MaxSize)
object->CellFull = 1;
break;
case NMPS_OPTYPE_REVERSE_BACK:
/* Insert at rear of object back of data */
if ( object->CellFull) return;
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex;
data_last->DataP = object->InPointer;
data_last->Data_ObjId = object->InObjId;
data_last->Data_Front = 0;
data_last->Data_Back = 1;
data_last->Data_Dlid = object->InDlid;
object->InFlag = 0;
object->RearNew = 1;
object->LastIndex++;
if ( object->LastIndex == object->MaxSize)
object->CellFull = 1;
memcpy( &object->DataLP, data_last, sizeof( *data_last));
memcpy( &object->DataLastP, data_last, sizeof( *data_last));
break;
case NMPS_OPTYPE_REVERSE_UNIT:
/* Insert at rear of object all of data */
if ( object->CellFull) return;
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex;
data_last->DataP = object->InPointer;
data_last->Data_ObjId = object->InObjId;
data_last->Data_Front = 1;
data_last->Data_Back = 1;
data_last->Data_Dlid = object->InDlid;
object->InFlag = 0;
object->LastIndex++;
object->RearNew = 1;
if ( object->LastIndex == object->MaxSize)
object->CellFull = 1;
memcpy( &object->DataLP, data_last, sizeof( *data_last));
memcpy( &object->DataLastP, data_last, sizeof( *data_last));
break;
case NMPS_OPTYPE_REVERSE_FRONT:
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex - 1;
if ( memcmp( &data_last->Data_ObjId, &object->InObjId,
sizeof(pwr_tObjid)))
{
/* This it not the correct object */
object->InFlag = 0;
return;
}
data_last->Data_Front = 1;
object->DataL_Front = 1;
object->DataLast_Front = 1;
object->InFlag = 0;
break;
}
if (object->Function & NMPS_CELLFUNC_BACKUP) object->BackupNow = 1;
}
if ( object->OutRearFlag)
{
/* Remove an object in Rear position */
switch( object->OutRearOpType)
{
case NMPS_OPTYPE_BACK:
case NMPS_OPTYPE_UNIT:
/* Get the last data */
if ( object->LastIndex == 0)
{
object->OutRearFlag = 0;
return;
}
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex - 1;
memset( data_last, 0, sizeof( *data_last));
object->OutRearFlag = 0;
object->CellFull = 0;
object->LastIndex--;
if ( object->LastIndex != 0)
{
data_last--;
memcpy( &object->DataLP, data_last, sizeof( *data_last));
memcpy( &object->DataLastP, data_last, sizeof( *data_last));
}
else
{
memset( &object->DataLP, 0, sizeof( *data_last));
memset( &object->DataLastP, 0, sizeof( *data_last));
}
break;
case NMPS_OPTYPE_FRONT:
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex - 1;
data_last->Data_Front = 0;
object->OutRearFlag = 0;
object->DataL_Front = 0; /* Korrigeras !!! */
object->DataLast_Front = 0; /* Korrigeras !!! */
break;
}
if (object->Function & NMPS_CELLFUNC_BACKUP) object->BackupNow = 1;
}
if ( object->OutFrontFlag)
{
/* Remove an object in Front position */
switch( object->OutFrontOpType)
{
case NMPS_OPTYPE_FRONT:
case NMPS_OPTYPE_UNIT:
/* Get the last data */
if ( object->LastIndex == 0)
{
object->OutFrontFlag = 0;
return;
}
#if defined OS_LINUX
memcpy( &cpy_buf, &object->Data2P,
(object->LastIndex - 1) * sizeof( *data_last));
memcpy( &object->Data1P, &cpy_buf,
(object->LastIndex - 1) * sizeof( *data_last));
#else
memcpy( &object->Data1P, &object->Data2P,
(object->LastIndex - 1) * sizeof( *data_last));
#endif
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex - 1;
memset( data_last, 0, sizeof( *data_last));
object->CellFull = 0;
object->LastIndex--;
object->OutFrontFlag = 0;
if ( object->LastIndex != 0)
{
data_last--;
memcpy( &object->DataLP, data_last, sizeof( *data_last));
memcpy( &object->DataLastP, data_last, sizeof( *data_last));
}
else
{
memset( &object->DataLP, 0, sizeof( *data_last));
memset( &object->DataLastP, 0, sizeof( *data_last));
}
break;
case NMPS_OPTYPE_BACK:
object->Data1_Back = 0;
object->OutFrontFlag = 0;
if ( object->LastIndex == 1)
{
object->DataL_Back = 0;
object->DataLast_Back = 0;
}
break;
}
if (object->Function & NMPS_CELLFUNC_BACKUP) object->BackupNow = 1;
}
object->NumberOfData = object->LastIndex;
}
/* NMpsStoreCell
*/
void NMpsStoreCell_init(object)
pwr_sClass_NMpsStoreCell *object;
{
plc_t_DataInfo *data_index;
int i;
if ( !(object->Function & NMPS_CELLFUNC_BACKUP))
NMpsCell_init_time( (pwr_sClass_NMpsCell *) object);
else
{
/* Backup, reset all nonvalid pointers */
data_index = (plc_t_DataInfo *) &object->Data1P;
for ( i = 1; i <= object->LastIndex; i++)
{
data_index->DataP = NULL;
data_index++;
}
if ( object->LastIndex)
{
object->DataLP = NULL;
object->DataLastP = NULL;
}
object->InitTime = 1;
}
}
/**
NMpsStoreCell
@aref nmpsstorecell NMpsStoreCell
*/
void NMpsStoreCell_exec(
plc_sThread *tp,
pwr_sClass_NMpsStoreCell *object)
{
int i, sts;
plc_t_DataInfo *data_max;
plc_t_DataInfo *data_last;
plc_t_DataInfo *data_index;
plc_t_DataInfo data_tmp;
int size;
pwr_sAttrRef extern_attrref;
gdh_tDlid data_dlid;
unsigned long *data_pointer;
int reloaddone;
#if defined OS_LINUX
plc_t_DataInfo cpy_buf[NMPS_CELL_SIZE];
#endif
if ( object->InitTime)
{
if ( !(object->ReloadDone & NMPS_CELL_RELOADDONE))
return;
else
{
NMpsCell_init_time( object);
object->ReloadDone &= ~NMPS_CELL_RELOADDONE;
}
}
if ( object->FrontNew) object->FrontNew = 0;
if ( object->RearNew) object->RearNew = 0;
if ( object->MaxSize > NMPS_CELL_SIZE)
object->MaxSize = NMPS_CELL_SIZE;
if ( object->ResetObjectP)
{
if ( *object->ResetObjectP)
{
data_index = (plc_t_DataInfo *) &object->Data1P;
for ( i = 1; i <= object->LastIndex; i++)
{
sts = gdh_DLUnrefObjectInfo( data_index->Data_Dlid);
if ( object->Function & NMPS_CELLFUNC_RESETDELETE)
sts = gdh_DeleteObject( data_index->Data_ObjId);
data_index++;
}
reloaddone = object->ReloadDone;
memset( &object->CellFull, 0, sizeof(pwr_sClass_NMpsStoreCell) -
((unsigned long)(&object->CellFull) -
(unsigned long)object));
object->ReloadDone = reloaddone;
if (object->Function & NMPS_CELLFUNC_BACKUP) object->BackupNow = 1;
}
}
if ( object->ExternFlag)
{
/* Insert new object in Front position */
switch( object->ExternOpType)
{
case NMPS_OPTYPE_EXTINSERT:
case NMPS_OPTYPE_EXTINSERTSELECT:
object->ExternIndex = 1;
case NMPS_OPTYPE_EXTINSERT_IDX:
/* Direct link to extern objid */
if ( object->CellFull)
object->ExternStatus = 2; /* Felkod !!! */
else if ( object->ExternIndex > object->LastIndex + 1)
object->ExternStatus = 2; /* Felkod !!! */
else
{
extern_attrref.Objid = object->ExternObjId;
extern_attrref.Offset = 0;
extern_attrref.Size = 4;
extern_attrref.Flags.b.Indirect = 0;
object->ExternStatus = gdh_DLRefObjectInfoAttrref ( &extern_attrref,
(pwr_tAddress *) &data_pointer, &data_dlid);
}
if ( ODD( object->ExternStatus))
{
object->ExternFlag = 0;
data_index = (plc_t_DataInfo *) &object->Data1P;
data_index += object->ExternIndex - 1;
if ( object->LastIndex >= object->ExternIndex)
{
#if defined OS_LINUX
memcpy( &cpy_buf, data_index,
(object->LastIndex - object->ExternIndex + 1)
* sizeof ( *data_max));
memcpy( (char *) data_index + sizeof( *data_max), cpy_buf,
(object->LastIndex - object->ExternIndex + 1)
* sizeof ( *data_max));
#else
memcpy( (char *) data_index + sizeof( *data_max),
data_index,
(object->LastIndex - object->ExternIndex + 1)
* sizeof ( *data_max));
#endif
}
data_index->DataP = (pwr_tFloat32 *) data_pointer;
data_index->Data_ObjId = object->ExternObjId;
data_index->Data_Front = 1;
data_index->Data_Back = 1;
data_index->Data_Dlid = data_dlid;
if ( object->ExternOpType == NMPS_OPTYPE_EXTINSERTSELECT)
{
data_index->Data_Select = 1;
}
object->LastIndex++;
if ( object->LastIndex == object->MaxSize)
object->CellFull = 1;
if (( object->ExternOpType == NMPS_OPTYPE_EXTINSERT) ||
( object->ExternOpType == NMPS_OPTYPE_EXTINSERTSELECT))
object->FrontNew = 1;
if (( object->SelectIndex != 0) &&
( object->SelectIndex >= object->ExternIndex))
object->SelectIndex++;
}
else
object->ExternFlag = 0;
break;
case NMPS_OPTYPE_EXTSELECT_OBJID:
data_index = (plc_t_DataInfo *) &object->Data1P;
for ( i = 1; i <= object->LastIndex; i++)
{
if ( !memcmp( &data_index->Data_ObjId, &object->ExternObjId,
sizeof(pwr_tObjid)))
{
data_index->Data_Select = 1;
break;
}
data_index++;
}
if ( memcmp( &data_index->Data_ObjId, &object->ExternObjId,
sizeof(pwr_tObjid)))
{
object->ExternStatus = 2; /* Felkod !!! */
}
object->ExternFlag = 0;
break;
case NMPS_OPTYPE_EXTUNSELECT_OBJID:
data_index = (plc_t_DataInfo *) &object->Data1P;
for ( i = 1; i <= object->LastIndex; i++)
{
if ( !memcmp( &data_index->Data_ObjId, &object->ExternObjId,
sizeof(pwr_tObjid)))
{
if ( data_index->Data_Select)
object->DataSelected--;
data_index->Data_Select = 0;
if ( i == object->SelectIndex)
{
if ( object->DataSelected > 0)
{
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex - 1;
for ( i = object->LastIndex; i > 0; i--)
{
if ( data_last->Data_Select)
{
memcpy( &object->DataLP, data_last,
sizeof( *data_last));
memcpy( &object->DataLastP, data_last,
sizeof( *data_last));
object->SelectIndex = i;
break;
}
data_last--;
}
}
else
{
memset( &object->DataLP, 0, sizeof( *data_last));
memset( &object->DataLastP, 0, sizeof( *data_last));
object->SelectIndex = 0;
}
}
break;
}
data_index++;
}
if ( memcmp( &data_index->Data_ObjId, &object->ExternObjId,
sizeof(pwr_tObjid)))
{
object->ExternStatus = 2; /* Felkod !!! */
}
object->ExternFlag = 0;
break;
case NMPS_OPTYPE_EXTDELETE_OBJID:
case NMPS_OPTYPE_EXTREMOVE_OBJID:
data_index = (plc_t_DataInfo *) &object->Data1P;
for ( object->ExternIndex = 1;
object->ExternIndex <= object->LastIndex;
object->ExternIndex++)
{
if ( !memcmp( &data_index->Data_ObjId, &object->ExternObjId,
sizeof(pwr_tObjid)))
break;
data_index++;
}
if ( memcmp( &data_index->Data_ObjId, &object->ExternObjId,
sizeof(pwr_tObjid)))
{
object->ExternStatus = 2; /* Felkod !!! */
object->ExternFlag = 0;
break;
}
case NMPS_OPTYPE_EXTDELETE:
if ( object->ExternOpType == NMPS_OPTYPE_EXTDELETE)
object->ExternIndex = 1;
case NMPS_OPTYPE_EXTDELETE_IDX:
if ( object->ExternIndex > object->LastIndex)
{
object->ExternStatus = 2; /* Felkod !!! */
object->ExternFlag = 0;
break;
}
object->ExternFlag = 0;
data_index = (plc_t_DataInfo *) &object->Data1P;
data_index += object->ExternIndex - 1;
sts = gdh_DLUnrefObjectInfo( data_index->Data_Dlid);
if ( object->Function & NMPS_CELLFUNC_DELETE &&
object->ExternOpType != NMPS_OPTYPE_EXTREMOVE_OBJID)
sts = gdh_DeleteObject( data_index->Data_ObjId);
/* Look for new last selected if data is selected */
if ( data_index->Data_Select)
{
object->DataSelected--;
if ( object->SelectIndex == object->ExternIndex)
{
if ( object->DataSelected > 0)
{
data_index = (plc_t_DataInfo *) &object->Data1P;
data_index += object->LastIndex - 1;
for ( i = object->LastIndex; i > 0; i--)
{
if ( data_index->Data_Select && i != object->ExternIndex)
{
memcpy( &object->DataLP, data_index,
sizeof( *data_index));
memcpy( &object->DataLastP, data_index,
sizeof( *data_index));
object->SelectIndex = i;
break;
}
data_index--;
}
}
else
{
memset( &object->DataLP, 0, sizeof( *data_last));
memset( &object->DataLastP, 0, sizeof( *data_last));
object->SelectIndex = 0;
}
}
}
if ( object->ExternIndex < object->LastIndex)
{
size = (object->LastIndex - object->ExternIndex)
* sizeof ( *data_max);
#if defined OS_LINUX
memcpy( &cpy_buf, (char *) data_index + sizeof( *data_max), size);
memcpy( data_index, &cpy_buf, size);
#else
memcpy( data_index, (char *) data_index + sizeof( *data_max),
size);
#endif
}
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex - 1;
memset( data_last, 0, sizeof( *data_last));
object->CellFull = 0;
object->LastIndex--;
object->ExternFlag = 0;
data_last--;
if (( object->SelectIndex != 0) &&
( object->SelectIndex > object->ExternIndex))
object->SelectIndex--;
object->ExternStatus = 1; /* Felkod Success!!! */
break;
case NMPS_OPTYPE_EXTMOVEFORW_OBJID:
data_index = (plc_t_DataInfo *) &object->Data1P;
for ( object->ExternIndex = 1;
object->ExternIndex <= object->LastIndex;
object->ExternIndex++)
{
if ( !memcmp( &data_index->Data_ObjId, &object->ExternObjId,
sizeof(pwr_tObjid)))
break;
data_index++;
}
if ( memcmp( &data_index->Data_ObjId, &object->ExternObjId,
sizeof(pwr_tObjid)))
{
object->ExternStatus = 2; /* Felkod !!! */
object->ExternFlag = 0;
break;
}
if ( object->ExternIndex >= object->LastIndex)
{
object->ExternStatus = 2; /* Felkod !!! */
object->ExternFlag = 0;
break;
}
data_index = (plc_t_DataInfo *) &object->Data1P;
data_index += object->ExternIndex - 1;
if ( !(data_index->Data_Front && data_index->Data_Back))
{
object->ExternStatus = 2; /* Felkod !!! */
object->ExternFlag = 0;
break;
}
memcpy( &data_tmp, data_index+1, sizeof( *data_index));
memcpy( data_index+1, data_index, sizeof( *data_index));
memcpy( data_index, &data_tmp, sizeof( *data_index));
if ( object->SelectIndex == object->ExternIndex)
object->SelectIndex++;
else if ( object->SelectIndex == object->ExternIndex + 1)
object->SelectIndex--;
object->ExternFlag = 0;
if ( (object->DataSelected == 0) && (object->ExternIndex == object->LastIndex -1))
{
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex - 1;
memcpy( &object->DataLP, data_last,
sizeof( *data_last));
memcpy( &object->DataLastP, data_last,
sizeof( *data_last));
}
object->ExternStatus = 1; /* Felkod Success!!! */
break;
case NMPS_OPTYPE_EXTMOVEBACKW_OBJID:
data_index = (plc_t_DataInfo *) &object->Data1P;
for ( object->ExternIndex = 1;
object->ExternIndex <= object->LastIndex;
object->ExternIndex++)
{
if ( !memcmp( &data_index->Data_ObjId, &object->ExternObjId,
sizeof(pwr_tObjid)))
break;
data_index++;
}
if ( memcmp( &data_index->Data_ObjId, &object->ExternObjId,
sizeof(pwr_tObjid)))
{
object->ExternStatus = 2; /* Felkod !!! */
object->ExternFlag = 0;
break;
}
if ( object->ExternIndex <= 1)
{
object->ExternStatus = 2; /* Felkod !!! */
object->ExternFlag = 0;
break;
}
data_index = (plc_t_DataInfo *) &object->Data1P;
data_index += object->ExternIndex - 1;
if ( !(data_index->Data_Front && data_index->Data_Back))
{
object->ExternStatus = 2; /* Felkod !!! */
object->ExternFlag = 0;
break;
}
memcpy( &data_tmp, data_index-1, sizeof( *data_index));
memcpy( data_index-1, data_index, sizeof( *data_index));
memcpy( data_index, &data_tmp, sizeof( *data_index));
if ( object->SelectIndex == object->ExternIndex)
object->SelectIndex--;
else if ( object->SelectIndex == object->ExternIndex - 1)
object->SelectIndex++;
object->ExternFlag = 0;
if ( (object->DataSelected == 0) && (object->ExternIndex == object->LastIndex))
{
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex - 1;
memcpy( &object->DataLP, data_last,
sizeof( *data_last));
memcpy( &object->DataLastP, data_last,
sizeof( *data_last));
}
object->ExternStatus = 1; /* Felkod Success!!! */
break;
}
if (object->Function & NMPS_CELLFUNC_BACKUP) object->BackupNow = 1;
}
/* Count and find new selected objects */
object->DataSelected = 0;
data_index = (plc_t_DataInfo *) &object->Data1P;
for ( i = 1; i <= object->LastIndex; i++)
{
if ( data_index->Data_Select && !data_index->Data_OldSelect)
{
memcpy( &object->DataLP, data_index,
sizeof( *data_index));
memcpy( &object->DataLastP, data_index,
sizeof( *data_index));
object->SelectIndex = i;
object->RearNew = 1;
if (object->Function & NMPS_CELLFUNC_BACKUP) object->BackupNow = 1;
}
if ( data_index->Data_Select )
object->DataSelected++;
data_index->Data_OldSelect = data_index->Data_Select;
data_index++;
}
if (( object->Function & NMPS_CELLFUNC_SINGELSELECT) ||
( object->Function & NMPS_CELLFUNC_ONESELECT))
{
/* Unselect everone exept last selected */
if ( object->DataSelected > 1)
{
data_index = (plc_t_DataInfo *) &object->Data1P;
for ( i = 1; i <= object->LastIndex; i++)
{
if ( i != object->SelectIndex)
data_index->Data_Select = 0;
data_index++;
}
object->DataSelected = 1;
if (object->Function & NMPS_CELLFUNC_BACKUP) object->BackupNow = 1;
}
}
if ( object->Function & NMPS_CELLFUNC_ONESELECT)
{
if (( object->DataSelected == 0) && ( object->LastIndex != 0))
{
data_index = (plc_t_DataInfo *) &object->Data1P;
data_index += object->LastIndex - 1;
data_index->Data_Select = 1;
data_index->Data_OldSelect = 1;
memcpy( &object->DataLP, data_index, sizeof( *data_last));
memcpy( &object->DataLastP, data_index, sizeof( *data_last));
object->SelectIndex = object->LastIndex;
object->DataSelected = 1;
if (object->Function & NMPS_CELLFUNC_BACKUP) object->BackupNow = 1;
}
}
if ( object->DataSelected == 0)
{
memset( &object->DataLP, 0, sizeof( *data_last));
memset( &object->DataLastP, 0, sizeof( *data_last));
object->SelectIndex = 0;
}
if ( object->InFlag)
{
/* Insert new object in Front position */
switch( object->InOpType)
{
case NMPS_OPTYPE_FORWARD_FRONT:
/* Insert at front of object front of data */
if ( object->CellFull) return;
if ( object->LastIndex > 0)
{
#if defined OS_LINUX
memcpy( &cpy_buf, &object->Data1P,
object->LastIndex * sizeof ( *data_max));
memcpy( &object->Data2P, &cpy_buf,
object->LastIndex * sizeof ( *data_max));
#else
memcpy( &object->Data2P, &object->Data1P,
object->LastIndex * sizeof ( *data_max));
#endif
}
object->Data1P = object->InPointer;
object->Data1_ObjId = object->InObjId;
object->Data1_Front = 1;
object->Data1_Back = 0;
object->Data1_Select = 0;
object->InFlag = 0;
object->Data1_Dlid = object->InDlid;
object->FrontNew = 1;
object->LastIndex++;
if ( object->DataSelected > 0)
object->SelectIndex++;
if ( object->LastIndex == object->MaxSize)
object->CellFull = 1;
break;
case NMPS_OPTYPE_FORWARD_BACK:
if ( memcmp( &object->Data1_ObjId, &object->InObjId,
sizeof(pwr_tObjid)))
{
/* This it not the correct object */
object->InFlag = 0;
return;
}
object->Data1_Back = 1;
if ( object->SelectIndex == 1)
{
object->DataL_Back = 1;
object->DataLast_Back = 1;
}
object->InFlag = 0;
break;
case NMPS_OPTYPE_FORWARD_UNIT:
if ( object->CellFull) return;
if ( object->LastIndex > 0)
{
#if defined OS_LINUX
memcpy( &cpy_buf, &object->Data1P,
object->LastIndex * sizeof ( *data_max));
memcpy( &object->Data2P, &cpy_buf,
object->LastIndex * sizeof ( *data_max));
#else
memcpy( &object->Data2P, &object->Data1P,
object->LastIndex * sizeof ( *data_max));
#endif
}
object->Data1P = object->InPointer;
object->Data1_ObjId = object->InObjId;
object->Data1_Front = 1;
object->Data1_Back = 1;
object->Data1_Select = 0;
object->Data1_Dlid = object->InDlid;
object->InFlag = 0;
object->FrontNew = 1;
if ( object->DataSelected > 0)
object->SelectIndex++;
object->LastIndex++;
if ( object->LastIndex == object->MaxSize)
object->CellFull = 1;
break;
case NMPS_OPTYPE_REVERSE_BACK:
/* Insert at rear of object back of data */
if ( object->CellFull) return;
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex;
data_last->DataP = object->InPointer;
data_last->Data_ObjId = object->InObjId;
data_last->Data_Front = 0;
data_last->Data_Back = 1;
data_last->Data_Dlid = object->InDlid;
object->InFlag = 0;
object->LastIndex++;
if ( object->LastIndex == object->MaxSize)
object->CellFull = 1;
break;
case NMPS_OPTYPE_REVERSE_UNIT:
/* Insert at rear of object all of data */
if ( object->CellFull) return;
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex;
data_last->DataP = object->InPointer;
data_last->Data_ObjId = object->InObjId;
data_last->Data_Front = 1;
data_last->Data_Back = 1;
data_last->Data_Dlid = object->InDlid;
object->InFlag = 0;
object->LastIndex++;
if ( object->LastIndex == object->MaxSize)
object->CellFull = 1;
break;
case NMPS_OPTYPE_REVERSE_FRONT:
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex - 1;
if ( memcmp( &data_last->Data_ObjId, &object->InObjId,
sizeof(pwr_tObjid)))
{
/* This it not the correct object */
object->InFlag = 0;
return;
}
data_last->Data_Front = 1;
object->InFlag = 0;
break;
}
if (object->Function & NMPS_CELLFUNC_BACKUP) object->BackupNow = 1;
}
if ( object->OutRearFlag)
{
/* Remove an object in Rear position */
switch( object->OutRearOpType)
{
case NMPS_OPTYPE_UNIT:
/* Get the last data */
if ( object->LastIndex == 0)
{
object->OutRearFlag = 0;
return;
}
data_index = (plc_t_DataInfo *) &object->Data1P;
data_index += object->SelectIndex - 1;
if ( object->SelectIndex < object->LastIndex)
{
size = (object->LastIndex - object->SelectIndex)
* sizeof ( *data_max);
#if defined OS_LINUX
memcpy( &cpy_buf, (char *) data_index + sizeof( *data_max), size);
memcpy( data_index, &cpy_buf, size);
#else
memcpy( data_index, (char *) data_index + sizeof( *data_max),
size);
#endif
}
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex - 1;
memset( data_last, 0, sizeof( *data_last));
object->CellFull = 0;
object->LastIndex--;
object->DataSelected--;
/* Find next selected, search backwards */
if ( object->DataSelected > 0)
{
data_index = (plc_t_DataInfo *) &object->Data1P;
data_index += object->LastIndex - 1;
for ( i = object->LastIndex; i > 0; i--)
{
if ( data_index->Data_Select)
{
memcpy( &object->DataLP, data_index,
sizeof( *data_index));
memcpy( &object->DataLastP, data_index,
sizeof( *data_index));
object->SelectIndex = i;
break;
}
data_index--;
}
}
else
{
memset( &object->DataLP, 0, sizeof( *data_last));
memset( &object->DataLastP, 0, sizeof( *data_last));
object->SelectIndex = 0;
}
object->OutRearFlag = 0;
break;
}
if (object->Function & NMPS_CELLFUNC_BACKUP) object->BackupNow = 1;
}
if ( object->OutFrontFlag)
{
/* Remove an object in Front position */
switch( object->OutFrontOpType)
{
case NMPS_OPTYPE_FRONT:
case NMPS_OPTYPE_UNIT:
/* Get the last data */
if ( object->LastIndex == 0)
{
object->OutFrontFlag = 0;
return;
}
if ( object->Data1_Select)
{
object->DataSelected--;
if ( object->SelectIndex == 1)
{
if ( object->DataSelected > 0)
{
data_index = (plc_t_DataInfo *) &object->Data1P;
data_index += object->LastIndex - 1;
for ( i = object->LastIndex; i > 1; i--)
{
if ( data_index->Data_Select)
{
memcpy( &object->DataLP, data_index,
sizeof( *data_index));
memcpy( &object->DataLastP, data_index,
sizeof( *data_index));
object->SelectIndex = i;
break;
}
data_index--;
}
}
else
{
memset( &object->DataLP, 0, sizeof( *data_last));
memset( &object->DataLastP, 0, sizeof( *data_last));
object->SelectIndex = 0;
}
}
}
if ( object->SelectIndex > 0)
object->SelectIndex--;
#if defined OS_LINUX
memcpy( &cpy_buf, &object->Data2P,
(object->LastIndex - 1) * sizeof( *data_last));
memcpy( &object->Data1P, &cpy_buf,
(object->LastIndex - 1) * sizeof( *data_last));
#else
memcpy( &object->Data1P, &object->Data2P,
(object->LastIndex - 1) * sizeof( *data_last));
#endif
data_last = (plc_t_DataInfo *) &object->Data1P;
data_last += object->LastIndex - 1;
memset( data_last, 0, sizeof( *data_last));
object->CellFull = 0;
object->LastIndex--;
object->OutFrontFlag = 0;
break;
case NMPS_OPTYPE_BACK:
object->Data1_Back = 0;
object->OutFrontFlag = 0;
if ( object->LastIndex == object->SelectIndex)
{
object->DataL_Back = 0;
object->DataLast_Back = 0;
}
break;
}
if (object->Function & NMPS_CELLFUNC_BACKUP) object->BackupNow = 1;
}
object->NumberOfData = object->DataSelected;
}
/**
NMpsOutCell
@aref nmpsoutcell NMpsOutCell
*/
void NMpsOutCell_exec(
plc_sThread *tp,
pwr_sClass_NMpsOutCell *object)
{
int sts;
if ( object->FrontNew) object->FrontNew = 0;
if ( object->InFlag)
{
switch( object->InOpType)
{
case NMPS_OPTYPE_FORWARD_UNIT:
sts = gdh_DLUnrefObjectInfo ( object->InDlid);
if ( object->Function & NMPS_CELLFUNC_DELETE )
sts = gdh_DeleteObject( object->InObjId);
object->InFlag = 0;
object->FrontNew = 1;
break;
}
}
}
/**
NMpsTrp
@aref nmpstrp NMpsTrp
*/
void NMpsTrp_exec(
plc_sThread *tp,
pwr_sClass_NMpsTrp *object)
{
if (object->Status)
object->Status = 0;
if ( ( *(object->TriggForwFrontP) && !object->OldTriggForwFront) ||
( *(object->TriggForwFrontP) && object->Function & NMPS_TRPFUNC_LEVEL) ||
object->FuncAllForward )
{
if ( object->Function & NMPS_TRPFUNC_UNIT)
{
/* Move all of data */
/* Check destination */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
goto trp_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->NumberOfData == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trp_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->OutRearFlag ) return;
/* Check that both Back and Front is in the in cell */
if ( !( ((pwr_sClass_NMpsCell *)(object->InP))->DataL_Back &&
((pwr_sClass_NMpsCell *)(object->InP))->DataL_Front))
{
object->Status = 1;
goto trp_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->OutP))->InPointer =
((pwr_sClass_NMpsCell *)(object->InP))->DataLP;
((pwr_sClass_NMpsCell *)(object->OutP))->InObjId =
((pwr_sClass_NMpsCell *)(object->InP))->DataL_ObjId;
((pwr_sClass_NMpsCell *)(object->OutP))->InDlid =
((pwr_sClass_NMpsCell *)(object->InP))->DataL_Dlid;
((pwr_sClass_NMpsCell *)(object->OutP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->OutRearFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->InOpType =
NMPS_OPTYPE_FORWARD_UNIT;
((pwr_sClass_NMpsCell *)(object->InP))->OutRearOpType =
NMPS_OPTYPE_UNIT;
}
else if (( object->Function & NMPS_TRPFUNC_ALL) ||
( object->Function & NMPS_TRPFUNC_ALLEMPTY))
{
/* Move all of data */
/* Check destination */
if ( *(object->TriggForwFrontP) &&
!object->OldTriggForwFront)
{
/* This is the first object to move */
if ( object->FuncAllReverse || object->FuncAllForward)
{
/* We are already busy moving last trigg */
return;
}
if ( object->Function & NMPS_TRPFUNC_ALLEMPTY)
{
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->NumberOfData != 0)
{
/* Destination cell is not empty */
object->Status = 1;
goto trp_return;
}
}
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
object->FuncAllForward = 0;
goto trp_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->NumberOfData == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trp_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->OutRearFlag ) return;
if ( object->Function & NMPS_TRPFUNC_SLOW &&
object->FuncAllForward == 1)
{
/* Wait till next scan */
object->FuncAllForward = 2;
goto trp_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->OutP))->InPointer =
((pwr_sClass_NMpsCell *)(object->InP))->DataLP;
((pwr_sClass_NMpsCell *)(object->OutP))->InObjId =
((pwr_sClass_NMpsCell *)(object->InP))->DataL_ObjId;
((pwr_sClass_NMpsCell *)(object->OutP))->InDlid =
((pwr_sClass_NMpsCell *)(object->InP))->DataL_Dlid;
((pwr_sClass_NMpsCell *)(object->OutP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->OutRearFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->InOpType =
NMPS_OPTYPE_FORWARD_UNIT;
((pwr_sClass_NMpsCell *)(object->InP))->OutRearOpType =
NMPS_OPTYPE_UNIT;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->NumberOfData == 1)
object->FuncAllForward = 0;
else
object->FuncAllForward = 1;
}
else
{
/* Move front of data */
/* Check destination */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
goto trp_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->LastIndex == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trp_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->OutRearFlag ) return;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->DataLP ==
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P )
{
/* This should be a Back trigg */
object->Status = 1;
goto trp_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->OutP))->InPointer =
((pwr_sClass_NMpsCell *)(object->InP))->DataLP;
((pwr_sClass_NMpsCell *)(object->OutP))->InObjId =
((pwr_sClass_NMpsCell *)(object->InP))->DataL_ObjId;
((pwr_sClass_NMpsCell *)(object->OutP))->InDlid =
((pwr_sClass_NMpsCell *)(object->InP))->DataL_Dlid;
((pwr_sClass_NMpsCell *)(object->OutP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->OutRearFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->InOpType =
NMPS_OPTYPE_FORWARD_FRONT;
((pwr_sClass_NMpsCell *)(object->InP))->OutRearOpType = NMPS_OPTYPE_FRONT;
}
}
if ( *(object->TriggForwBackP) && !object->OldTriggForwBack)
{
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->LastIndex == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trp_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->OutRearFlag ) return;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->DataLP !=
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P )
{
/* This should be a Front trigg */
object->Status = 1;
goto trp_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->OutP))->InPointer =
((pwr_sClass_NMpsCell *)(object->InP))->DataLP;
((pwr_sClass_NMpsCell *)(object->OutP))->InObjId =
((pwr_sClass_NMpsCell *)(object->InP))->DataL_ObjId;
((pwr_sClass_NMpsCell *)(object->OutP))->InDlid =
((pwr_sClass_NMpsCell *)(object->InP))->DataL_Dlid;
((pwr_sClass_NMpsCell *)(object->OutP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->OutRearFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->InOpType =
NMPS_OPTYPE_FORWARD_BACK;
((pwr_sClass_NMpsCell *)(object->InP))->OutRearOpType = NMPS_OPTYPE_BACK;
}
if ( *(object->TriggReverseBackP) && !object->OldTriggReverseBack)
{
/* Check destination */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
goto trp_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->LastIndex == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trp_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontFlag ) return;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->DataLP ==
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P )
{
/* This should be a Front trigg */
object->Status = 1;
goto trp_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->InP))->InPointer =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P;
((pwr_sClass_NMpsCell *)(object->InP))->InObjId =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_ObjId;
((pwr_sClass_NMpsCell *)(object->InP))->InDlid =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_Dlid;
((pwr_sClass_NMpsCell *)(object->InP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->InOpType =
NMPS_OPTYPE_REVERSE_BACK;
((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontOpType =
NMPS_OPTYPE_BACK;
}
if ( ( *(object->TriggReverseFrontP) && !object->OldTriggReverseFront) ||
( *(object->TriggReverseFrontP) && object->Function & NMPS_TRPFUNC_LEVEL) ||
object->FuncAllReverse)
{
if ( object->Function & NMPS_TRPFUNC_UNIT)
{
/* Check destination */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
goto trp_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->LastIndex == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trp_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontFlag ) return;
/* Check that both Front and Back is in the cell */
if ( !( ((pwr_sClass_NMpsCell *)(object->OutP))->Data1_Back &&
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_Front))
{
object->Status = 1;
goto trp_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->InP))->InPointer =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P;
((pwr_sClass_NMpsCell *)(object->InP))->InObjId =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_ObjId;
((pwr_sClass_NMpsCell *)(object->InP))->InDlid =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_Dlid;
((pwr_sClass_NMpsCell *)(object->InP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->InOpType =
NMPS_OPTYPE_REVERSE_UNIT;
((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontOpType =
NMPS_OPTYPE_UNIT;
}
else if (( object->Function & NMPS_TRPFUNC_ALL) ||
( object->Function & NMPS_TRPFUNC_ALLEMPTY))
{
if ( *(object->TriggReverseFrontP) &&
!object->OldTriggReverseFront)
{
/* This is the first object to move */
if ( object->FuncAllReverse || object->FuncAllForward)
{
/* We are already busy moving last trigg */
return;
}
/* Check destination */
if ( object->Function & NMPS_TRPFUNC_ALLEMPTY)
{
if ( ((pwr_sClass_NMpsCell *)(object->InP))->LastIndex)
{
/* Destination cell is not empty */
object->Status = 1;
goto trp_return;
}
}
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
object->FuncAllReverse = 0;
goto trp_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->NumberOfData == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trp_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontFlag ) return;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->DataLP ==
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P )
{
object->Status = 1;
goto trp_return;
}
if ( object->Function & NMPS_TRPFUNC_SLOW &&
object->FuncAllForward == 1)
{
/* Wait till next scan */
object->FuncAllForward = 2;
goto trp_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->InP))->InPointer =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P;
((pwr_sClass_NMpsCell *)(object->InP))->InObjId =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_ObjId;
((pwr_sClass_NMpsCell *)(object->InP))->InDlid =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_Dlid;
((pwr_sClass_NMpsCell *)(object->InP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->InOpType =
NMPS_OPTYPE_REVERSE_UNIT;
((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontOpType =
NMPS_OPTYPE_UNIT;
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->NumberOfData == 1)
object->FuncAllReverse = 0;
else
object->FuncAllReverse = 1;
}
else
{
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->NumberOfData == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trp_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontFlag ) return;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->DataLP !=
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P )
{
/* This should be a Back trigg */
object->Status = 1;
goto trp_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->InP))->InPointer =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P;
((pwr_sClass_NMpsCell *)(object->InP))->InObjId =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_ObjId;
((pwr_sClass_NMpsCell *)(object->InP))->InDlid =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_Dlid;
((pwr_sClass_NMpsCell *)(object->InP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->InOpType =
NMPS_OPTYPE_REVERSE_FRONT;
((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontOpType =
NMPS_OPTYPE_FRONT;
}
}
trp_return:
object->OldTriggForwFront = *(object->TriggForwFrontP);
object->OldTriggReverseFront = *(object->TriggReverseFrontP);
object->OldTriggForwBack = *(object->TriggForwBackP);
object->OldTriggReverseBack = *(object->TriggReverseBackP);
if ( object->Function & NMPS_TRPFUNC_TRIGGRESET)
{
/* Reset the trigg flags */
object->TriggForwFront = 0;
object->TriggReverseFront = 0;
object->TriggForwBack = 0;
object->TriggReverseBack = 0;
}
}
/**
NMpsTrpRR
@aref nmpstrprr NMpsTrpRR
*/
void NMpsTrpRR_exec(
plc_sThread *tp,
pwr_sClass_NMpsTrpRR *object)
{
if (object->Status)
object->Status = 0;
if ( ( *(object->TriggForwFrontP) && !object->OldTriggForwFront) ||
( *(object->TriggForwFrontP) && object->Function & NMPS_TRPFUNC_LEVEL) ||
object->FuncAllForward )
{
if ( object->Function & NMPS_TRPFUNC_UNIT)
{
/* Move all of data */
/* Check destination */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
goto trprr_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->NumberOfData == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trprr_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->OutRearFlag ) return;
/* Check that both Back and Front is in the in cell */
if ( !( ((pwr_sClass_NMpsCell *)(object->InP))->DataL_Back &&
((pwr_sClass_NMpsCell *)(object->InP))->DataL_Front))
{
object->Status = 1;
goto trprr_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->OutP))->InPointer =
((pwr_sClass_NMpsCell *)(object->InP))->DataLP;
((pwr_sClass_NMpsCell *)(object->OutP))->InObjId =
((pwr_sClass_NMpsCell *)(object->InP))->DataL_ObjId;
((pwr_sClass_NMpsCell *)(object->OutP))->InDlid =
((pwr_sClass_NMpsCell *)(object->InP))->DataL_Dlid;
((pwr_sClass_NMpsCell *)(object->OutP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->OutRearFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->InOpType =
NMPS_OPTYPE_REVERSE_UNIT;
((pwr_sClass_NMpsCell *)(object->InP))->OutRearOpType =
NMPS_OPTYPE_UNIT;
}
else if (( object->Function & NMPS_TRPFUNC_ALL) ||
( object->Function & NMPS_TRPFUNC_ALLEMPTY))
{
/* Move all of data */
/* Check destination */
if ( *(object->TriggForwFrontP) &&
!object->OldTriggForwFront)
{
/* This is the first object to move */
if ( object->FuncAllReverse || object->FuncAllForward)
{
/* We are already busy moving last trigg */
return;
}
if ( object->Function & NMPS_TRPFUNC_ALLEMPTY)
{
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->NumberOfData != 0)
{
/* Destination cell is not empty */
object->Status = 1;
goto trprr_return;
}
}
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
object->FuncAllForward = 0;
goto trprr_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->NumberOfData == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trprr_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->OutRearFlag ) return;
if ( object->Function & NMPS_TRPFUNC_SLOW &&
object->FuncAllForward == 1)
{
/* Wait till next scan */
object->FuncAllForward = 2;
goto trprr_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->OutP))->InPointer =
((pwr_sClass_NMpsCell *)(object->InP))->DataLP;
((pwr_sClass_NMpsCell *)(object->OutP))->InObjId =
((pwr_sClass_NMpsCell *)(object->InP))->DataL_ObjId;
((pwr_sClass_NMpsCell *)(object->OutP))->InDlid =
((pwr_sClass_NMpsCell *)(object->InP))->DataL_Dlid;
((pwr_sClass_NMpsCell *)(object->OutP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->OutRearFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->InOpType =
NMPS_OPTYPE_REVERSE_UNIT;
((pwr_sClass_NMpsCell *)(object->InP))->OutRearOpType =
NMPS_OPTYPE_UNIT;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->NumberOfData == 1)
object->FuncAllForward = 0;
else
object->FuncAllForward = 1;
}
else
{
/* Move front of data */
/* Check destination */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
goto trprr_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->NumberOfData == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trprr_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->OutRearFlag ) return;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->DataLP ==
((pwr_sClass_NMpsCell *)(object->OutP))->DataLP )
{
/* This should be a Back trigg */
object->Status = 1;
goto trprr_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->OutP))->InPointer =
((pwr_sClass_NMpsCell *)(object->InP))->DataLP;
((pwr_sClass_NMpsCell *)(object->OutP))->InObjId =
((pwr_sClass_NMpsCell *)(object->InP))->DataL_ObjId;
((pwr_sClass_NMpsCell *)(object->OutP))->InDlid =
((pwr_sClass_NMpsCell *)(object->InP))->DataL_Dlid;
((pwr_sClass_NMpsCell *)(object->OutP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->OutRearFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->InOpType =
NMPS_OPTYPE_REVERSE_BACK;
((pwr_sClass_NMpsCell *)(object->InP))->OutRearOpType = NMPS_OPTYPE_FRONT;
}
}
if ( *(object->TriggForwBackP) && !object->OldTriggForwBack)
{
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->NumberOfData == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trprr_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->OutRearFlag ) return;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->DataLP !=
((pwr_sClass_NMpsCell *)(object->OutP))->DataLP )
{
/* This should be a Front trigg */
object->Status = 1;
goto trprr_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->OutP))->InPointer =
((pwr_sClass_NMpsCell *)(object->InP))->DataLP;
((pwr_sClass_NMpsCell *)(object->OutP))->InObjId =
((pwr_sClass_NMpsCell *)(object->InP))->DataL_ObjId;
((pwr_sClass_NMpsCell *)(object->OutP))->InDlid =
((pwr_sClass_NMpsCell *)(object->InP))->DataL_Dlid;
((pwr_sClass_NMpsCell *)(object->OutP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->OutRearFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->InOpType =
NMPS_OPTYPE_REVERSE_FRONT;
((pwr_sClass_NMpsCell *)(object->InP))->OutRearOpType = NMPS_OPTYPE_BACK;
}
if ( *(object->TriggReverseBackP) && !object->OldTriggReverseBack)
{
/* Check destination */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
goto trprr_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->NumberOfData == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trprr_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->OutRearFlag ) return;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->DataLP ==
((pwr_sClass_NMpsCell *)(object->OutP))->DataLP )
{
/* This should be a Front trigg */
object->Status = 1;
goto trprr_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->InP))->InPointer =
((pwr_sClass_NMpsCell *)(object->OutP))->DataLP;
((pwr_sClass_NMpsCell *)(object->InP))->InObjId =
((pwr_sClass_NMpsCell *)(object->OutP))->DataL_ObjId;
((pwr_sClass_NMpsCell *)(object->InP))->InDlid =
((pwr_sClass_NMpsCell *)(object->OutP))->DataL_Dlid;
((pwr_sClass_NMpsCell *)(object->InP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->OutRearFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->InOpType =
NMPS_OPTYPE_REVERSE_BACK;
((pwr_sClass_NMpsCell *)(object->OutP))->OutRearOpType =
NMPS_OPTYPE_FRONT;
}
if ( ( *(object->TriggReverseFrontP) && !object->OldTriggReverseFront) ||
( *(object->TriggReverseFrontP) && object->Function & NMPS_TRPFUNC_LEVEL) ||
object->FuncAllReverse)
{
if ( object->Function & NMPS_TRPFUNC_UNIT)
{
/* Check destination */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
goto trprr_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->NumberOfData == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trprr_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->OutRearFlag ) return;
/* Check that both Front and Back is in the cell */
if ( !( ((pwr_sClass_NMpsCell *)(object->OutP))->DataL_Back &&
((pwr_sClass_NMpsCell *)(object->OutP))->DataL_Front))
{
object->Status = 1;
goto trprr_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->InP))->InPointer =
((pwr_sClass_NMpsCell *)(object->OutP))->DataLP;
((pwr_sClass_NMpsCell *)(object->InP))->InObjId =
((pwr_sClass_NMpsCell *)(object->OutP))->DataL_ObjId;
((pwr_sClass_NMpsCell *)(object->InP))->InDlid =
((pwr_sClass_NMpsCell *)(object->OutP))->DataL_Dlid;
((pwr_sClass_NMpsCell *)(object->InP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->OutRearFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->InOpType =
NMPS_OPTYPE_REVERSE_UNIT;
((pwr_sClass_NMpsCell *)(object->OutP))->OutRearOpType =
NMPS_OPTYPE_UNIT;
}
else if (( object->Function & NMPS_TRPFUNC_ALL) ||
( object->Function & NMPS_TRPFUNC_ALLEMPTY))
{
if ( *(object->TriggReverseFrontP) &&
!object->OldTriggReverseFront)
{
/* This is the first object to move */
if ( object->FuncAllReverse || object->FuncAllForward)
{
/* We are already busy moving last trigg */
return;
}
/* Check destination */
if ( object->Function & NMPS_TRPFUNC_ALLEMPTY)
{
if ( ((pwr_sClass_NMpsCell *)(object->InP))->NumberOfData)
{
/* Destination cell is not empty */
object->Status = 1;
goto trprr_return;
}
}
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
object->FuncAllReverse = 0;
goto trprr_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->NumberOfData == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trprr_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->OutRearFlag ) return;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->DataLP ==
((pwr_sClass_NMpsCell *)(object->OutP))->DataLP )
{
object->Status = 1;
goto trprr_return;
}
if ( object->Function & NMPS_TRPFUNC_SLOW &&
object->FuncAllForward == 1)
{
/* Wait till next scan */
object->FuncAllForward = 2;
goto trprr_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->InP))->InPointer =
((pwr_sClass_NMpsCell *)(object->OutP))->DataLP;
((pwr_sClass_NMpsCell *)(object->InP))->InObjId =
((pwr_sClass_NMpsCell *)(object->OutP))->DataL_ObjId;
((pwr_sClass_NMpsCell *)(object->InP))->InDlid =
((pwr_sClass_NMpsCell *)(object->OutP))->DataL_Dlid;
((pwr_sClass_NMpsCell *)(object->InP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->OutRearFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->InOpType =
NMPS_OPTYPE_REVERSE_UNIT;
((pwr_sClass_NMpsCell *)(object->OutP))->OutRearOpType =
NMPS_OPTYPE_UNIT;
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->NumberOfData == 1)
object->FuncAllReverse = 0;
else
object->FuncAllReverse = 1;
}
else
{
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->NumberOfData == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trprr_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->OutRearFlag ) return;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->DataLP !=
((pwr_sClass_NMpsCell *)(object->OutP))->DataLP )
{
/* This should be a Back trigg */
object->Status = 1;
goto trprr_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->InP))->InPointer =
((pwr_sClass_NMpsCell *)(object->OutP))->DataLP;
((pwr_sClass_NMpsCell *)(object->InP))->InObjId =
((pwr_sClass_NMpsCell *)(object->OutP))->DataL_ObjId;
((pwr_sClass_NMpsCell *)(object->InP))->InDlid =
((pwr_sClass_NMpsCell *)(object->OutP))->DataL_Dlid;
((pwr_sClass_NMpsCell *)(object->InP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->OutRearFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->InOpType =
NMPS_OPTYPE_REVERSE_FRONT;
((pwr_sClass_NMpsCell *)(object->OutP))->OutRearOpType =
NMPS_OPTYPE_BACK;
}
}
trprr_return:
object->OldTriggForwFront = *(object->TriggForwFrontP);
object->OldTriggReverseFront = *(object->TriggReverseFrontP);
object->OldTriggForwBack = *(object->TriggForwBackP);
object->OldTriggReverseBack = *(object->TriggReverseBackP);
if ( object->Function & NMPS_TRPFUNC_TRIGGRESET)
{
/* Reset the trigg flags */
object->TriggForwFront = 0;
object->TriggReverseFront = 0;
object->TriggForwBack = 0;
object->TriggReverseBack = 0;
}
}
/**
NMpsTrpFF
@aref nmpstrpff NMpsTrpFF
*/
void NMpsTrpFF_exec(
plc_sThread *tp,
pwr_sClass_NMpsTrpFF *object)
{
if (object->Status)
object->Status = 0;
if ( ( *(object->TriggForwFrontP) && !object->OldTriggForwFront) ||
( *(object->TriggForwFrontP) && object->Function & NMPS_TRPFUNC_LEVEL) ||
object->FuncAllForward )
{
if ( object->Function & NMPS_TRPFUNC_UNIT)
{
/* Move all of data */
/* Check destination */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
goto trpff_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->LastIndex == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trpff_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->OutFrontFlag ) return;
/* Check that both Back and Front is in the in cell */
if ( !( ((pwr_sClass_NMpsCell *)(object->InP))->Data1_Back &&
((pwr_sClass_NMpsCell *)(object->InP))->Data1_Front))
{
object->Status = 1;
goto trpff_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->OutP))->InPointer =
((pwr_sClass_NMpsCell *)(object->InP))->Data1P;
((pwr_sClass_NMpsCell *)(object->OutP))->InObjId =
((pwr_sClass_NMpsCell *)(object->InP))->Data1_ObjId;
((pwr_sClass_NMpsCell *)(object->OutP))->InDlid =
((pwr_sClass_NMpsCell *)(object->InP))->Data1_Dlid;
((pwr_sClass_NMpsCell *)(object->OutP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->OutFrontFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->InOpType =
NMPS_OPTYPE_FORWARD_UNIT;
((pwr_sClass_NMpsCell *)(object->InP))->OutFrontOpType =
NMPS_OPTYPE_UNIT;
}
else if (( object->Function & NMPS_TRPFUNC_ALL) ||
( object->Function & NMPS_TRPFUNC_ALLEMPTY))
{
/* Move all of data */
/* Check destination */
if ( *(object->TriggForwFrontP) &&
!object->OldTriggForwFront)
{
/* This is the first object to move */
if ( object->FuncAllReverse || object->FuncAllForward)
{
/* We are already busy moving last trigg */
return;
}
if ( object->Function & NMPS_TRPFUNC_ALLEMPTY)
{
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->LastIndex != 0)
{
/* Destination cell is not empty */
object->Status = 1;
goto trpff_return;
}
}
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
object->FuncAllForward = 0;
goto trpff_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->LastIndex == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trpff_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->OutFrontFlag ) return;
if ( object->Function & NMPS_TRPFUNC_SLOW &&
object->FuncAllForward == 1)
{
/* Wait till next scan */
object->FuncAllForward = 2;
goto trpff_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->OutP))->InPointer =
((pwr_sClass_NMpsCell *)(object->InP))->Data1P;
((pwr_sClass_NMpsCell *)(object->OutP))->InObjId =
((pwr_sClass_NMpsCell *)(object->InP))->Data1_ObjId;
((pwr_sClass_NMpsCell *)(object->OutP))->InDlid =
((pwr_sClass_NMpsCell *)(object->InP))->Data1_Dlid;
((pwr_sClass_NMpsCell *)(object->OutP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->OutFrontFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->InOpType =
NMPS_OPTYPE_FORWARD_UNIT;
((pwr_sClass_NMpsCell *)(object->InP))->OutFrontOpType =
NMPS_OPTYPE_UNIT;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->LastIndex == 1)
object->FuncAllForward = 0;
else
object->FuncAllForward = 1;
}
else
{
/* Move front of data */
/* Check destination */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
goto trpff_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->LastIndex == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trpff_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->OutFrontFlag ) return;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->Data1P ==
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P )
{
/* This should be a Back trigg */
object->Status = 1;
goto trpff_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->OutP))->InPointer =
((pwr_sClass_NMpsCell *)(object->InP))->Data1P;
((pwr_sClass_NMpsCell *)(object->OutP))->InObjId =
((pwr_sClass_NMpsCell *)(object->InP))->Data1_ObjId;
((pwr_sClass_NMpsCell *)(object->OutP))->InDlid =
((pwr_sClass_NMpsCell *)(object->InP))->Data1_Dlid;
((pwr_sClass_NMpsCell *)(object->OutP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->OutFrontFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->InOpType =
NMPS_OPTYPE_FORWARD_FRONT;
((pwr_sClass_NMpsCell *)(object->InP))->OutFrontOpType =
NMPS_OPTYPE_BACK;
}
}
if ( *(object->TriggForwBackP) && !object->OldTriggForwBack)
{
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->LastIndex == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trpff_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->OutRearFlag ) return;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->Data1P !=
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P )
{
/* This should be a Front trigg */
object->Status = 1;
goto trpff_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->OutP))->InPointer =
((pwr_sClass_NMpsCell *)(object->InP))->Data1P;
((pwr_sClass_NMpsCell *)(object->OutP))->InObjId =
((pwr_sClass_NMpsCell *)(object->InP))->Data1_ObjId;
((pwr_sClass_NMpsCell *)(object->OutP))->InDlid =
((pwr_sClass_NMpsCell *)(object->InP))->Data1_Dlid;
((pwr_sClass_NMpsCell *)(object->OutP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->OutFrontFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->InOpType =
NMPS_OPTYPE_FORWARD_BACK;
((pwr_sClass_NMpsCell *)(object->InP))->OutFrontOpType =
NMPS_OPTYPE_FRONT;
}
if ( *(object->TriggReverseBackP) && !object->OldTriggReverseBack)
{
/* Check destination */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
goto trpff_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->LastIndex == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trpff_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontFlag ) return;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->Data1P ==
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P )
{
/* This should be a Front trigg */
object->Status = 1;
goto trpff_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->InP))->InPointer =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P;
((pwr_sClass_NMpsCell *)(object->InP))->InObjId =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_ObjId;
((pwr_sClass_NMpsCell *)(object->InP))->InDlid =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_Dlid;
((pwr_sClass_NMpsCell *)(object->InP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->InOpType =
NMPS_OPTYPE_FORWARD_FRONT;
((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontOpType =
NMPS_OPTYPE_BACK;
}
if ( ( *(object->TriggReverseFrontP) && !object->OldTriggReverseFront) ||
( *(object->TriggReverseFrontP) && object->Function & NMPS_TRPFUNC_LEVEL) ||
object->FuncAllReverse)
{
if ( object->Function & NMPS_TRPFUNC_UNIT)
{
/* Check destination */
if ( ((pwr_sClass_NMpsCell *)(object->InP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
goto trpff_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->LastIndex == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trpff_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontFlag ) return;
/* Check that both Front and Back is in the cell */
if ( !( ((pwr_sClass_NMpsCell *)(object->OutP))->Data1_Back &&
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_Front))
{
object->Status = 1;
goto trpff_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->InP))->InPointer =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P;
((pwr_sClass_NMpsCell *)(object->InP))->InObjId =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_ObjId;
((pwr_sClass_NMpsCell *)(object->InP))->InDlid =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_Dlid;
((pwr_sClass_NMpsCell *)(object->InP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->InOpType =
NMPS_OPTYPE_FORWARD_UNIT;
((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontOpType =
NMPS_OPTYPE_UNIT;
}
else if (( object->Function & NMPS_TRPFUNC_ALL) ||
( object->Function & NMPS_TRPFUNC_ALLEMPTY))
{
if ( *(object->TriggReverseFrontP) &&
!object->OldTriggReverseFront)
{
/* This is the first object to move */
if ( object->FuncAllReverse || object->FuncAllForward)
{
/* We are already busy moving last trigg */
return;
}
/* Check destination */
if ( object->Function & NMPS_TRPFUNC_ALLEMPTY)
{
if ( ((pwr_sClass_NMpsCell *)(object->InP))->LastIndex)
{
/* Destination cell is not empty */
object->Status = 1;
goto trpff_return;
}
}
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->CellFull)
{
/* Destination cell is full */
object->Status = 1;
object->FuncAllReverse = 0;
goto trpff_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->InP))->InFlag ) return;
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->LastIndex == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trpff_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontFlag ) return;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->Data1P ==
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P )
{
object->Status = 1;
goto trpff_return;
}
if ( object->Function & NMPS_TRPFUNC_SLOW &&
object->FuncAllForward == 1)
{
/* Wait till next scan */
object->FuncAllForward = 2;
goto trpff_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->InP))->InPointer =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P;
((pwr_sClass_NMpsCell *)(object->InP))->InObjId =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_ObjId;
((pwr_sClass_NMpsCell *)(object->InP))->InDlid =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_Dlid;
((pwr_sClass_NMpsCell *)(object->InP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->InOpType =
NMPS_OPTYPE_FORWARD_UNIT;
((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontOpType =
NMPS_OPTYPE_UNIT;
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->LastIndex == 1)
object->FuncAllReverse = 0;
else
object->FuncAllReverse = 1;
}
else
{
/* Check source */
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->LastIndex == 0 )
{
/* Nothing to transport */
object->Status = 1;
goto trpff_return;
}
if ( ((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontFlag ) return;
if ( ((pwr_sClass_NMpsCell *)(object->InP))->Data1P !=
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P )
{
/* This should be a Back trigg */
object->Status = 1;
goto trpff_return;
}
/* Transport data */
((pwr_sClass_NMpsCell *)(object->InP))->InPointer =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1P;
((pwr_sClass_NMpsCell *)(object->InP))->InObjId =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_ObjId;
((pwr_sClass_NMpsCell *)(object->InP))->InDlid =
((pwr_sClass_NMpsCell *)(object->OutP))->Data1_Dlid;
((pwr_sClass_NMpsCell *)(object->InP))->InFlag = 1;
((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontFlag = 1;
((pwr_sClass_NMpsCell *)(object->InP))->InOpType =
NMPS_OPTYPE_FORWARD_BACK;
((pwr_sClass_NMpsCell *)(object->OutP))->OutFrontOpType =
NMPS_OPTYPE_FRONT;
}
}
trpff_return:
object->OldTriggForwFront = *(object->TriggForwFrontP);
object->OldTriggReverseFront = *(object->TriggReverseFrontP);
object->OldTriggForwBack = *(object->TriggForwBackP);
object->OldTriggReverseBack = *(object->TriggReverseBackP);
if ( object->Function & NMPS_TRPFUNC_TRIGGRESET)
{
/* Reset the trigg flags */
object->TriggForwFront = 0;
object->TriggReverseFront = 0;
object->TriggForwBack = 0;
object->TriggReverseBack = 0;
}
}
/**
DataSelect
@aref dataselect DataSelect
*/
void DataSelect_exec(
plc_sThread *tp,
pwr_sClass_DataSelect *object)
{
int i;
float **DataP;
i = *object->IndexP + FLT_EPSILON;
if ( i < 1)
i = 1;
if ( i > *object->MaxIndexP)
i = *object->MaxIndexP + FLT_EPSILON;
i--;
DataP = (float **)((char *) &object->DataIn1P +
i * (sizeof(object->DataIn1) + sizeof(object->DataIn1P)));
memcpy( &object->OutDataP, *DataP,
sizeof( object->OutDataP) + sizeof( object->OutData_ObjId));
}
/* NMpsMirrorCell
*/
void NMpsMirrorCell_init(object)
pwr_sClass_NMpsMirrorCell *object;
{
pwr_sAttrRef attrref;
plc_t_DataInfoMirCell *data_index;
int i, sts;
/* Get new object pointers at restart av plc program */
data_index = (plc_t_DataInfoMirCell *) &object->Data1P;
memset( &attrref, 0, sizeof(attrref));
for ( i = 0; i < object->LastIndex; i++)
{
attrref.Objid = data_index->Data_ObjId;
sts = gdh_DLRefObjectInfoAttrref ( &attrref,
(pwr_tAddress *) &data_index->DataP,
&data_index->Data_Dlid);
data_index++;
}
if ( object->LastIndex)
{
data_index = (plc_t_DataInfoMirCell *) &object->Data1P;
data_index += object->LastIndex - 1;
memcpy( &object->DataLastP, data_index, sizeof( *data_index));
}
else
{
memset( &object->DataLastP, 0, sizeof( *data_index));
}
object->InitFlag = 1;
}
/**
NMpsMirrorCell
@aref nmpsmirrorcell NMpsMirrorCell
*/
void NMpsMirrorCell_exec(
plc_sThread *tp,
pwr_sClass_NMpsMirrorCell *object)
{
pwr_sAttrRef attrref;
plc_t_DataInfoMirCell *data_index;
int i, sts;
if ( !object->UpdateFlag)
return;
/* Get new object pointers to new objects */
data_index = (plc_t_DataInfoMirCell *) object->TempArea;
memset( &attrref, 0, sizeof(attrref));
for ( i = 0; i < object->TempLastIndex; i++)
{
if ( data_index->DataP == 0)
{
attrref.Objid = data_index->Data_ObjId;
sts = gdh_DLRefObjectInfoAttrref ( &attrref,
(pwr_tAddress *) &data_index->DataP,
&data_index->Data_Dlid);
}
data_index++;
}
memcpy( &object->Data1P, object->TempArea, sizeof(object->TempArea));
object->LastIndex = object->TempLastIndex;
if ( object->LastIndex)
{
data_index = (plc_t_DataInfoMirCell *) &object->Data1P;
data_index += object->LastIndex - 1;
memcpy( &object->DataLastP, data_index, sizeof( *data_index));
}
else
{
memset( &object->DataLastP, 0, sizeof( *data_index));
}
if ( object->LastIndex == object->MaxSize)
object->CellFull = 1;
else
object->CellFull = 0;
object->UpdateFlag = 0;
if ( object->BackupNowMsg)
{
object->BackupNow = 1;
object->BackupNowMsg = 0;
}
}
int nmps_RemoveData( pwr_tObjid objid)
{
int sts;
pwr_tObjid cell_objid;
pwr_sClass_NMpsCell *cell_p;
pwr_sClass_NMpsStoreCell *scell_p;
sts = gdh_GetClassList ( pwr_cClass_NMpsCell, &cell_objid);
while( ODD(sts))
{
sts = gdh_ObjidToPointer ( cell_objid, (pwr_tAddress *) &cell_p);
if ( EVEN(sts)) return sts;
cell_p->ExternOpType = NMPS_OPTYPE_EXTDELETE_OBJID;
cell_p->ExternObjId = objid;
cell_p->ExternFlag = 1;
sts = gdh_GetNextObject ( cell_objid, &cell_objid);
}
sts = gdh_GetClassList ( pwr_cClass_NMpsStoreCell, &cell_objid);
while( ODD(sts))
{
sts = gdh_ObjidToPointer ( cell_objid, (pwr_tAddress *) &scell_p);
if ( EVEN(sts)) return sts;
scell_p->ExternOpType = NMPS_OPTYPE_EXTDELETE_OBJID;
scell_p->ExternObjId = objid;
scell_p->ExternFlag = 1;
sts = gdh_GetNextObject ( cell_objid, &cell_objid);
}
return 1;
}
int nmps_RemoveAndDeleteData( pwr_tObjid objid)
{
int sts;
pwr_tObjid cell_objid;
pwr_sClass_NMpsCell *cell_p;
pwr_sClass_NMpsStoreCell *scell_p;
sts = gdh_GetClassList ( pwr_cClass_NMpsCell, &cell_objid);
while( ODD(sts))
{
sts = gdh_ObjidToPointer ( cell_objid, (pwr_tAddress *) &cell_p);
if ( EVEN(sts)) return sts;
cell_p->ExternOpType = NMPS_OPTYPE_EXTDELETE_OBJID;
cell_p->ExternObjId = objid;
cell_p->ExternFlag = 1;
sts = gdh_GetNextObject ( cell_objid, &cell_objid);
}
sts = gdh_GetClassList ( pwr_cClass_NMpsStoreCell, &cell_objid);
while( ODD(sts))
{
sts = gdh_ObjidToPointer ( cell_objid, (pwr_tAddress *) &scell_p);
if ( EVEN(sts)) return sts;
scell_p->ExternOpType = NMPS_OPTYPE_EXTDELETE_OBJID;
scell_p->ExternObjId = objid;
scell_p->ExternFlag = 1;
sts = gdh_GetNextObject ( cell_objid, &cell_objid);
}
sts = gdh_DeleteObject(objid);
if ( EVEN(sts)) return sts;
return 1;
}
/*
* Proview $Id: nmps_plc_display.c,v 1.1 2006-01-12 05:57:43 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.
*/
#if defined(OS_VMS) || defined(OS_LYNX) || defined(OS_LINUX)
#include <stdio.h>
#include <float.h>
#include <string.h>
#endif
#ifdef OS_ELN
#include stdio
#include float
#include string
#endif
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_nmpsclasses.h"
#include "rt_gdh.h"
#include "rt_errh.h"
#include "rt_plc.h"
#include "co_cdh.h"
#include "nmps.h"
#include "rs_nmps_msg.h"
#define ODD(a) (((int)(a) & 1) != 0)
#define EVEN(a) (((int)(a) & 1) == 0)
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
#ifndef __ALPHA
#define abs(Dragon) ((Dragon) >= 0 ? (Dragon) : (-(Dragon)))
#endif
#define NMPS_OPTYPE_FRONT 0
#define NMPS_OPTYPE_BACK 1
#define NMPS_OPTYPE_UNIT 2
#define NMPS_OPTYPE_FORWARD_FRONT 3
#define NMPS_OPTYPE_FORWARD_BACK 4
#define NMPS_OPTYPE_FORWARD_UNIT 5
#define NMPS_OPTYPE_REVERSE_FRONT 6
#define NMPS_OPTYPE_REVERSE_BACK 7
#define NMPS_OPTYPE_REVERSE_UNIT 8
#define NMPS_DISP_SIZE 60
#define NMPS_DISP_CELLNUM 10
#define NMPS_DISP_DIRECT_FORW 0
#define NMPS_DISP_DIRECT_BACKW 1
#define NMPS_DISP_ORDERTYPE_NEXT 1
#define NMPS_DISP_ORDERTYPE_PREV 2
#define NMPS_DISP_ORDEROWNER_LINK 9999
#define NMPS_DISPFUNC_REVERSE 1
/* NMPS RUTINER */
typedef struct {
pwr_tFloat32 **CellP;
pwr_tFloat32 *Cell;
} nmps_sCellInput;
/**
@aref celldisp CellDisp
*/
void CellDisp_init( pwr_sClass_CellDisp *object)
{
pwr_tStatus sts;
int i;
char attr_str[32];
pwr_sAttrRef attr_ref;
char classname[120];
pwr_sObjBodyDef *bodyp;
pwr_tObjid rtbody_objid;
pwr_sClass_DispLink *link;
/* Get size of data objects */
for (;;)
{
sts = gdh_ObjidToName ( cdh_ClassIdToObjid(object->DataClass),
classname, sizeof(classname), cdh_mName_volumeStrict);
if ( EVEN(sts))
{
errh_CErrLog(NMPS__DISPCLASS, errh_ErrArgMsg(sts), NULL);
break;
}
strcat( classname, "-RtBody");
sts = gdh_NameToObjid ( classname, &rtbody_objid);
if ( EVEN(sts))
{
errh_CErrLog(NMPS__DISPCLASS, errh_ErrArgMsg(sts), NULL);
break;
}
sts = gdh_ObjidToPointer( rtbody_objid, (void *)&bodyp);
if ( EVEN(sts))
{
errh_CErrLog(NMPS__DISPCLASS, errh_ErrArgMsg(sts), NULL);
break;
}
object->DataSize = bodyp->Size;
break;
}
/* Get offset for the attributes */
for ( i = 0; i < 5; i++)
{
if ( object->FloatAttr[i][0] != 0)
{
strcpy( attr_str, ".");
strcat( attr_str, object->FloatAttr[i]);
sts = gdh_ClassAttrToAttrref( object->DataClass,
attr_str, &attr_ref);
if ( ODD(sts))
object->FloatAttrOffs[i] = attr_ref.Offset;
else
{
object->FloatAttrOffs[i] = -1;
errh_CErrLog(NMPS__DISPFATTR, errh_ErrArgMsg(sts), NULL);
}
}
else
object->FloatAttrOffs[i] = -1;
}
for ( i = 0; i < 5; i++)
{
if ( object->BooleanAttr[i][0] != 0)
{
strcpy( attr_str, ".");
strcat( attr_str, object->BooleanAttr[i]);
sts = gdh_ClassAttrToAttrref( object->DataClass,
attr_str, &attr_ref);
if ( ODD(sts))
object->BooleanAttrOffs[i] = attr_ref.Offset;
else
{
object->BooleanAttrOffs[i] = -1;
errh_CErrLog(NMPS__DISPBATTR, errh_ErrArgMsg(sts), NULL);
}
}
else
object->BooleanAttrOffs[i] = -1;
}
for ( i = 0; i < 5; i++)
{
if ( object->IntAttr[i][0] != 0)
{
strcpy( attr_str, ".");
strcat( attr_str, object->IntAttr[i]);
sts = gdh_ClassAttrToAttrref( object->DataClass,
attr_str, &attr_ref);
if ( ODD(sts))
object->IntAttrOffs[i] = attr_ref.Offset;
else
{
object->IntAttrOffs[i] = -1;
errh_CErrLog(NMPS__DISPIATTR, errh_ErrArgMsg(sts), NULL);
}
}
else
object->IntAttrOffs[i] = -1;
}
link = (pwr_sClass_DispLink *) object->LinkP;
if ( object->LinkP == &object->Link)
link = 0;
if ( link && link->MaxDispNumber < object->Number)
link->MaxDispNumber = object->Number;
}
void CellDisp_exec(
plc_sThread *tp,
pwr_sClass_CellDisp *object)
{
pwr_sClass_NMpsCell *cell;
pwr_sClass_DispLink *link;
nmps_sCellInput *cellp;
plc_t_DataInfo *data_info;
int i, j;
char *datap;
int select_exist;
int num;
int full;
int max_size;
char *dataptr[NMPS_DISP_SIZE];
max_size = min( object->MaxSize, NMPS_DISP_SIZE);
link = (pwr_sClass_DispLink *) object->LinkP;
if ( object->LinkP == &object->Link)
link = 0;
num = 0;
full = 0;
cellp = (nmps_sCellInput *) &object->Cell1P;
if ( object->Function == NMPS_DISPFUNC_REVERSE)
cellp += NMPS_DISP_CELLNUM - 1;
/* Check that the cell is initialized */
for ( j = 0; j < NMPS_DISP_CELLNUM; j++)
{
if ( cellp->CellP != &cellp->Cell)
{
cell = (pwr_sClass_NMpsCell *) *(cellp->CellP);
if ( !(cell->ReloadDone & NMPS_CELL_INITIALIZED))
return;
if ( object->Function != NMPS_DISPFUNC_REVERSE)
cellp++;
else
cellp--;
}
}
cellp = (nmps_sCellInput *) &object->Cell1P;
if ( object->Function == NMPS_DISPFUNC_REVERSE)
cellp += NMPS_DISP_CELLNUM - 1;
for ( j = 0; j < NMPS_DISP_CELLNUM; j++)
{
if ( cellp->CellP != &cellp->Cell)
{
cell = (pwr_sClass_NMpsCell *) *(cellp->CellP);
data_info = (plc_t_DataInfo *) &cell->Data1P;
if ( object->Function == NMPS_DISPFUNC_REVERSE)
data_info += cell->LastIndex - 1;
for ( i = num; i < num + cell->LastIndex; i++)
{
datap = (char *) data_info->DataP;
dataptr[i] = datap;
if ( datap)
{
object->Objid[i] = data_info->Data_ObjId;
if ( object->FloatAttrOffs[0] >= 0)
object->F1[i] = *(pwr_tFloat32 *)(datap + object->FloatAttrOffs[0]);
if ( object->FloatAttrOffs[1] >= 0)
object->F2[i] = *(pwr_tFloat32 *)(datap + object->FloatAttrOffs[1]);
if ( object->FloatAttrOffs[2] >= 0)
object->F3[i] = *(pwr_tFloat32 *)(datap + object->FloatAttrOffs[2]);
if ( object->FloatAttrOffs[3] >= 0)
object->F4[i] = *(pwr_tFloat32 *)(datap + object->FloatAttrOffs[3]);
if ( object->FloatAttrOffs[4] >= 0)
object->F5[i] = *(pwr_tFloat32 *)(datap + object->FloatAttrOffs[4]);
if ( object->BooleanAttrOffs[0] >= 0)
object->B1[i] = *(pwr_tBoolean *)(datap + object->BooleanAttrOffs[0]);
if ( object->BooleanAttrOffs[1] >= 0)
object->B2[i] = *(pwr_tBoolean *)(datap + object->BooleanAttrOffs[1]);
if ( object->BooleanAttrOffs[2] >= 0)
object->B3[i] = *(pwr_tBoolean *)(datap + object->BooleanAttrOffs[2]);
if ( object->BooleanAttrOffs[3] >= 0)
object->B4[i] = *(pwr_tBoolean *)(datap + object->BooleanAttrOffs[3]);
if ( object->BooleanAttrOffs[4] >= 0)
object->B5[i] = *(pwr_tBoolean *)(datap + object->BooleanAttrOffs[4]);
if ( object->IntAttrOffs[0] >= 0)
object->I1[i] = *(pwr_tInt32 *)(datap + object->IntAttrOffs[0]);
if ( object->IntAttrOffs[1] >= 0)
object->I2[i] = *(pwr_tInt32 *)(datap + object->IntAttrOffs[1]);
if ( object->IntAttrOffs[2] >= 0)
object->I3[i] = *(pwr_tInt32 *)(datap + object->IntAttrOffs[2]);
if ( object->IntAttrOffs[3] >= 0)
object->I4[i] = *(pwr_tInt32 *)(datap + object->IntAttrOffs[3]);
if ( object->IntAttrOffs[4] >= 0)
object->I5[i] = *(pwr_tInt32 *)(datap + object->IntAttrOffs[4]);
}
if ( i == max_size - 1)
{
full = 1;
num = i + 1;
break;
}
if ( object->Function != NMPS_DISPFUNC_REVERSE)
data_info++;
else
data_info--;
}
if ( full)
break;
num += cell->LastIndex;
}
if ( object->Function != NMPS_DISPFUNC_REVERSE)
cellp++;
else
cellp--;
}
if ( object->OldLastIndex > num)
{
/* Reset values */
memset( &object->Objid[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tObjid));
memset( &object->Select[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
memset( &object->OldSelect[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
if ( object->FloatAttrOffs[0] >= 0)
memset( &object->F1[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
if ( object->FloatAttrOffs[1] >= 0)
memset( &object->F2[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
if ( object->FloatAttrOffs[2] >= 0)
memset( &object->F3[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
if ( object->FloatAttrOffs[3] >= 0)
memset( &object->F4[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
if ( object->FloatAttrOffs[4] >= 0)
memset( &object->F5[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
if ( object->BooleanAttrOffs[0] >= 0)
memset( &object->B1[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
if ( object->BooleanAttrOffs[1] >= 0)
memset( &object->B2[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
if ( object->BooleanAttrOffs[2] >= 0)
memset( &object->B3[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
if ( object->BooleanAttrOffs[3] >= 0)
memset( &object->B4[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
if ( object->BooleanAttrOffs[4] >= 0)
memset( &object->B5[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
if ( object->IntAttrOffs[0] >= 0)
memset( &object->I1[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
if ( object->IntAttrOffs[1] >= 0)
memset( &object->I2[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
if ( object->IntAttrOffs[2] >= 0)
memset( &object->I3[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
if ( object->IntAttrOffs[3] >= 0)
memset( &object->I4[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
if ( object->IntAttrOffs[4] >= 0)
memset( &object->I5[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
}
memset( &object->Select[object->OldLastIndex], 0, (max_size - object->OldLastIndex) * sizeof(pwr_tBoolean));
if ( link && link->ResetData)
if ( object->DisplayObjectP != &object->DisplayObject)
{
memset( *object->DisplayObjectP, 0, object->DataSize);
link->ResetData = 0;
}
/* Detect new selection */
select_exist = 0;
for ( i = 0; i < num; i++)
{
if ( object->Select[i] && !object->OldSelect[i])
{
/* New selection */
if ( link)
{
link->SelectObjid = object->Objid[i];
link->SelectExist = 1;
}
else
object->SelectObjid = object->Objid[i];
object->OldSelect[i] = object->Select[i];
}
else if ( !object->Select[i] && object->OldSelect[i])
{
/* New deselection */
if ( link)
{
if ( cdh_ObjidIsEqual( object->Objid[i], link->SelectObjid))
link->SelectObjid = pwr_cNObjid;
}
else
{
if ( cdh_ObjidIsEqual( object->Objid[i], object->SelectObjid))
object->SelectObjid = pwr_cNObjid;
}
object->OldSelect[i] = object->Select[i];
}
if ( link)
{
if ( cdh_ObjidIsEqual( object->Objid[i], link->SelectObjid))
{
object->Select[i] = 1;
link->SelectExist = 1;
if ( object->DisplayObjectP != &object->DisplayObject)
{
if ( dataptr[i])
memcpy( *object->DisplayObjectP, dataptr[i], object->DataSize);
}
}
else
object->Select[i] = 0;
}
else
{
if ( cdh_ObjidIsEqual( object->Objid[i], object->SelectObjid))
{
select_exist = 1;
object->Select[i] = 1;
}
else
object->Select[i] = 0;
}
}
if ( !link && !select_exist)
object->SelectObjid = pwr_cNObjid;
if ( link && link->DoRemove)
{
cellp = (nmps_sCellInput *) &object->Cell1P;
for ( j = 0; j < NMPS_DISP_CELLNUM; j++)
{
if ( cellp->CellP != &cellp->Cell)
{
cell = (pwr_sClass_NMpsCell *) *(cellp->CellP);
if ( !cell->ExternFlag)
{
cell->ExternObjId = link->SelectObjid;
cell->ExternOpType = NMPS_OPTYPE_EXTDELETE_OBJID;
cell->ExternFlag = 1;
}
}
cellp++;
}
}
else if ( link && link->DoMoveForward)
{
cellp = (nmps_sCellInput *) &object->Cell1P;
for ( j = 0; j < NMPS_DISP_CELLNUM; j++)
{
if ( cellp->CellP != &cellp->Cell)
{
cell = (pwr_sClass_NMpsCell *) *(cellp->CellP);
if ( !cell->ExternFlag)
{
cell->ExternObjId = link->SelectObjid;
if ( object->SelDirection == NMPS_DISP_DIRECT_FORW)
cell->ExternOpType = NMPS_OPTYPE_EXTMOVEFORW_OBJID;
else
cell->ExternOpType = NMPS_OPTYPE_EXTMOVEBACKW_OBJID;
cell->ExternFlag = 1;
}
}
cellp++;
}
}
else if ( link && link->DoMoveBackward)
{
cellp = (nmps_sCellInput *) &object->Cell1P;
for ( j = 0; j < NMPS_DISP_CELLNUM; j++)
{
if ( cellp->CellP != &cellp->Cell)
{
cell = (pwr_sClass_NMpsCell *) *(cellp->CellP);
if ( !cell->ExternFlag)
{
cell->ExternObjId = link->SelectObjid;
if ( object->SelDirection == NMPS_DISP_DIRECT_FORW)
cell->ExternOpType = NMPS_OPTYPE_EXTMOVEBACKW_OBJID;
else
cell->ExternOpType = NMPS_OPTYPE_EXTMOVEFORW_OBJID;
cell->ExternFlag = 1;
}
}
cellp++;
}
}
if ( link && link->SelectOrder && link->SelectOrderOwner == object->Number)
/* Noone responded, selection remains */
link->SelectOrder = 0;
if ( link && link->DoSelectNext)
{
for ( i = 0; i < num; i++)
{
if ( object->Select[i])
{
if ( ((i == num - 1 &&
object->SelDirection == NMPS_DISP_DIRECT_FORW) ||
(i == 0 &&
object->SelDirection != NMPS_DISP_DIRECT_FORW)) &&
!(object->Number == 1 && link->MaxDispNumber == 1))
{
/* Transfer selection to next cell */
if ( object->Number != link->MaxDispNumber)
link->SelectOrderNumber = object->Number + 1;
else
link->SelectOrderNumber = 1;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_NEXT;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
else
{
/* Move selection in the cell */
object->Select[i] = 0;
object->OldSelect[i] = 0;
if ( object->SelDirection == NMPS_DISP_DIRECT_FORW)
{
if ( i != num - 1)
{
object->Select[i+1] = 1;
object->OldSelect[i+1] = 1;
link->SelectObjid = object->Objid[i+1];
}
else
{
object->Select[0] = 1;
object->OldSelect[0] = 1;
link->SelectObjid = object->Objid[0];
}
}
else
{
if ( i != 0)
{
object->Select[i-1] = 1;
object->OldSelect[i-1] = 1;
link->SelectObjid = object->Objid[i-1];
}
else
{
object->Select[num-1] = 1;
object->OldSelect[num-1] = 1;
link->SelectObjid = object->Objid[num-1];
}
}
}
break;
}
}
}
if ( link && link->DoSelectPrevious)
{
for ( i = 0; i < num; i++)
{
if ( object->Select[i])
{
if ( ((i == num - 1 &&
object->SelDirection != NMPS_DISP_DIRECT_FORW) ||
(i == 0 &&
object->SelDirection == NMPS_DISP_DIRECT_FORW)) &&
!(object->Number == 1 && link->MaxDispNumber == 1))
{
/* Transfer selection to next cell */
if ( object->Number != 1)
link->SelectOrderNumber = object->Number - 1;
else
link->SelectOrderNumber = link->MaxDispNumber;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_PREV;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
else
{
/* Move selection in the cell */
object->Select[i] = 0;
object->OldSelect[i] = 0;
if ( object->SelDirection == NMPS_DISP_DIRECT_FORW)
{
if ( i != 0)
{
object->Select[i-1] = 1;
object->OldSelect[i-1] = 1;
link->SelectObjid = object->Objid[i-1];
}
else
{
object->Select[num-1] = 1;
object->OldSelect[num-1] = 1;
link->SelectObjid = object->Objid[num-1];
}
}
else
{
if ( i != num - 1)
{
object->Select[i+1] = 1;
object->OldSelect[i+1] = 1;
link->SelectObjid = object->Objid[i+1];
}
else
{
object->Select[0] = 1;
object->OldSelect[0] = 1;
link->SelectObjid = object->Objid[0];
}
}
}
break;
}
}
}
if ( link && link->SelectOrder && link->SelectOrderNumber == object->Number)
{
if ( link->SelectOrderType == NMPS_DISP_ORDERTYPE_NEXT)
{
if ( num == 0 )
{
if ( object->Number != link->MaxDispNumber)
{
/* Transfer to next */
link->SelectOrderNumber = object->Number + 1;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_NEXT;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
else
{
/* Transfer to next */
link->SelectOrderNumber = 1;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_NEXT;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
}
else
{
if ( object->SelDirection == NMPS_DISP_DIRECT_FORW)
{
/* Select first */
object->Select[0] = 1;
object->OldSelect[0] = 1;
link->SelectObjid = object->Objid[0];
}
else
{
/* Select last */
object->Select[num-1] = 1;
object->OldSelect[num-1] = 1;
link->SelectObjid = object->Objid[num-1];
}
link->SelectOrder = 0;
}
}
if ( link->SelectOrderType == NMPS_DISP_ORDERTYPE_PREV)
{
if ( num == 0)
{
if ( object->Number != 1)
{
/* Transfer to previous */
link->SelectOrderNumber = object->Number - 1;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_PREV;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
else
{
/* Transfer to last */
link->SelectOrderNumber = link->MaxDispNumber;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_PREV;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
}
else
{
if ( object->SelDirection == NMPS_DISP_DIRECT_FORW)
{
/* Select last */
object->Select[num - 1] = 1;
object->OldSelect[num - 1] = 1;
link->SelectObjid = object->Objid[num-1];
}
else
{
/* Select first */
object->Select[0] = 1;
object->OldSelect[0] = 1;
link->SelectObjid = object->Objid[0];
}
link->SelectOrder = 0;
}
}
}
object->OldLastIndex = num;
}
/**
@aref celldispmir CellDispMir
*/
void CellDispMir_init( pwr_sClass_CellDispMir *object)
{
pwr_tStatus sts;
int i;
char attr_str[32];
pwr_sAttrRef attr_ref;
char classname[120];
pwr_sObjBodyDef *bodyp;
pwr_tObjid rtbody_objid;
pwr_sClass_DispLink *link;
/* Get size of data objects */
for (;;)
{
sts = gdh_ObjidToName ( cdh_ClassIdToObjid(object->DataClass),
classname, sizeof(classname), cdh_mName_volumeStrict);
if ( EVEN(sts))
{
errh_CErrLog(NMPS__DISPCLASS, errh_ErrArgMsg(sts), NULL);
break;
}
strcat( classname, "-RtBody");
sts = gdh_NameToObjid ( classname, &rtbody_objid);
if ( EVEN(sts))
{
errh_CErrLog(NMPS__DISPCLASS, errh_ErrArgMsg(sts), NULL);
break;
}
sts = gdh_ObjidToPointer( rtbody_objid, (void *)&bodyp);
if ( EVEN(sts))
{
errh_CErrLog(NMPS__DISPCLASS, errh_ErrArgMsg(sts), NULL);
break;
}
object->DataSize = bodyp->Size;
break;
}
/* Get offset for the attributes */
for ( i = 0; i < 5; i++)
{
if ( object->FloatAttr[i][0] != 0)
{
strcpy( attr_str, ".");
strcat( attr_str, object->FloatAttr[i]);
sts = gdh_ClassAttrToAttrref( object->DataClass,
attr_str, &attr_ref);
if ( ODD(sts))
object->FloatAttrOffs[i] = attr_ref.Offset;
else
{
object->FloatAttrOffs[i] = -1;
errh_CErrLog(NMPS__DISPFATTR, errh_ErrArgMsg(sts), NULL);
}
}
else
object->FloatAttrOffs[i] = -1;
}
for ( i = 0; i < 5; i++)
{
if ( object->BooleanAttr[i][0] != 0)
{
strcpy( attr_str, ".");
strcat( attr_str, object->BooleanAttr[i]);
sts = gdh_ClassAttrToAttrref( object->DataClass,
attr_str, &attr_ref);
if ( ODD(sts))
object->BooleanAttrOffs[i] = attr_ref.Offset;
else
{
object->BooleanAttrOffs[i] = -1;
errh_CErrLog(NMPS__DISPBATTR, errh_ErrArgMsg(sts), NULL);
}
}
else
object->BooleanAttrOffs[i] = -1;
}
for ( i = 0; i < 5; i++)
{
if ( object->IntAttr[i][0] != 0)
{
strcpy( attr_str, ".");
strcat( attr_str, object->IntAttr[i]);
sts = gdh_ClassAttrToAttrref( object->DataClass,
attr_str, &attr_ref);
if ( ODD(sts))
object->IntAttrOffs[i] = attr_ref.Offset;
else
{
object->IntAttrOffs[i] = -1;
errh_CErrLog(NMPS__DISPIATTR, errh_ErrArgMsg(sts), NULL);
}
}
else
object->IntAttrOffs[i] = -1;
}
link = (pwr_sClass_DispLink *) object->LinkP;
if ( object->LinkP == &object->Link)
link = 0;
if ( link && link->MaxDispNumber < object->Number)
link->MaxDispNumber = object->Number;
}
void CellDispMir_exec(
plc_sThread *tp,
pwr_sClass_CellDispMir *object)
{
pwr_sClass_NMpsMirrorCell *cell;
pwr_sClass_DispLink *link;
nmps_sCellInput *cellp;
plc_t_DataInfoMirCell *data_info;
int i, j;
char *datap;
int select_exist;
int num;
int full;
int max_size;
char *dataptr[NMPS_DISP_SIZE];
max_size = min( object->MaxSize, NMPS_DISP_SIZE);
link = (pwr_sClass_DispLink *) object->LinkP;
if ( object->LinkP == &object->Link)
link = 0;
num = 0;
full = 0;
cellp = (nmps_sCellInput *) &object->Cell1P;
if ( object->Function == NMPS_DISPFUNC_REVERSE)
cellp += NMPS_DISP_CELLNUM - 1;
/* Check that the cell is initialized */
for ( j = 0; j < NMPS_DISP_CELLNUM; j++)
{
if ( cellp->CellP != &cellp->Cell)
{
cell = (pwr_sClass_NMpsMirrorCell *) *(cellp->CellP);
if ( !(cell->ReloadDone & NMPS_CELL_INITIALIZED))
return;
if ( object->Function != NMPS_DISPFUNC_REVERSE)
cellp++;
else
cellp--;
}
}
cellp = (nmps_sCellInput *) &object->Cell1P;
if ( object->Function == NMPS_DISPFUNC_REVERSE)
cellp += NMPS_DISP_CELLNUM - 1;
for ( j = 0; j < NMPS_DISP_CELLNUM; j++)
{
if ( cellp->CellP != &cellp->Cell)
{
cell = (pwr_sClass_NMpsMirrorCell *) *(cellp->CellP);
data_info = (plc_t_DataInfoMirCell *) &cell->Data1P;
if ( object->Function == NMPS_DISPFUNC_REVERSE)
data_info += cell->LastIndex - 1;
for ( i = num; i < num + cell->LastIndex; i++)
{
datap = (char *) data_info->DataP;
dataptr[i] = datap;
if ( datap)
{
object->Objid[i] = data_info->Data_ObjId;
if ( object->FloatAttrOffs[0] >= 0)
object->F1[i] = *(pwr_tFloat32 *)(datap + object->FloatAttrOffs[0]);
if ( object->FloatAttrOffs[1] >= 0)
object->F2[i] = *(pwr_tFloat32 *)(datap + object->FloatAttrOffs[1]);
if ( object->FloatAttrOffs[2] >= 0)
object->F3[i] = *(pwr_tFloat32 *)(datap + object->FloatAttrOffs[2]);
if ( object->FloatAttrOffs[3] >= 0)
object->F4[i] = *(pwr_tFloat32 *)(datap + object->FloatAttrOffs[3]);
if ( object->FloatAttrOffs[4] >= 0)
object->F5[i] = *(pwr_tFloat32 *)(datap + object->FloatAttrOffs[4]);
if ( object->BooleanAttrOffs[0] >= 0)
object->B1[i] = *(pwr_tBoolean *)(datap + object->BooleanAttrOffs[0]);
if ( object->BooleanAttrOffs[1] >= 0)
object->B2[i] = *(pwr_tBoolean *)(datap + object->BooleanAttrOffs[1]);
if ( object->BooleanAttrOffs[2] >= 0)
object->B3[i] = *(pwr_tBoolean *)(datap + object->BooleanAttrOffs[2]);
if ( object->BooleanAttrOffs[3] >= 0)
object->B4[i] = *(pwr_tBoolean *)(datap + object->BooleanAttrOffs[3]);
if ( object->BooleanAttrOffs[4] >= 0)
object->B5[i] = *(pwr_tBoolean *)(datap + object->BooleanAttrOffs[4]);
if ( object->IntAttrOffs[0] >= 0)
object->I1[i] = *(pwr_tInt32 *)(datap + object->IntAttrOffs[0]);
if ( object->IntAttrOffs[1] >= 0)
object->I2[i] = *(pwr_tInt32 *)(datap + object->IntAttrOffs[1]);
if ( object->IntAttrOffs[2] >= 0)
object->I3[i] = *(pwr_tInt32 *)(datap + object->IntAttrOffs[2]);
if ( object->IntAttrOffs[3] >= 0)
object->I4[i] = *(pwr_tInt32 *)(datap + object->IntAttrOffs[3]);
if ( object->IntAttrOffs[4] >= 0)
object->I5[i] = *(pwr_tInt32 *)(datap + object->IntAttrOffs[4]);
}
if ( i == max_size - 1)
{
full = 1;
num = i + 1;
break;
}
if ( object->Function != NMPS_DISPFUNC_REVERSE)
data_info++;
else
data_info--;
}
if ( full)
break;
num += cell->LastIndex;
}
if ( object->Function != NMPS_DISPFUNC_REVERSE)
cellp++;
else
cellp--;
}
if ( object->OldLastIndex > num)
{
/* Reset values */
memset( &object->Objid[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tObjid));
memset( &object->Select[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
memset( &object->OldSelect[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
if ( object->FloatAttrOffs[0] >= 0)
memset( &object->F1[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
if ( object->FloatAttrOffs[1] >= 0)
memset( &object->F2[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
if ( object->FloatAttrOffs[2] >= 0)
memset( &object->F3[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
if ( object->FloatAttrOffs[3] >= 0)
memset( &object->F4[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
if ( object->FloatAttrOffs[4] >= 0)
memset( &object->F5[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
if ( object->BooleanAttrOffs[0] >= 0)
memset( &object->B1[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
if ( object->BooleanAttrOffs[1] >= 0)
memset( &object->B2[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
if ( object->BooleanAttrOffs[2] >= 0)
memset( &object->B3[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
if ( object->BooleanAttrOffs[3] >= 0)
memset( &object->B4[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
if ( object->BooleanAttrOffs[4] >= 0)
memset( &object->B5[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
if ( object->IntAttrOffs[0] >= 0)
memset( &object->I1[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
if ( object->IntAttrOffs[1] >= 0)
memset( &object->I2[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
if ( object->IntAttrOffs[2] >= 0)
memset( &object->I3[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
if ( object->IntAttrOffs[3] >= 0)
memset( &object->I4[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
if ( object->IntAttrOffs[4] >= 0)
memset( &object->I5[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
}
memset( &object->Select[object->OldLastIndex], 0, (max_size - object->OldLastIndex) * sizeof(pwr_tBoolean));
if ( link && link->ResetData)
if ( object->DisplayObjectP != &object->DisplayObject)
{
memset( *object->DisplayObjectP, 0, object->DataSize);
link->ResetData = 0;
}
/* Detect new selection */
select_exist = 0;
for ( i = 0; i < num; i++)
{
if ( object->Select[i] && !object->OldSelect[i])
{
/* New selection */
if ( link)
{
link->SelectObjid = object->Objid[i];
link->SelectExist = 1;
}
else
object->SelectObjid = object->Objid[i];
object->OldSelect[i] = object->Select[i];
}
else if ( !object->Select[i] && object->OldSelect[i])
{
/* New deselection */
if ( link)
{
if ( cdh_ObjidIsEqual( object->Objid[i], link->SelectObjid))
link->SelectObjid = pwr_cNObjid;
}
else
{
if ( cdh_ObjidIsEqual( object->Objid[i], object->SelectObjid))
object->SelectObjid = pwr_cNObjid;
}
object->OldSelect[i] = object->Select[i];
}
if ( link)
{
if ( cdh_ObjidIsEqual( object->Objid[i], link->SelectObjid))
{
object->Select[i] = 1;
link->SelectExist = 1;
if ( object->DisplayObjectP != &object->DisplayObject)
{
if ( dataptr[i])
memcpy( *object->DisplayObjectP, dataptr[i], object->DataSize);
}
}
else
object->Select[i] = 0;
}
else
{
if ( cdh_ObjidIsEqual( object->Objid[i], object->SelectObjid))
{
select_exist = 1;
object->Select[i] = 1;
}
else
object->Select[i] = 0;
}
}
if ( !link && !select_exist)
object->SelectObjid = pwr_cNObjid;
if ( link && link->SelectOrder && link->SelectOrderOwner == object->Number)
/* Noone responded, selection remains */
link->SelectOrder = 0;
if ( link && link->DoSelectNext)
{
for ( i = 0; i < num; i++)
{
if ( object->Select[i])
{
if ( ((i == num - 1 &&
object->SelDirection == NMPS_DISP_DIRECT_FORW) ||
(i == 0 &&
object->SelDirection != NMPS_DISP_DIRECT_FORW)) &&
!(object->Number == 1 && link->MaxDispNumber == 1))
{
/* Transfer selection to next cell */
if ( object->Number != link->MaxDispNumber)
link->SelectOrderNumber = object->Number + 1;
else
link->SelectOrderNumber = 1;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_NEXT;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
else
{
/* Move selection in the cell */
object->Select[i] = 0;
object->OldSelect[i] = 0;
if ( object->SelDirection == NMPS_DISP_DIRECT_FORW)
{
if ( i != num - 1)
{
object->Select[i+1] = 1;
object->OldSelect[i+1] = 1;
link->SelectObjid = object->Objid[i+1];
}
else
{
object->Select[0] = 1;
object->OldSelect[0] = 1;
link->SelectObjid = object->Objid[0];
}
}
else
{
if ( i != 0)
{
object->Select[i-1] = 1;
object->OldSelect[i-1] = 1;
link->SelectObjid = object->Objid[i-1];
}
else
{
object->Select[num-1] = 1;
object->OldSelect[num-1] = 1;
link->SelectObjid = object->Objid[num-1];
}
}
}
break;
}
}
}
if ( link && link->DoSelectPrevious)
{
for ( i = 0; i < num; i++)
{
if ( object->Select[i])
{
if ( ((i == num - 1 &&
object->SelDirection != NMPS_DISP_DIRECT_FORW) ||
(i == 0 &&
object->SelDirection == NMPS_DISP_DIRECT_FORW)) &&
!(object->Number == 1 && link->MaxDispNumber == 1))
{
/* Transfer selection to next cell */
if ( object->Number != 1)
link->SelectOrderNumber = object->Number - 1;
else
link->SelectOrderNumber = link->MaxDispNumber;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_PREV;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
else
{
/* Move selection in the cell */
object->Select[i] = 0;
object->OldSelect[i] = 0;
if ( object->SelDirection == NMPS_DISP_DIRECT_FORW)
{
if ( i != 0)
{
object->Select[i-1] = 1;
object->OldSelect[i-1] = 1;
link->SelectObjid = object->Objid[i-1];
}
else
{
object->Select[num-1] = 1;
object->OldSelect[num-1] = 1;
link->SelectObjid = object->Objid[num-1];
}
}
else
{
if ( i != num - 1)
{
object->Select[i+1] = 1;
object->OldSelect[i+1] = 1;
link->SelectObjid = object->Objid[i+1];
}
else
{
object->Select[0] = 1;
object->OldSelect[0] = 1;
link->SelectObjid = object->Objid[0];
}
}
}
break;
}
}
}
if ( link && link->SelectOrder && link->SelectOrderNumber == object->Number)
{
if ( link->SelectOrderType == NMPS_DISP_ORDERTYPE_NEXT)
{
if ( num == 0 )
{
if ( object->Number != link->MaxDispNumber)
{
/* Transfer to next */
link->SelectOrderNumber = object->Number + 1;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_NEXT;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
else
{
/* Transfer to next */
link->SelectOrderNumber = 1;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_NEXT;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
}
else
{
if ( object->SelDirection == NMPS_DISP_DIRECT_FORW)
{
/* Select first */
object->Select[0] = 1;
object->OldSelect[0] = 1;
link->SelectObjid = object->Objid[0];
}
else
{
/* Select last */
object->Select[num-1] = 1;
object->OldSelect[num-1] = 1;
link->SelectObjid = object->Objid[num-1];
}
link->SelectOrder = 0;
}
}
if ( link->SelectOrderType == NMPS_DISP_ORDERTYPE_PREV)
{
if ( num == 0)
{
if ( object->Number != 1)
{
/* Transfer to previous */
link->SelectOrderNumber = object->Number - 1;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_PREV;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
else
{
/* Transfer to last */
link->SelectOrderNumber = link->MaxDispNumber;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_PREV;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
}
else
{
if ( object->SelDirection == NMPS_DISP_DIRECT_FORW)
{
/* Select last */
object->Select[num - 1] = 1;
object->OldSelect[num - 1] = 1;
link->SelectObjid = object->Objid[num-1];
}
else
{
/* Select first */
object->Select[0] = 1;
object->OldSelect[0] = 1;
link->SelectObjid = object->Objid[0];
}
link->SelectOrder = 0;
}
}
}
object->OldLastIndex = num;
}
/**
@aref cellupdate CellUpdate
*/
void CellUpdate_init( pwr_sClass_CellUpdate *object)
{
pwr_tStatus sts;
int i;
char attr_str[32];
pwr_sAttrRef attr_ref;
char classname[120];
pwr_sObjBodyDef *bodyp;
pwr_tObjid rtbody_objid;
pwr_sClass_DispLink *link;
/* Get size of data objects */
for (;;)
{
sts = gdh_ObjidToName ( cdh_ClassIdToObjid(object->DataClass),
classname, sizeof(classname), cdh_mName_volumeStrict);
if ( EVEN(sts))
{
errh_CErrLog(NMPS__DISPCLASS, errh_ErrArgMsg(sts), NULL);
break;
}
strcat( classname, "-RtBody");
sts = gdh_NameToObjid ( classname, &rtbody_objid);
if ( EVEN(sts))
{
errh_CErrLog(NMPS__DISPCLASS, errh_ErrArgMsg(sts), NULL);
break;
}
sts = gdh_ObjidToPointer( rtbody_objid, (void *)&bodyp);
if ( EVEN(sts))
{
errh_CErrLog(NMPS__DISPCLASS, errh_ErrArgMsg(sts), NULL);
break;
}
object->DataSize = bodyp->Size;
break;
}
/* Get offset for the attributes */
for ( i = 0; i < 5; i++)
{
if ( object->FloatAttr[i][0] != 0)
{
strcpy( attr_str, ".");
strcat( attr_str, object->FloatAttr[i]);
sts = gdh_ClassAttrToAttrref( object->DataClass,
attr_str, &attr_ref);
if ( ODD(sts))
object->FloatAttrOffs[i] = attr_ref.Offset;
else
{
object->FloatAttrOffs[i] = -1;
errh_CErrLog(NMPS__DISPFATTR, errh_ErrArgMsg(sts), NULL);
}
}
else
object->FloatAttrOffs[i] = -1;
}
for ( i = 0; i < 5; i++)
{
if ( object->BooleanAttr[i][0] != 0)
{
strcpy( attr_str, ".");
strcat( attr_str, object->BooleanAttr[i]);
sts = gdh_ClassAttrToAttrref( object->DataClass,
attr_str, &attr_ref);
if ( ODD(sts))
object->BooleanAttrOffs[i] = attr_ref.Offset;
else
{
object->BooleanAttrOffs[i] = -1;
errh_CErrLog(NMPS__DISPBATTR, errh_ErrArgMsg(sts), NULL);
}
}
else
object->BooleanAttrOffs[i] = -1;
}
for ( i = 0; i < 5; i++)
{
if ( object->IntAttr[i][0] != 0)
{
strcpy( attr_str, ".");
strcat( attr_str, object->IntAttr[i]);
sts = gdh_ClassAttrToAttrref( object->DataClass,
attr_str, &attr_ref);
if ( ODD(sts))
object->IntAttrOffs[i] = attr_ref.Offset;
else
{
object->IntAttrOffs[i] = -1;
errh_CErrLog(NMPS__DISPIATTR, errh_ErrArgMsg(sts), NULL);
}
}
else
object->IntAttrOffs[i] = -1;
}
link = (pwr_sClass_DispLink *) object->LinkP;
if ( object->LinkP == &object->Link)
link = 0;
if ( link && link->MaxDispNumber < object->Number)
link->MaxDispNumber = object->Number;
}
void CellUpdate_exec(
plc_sThread *tp,
pwr_sClass_CellUpdate *object)
{
pwr_sClass_NMpsCell *cell;
pwr_sClass_DispLink *link;
nmps_sCellInput *cellp;
plc_t_DataInfo *data_info;
int i, j;
char *datap;
int select_exist;
int num;
int full;
int max_size;
char *dataptr[NMPS_DISP_SIZE];
max_size = min( object->MaxSize, NMPS_DISP_SIZE);
link = (pwr_sClass_DispLink *) object->LinkP;
if ( object->LinkP == &object->Link)
link = 0;
num = 0;
full = 0;
cellp = (nmps_sCellInput *) &object->Cell1P;
if ( object->Function == NMPS_DISPFUNC_REVERSE)
cellp += NMPS_DISP_CELLNUM - 1;
/* Check that the cell is initialized */
for ( j = 0; j < NMPS_DISP_CELLNUM; j++)
{
if ( cellp->CellP != &cellp->Cell)
{
cell = (pwr_sClass_NMpsCell *) *(cellp->CellP);
if ( !(cell->ReloadDone & NMPS_CELL_INITIALIZED))
return;
if ( object->Function != NMPS_DISPFUNC_REVERSE)
cellp++;
else
cellp--;
}
}
cellp = (nmps_sCellInput *) &object->Cell1P;
if ( object->Function == NMPS_DISPFUNC_REVERSE)
cellp += NMPS_DISP_CELLNUM - 1;
for ( j = 0; j < NMPS_DISP_CELLNUM; j++)
{
if ( cellp->CellP != &cellp->Cell)
{
cell = (pwr_sClass_NMpsCell *) *(cellp->CellP);
data_info = (plc_t_DataInfo *) &cell->Data1P;
if ( object->Function == NMPS_DISPFUNC_REVERSE)
data_info += cell->LastIndex - 1;
for ( i = num; i < num + cell->LastIndex; i++)
{
datap = (char *) data_info->DataP;
dataptr[i] = datap;
if ( datap)
{
object->Objid[i] = data_info->Data_ObjId;
if ( object->FloatAttrOffs[0] >= 0)
{
if ( object->F1[i] != object->F1Old[i])
*(pwr_tFloat32 *)(datap + object->FloatAttrOffs[0]) = object->F1[i];
else
object->F1[i] = *(pwr_tFloat32 *)(datap + object->FloatAttrOffs[0]);
object->F1Old[i] = object->F1[i];
}
if ( object->FloatAttrOffs[1] >= 0)
{
if ( object->F2[i] != object->F2Old[i])
*(pwr_tFloat32 *)(datap + object->FloatAttrOffs[1]) = object->F2[i];
else
object->F2[i] = *(pwr_tFloat32 *)(datap + object->FloatAttrOffs[1]);
object->F2Old[i] = object->F2[i];
}
if ( object->FloatAttrOffs[2] >= 0)
{
if ( object->F3[i] != object->F3Old[i])
*(pwr_tFloat32 *)(datap + object->FloatAttrOffs[2]) = object->F3[i];
else
object->F3[i] = *(pwr_tFloat32 *)(datap + object->FloatAttrOffs[2]);
object->F3Old[i] = object->F3[i];
}
if ( object->FloatAttrOffs[3] >= 0)
{
if ( object->F4[i] != object->F4Old[i])
*(pwr_tFloat32 *)(datap + object->FloatAttrOffs[3]) = object->F4[i];
else
object->F4[i] = *(pwr_tFloat32 *)(datap + object->FloatAttrOffs[3]);
object->F4Old[i] = object->F4[i];
}
if ( object->FloatAttrOffs[4] >= 0)
{
if ( object->F5[i] != object->F5Old[i])
*(pwr_tFloat32 *)(datap + object->FloatAttrOffs[4]) = object->F5[i];
else
object->F5[i] = *(pwr_tFloat32 *)(datap + object->FloatAttrOffs[4]);
object->F5Old[i] = object->F5[i];
}
if ( object->BooleanAttrOffs[0] >= 0)
{
if ( object->B1[i] != object->B1Old[i])
*(pwr_tBoolean *)(datap + object->BooleanAttrOffs[0]) = object->B1[i];
else
object->B1[i] = *(pwr_tBoolean *)(datap + object->BooleanAttrOffs[0]);
object->B1Old[i] = object->B1[i];
}
if ( object->BooleanAttrOffs[1] >= 0)
{
if ( object->B2[i] != object->B2Old[i])
*(pwr_tBoolean *)(datap + object->BooleanAttrOffs[1]) = object->B2[i];
else
object->B2[i] = *(pwr_tBoolean *)(datap + object->BooleanAttrOffs[1]);
object->B2Old[i] = object->B2[i];
}
if ( object->BooleanAttrOffs[2] >= 0)
{
if ( object->B3[i] != object->B3Old[i])
*(pwr_tBoolean *)(datap + object->BooleanAttrOffs[2]) = object->B3[i];
else
object->B3[i] = *(pwr_tBoolean *)(datap + object->BooleanAttrOffs[2]);
object->B3Old[i] = object->B3[i];
}
if ( object->BooleanAttrOffs[3] >= 0)
{
if ( object->B4[i] != object->B4Old[i])
*(pwr_tBoolean *)(datap + object->BooleanAttrOffs[3]) = object->B4[i];
else
object->B4[i] = *(pwr_tBoolean *)(datap + object->BooleanAttrOffs[3]);
object->B4Old[i] = object->B4[i];
}
if ( object->BooleanAttrOffs[4] >= 0)
{
if ( object->B5[i] != object->B5Old[i])
*(pwr_tBoolean *)(datap + object->BooleanAttrOffs[4]) = object->B5[i];
else
object->B5[i] = *(pwr_tBoolean *)(datap + object->BooleanAttrOffs[4]);
object->B5Old[i] = object->B5[i];
}
if ( object->IntAttrOffs[0] >= 0)
{
if ( object->I1[i] != object->I1Old[i])
*(pwr_tInt32 *)(datap + object->IntAttrOffs[0]) = object->I1[i];
else
object->I1[i] = *(pwr_tInt32 *)(datap + object->IntAttrOffs[0]);
object->I1Old[i] = object->I1[i];
}
if ( object->IntAttrOffs[1] >= 0)
{
if ( object->I2[i] != object->I2Old[i])
*(pwr_tInt32 *)(datap + object->IntAttrOffs[1]) = object->I2[i];
else
object->I2[i] = *(pwr_tInt32 *)(datap + object->IntAttrOffs[1]);
object->I2Old[i] = object->I2[i];
}
if ( object->IntAttrOffs[2] >= 0)
{
if ( object->I3[i] != object->I3Old[i])
*(pwr_tInt32 *)(datap + object->IntAttrOffs[2]) = object->I3[i];
else
object->I3[i] = *(pwr_tInt32 *)(datap + object->IntAttrOffs[2]);
object->I3Old[i] = object->I3[i];
}
if ( object->IntAttrOffs[3] >= 0)
{
if ( object->I4[i] != object->I4Old[i])
*(pwr_tInt32 *)(datap + object->IntAttrOffs[3]) = object->I4[i];
else
object->I4[i] = *(pwr_tInt32 *)(datap + object->IntAttrOffs[3]);
object->I4Old[i] = object->I4[i];
}
if ( object->IntAttrOffs[4] >= 0)
{
if ( object->I5[i] != object->I5Old[i])
*(pwr_tInt32 *)(datap + object->IntAttrOffs[4]) = object->I5[i];
else
object->I5[i] = *(pwr_tInt32 *)(datap + object->IntAttrOffs[4]);
object->I5Old[i] = object->I5[i];
}
}
if ( i == max_size - 1)
{
full = 1;
num = i + 1;
break;
}
if ( object->Function != NMPS_DISPFUNC_REVERSE)
data_info++;
else
data_info--;
}
if ( full)
break;
num += cell->LastIndex;
}
if ( object->Function != NMPS_DISPFUNC_REVERSE)
cellp++;
else
cellp--;
}
if ( object->OldLastIndex > num)
{
/* Reset values */
memset( &object->Objid[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tObjid));
memset( &object->Select[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
memset( &object->OldSelect[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
if ( object->FloatAttrOffs[0] >= 0) {
memset( &object->F1[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
memset( &object->F1Old[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
}
if ( object->FloatAttrOffs[1] >= 0) {
memset( &object->F2[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
memset( &object->F2Old[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
}
if ( object->FloatAttrOffs[2] >= 0) {
memset( &object->F3[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
memset( &object->F3Old[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
}
if ( object->FloatAttrOffs[3] >= 0) {
memset( &object->F4[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
memset( &object->F4Old[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
}
if ( object->FloatAttrOffs[4] >= 0) {
memset( &object->F5[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
memset( &object->F5Old[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tFloat32));
}
if ( object->BooleanAttrOffs[0] >= 0) {
memset( &object->B1[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
memset( &object->B1Old[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
}
if ( object->BooleanAttrOffs[1] >= 0) {
memset( &object->B2[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
memset( &object->B2Old[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
}
if ( object->BooleanAttrOffs[2] >= 0) {
memset( &object->B3[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
memset( &object->B3Old[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
}
if ( object->BooleanAttrOffs[3] >= 0) {
memset( &object->B4[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
memset( &object->B4Old[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
}
if ( object->BooleanAttrOffs[4] >= 0) {
memset( &object->B5[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
memset( &object->B5Old[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tBoolean));
}
if ( object->IntAttrOffs[0] >= 0) {
memset( &object->I1[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
memset( &object->I1Old[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
}
if ( object->IntAttrOffs[1] >= 0) {
memset( &object->I2[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
memset( &object->I2Old[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
}
if ( object->IntAttrOffs[2] >= 0) {
memset( &object->I3[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
memset( &object->I3Old[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
}
if ( object->IntAttrOffs[3] >= 0) {
memset( &object->I4[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
memset( &object->I4Old[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
}
if ( object->IntAttrOffs[4] >= 0) {
memset( &object->I5[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
memset( &object->I5Old[num], 0, (object->OldLastIndex - num ) * sizeof(pwr_tInt32));
}
}
memset( &object->Select[object->OldLastIndex], 0, (max_size - object->OldLastIndex) * sizeof(pwr_tBoolean));
if ( link && link->ResetData)
if ( object->DisplayObjectP != &object->DisplayObject)
{
memset( *object->DisplayObjectP, 0, object->DataSize);
link->ResetData = 0;
}
/* Detect new selection */
select_exist = 0;
for ( i = 0; i < num; i++)
{
if ( object->Select[i] && !object->OldSelect[i])
{
/* New selection */
if ( link)
{
link->SelectObjid = object->Objid[i];
link->SelectExist = 1;
}
else
object->SelectObjid = object->Objid[i];
object->OldSelect[i] = object->Select[i];
}
else if ( !object->Select[i] && object->OldSelect[i])
{
/* New deselection */
if ( link)
{
if ( cdh_ObjidIsEqual( object->Objid[i], link->SelectObjid))
link->SelectObjid = pwr_cNObjid;
}
else
{
if ( cdh_ObjidIsEqual( object->Objid[i], object->SelectObjid))
object->SelectObjid = pwr_cNObjid;
}
object->OldSelect[i] = object->Select[i];
}
if ( link)
{
if ( cdh_ObjidIsEqual( object->Objid[i], link->SelectObjid))
{
object->Select[i] = 1;
link->SelectExist = 1;
if ( object->DisplayObjectP != &object->DisplayObject)
{
if ( dataptr[i])
memcpy( *object->DisplayObjectP, dataptr[i], object->DataSize);
}
}
else
object->Select[i] = 0;
}
else
{
if ( cdh_ObjidIsEqual( object->Objid[i], object->SelectObjid))
{
select_exist = 1;
object->Select[i] = 1;
}
else
object->Select[i] = 0;
}
}
if ( !link && !select_exist)
object->SelectObjid = pwr_cNObjid;
if ( link && link->DoRemove)
{
cellp = (nmps_sCellInput *) &object->Cell1P;
for ( j = 0; j < NMPS_DISP_CELLNUM; j++)
{
if ( cellp->CellP != &cellp->Cell)
{
cell = (pwr_sClass_NMpsCell *) *(cellp->CellP);
if ( !cell->ExternFlag)
{
cell->ExternObjId = link->SelectObjid;
cell->ExternOpType = NMPS_OPTYPE_EXTDELETE_OBJID;
cell->ExternFlag = 1;
}
}
cellp++;
}
}
else if ( link && link->DoMoveForward)
{
cellp = (nmps_sCellInput *) &object->Cell1P;
for ( j = 0; j < NMPS_DISP_CELLNUM; j++)
{
if ( cellp->CellP != &cellp->Cell)
{
cell = (pwr_sClass_NMpsCell *) *(cellp->CellP);
if ( !cell->ExternFlag)
{
cell->ExternObjId = link->SelectObjid;
if ( object->SelDirection == NMPS_DISP_DIRECT_FORW)
cell->ExternOpType = NMPS_OPTYPE_EXTMOVEFORW_OBJID;
else
cell->ExternOpType = NMPS_OPTYPE_EXTMOVEBACKW_OBJID;
cell->ExternFlag = 1;
}
}
cellp++;
}
}
else if ( link && link->DoMoveBackward)
{
cellp = (nmps_sCellInput *) &object->Cell1P;
for ( j = 0; j < NMPS_DISP_CELLNUM; j++)
{
if ( cellp->CellP != &cellp->Cell)
{
cell = (pwr_sClass_NMpsCell *) *(cellp->CellP);
if ( !cell->ExternFlag)
{
cell->ExternObjId = link->SelectObjid;
if ( object->SelDirection == NMPS_DISP_DIRECT_FORW)
cell->ExternOpType = NMPS_OPTYPE_EXTMOVEBACKW_OBJID;
else
cell->ExternOpType = NMPS_OPTYPE_EXTMOVEFORW_OBJID;
cell->ExternFlag = 1;
}
}
cellp++;
}
}
if ( link && link->SelectOrder && link->SelectOrderOwner == object->Number)
/* Noone responded, selection remains */
link->SelectOrder = 0;
if ( link && link->DoSelectNext)
{
for ( i = 0; i < num; i++)
{
if ( object->Select[i])
{
if ( ((i == num - 1 &&
object->SelDirection == NMPS_DISP_DIRECT_FORW) ||
(i == 0 &&
object->SelDirection != NMPS_DISP_DIRECT_FORW)) &&
!(object->Number == 1 && link->MaxDispNumber == 1))
{
/* Transfer selection to next cell */
if ( object->Number != link->MaxDispNumber)
link->SelectOrderNumber = object->Number + 1;
else
link->SelectOrderNumber = 1;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_NEXT;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
else
{
/* Move selection in the cell */
object->Select[i] = 0;
object->OldSelect[i] = 0;
if ( object->SelDirection == NMPS_DISP_DIRECT_FORW)
{
if ( i != num - 1)
{
object->Select[i+1] = 1;
object->OldSelect[i+1] = 1;
link->SelectObjid = object->Objid[i+1];
}
else
{
object->Select[0] = 1;
object->OldSelect[0] = 1;
link->SelectObjid = object->Objid[0];
}
}
else
{
if ( i != 0)
{
object->Select[i-1] = 1;
object->OldSelect[i-1] = 1;
link->SelectObjid = object->Objid[i-1];
}
else
{
object->Select[num-1] = 1;
object->OldSelect[num-1] = 1;
link->SelectObjid = object->Objid[num-1];
}
}
}
break;
}
}
}
if ( link && link->DoSelectPrevious)
{
for ( i = 0; i < num; i++)
{
if ( object->Select[i])
{
if ( ((i == num - 1 &&
object->SelDirection != NMPS_DISP_DIRECT_FORW) ||
(i == 0 &&
object->SelDirection == NMPS_DISP_DIRECT_FORW)) &&
!(object->Number == 1 && link->MaxDispNumber == 1))
{
/* Transfer selection to next cell */
if ( object->Number != 1)
link->SelectOrderNumber = object->Number - 1;
else
link->SelectOrderNumber = link->MaxDispNumber;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_PREV;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
else
{
/* Move selection in the cell */
object->Select[i] = 0;
object->OldSelect[i] = 0;
if ( object->SelDirection == NMPS_DISP_DIRECT_FORW)
{
if ( i != 0)
{
object->Select[i-1] = 1;
object->OldSelect[i-1] = 1;
link->SelectObjid = object->Objid[i-1];
}
else
{
object->Select[num-1] = 1;
object->OldSelect[num-1] = 1;
link->SelectObjid = object->Objid[num-1];
}
}
else
{
if ( i != num - 1)
{
object->Select[i+1] = 1;
object->OldSelect[i+1] = 1;
link->SelectObjid = object->Objid[i+1];
}
else
{
object->Select[0] = 1;
object->OldSelect[0] = 1;
link->SelectObjid = object->Objid[0];
}
}
}
break;
}
}
}
if ( link && link->SelectOrder && link->SelectOrderNumber == object->Number)
{
if ( link->SelectOrderType == NMPS_DISP_ORDERTYPE_NEXT)
{
if ( num == 0 )
{
if ( object->Number != link->MaxDispNumber)
{
/* Transfer to next */
link->SelectOrderNumber = object->Number + 1;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_NEXT;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
else
{
/* Transfer to next */
link->SelectOrderNumber = 1;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_NEXT;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
}
else
{
if ( object->SelDirection == NMPS_DISP_DIRECT_FORW)
{
/* Select first */
object->Select[0] = 1;
object->OldSelect[0] = 1;
link->SelectObjid = object->Objid[0];
}
else
{
/* Select last */
object->Select[num-1] = 1;
object->OldSelect[num-1] = 1;
link->SelectObjid = object->Objid[num-1];
}
link->SelectOrder = 0;
}
}
if ( link->SelectOrderType == NMPS_DISP_ORDERTYPE_PREV)
{
if ( num == 0)
{
if ( object->Number != 1)
{
/* Transfer to previous */
link->SelectOrderNumber = object->Number - 1;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_PREV;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
else
{
/* Transfer to last */
link->SelectOrderNumber = link->MaxDispNumber;
link->SelectOrderType = NMPS_DISP_ORDERTYPE_PREV;
link->SelectOrder = 1;
link->SelectOrderOwner = object->Number;
}
}
else
{
if ( object->SelDirection == NMPS_DISP_DIRECT_FORW)
{
/* Select last */
object->Select[num - 1] = 1;
object->OldSelect[num - 1] = 1;
link->SelectObjid = object->Objid[num-1];
}
else
{
/* Select first */
object->Select[0] = 1;
object->OldSelect[0] = 1;
link->SelectObjid = object->Objid[0];
}
link->SelectOrder = 0;
}
}
}
object->OldLastIndex = num;
}
void DispLink_exec(
plc_sThread *tp,
pwr_sClass_DispLink *object)
{
if ( !object->SelectExist)
object->ResetData = 1;
if ( object->SelectOrder && object->SelectOrderOwner == NMPS_DISP_ORDEROWNER_LINK)
object->SelectOrder = 0;
object->DoRemove = 0;
object->DoMoveForward = 0;
object->DoMoveBackward = 0;
object->DoSelectNext = 0;
object->DoSelectPrevious = 0;
if ( object->Remove)
{
object->DoRemove = 1;
object->Remove = 0;
}
if ( object->MoveForward)
{
object->DoMoveForward = 1;
object->MoveForward = 0;
}
if ( object->MoveBackward)
{
object->DoMoveBackward = 1;
object->MoveBackward = 0;
}
if ( object->SelectNext)
{
if ( !object->SelectExist)
{
/* Give an order to first cell */
object->SelectOrderNumber = 1;
object->SelectOrderType = NMPS_DISP_ORDERTYPE_NEXT;
object->SelectOrder = 1;
object->SelectOrderOwner = NMPS_DISP_ORDEROWNER_LINK;
}
else
object->DoSelectNext = 1;
object->SelectNext = 0;
}
if ( object->SelectPrevious)
{
if ( !object->SelectExist)
{
/* Give an order to last cell */
object->SelectOrderNumber = object->MaxDispNumber;
object->SelectOrderType = NMPS_DISP_ORDERTYPE_PREV;
object->SelectOrder = 1;
object->SelectOrderOwner = NMPS_DISP_ORDEROWNER_LINK;
}
else
object->DoSelectPrevious = 1;
object->SelectPrevious = 0;
}
object->SelectExist = 0;
}
/*
* Proview $Id: nmps_plc_macro.h,v 1.1 2006-01-12 05:57:43 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.
*/
/* PREPROCESSOR RUTINER */
#if defined OS_ELN
# include float
#else
# include <float.h>
#endif
typedef struct {
char Key[40];
pwr_tStatus Status;
char Data[1];
} nmps_sTrans;
typedef struct {
pwr_tUInt32 *DataP;
pwr_tObjid Data_ObjId;
pwr_tBoolean Data_Front;
pwr_tBoolean Data_Back;
pwr_tRefId Data_Dlid;
pwr_tBoolean Data_Select;
pwr_tBoolean Data_OldSelect;
} plc_t_DataInfo;
typedef struct {
pwr_tUInt32 *DataP;
pwr_tObjid Data_ObjId;
pwr_tRefId Data_Dlid;
} plc_t_DataInfoMirCell;
/**
DataCopy
@aref datacopy DataCopy
*/
#define datacopy_exec( object, datasize) \
if ( *object->ConditionP ) \
{ \
if ( *object->DataToP != 0 && *object->DataFromP != 0) \
memcpy( *object->DataToP, *object->DataFromP, datasize); \
}
/**
DataReset
@aref datareset DataReset
*/
#define datareset_exec( object, datasize) \
if ( *object->ConditionP ) \
{ \
if ( *object->DataP != 0 ) \
memset( *object->DataP, 0, datasize); \
}
/**
NMpsCellSubWind
@aref nmpscellsubwind NMpsCellSubWind
*/
#define NMpsCellSubWind_exec( object, subwindow) \
if ( !(object->InitTime && !object->ReloadDone)) \
{ \
object->CurrentIndex = 0; \
memset( &(object->DataCurrentP), 0, \
sizeof( plc_t_DataInfo) - 16); \
subwindow; \
for ( object->Idx = 1; object->Idx <= \
object->LastIndex; object->Idx++ ) \
{ \
memcpy( &(object->DataCurrentP), \
(char *) &object->Data1P + \
(object->Idx - 1) * sizeof( plc_t_DataInfo), \
sizeof( plc_t_DataInfo) - 16); \
object->CurrentIndex = object->Idx; \
subwindow; \
} \
}
/**
NMpsStoreCellSubWind
@aref nmpscellstoresubwind NMpsStoreCellSubWind
*/
#define NMpsStoreCellSubWind_exec( object, subwindow) \
if ( !(object->InitTime && !object->ReloadDone)) \
{ \
object->CurrentIndex = 0; \
memset( &(object->DataCurrentP), 0, \
sizeof( plc_t_DataInfo) - 16); \
subwindow; \
for ( object->Idx = 1; object->Idx <= \
object->LastIndex; object->Idx++ ) \
{ \
memcpy( &(object->DataCurrentP), \
(char *) &object->Data1P + \
(object->Idx - 1) * sizeof( plc_t_DataInfo), \
sizeof( plc_t_DataInfo) - 16); \
object->CurrentIndex = object->Idx; \
subwindow; \
} \
}
/**
CLoop
@aref cloop CLoop
*/
#define CLoop_exec( object, subwindow) \
if ( *object->ConditionP) \
{ \
object->CurrentIndex = object->StartIndex; \
for ( object->CurrentIndex = object->StartIndex; \
object->CurrentIndex <= object->StopIndex + FLT_EPSILON; \
object->CurrentIndex += object->Increment) \
{ \
subwindow; \
} \
}
/**
GetDap
@aref getdap GetDap
*/
#define GetDap_exec( object, attribute) \
memcpy( &object->OutDataP, &attribute, \
sizeof( object->OutDataP) + sizeof( object->OutData_ObjId));
/**
GetObjidp
@aref getobjidp GetObjidp
*/
#define GetObjidp_exec( object, attribute) \
object->ObjId = attribute;
/**
Func
@aref func Func
*/
#define Func_exec( object, subwindow) \
if ( object->ConditionP) object->Condition = *object->ConditionP; \
if ( object->A1P) object->A1 = *object->A1P; \
if ( object->A2P) object->A2 = *object->A2P; \
if ( object->A3P) object->A3 = *object->A3P; \
if ( object->A4P) object->A4 = *object->A4P; \
if ( object->A5P) object->A5 = *object->A5P; \
if ( object->A6P) object->A6 = *object->A6P; \
if ( object->A7P) object->A7 = *object->A7P; \
if ( object->A8P) object->A8 = *object->A8P; \
if ( object->d1P) object->d1 = *object->d1P; \
if ( object->d2P) object->d2 = *object->d2P; \
if ( object->d3P) object->d3 = *object->d3P; \
if ( object->d4P) object->d4 = *object->d4P; \
if ( object->d5P) object->d5 = *object->d5P; \
if ( object->d6P) object->d6 = *object->d6P; \
if ( object->d7P) object->d7 = *object->d7P; \
if ( object->d8P) object->d8 = *object->d8P; \
if ( object->Condition) { \
subwindow; \
}
/**
FuncExtend
@aref funcextend FuncExtend
*/
#define FuncExtend_exec( object) \
if ( object->A1P) object->A1 = *object->A1P; \
if ( object->A2P) object->A2 = *object->A2P; \
if ( object->A3P) object->A3 = *object->A3P; \
if ( object->A4P) object->A4 = *object->A4P; \
if ( object->A5P) object->A5 = *object->A5P; \
if ( object->A6P) object->A6 = *object->A6P; \
if ( object->A7P) object->A7 = *object->A7P; \
if ( object->A8P) object->A8 = *object->A8P; \
if ( object->d1P) object->d1 = *object->d1P; \
if ( object->d2P) object->d2 = *object->d2P; \
if ( object->d3P) object->d3 = *object->d3P; \
if ( object->d4P) object->d4 = *object->d4P; \
if ( object->d5P) object->d5 = *object->d5P; \
if ( object->d6P) object->d6 = *object->d6P; \
if ( object->d7P) object->d7 = *object->d7P; \
if ( object->d8P) object->d8 = *object->d8P;
/**
FuncInput
@aref funcinput FuncInput
*/
#define FuncInput_exec( object, funcobject) \
object->A1 = funcobject->A1; \
object->A2 = funcobject->A2; \
object->A3 = funcobject->A3; \
object->A4 = funcobject->A4; \
object->A5 = funcobject->A5; \
object->A6 = funcobject->A6; \
object->A7 = funcobject->A7; \
object->A8 = funcobject->A8; \
object->d1 = funcobject->d1; \
object->d2 = funcobject->d2; \
object->d3 = funcobject->d3; \
object->d4 = funcobject->d4; \
object->d5 = funcobject->d5; \
object->d6 = funcobject->d6; \
object->d7 = funcobject->d7; \
object->d8 = funcobject->d8;
/**
FuncOutput
@aref funcoutput FuncOutput
*/
#define FuncOutput_exec( object, funcobject) \
funcobject->OA1 = *object->OA1P; \
funcobject->OA2 = *object->OA2P; \
funcobject->OA3 = *object->OA3P; \
funcobject->OA4 = *object->OA4P; \
funcobject->OA5 = *object->OA5P; \
funcobject->OA6 = *object->OA6P; \
funcobject->OA7 = *object->OA7P; \
funcobject->OA8 = *object->OA8P; \
funcobject->od1 = *object->od1P; \
funcobject->od2 = *object->od2P; \
funcobject->od3 = *object->od3P; \
funcobject->od4 = *object->od4P; \
funcobject->od5 = *object->od5P; \
funcobject->od6 = *object->od6P; \
funcobject->od7 = *object->od7P; \
funcobject->od8 = *object->od8P;
/**
NMpsMirrorCellSubWind
@aref nmpsmirrorcellsubwind NMpsMirroCellSubWind
*/
#define NMpsMirrorCellSubWind_exec( object, subwindow) \
object->CurrentIndex = 0; \
memset( &(object->DataCurrentP), 0, \
sizeof( plc_t_DataInfoMirCell) - sizeof(pwr_tRefId)); \
subwindow; \
for ( object->Idx = 1; object->Idx <= \
object->LastIndex; object->Idx++ ) \
{ \
memcpy( &(object->DataCurrentP), \
(char *) &object->Data1P + \
(object->Idx - 1) * sizeof( plc_t_DataInfoMirCell), \
sizeof( plc_t_DataInfoMirCell) - sizeof(pwr_tRefId)); \
object->CurrentIndex = object->Idx; \
subwindow; \
}
/**
RemTransSend
@aref remtranssend RemTransSend
*/
#define RemTransSend_exec( object, subwindow) \
if ( *object->SendP && !object->Send) { \
if ( ((pwr_sClass_RemTrans *)(*object->RemTransP))->DataValid > 0) \
object->Error = 1; \
else { \
subwindow; \
((pwr_sClass_RemTrans *)(*object->RemTransP))->DataValid = 1; \
object->Error = 0; \
} \
} \
else \
object->Error = \
EVEN( ((pwr_sClass_RemTrans *)(*object->RemTransP))->LastSts); \
\
object->Send = *object->SendP; \
\
if ( ((pwr_sClass_RemTrans *)(*object->RemTransP))->DataValid > 0) \
object->Occupied = 1; \
else \
object->Occupied = 0; \
\
if ( ((pwr_sClass_RemTrans *)(*object->RemTransP))->Buffers > 0) { \
object->Buffer = 1; \
if ( ((pwr_sClass_RemTrans *)(*object->RemTransP))->Buffers >= \
((pwr_sClass_RemTrans *)(*object->RemTransP))->MaxBuffers) \
object->Occupied = 1; \
} \
else \
object->Buffer = 0;
/**
RemTransRcv
@aref remtransrcv RemTransRcv
*/
#define RemTransRcv_exec( object, subwindow) \
if ( ((pwr_sClass_RemTrans *)(*object->RemTransP))->DataValid > 0) { \
subwindow; \
((pwr_sClass_RemTrans *)(*object->RemTransP))->DataValid = 0; \
object->Received = 1; \
} \
else \
object->Received = 0;
/*
* Proview $Id: nmps_plc_runtime.c,v 1.1 2006-01-12 05:57:43 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.
*/
#ifdef OS_ELN
#include stdio
#else
#include <stdio.h>
#endif
#include "pwr.h"
#include "pwr_nmpsclasses.h"
#include "rt_plc.h"
#include "co_time.h"
#define ODD(a) (((int)(a) & 1) != 0)
#define EVEN(a) (((int)(a) & 1) == 0)
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
#ifndef __ALPHA
#define abs(Dragon) ((Dragon) >= 0 ? (Dragon) : (-(Dragon)))
#endif
/**
RunningTime
@aref runningtime RunningTime
*/
void RunningTime_exec(
plc_sThread *tp,
pwr_sClass_RunningTime *object)
{
pwr_tFloat32 TimeSince;
/* Safeguard reasonable time 10 ms - 30 min */
TimeSince = *object->ScanTime;
if (TimeSince <= 0.0) TimeSince = 0.01;
if (TimeSince > 1800.0) TimeSince = 0.01;
/* Test if New Trip */
if (object->TripReset)
{
object->OldTripNOfStarts = object->TripNOfStarts;
object->OldTripRunHours = object->TripRunHours;
object->OldTripRunSeconds = object->TripRunSeconds;
object->OldTripHours = object->TripHours;
object->OldTripSeconds = object->TripSeconds;
object->OldTripUsage = object->TripUsage;
object->TripNOfStarts = 0;
object->TripRunHours = 0;
object->TripRunSeconds = 0.0;
object->TripHours = 0;
object->TripSeconds = 0.0;
clock_gettime(CLOCK_REALTIME, &object->ResetTime);
object->TripReset = 0;
}
/* Update Calendar time */
object->TotalSeconds += TimeSince;
if (object->TotalSeconds >= 3600.0)
{
object->TotalSeconds -= 3600.0;
object->TotalHours++;
}
object->TripSeconds += TimeSince;
if (object->TripSeconds >= 3600.0)
{
object->TripSeconds -= 3600.0;
object->TripHours++;
}
/* Test if running */
object->Start = 0;
if (*object->RunningP)
{
/* New start ? */
if (!object->Running)
{
object->Start = 1;
object->TotalNOfStarts++;
object->TripNOfStarts++;
clock_gettime(CLOCK_REALTIME, &object->StartTime);
} /* End if new start */
/* Update Running Time */
object->TripRunSeconds += TimeSince;
if (object->TripRunSeconds >= 3600.0)
{
object->TripRunSeconds -= 3600.0;
object->TripRunHours++;
}
object->TotalRunSeconds += TimeSince;
if (object->TotalRunSeconds >= 3600.0)
{
object->TotalRunSeconds -= 3600.0;
object->TotalRunHours++;
}
} /* End if Running */
object->Running = *object->RunningP;
/* Calculate usage % */
object->TotalUsage = (object->TotalRunHours * 3600.0 +
object->TotalRunSeconds) /
(object->TotalHours * 3600.0 + object->TotalSeconds) * 100.0;
object->TripUsage = (object->TripRunHours * 3600.0 +
object->TripRunSeconds) /
(object->TripHours * 3600.0 + object->TripSeconds) * 100.0;
}
/*
* Proview $Id: nmps_plc_trans.c,v 1.1 2006-01-12 05:57:43 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.
*/
#if defined(OS_VMS) || defined(OS_LYNX)
#include <stdio.h>
#include <float.h>
#include <string.h>
#endif
#ifdef OS_ELN
#include stdio
#include float
#include string
#endif
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_nmpsclasses.h"
#include "rt_gdh.h"
#include "rt_plc.h"
#include "nmps_cnv.h"
#define ODD(a) (((int)(a) & 1) != 0)
#define EVEN(a) (((int)(a) & 1) == 0)
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
#ifndef __ALPHA
#define abs(Dragon) ((Dragon) >= 0 ? (Dragon) : (-(Dragon)))
#endif
#define NMPS_REQUESTFUNC_ACCEPTBOTH 16
void datacnv_init( pwr_sClass_datacnv *object)
{
int sts;
sts = cvn_ConvInit( object->ToConvdefType,
object->ToConvdef,
object->ToConvdefFile,
object->FromConvdefType,
object->FromConvdef,
object->FromConvdefFile,
&object->ConvTableCount,
0,
(char **) object->ConvTable);
}
void datacnv_exec(
plc_sThread *tp,
pwr_sClass_datacnv *object)
{
if ( *object->ConditionP)
cnv_ConvertData(
(cnv_t_conv_table *) object->ConvTable,
object->ConvTableCount,
(char *)(* object->DataFromP),
(char *)(* object->DataToP));
}
void DataRequest_exec(
plc_sThread *tp,
pwr_sClass_DataRequest *object)
{
object->DataReceived = 0;
object->Error = 0;
if ( *object->TriggP && !object->TriggOld)
object->TriggDetected = 1;
if ( object->OpTrigg)
{
object->TriggDetected = 1;
object->OpTrigg = 0;
}
if ( object->Function & NMPS_REQUESTFUNC_ACCEPTBOTH)
{
if ( *object->AcceptP && !object->AcceptOld)
object->SysAcceptDetected = 1;
if ( object->OpAccept)
{
object->OpAccept = 0;
object->OpAcceptDetected = 1;
}
if ( object->OpAcceptDetected && object->SysAcceptDetected)
{
object->AcceptDetected = 1;
object->OpAcceptDetected = 0;
object->SysAcceptDetected = 0;
}
}
else
{
if ( *object->AcceptP && !object->AcceptOld)
object->AcceptDetected = 1;
if ( object->OpAccept)
{
object->OpAccept = 0;
object->AcceptDetected = 1;
}
}
if ( *object->ResetP && !object->ResetOld)
{
object->ResetDetected = 1;
object->OpAcceptDetected = 0;
object->SysAcceptDetected = 0;
}
if ( object->OpReset)
{
object->ResetDetected = 1;
object->OpReset = 0;
object->OpAcceptDetected = 0;
object->SysAcceptDetected = 0;
}
if ( object->DataRcvDetected)
{
object->DataReceived = 1;
object->DataRcvDetected = 0;
}
if ( object->ErrorDetected)
{
object->Error = 1;
object->ErrorDetected = 0;
}
object->TriggOld = *object->TriggP;
object->AcceptOld = *object->AcceptP;
object->ResetOld = *object->ResetP;
}
void DataRcv_exec(
plc_sThread *tp,
pwr_sClass_DataRcv *object)
{
object->DataReceived = 0;
object->Error = 0;
if ( object->Function & NMPS_REQUESTFUNC_ACCEPTBOTH)
{
if ( *object->AcceptP && !object->AcceptOld)
object->SysAcceptDetected = 1;
if ( object->OpAccept)
{
object->OpAccept = 0;
object->OpAcceptDetected = 1;
}
if ( object->OpAcceptDetected && object->SysAcceptDetected)
{
object->AcceptDetected = 1;
object->OpAcceptDetected = 0;
object->SysAcceptDetected = 0;
}
}
else
{
if ( *object->AcceptP && !object->AcceptOld)
object->AcceptDetected = 1;
if ( object->OpAccept)
{
object->OpAccept = 0;
object->AcceptDetected = 1;
}
}
if ( *object->ResetP && !object->ResetOld)
{
object->ResetDetected = 1;
object->OpAcceptDetected = 0;
object->SysAcceptDetected = 0;
}
if ( object->OpReset)
{
object->ResetDetected = 1;
object->OpReset = 0;
object->OpAcceptDetected = 0;
object->SysAcceptDetected = 0;
}
if ( object->DataRcvDetected)
{
object->DataReceived = 1;
object->DataRcvDetected = 0;
}
if ( object->ErrorDetected)
{
object->Error = 1;
object->ErrorDetected = 0;
}
object->AcceptOld = *object->AcceptP;
object->ResetOld = *object->ResetP;
}
void DataSend_exec(
plc_sThread *tp,
pwr_sClass_DataSend *object)
{
object->Error = 0;
object->DataSent = 0;
if ( *object->TriggP && !object->TriggOld)
object->TriggDetected = 1;
if ( object->ErrorDetected)
{
object->Error = 1;
object->ErrorDetected = 0;
}
if ( object->DataSentDetected)
{
object->DataSent = 1;
object->DataSentDetected = 0;
}
object->TriggOld = *object->TriggP;
}
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
!
! Proview $Id: nmps_c_loctrans.wb_load,v 1.1 2006-01-12 05:57:43 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.
!
! nmps_c_loctrans.wb_load -- Defines the class LocTrans.
!
SObject NMps:Class
!
! LocTrans - Local Trans descripton
!
Object LocTrans $ClassDef 49
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
EndBody
!
! RemTrans Runtime Body
!
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "LocTrans"
EndBody
!
! Parameter Description
!
Object Description $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!
! Parameter DataValid
!
Object DataValid $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_NOEDIT
EndBody
EndObject
EndObject
EndObject ! $ClassDef
EndSObject ! SObject
/*
* Proview $Id: qbus_io.h,v 1.1 2006-01-12 05:54:27 claes Exp $
* 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.
*/
#define QBUS_IOCTL_PHYSBADLA 1
typedef struct {
unsigned int Address;
unsigned int Data;
} qbus_io_read;
typedef struct {
unsigned int Address;
unsigned int Data;
} qbus_io_write;
typedef struct {
unsigned int PhysBadla;
} qbus_io_ioctl;
/*
* Proview $Id: rs_showqbus.c,v 1.1 2006-01-12 05:54:27 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.
*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <sys/file.h>
#include <time.h>
#include <smem.h>
#include "qbus_io.h"
#define C0 0x400000
#define C1 0x800000
typedef struct {
unsigned int CtrlStatus;
unsigned int reserved1;
unsigned int BusData;
unsigned int BusVector;
unsigned int BusPriority;
unsigned int QbusMaintenance;
unsigned int QbusAddress;
unsigned int Offset;
unsigned int reserved2;
unsigned int TestPoint;
} t_QbusReg;
int main ()
{
int fp;
// qbus_io_write wb;
qbus_io_read rb;
int sts;
unsigned int start_address = 017760000;
unsigned int stop_address = 017777776;
unsigned int address;
fp = open( "/dev/qbus", O_RDWR);
address = start_address;
for ( ;;)
{
/* Read */
rb.Address = address;
sts = read( fp, &rb, sizeof(rb));
if ( sts != -1)
printf( "Address: %o (%d) sts: %d read\n", address, address, sts);
// else
// {
// /* Write */
// wb.Data = 0;
// wb.Address = address;
// sts = write( fp, &wb, sizeof(wb));
// if ( sts != -1)
// printf( "Address: %o (%d) sts: %d write\n", address, address, sts);
// }
address += 2;
if ( address > stop_address)
break;
}
return 1;
}
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include ../../special.mk
-include ../special.mk
-include special.mk
/*
* Proview $Id: ssabox_plc_pidx.c,v 1.1 2006-01-12 05:54:27 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.
*/
/* PLC-code for PidX */
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "rt_plc.h"
#define ODD(a) (((int)(a) & 1) != 0)
#define EVEN(a) (((int)(a) & 1) == 0)
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
#ifndef __ALPHA
#define abs(Dragon) ((Dragon) >= 0 ? (Dragon) : (-(Dragon)))
#endif
/* PIDX
*/
void PidX_exec(
plc_sThread *tp,
pwr_sClass_PidX *object)
{
/* Input */
object->SetVal = *object->SetValP;
object->BiasD = *object->BiasDP;
object->ForcVal = *object->ForcValP;
object->Force = *object->ForceP;
object->IntOff = *object->IntOffP;
/* Everything else by I/O-routine and on the local board */
}
/*
* Proview $Id: ssabox_ssabutil.c,v 1.1 2006-01-12 05:54:27 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.
*/
/************************************************************************
*
* Filename: rs_ssabutil.c
*
* Datum Pgm. Anm
* Reviderad 920724 CS Skapad.
*
* Beskrivning:
* Filen innehller diverse rutiner fr proview/R.
*
**************************************************************************/
/*_Include files_________________________________________________________*/
#ifdef OS_ELN
#include stdio
#include string
#else
#include <stdio.h>
#include <string.h>
#endif
#include "pwr.h"
#include "rt_gdh.h"
#include "rs_ssabutil.h"
/* Nice functions */
#define ODD(a) (((int)(a) & 1) != 0)
#define EVEN(a) (((int)(a) & 1) == 0)
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
#define abs(Dragon) ((Dragon) >= 0 ? (Dragon) : (-(Dragon)))
/* Global variable */
/* Local static variables */
/*************************************************************************
*
* Name: ssabutil_lopnr_check()
*
* Type int
*
* Type Parameter IOGF Description
*
* Description:
* Kontrollerar att checksiffran {r ok p} ett l|pnummer.
* Returnerar0 om ej ok, 1 om ok.
*
**************************************************************************/
int ssabutil_lopnr_check( pwr_tInt32 lopnr)
{
pwr_tInt32 tst_lopnr;
tst_lopnr = lopnr / 10;
tst_lopnr = ssabutil_chksum_lop( tst_lopnr);
if ( tst_lopnr != lopnr)
return 0;
else
return 1;
}
/************************************************************************
*
* Namn: ssabutil_chksum_lop
*
* Typ: pwr_tInt32
*
* TYP PARAMETER IOGF BESKRIVNING
* pwr_tInt32 ssabutil_chksum_lop O Lpnummer med checksiffra.
* pwr_tInt32 lopnummer I Lpnumret som checksiffran skall
* berknas ifrn.
*
* Beskrivning: Rutinen berknar checksiffra i lpnummer.
*
*************************************************************************/
pwr_tInt32 ssabutil_chksum_lop( pwr_tInt32 lopnummer)
{
static pwr_tInt16 lop_fig_weights[6] = {1,7,3,1,7,3};
lopnummer=lopnummer*10 +
ssabutil_chksum_calculate( lopnummer,
lop_fig_weights,
6);
return(lopnummer);
}
/* END_OF ssabutil_chksum_lop */
/************************************************************************
*
* Namn: ssabutil_chksum_kupong
*
* Typ: pwr_tInt32
*
* TYP PARAMETER IOGF BESKRIVNING
* pwr_tInt32 ssabutil_chksum_kupong O Kupongnummer med checksiffra.
* pwr_tInt32 kupong_nummer I Kupongnumret som checksiffran skall
* berknas ifrn.
*
* Beskrivning: Rutinen berknar checksiffra i kupongnummer.
*
*************************************************************************/
pwr_tInt32 ssabutil_chksum_kupong( pwr_tInt32 kupong_nummer)
{
static pwr_tInt16 kupong_fig_weights[5] = {1,3,9,1,7};
kupong_nummer=kupong_nummer*10 +
ssabutil_chksum_calculate( kupong_nummer,
kupong_fig_weights,
5);
return(kupong_nummer);
}
/* END_OF ssabutil_chksum_kupong */
/************************************************************************
*
* Namn: ssabutil_chksum_calculate
*
* Typ: pwr_tInt32
*
* TYP PARAMETER IOGF BESKRIVNING
* pwr_tInt32 ssabutil_chksum_
* calculate O Berknad checksiffra.
* pwr_tInt32 value I Talet som checksiffran skall berknas
* ifrn.
* pwr_tInt16 *weights I Pekare till viktvektor.
* pwr_tInt16 num_figures I Antalet sifror i value.
*
*
* Beskrivning: Rutinen berknar checksiffra i fljande steg.
* 1. Varje siffra i value multipliceras med sin respektive
* vikt.
* 2. Produkterna adderas.
* 3. Checksiffra = Skillnaden till nrmast hgre tiotal
*
*************************************************************************/
pwr_tInt32 ssabutil_chksum_calculate( pwr_tInt32 value,
pwr_tInt16 *weights,
pwr_tInt16 num_figures)
{
pwr_tInt16 sum; /* Arbetsvariabel */
pwr_tInt16 *weightP; /* Pekar p vikter */
/* Berkna perkaren till entalssiffran */
weightP = weights + num_figures - 1;
/* Berkna den viktade summan av siffrorona i talet */
for (sum=0; num_figures>0; num_figures--)
{
sum += (value % 10) * (*weightP--);
value /= 10 ;
}
/* Berkna skillnaden till nrmast hgre tiotal */
sum = ((sum/10) + 1)*10 - sum;
if (sum == 10) sum = 0;
return (sum);
}
/* END_OF ssabutil_chksum_calculate */
/*
* Proview $Id: ssabox_ssabutil.h,v 1.1 2006-01-12 05:54:27 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.
*/
/************************************************************************
*
* Filename: rs_ssabutil.h
*
* Datum Pgm. Anm
* Reviderad 920724 CS Skapad.
*
* Beskrivning:
*
**************************************************************************/
int ssabutil_lopnr_check( pwr_tInt32 lopnr);
pwr_tInt32 ssabutil_chksum_lop( pwr_tInt32 lopnummer);
pwr_tInt32 ssabutil_chksum_kupong( pwr_tInt32 kupong_nummer);
pwr_tInt32 ssabutil_chksum_calculate( pwr_tInt32 value,
pwr_tInt16 *weights,
pwr_tInt16 num_figures);
int ssab_curve( float x,
float *y,
float *table,
int size);
int ssab_curve_2d( float x,
float y,
float *z,
float *table,
int x_size,
int y_size);
#define SSAB_CURVE_2D( x, y, z, table) ssab_curve_2d( x, y, z, (float *)&table,\
sizeof(table[0])/sizeof(table[0][0])-1,\
sizeof(table)/sizeof(table[0])-1)
#define SSAB_CURVE( x, y, table) ssab_curve( x, y, (float *)&table,\
sizeof(table)/sizeof(table[0]))
/*
* Proview $Id: ssabox_ssabutil_matrix.c,v 1.1 2006-01-12 05:54:27 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.
*/
/*************************************************************************
*
* PROGRAM rs_ssabutil_matrix
*
* Modifierad
* 96 01 26 CS Skapad
*
* Funktion:
* Interpolation i tabeller.
*
**************************************************************************/
/*_Include filer_________________________________________________________*/
#if defined OS_ELN
#include stdlib
#include float
#else
#include <stdlib.h>
#include <float.h>
#endif
#include "pwr.h"
#include "rs_ssabutil.h"
#include "rs_sutl_msg.h"
/*_Globala variabler______________________________________________________*/
/*_Local proceduer________________________________________________________*/
/* Globala procedurer_____________________________________________________*/
/*************************************************************************
*
* Name: ssab_curve
*
* Typ int
*
* Typ Parameter IOGF Beskrivning
* float x I x-vrde.
* float* y O interpolerat y-vrde.
* float* table I tabell.
* int size I antal punkter i tabellen (n).
*
* Beskrivning:
* Interpolerar i en tabell av float. Tabellen ska vara
* av formatet
* float some_table[n][2] = {
* { x1, y1},
* { x2, y2},
* { x3, y3},
* ...
* { xn, yn}};
*
*
**************************************************************************/
int ssab_curve( float x,
float *y,
float *table,
int size)
{
int x_idx;
int x_found;
float *ptr;
float x1, x2, y1, y2;
#define TABLE_Y(ix) (*(table + 2 * (ix) - 1))
#define TABLE_X(ix) (*(table + 2 * (ix) - 2))
/* Get the x point */
ptr = table;
x_found = 0;
for ( x_idx = 0; x_idx < size; x_idx++)
{
if ( *ptr > x)
{
x_found = 1;
break;
}
ptr += 2;
}
/* Interpolate */
if ( !x_found )
{
/* Take the very last point */
*y = TABLE_Y( size);
}
else if ( x_idx == 0 )
{
/* Take the first point */
*y = TABLE_Y( 1);
}
else
{
y1 = TABLE_Y( x_idx);
y2 = TABLE_Y( x_idx + 1);
x1 = TABLE_X( x_idx);
x2 = TABLE_X( x_idx + 1);
*y = y1 + ( y2 - y1) * (x - x1)/(x2 - x1);
}
return SUTL__SUCCESS;
}
/*************************************************************************
*
* Name: ssab_curve_2d
*
* Typ int
*
* Typ Parameter IOGF Beskrivning
* float x I x-vrde.
* float y I y-vrde.
* float* z O interpolerat z-vrde.
* float* table I tabell.
* int x_size I antal rader med x-vrden (n) i tabellen.
* int y_size I antal kolumner med y-vrden (m) i
* tabellen.
*
* Beskrivning:
* Interpolerar i en tvdimensionell matris av float.
* Frsta i raden i matrisen ska innehlla x-vrden, frsta
* kolumnen y-vrden. vriga element innehller z-vrden som
* ges av x-vrdet fr raden och y-vrden fr kolumnen.
* Element [0][0] anvnds ej.
*
* Tabellen ska vara av formatet
*
* float temp_tjl_table[n+1][m+1] = {
* { 0, y1, y2, y3, ..., ym},
* { x1, z11, z12, z13, ..., z1m},
* { x2, z21, z22, z23, ..., z2m},
* { x3, z31, z32, z33, ..., z3m},
* ...
* { xn, zn1, zn2, zn3, ..., znm}};
*
**************************************************************************/
int ssab_curve_2d( float x,
float y,
float *z,
float *table,
int x_size,
int y_size)
{
int x_idx, y_idx;
int x_found, y_found;
float *ptr;
float x1, x2, y1, y2, z1, z2, z11, z12, z21, z22;
#define TABLE2D_Z(ix,iy) (*(table + (iy) * (x_size + 1) + (ix)))
#define TABLE2D_X(ix) (*(table + (ix)))
#define TABLE2D_Y(iy) (*(table + (iy) * (x_size + 1)))
/* Get the x point */
ptr = table + 1;
x_found = 0;
for ( x_idx = 0; x_idx < x_size; x_idx++)
{
if ( *ptr > x)
{
x_found = 1;
break;
}
ptr++;
}
/* Get the y point */
ptr = table + x_size + 1;
y_found = 0;
for ( y_idx = 0; y_idx < y_size; y_idx++)
{
if ( *ptr > y)
{
y_found = 1;
break;
}
ptr += x_size + 1;
}
/* Interpolate */
if ( !x_found && !y_found)
{
/* Take the very last point */
*z = TABLE2D_Z( x_size, y_size);
}
else if ( x_idx == 0 && y_idx == 0)
{
/* Take the first point */
*z = TABLE2D_Z( 1, 1);
}
else if ( !x_found && y_idx == 0)
{
*z = TABLE2D_Z( x_size, 1);
}
else if ( !y_found && x_idx == 0)
{
*z = TABLE2D_Z( 1, y_size);
}
else if ( !x_found)
{
z1 = TABLE2D_Z( x_size, y_idx);
z2 = TABLE2D_Z( x_size, y_idx + 1);
y1 = TABLE2D_Y( y_idx);
y2 = TABLE2D_Y( y_idx + 1);
if (abs( y2 - y1) < FLT_EPSILON)
*z = z1;
else
*z = z1 + ( z2 - z1) * (y - y1)/(y2 - y1);
}
else if ( x_idx == 0)
{
z1 = TABLE2D_Z( 1, y_idx);
z2 = TABLE2D_Z( 1, y_idx + 1);
y1 = TABLE2D_Y( y_idx);
y2 = TABLE2D_Y( y_idx + 1);
if (abs( y2 - y1) < FLT_EPSILON)
*z = z1;
else
*z = z1 + ( z2 - z1) * (y - y1)/(y2 - y1);
}
else if ( y_idx == 0)
{
z1 = TABLE2D_Z( x_idx, 1);
z2 = TABLE2D_Z( x_idx + 1, 1);
x1 = TABLE2D_X( x_idx);
x2 = TABLE2D_X( x_idx + 1);
if (abs( x2 - x1) < FLT_EPSILON)
*z = z1;
else
*z = z1 + ( z2 - z1) * (x - x1)/(x2 - x1);
}
else if ( !y_found)
{
z1 = TABLE2D_Z( x_idx, y_size);
z2 = TABLE2D_Z( x_idx + 1, y_size);
x1 = TABLE2D_X( x_idx);
x2 = TABLE2D_X( x_idx + 1);
if (abs( x2 - x1) < FLT_EPSILON)
*z = z1;
else
*z = z1 + ( z2 - z1) * (x - x1)/(x2 - x1);
}
else
{
z11 = TABLE2D_Z( x_idx, y_idx);
z12 = TABLE2D_Z( x_idx + 1, y_idx);
z21 = TABLE2D_Z( x_idx, y_idx + 1);
z22 = TABLE2D_Z( x_idx + 1, y_idx + 1);
y1 = TABLE2D_Y( y_idx);
y2 = TABLE2D_Y( y_idx + 1);
x1 = TABLE2D_X( x_idx);
x2 = TABLE2D_X( x_idx + 1);
if (abs( y2 - y1) < FLT_EPSILON)
{
z1 = z11;
z2 = z12;
}
else
{
z1 = z11 + (z21 - z11) * (y - y1) / (y2 - y1);
z2 = z12 + (z22 - z12) * (y - y1) / (y2 - y1);
}
if (abs( x2 - x1) < FLT_EPSILON)
*z = z1;
else
*z = z1 + ( z2 - z1) * (x - x1)/(x2 - x1);
}
return SUTL__SUCCESS;
}
#ifdef TEST
main()
{
int sts;
float temp_tjl_table[6][4] = {
/* Tjl */
{ 0, 200, 420, 640}, /* Anlpnings Temperaturer */
{ 20, 11, 14, 25},
{ 25, 13,17.5, 30},
{ 50, 20, 35, 47},
{ 70, 29, 49, 65},
{ 100, 33, 70, 93}};
float temp_step1_table[3][2] = {
/* Anlpnings temp, Steg1 temp */
{ 200, 430},
{ 420, 615},
{ 640, 830}};
float x, y, z;
int i;
for ( i = 0; i < 15; i ++)
{
if ( i == 0) { x = 0; y = 0; }
if ( i == 1) { x = 0; y = 120; }
if ( i == 2) { x = 700; y = 0; }
if ( i == 3) { x = 700; y = 120; }
if ( i == 4) { x = 0; y = 22.5; }
if ( i == 5) { x = 700; y = 22.5; }
if ( i == 6) { x = 310; y = 0; }
if ( i == 7) { x = 310; y = 120; }
if ( i == 8) { x = 310; y = 22.5; }
if ( i == 9) { x = 420; y = 50; }
if ( i == 10) { x = 420; y = 60; }
if ( i == 11) { x = 420; y = 70; }
if ( i == 12) { x = 310; y = 100; }
if ( i == 13) { x = 310; y = 70; }
if ( i == 14) { x = 310; y = 69.5; }
/*
if ( i == 0) { x = 100; y = 0; }
if ( i == 1) { x = 190; y = 120; }
if ( i == 2) { x = 200; y = 0; }
if ( i == 3) { x = 310; y = 120; }
if ( i == 4) { x = 420; y = 22.5; }
if ( i == 5) { x = 500; y = 22.5; }
if ( i == 6) { x = 530; y = 0; }
if ( i == 7) { x = 635; y = 120; }
if ( i == 8) { x = 640; y = 22.5; }
if ( i == 9) { x = 645; y = 50; }
if ( i == 10) { x = 1000; y = 60; }
if ( i == 11) { x = 420; y = 70; }
if ( i == 12) { x = 310; y = 100; }
if ( i == 13) { x = 310; y = 70; }
if ( i == 14) { x = 310; y = 69.5; }
*/
#define SSAB_CURVE_2D( x, y, z, table) ssab_curve_2d( x, y, z, (float *)&table,\
sizeof(table[0])/sizeof(table[0][0])-1,\
sizeof(table)/sizeof(table[0])-1)
#define SSAB_CURVE( x, y, table) ssab_curve( x, y, (float *)&table,\
sizeof(table)/sizeof(table[0]))
sts = SSAB_CURVE_2D( x, y, &z , temp_tjl_table);
printf( "x: %7.2f y: %7.2f z: %7.2f\n", x, y, z);
sts = SSAB_CURVE( x, &z, temp_step1_table);
printf( "x: %7.2f z: %7.2f\n", x, z);
}
}
#endif
Volume SsabOx $ClassVolume 0.0.250.5
Body SysBody 01-JAN-1970 01:00:00.00
Attr NextOix = "_X147"
Attr NextCix = "_X25"
Attr NextOix = "_X148"
Attr NextCix = "_X27"
Attr NextTix[0] = "_X4"
EndBody
Object Type $TypeHier 138 30-DEC-2005 14:28:03.99
......@@ -5089,30 +5089,30 @@ Volume SsabOx $ClassVolume 0.0.250.5
EndObject
Object Template Co_CO4uP 2152955904 01-JAN-1970 01:00:00.00
Body RtBody 30-DEC-2005 11:44:27.44
Attr ConvMask = 65535
Attr COAbsFlag[0] = 1
Attr COAbsFlag[1] = 1
Attr COAbsFlag[2] = 1
Attr COAbsFlag[3] = 1
Attr NoOfBits[0] = 24
Attr NoOfBits[1] = 24
Attr NoOfBits[2] = 24
Attr NoOfBits[3] = 24
Attr MulCount[0] = 4
Attr MulCount[1] = 4
Attr MulCount[2] = 4
Attr MulCount[3] = 4
Attr CopWrRough[0] = 1
Attr CopWrRough[1] = 1
Attr CopWrRough[2] = 1
Attr CopWrRough[3] = 1
Attr CopWrFine[0] = 1
Attr CopWrFine[1] = 1
Attr CopWrFine[2] = 1
Attr CopWrFine[3] = 1
Attr MaxNoOfCounters = 4
Attr Process = 1
Attr DataSheet = "$pwr_lang/dsh/ssab_co_co4up.pdf"
Attr ConvMask = 65535
Attr MaxNoOfCounters = 4
Attr COAbsFlag[0] = 1
Attr COAbsFlag[1] = 1
Attr COAbsFlag[2] = 1
Attr COAbsFlag[3] = 1
Attr NoOfBits[0] = 24
Attr NoOfBits[1] = 24
Attr NoOfBits[2] = 24
Attr NoOfBits[3] = 24
Attr MulCount[0] = 4
Attr MulCount[1] = 4
Attr MulCount[2] = 4
Attr MulCount[3] = 4
Attr CopWrRough[0] = 1
Attr CopWrRough[1] = 1
Attr CopWrRough[2] = 1
Attr CopWrRough[3] = 1
Attr CopWrFine[0] = 1
Attr CopWrFine[1] = 1
Attr CopWrFine[2] = 1
Attr CopWrFine[3] = 1
Attr Process = 1
Attr DataSheet = "$pwr_lang/dsh/ssab_co_co4up.pdf"
EndBody
Body DevBody 01-JAN-1970 01:00:00.00
EndBody
......@@ -5352,30 +5352,30 @@ Volume SsabOx $ClassVolume 0.0.250.5
EndObject
Object Template Co_PI24BO 2153218048 01-JAN-1970 01:00:00.00
Body RtBody 30-DEC-2005 11:45:40.31
Attr ConvMask = 65535
Attr COAbsFlag[0] = 1
Attr COAbsFlag[1] = 1
Attr COAbsFlag[2] = 1
Attr COAbsFlag[3] = 1
Attr NoOfBits[0] = 24
Attr NoOfBits[1] = 24
Attr NoOfBits[2] = 24
Attr NoOfBits[3] = 24
Attr MulCount[0] = 4
Attr MulCount[1] = 4
Attr MulCount[2] = 4
Attr MulCount[3] = 4
Attr CopWrRough[0] = 1
Attr CopWrRough[1] = 1
Attr CopWrRough[2] = 1
Attr CopWrRough[3] = 1
Attr CopWrFine[0] = 1
Attr CopWrFine[1] = 1
Attr CopWrFine[2] = 1
Attr CopWrFine[3] = 1
Attr MaxNoOfCounters = 1
Attr Process = 1
Attr DataSheet = "$pwr_lang/dsh/ssab_co_pi24bo.pdf"
Attr ConvMask = 65535
Attr MaxNoOfCounters = 1
Attr COAbsFlag[0] = 1
Attr COAbsFlag[1] = 1
Attr COAbsFlag[2] = 1
Attr COAbsFlag[3] = 1
Attr NoOfBits[0] = 24
Attr NoOfBits[1] = 24
Attr NoOfBits[2] = 24
Attr NoOfBits[3] = 24
Attr MulCount[0] = 4
Attr MulCount[1] = 4
Attr MulCount[2] = 4
Attr MulCount[3] = 4
Attr CopWrRough[0] = 1
Attr CopWrRough[1] = 1
Attr CopWrRough[2] = 1
Attr CopWrRough[3] = 1
Attr CopWrFine[0] = 1
Attr CopWrFine[1] = 1
Attr CopWrFine[2] = 1
Attr CopWrFine[3] = 1
Attr Process = 1
Attr DataSheet = "$pwr_lang/dsh/ssab_co_pi24bo.pdf"
EndBody
Body DevBody 01-JAN-1970 01:00:00.00
EndBody
......@@ -5761,5 +5761,849 @@ Volume SsabOx $ClassVolume 0.0.250.5
EndBody
EndObject
EndObject
Object PID_1uP $ClassDef 25 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr Method = 5
Attr Flags = 2128
EndBody
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
EndObject
Object PidXCon $Intern 11 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "PidXCon"
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
Object SetVal $Attribute 12 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "SetVal"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object BiasD $Attribute 13 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "BiasD"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object ForcVal $Attribute 14 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "ForcVal"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object Force $Attribute 15 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "Force"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
Object IntOff $Attribute 16 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "IntOff"
Attr Flags = 2048
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"
EndBody
EndObject
Object PidAlg $Attribute 18 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "PidAlg"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
Object Inverse $Attribute 19 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "Inverse"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
Object PidGain $Attribute 20 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "PidGain"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object IntTime $Attribute 21 12-JAN-2006 07:29:56.01
Body SysBody 12-JAN-2006 07:29:56.01
Attr PgmName = "IntTime"
Attr Flags = 2048
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object DerTime $Attribute 22 12-JAN-2006 07:29:56.01
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
EndObject
Object PidX $ClassDef 26 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
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"
EndBody
EndObject
Object ControlDiff $Intern 13 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ControlDiff"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object XScanTime $Intern 14 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "XScanTime"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object EndMax $Intern 15 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "EndMax"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
Object EndMin $Intern 16 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "EndMin"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
Object Init $Intern 17 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Init"
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
Object PidAlg $Intern 18 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "PidAlg"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
Object Inverse $Intern 19 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Inverse"
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
Object PidGain $Intern 20 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "PidGain"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object IntTime $Intern 21 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "IntTime"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object DerTime $Intern 22 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "DerTime"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object DerGain $Intern 23 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "DerGain"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object MinOut $Intern 24 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "MinOut"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object MaxOut $Intern 25 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "MaxOut"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object EndHys $Intern 26 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "EndHys"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object BiasGain $Intern 27 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "BiasGain"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object UseDynBias $Intern 28 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "UseDynBias"
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
Object ProcMax $Intern 29 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ProcMax"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object ProcMin $Intern 30 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ProcMin"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object ProcValueUnit $Intern 31 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ProcValueUnit"
Attr TypeRef = "pwrs:Type-$String16"
EndBody
EndObject
Object ProcFiltTime $Intern 32 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ProcFiltTime"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object ProcRawMax $Intern 33 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ProcRawMax"
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
Object ProcRawMin $Intern 34 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ProcRawMin"
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
Object BiasMax $Intern 35 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "BiasMax"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object BiasMin $Intern 36 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "BiasMin"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object BiasValueUnit $Intern 37 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "BiasValueUnit"
Attr TypeRef = "pwrs:Type-$String16"
EndBody
EndObject
Object BiasFiltTime $Intern 38 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "BiasFiltTime"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object BiasRawMax $Intern 39 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "BiasRawMax"
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
Object BiasRawMin $Intern 40 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "BiasRawMin"
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
Object UseAo $Intern 41 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "UseAo"
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
Object AoMax $Intern 42 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "AoMax"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object AoMin $Intern 43 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "AoMin"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object AoValueUnit $Intern 44 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "AoValueUnit"
Attr TypeRef = "pwrs:Type-$String16"
EndBody
EndObject
Object AoRawMax $Intern 45 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "AoRawMax"
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
Object AoRawMin $Intern 46 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "AoRawMin"
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
Object UsePos3p $Intern 47 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "UsePos3p"
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
Object PosMax $Intern 48 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "PosMax"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object PosMin $Intern 49 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "PosMin"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object PosValueUnit $Intern 50 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "PosValueUnit"
Attr TypeRef = "pwrs:Type-$String16"
EndBody
EndObject
Object PosFiltTime $Intern 51 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "PosFiltTime"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object PosRawMax $Intern 52 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "PosRawMax"
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
Object PosRawMin $Intern 53 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "PosRawMin"
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
Object ErrSta $Intern 54 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ErrSta"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object ErrSto $Intern 55 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "ErrSto"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object Pos3pGain $Intern 56 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Pos3pGain"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object UseInc3p $Intern 57 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "UseInc3p"
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
Object Inc3pGain $Intern 58 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "Inc3pGain"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object MinTim $Intern 59 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "MinTim"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object MaxTim $Intern 60 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "MaxTim"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object MaxInteg $Intern 61 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr PgmName = "MaxInteg"
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
EndObject
Object DevBody $ObjBodyDef 2 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr NextAix = "_X2"
EndBody
Object PlcNode $Buffer 1 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr Flags = 2048
Attr Class = "pwrs:Class-$PlcNode"
EndBody
EndObject
EndObject
Object GraphPlcNode $GraphPlcNode 148 12-JAN-2006 07:30:19.53
Body SysBody 12-JAN-2006 07:30:19.53
Attr object_type = 11
Attr parameters[0] = 5
Attr parameters[1] = 0
Attr parameters[2] = 3
Attr parameters[3] = 0
Attr graphmethod = 2
Attr graphindex = 0
Attr default_mask[0] = 1
Attr default_mask[1] = 2
Attr segname_annotation = 3
Attr compmethod = 4
Attr compindex = 0
Attr tracemethod = 0
Attr traceindex = 0
Attr connectmethod = 0
Attr executeordermethod = 2
Attr objname = "PidX"
Attr graphname = "PidX"
EndBody
EndObject
EndObject
EndObject
EndVolume
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