Commit da4cb706 authored by claes's avatar claes

Division in modules

parent d13ba328
#
# Script to export all classgraphs to java
#
#
#
function int process( string graph)
open 'graph'
printf( "Exporting %s...\n", graph);
export java
endfunction
main()
process( "pwr_c_abb_acs800_1");
process( "pwr_c_abb_acs800fanaggr");
process( "pwr_c_abb_acs800motoraggr");
process( "pwr_c_abb_acs800pumpaggr");
endmain
#! /bin/bash
#
# Proview $Id: upgrade_cnvdmp.sh,v 1.2 2005-09-01 14:57:49 claes Exp $
# Proview $Id: upgrade_cnvdmp.sh,v 1.3 2005-12-30 15:47:43 claes Exp $
# Copyright (C) 2005 SSAB Oxelsund AB.
#
# This program is free software; you can redistribute it and/or
......@@ -32,6 +32,14 @@ s/Attr parent_node_did = /Attr poid = /
s/Attr dest_node_did = /Attr dest_oid = /
s/Attr source_node_did = /Attr source_oid = /
s/Attr reset_objdid = /Attr reset_oid = /
s/pwrb:Ai_AI32uP/SsabOx:Ai_AI32uP/
s/pwrb:Ai_HVAI32/SsabOx:Ai_HVAI32/
s/pwrb:Ao_AO8uP/SsabOx:Ao_AO8uP/
s/pwrb:Ao_HVAO4/SsabOx:Ao_HVAO4/
s/pwrb:Co_CO4uP/SsabOx:Co_CO4uP/
s/pwrb:Co_PI24BO/SsabOx:Co_PI24BO/
s/pwrb:Di_DIX2/SsabOx:Di_DIX2/
s/pwrb:Do_HVDO32/SsabOx:Do_HVDO32/
/PlcProgram$/{
N
N
......@@ -62,3 +70,4 @@ s/Attr classid = /Attr cid =/
}
' $1 > $2
#!/bin/bash
#
# Edit a base wb_load-file with classeditor
#
export pwr_exe=$pwr_eexe
export pwr_load=$pwr_eload
wb -c $1
\ No newline at end of file
#include "rt_io_base.h"
pwr_dImport pwr_BindIoMethods(Node);
pwr_dImport pwr_BindIoMethods(Pb_Profiboard);
pwr_dImport pwr_BindIoMethods(Pb_DP_Slave);
pwr_dImport pwr_BindIoMethods(Pb_Module);
pwr_dImport pwr_BindIoMethods(Pb_Di);
pwr_dImport pwr_BindIoMethods(Pb_Do);
pwr_dImport pwr_BindIoMethods(Pb_Ai);
pwr_dImport pwr_BindIoMethods(Pb_Ao);
pwr_dImport pwr_BindIoMethods(Pb_Ii);
pwr_dImport pwr_BindIoMethods(Pb_Io);
pwr_BindIoClasses(Base) = {
pwr_BindIoClass(Node),
pwr_BindIoClass(Pb_Profiboard),
pwr_BindIoClass(Pb_DP_Slave),
pwr_BindIoClass(Pb_Module),
pwr_BindIoClass(Pb_Di),
pwr_BindIoClass(Pb_Do),
pwr_BindIoClass(Pb_Ai),
pwr_BindIoClass(Pb_Ao),
pwr_BindIoClass(Pb_Ii),
pwr_BindIoClass(Pb_Io),
pwr_NullClass
};
Node
Pb_Profiboard
Pb_DP_Slave
Pb_Module
Pb_Di
Pb_Do
Pb_Ai
Pb_Ao
Pb_Ii
Pb_Io
/*
* Proview $Id: rt_io_methods.h,v 1.1 2005-12-30 15:45:31 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef rt_io_methods_h
#define rt_io_methods_h
/* rt_io_methods.h -- includefile for io methods. */
#ifndef pwr_h
#include "pwr.h"
#endif
typedef struct {
pwr_tObjName MethodName;
pwr_tStatus (*Method)();
} pwr_sMethodBinding;
typedef struct {
pwr_tObjName ClassName;
pwr_sMethodBinding (*Methods)[];
} pwr_sClassBinding;
/* Base methods */
#if defined (__DECC) || defined (OS_LYNX) || defined (OS_LINUX)
# define pwr_BindIoMethods(Class) pwr_sMethodBinding pwr_g ## Class ## _IoMethods[]
# define pwr_BindIoClasses(Type) pwr_sClassBinding pwr_g ## Type ## _IoClassMethods[]
# define pwr_BindIoClass(Class) {#Class, (void *)pwr_g ## Class ## _IoMethods}
# define pwr_BindIoMethod(Method) {#Method, (pwr_tStatus (*)())Method}
#else
# define pwr_BindIoMethods(Class) pwr_sMethodBinding pwr_g/**/Class/**/_IoMethods[]
# define pwr_BindIoClasses(Type) pwr_sClassBinding pwr_g/**/Type/**/_IoClassMethods[]
# define pwr_BindIoClass(Class) {"Class", pwr_g/**/Class/**/_IoMethods}
# define pwr_BindIoMethod(Method) {"Method", (pwr_tStatus (*)())Method}
#endif
/* User methods */
#if defined (__DECC) || defined (OS_LYNX) || defined(OS_LINUX)
#define pwr_BindIoUserMethods(Class) pwr_sMethodBinding pwr_g ## Class ## _IoUserMethods[]
#define pwr_BindIoUserClasses(Type) pwr_sClassBinding pwr_g ## Type ## _IoUserClassMethods[]
#define pwr_BindIoUserClass(Class) {#Class, (void *)pwr_g ## Class ## _IoUserMethods}
#define pwr_BindIoUserMethod(Method) {#Method, (pwr_tStatus (*)())Method}
#else
#define pwr_BindIoUserMethods(Class) pwr_sMethodBinding pwr_g/**/Class/**/_IoUserMethods[]
#define pwr_BindIoUserClasses(Type) pwr_sClassBinding pwr_g/**/Type/**/_IoUserClassMethods[]
#define pwr_BindIoUserClass(Class) {"Class", pwr_g/**/Class/**/_IoUserMethods}
#define pwr_BindIoUserMethod(Method) {"Method", (pwr_tStatus (*)())Method}
#endif
#define pwr_NullMethod {"", NULL}
#define pwr_NullClass {"", NULL}
#endif
/*
* Proview $Id: rt_io_util.c,v 1.1 2005-12-30 15:45:31 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 <stdlib.h>
#include "pwr.h"
#include "pwr_class.h"
#include "rt_gdh.h"
#include "co_cdh.h"
#include "rt_gdh_msg.h"
#include "rt_io_msg.h"
#include "rt_io_base.h"
#include "rt_io_util.h"
#define IO_CLASSES_SIZE 200
/*----------------------------------------------------------------------------*\
Find classes belonging to an specific IO-type.
\*----------------------------------------------------------------------------*/
pwr_tStatus io_GetIoTypeClasses(
io_eType type,
pwr_tClassId **classes,
int *size
)
{
pwr_tStatus sts;
pwr_sClassDef cdef;
pwr_tOid oid;
int add_class;
pwr_sAttrRef aref;
*size = 0;
*classes = calloc( IO_CLASSES_SIZE, sizeof(pwr_tCid));
for ( sts = gdh_GetClassList( pwr_eClass_ClassDef, &oid);
ODD(sts);
sts = gdh_GetNextObject( oid, &oid)) {
aref = cdh_ObjidToAref( oid);
sts = gdh_GetObjectInfoAttrref( &aref, &cdef, sizeof(cdef));
if ( EVEN(sts)) return sts;
add_class = 0;
switch ( type) {
case io_eType_Agent:
if ( cdef.Flags.b.IOAgent)
add_class = 1;
break;
case io_eType_Rack:
if ( cdef.Flags.b.IORack)
add_class = 1;
break;
case io_eType_Card:
if ( cdef.Flags.b.IOCard)
add_class = 1;
break;
default:
return IO__NOMETHOD;
}
if ( add_class) {
if ( *size >= IO_CLASSES_SIZE)
return IO__CLASSEXCEED;
(*classes)[ *size] = cdh_ClassObjidToId( oid);
(*size)++;
}
}
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Check if class is an IO-type.
\*----------------------------------------------------------------------------*/
int io_CheckClassIoType(
io_eType type,
pwr_tCid cid
)
{
pwr_tStatus sts;
pwr_sClassDef cdef;
pwr_sAttrRef aref;
aref = cdh_ObjidToAref( cdh_ClassIdToObjid( cid));
sts = gdh_GetObjectInfoAttrref( &aref, &cdef, sizeof(cdef));
if ( EVEN(sts)) return 0;
switch ( type) {
case io_eType_Agent:
if ( cdef.Flags.b.IOAgent)
return 1;
break;
case io_eType_Rack:
if ( cdef.Flags.b.IORack)
return 1;
break;
case io_eType_Card:
if ( cdef.Flags.b.IOCard)
return 1;
break;
default: ;
}
return 0;
}
/*
* Proview $Id: rt_io_util.h,v 1.1 2005-12-30 15:45:31 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef rt_io_util_h
#define rt_io_util_h
/* rt_io_util.h -- includefile for io util. */
#ifndef pwr_h
#include "pwr.h"
#endif
#ifndef pwr_class_h
#include "pwr_class.h"
#endif
pwr_tStatus io_GetIoTypeClasses(
io_eType type,
pwr_tClassId **classes,
int *size
);
int io_CheckClassIoType(
io_eType type,
pwr_tCid cid
);
#endif
......@@ -9,19 +9,22 @@ ifndef variables_mk
variables_mk := 1
release_root := $(pwre_broot)/$(os_name)/$(hw_name)
exp_root := $(release_root)/exp
exe_dir := $(exp_root)/exe
lib_dir := $(exp_root)/lib
obj_dir := $(exp_root)/obj
cnf_dir := $(exp_root)/cnf
db_dir := $(exp_root)/db
inc_dir := $(exp_root)/inc
lis_dir := $(exp_root)/lis
kit_dir := $(exp_root)/kit
src_dir := $(exp_root)/src
doc_dir := $(exp_root)/doc
load_dir := $(exp_root)/load
module_root := $(release_root)/$(pwre_bmodule)
exe_dir := $(module_root)/exe
lib_dir := $(module_root)/lib
obj_dir := $(module_root)/obj
cnf_dir := $(module_root)/cnf
db_dir := $(module_root)/db
inc_dir := $(module_root)/inc
lis_dir := $(module_root)/lis
kit_dir := $(module_root)/kit
src_dir := $(module_root)/src
load_dir := $(module_root)/load
doc_dir := $(release_root)/exp/doc
elib_dir := $(release_root)/exp/lib
einc_dir := $(release_root)/exp/inc
bld_dir := $(release_root)/bld/$(type_name)/$(comp_name)
tmp_dir := $(release_root)/tmp
......@@ -85,7 +88,7 @@ wb_msg_objs := $(obj_dir)/pwr_msg_wb.o $(obj_dir)/pwr_msg_ge.o $(obj_dir)/pwr_m
log_done =
csetos := -DOS_LINUX=1 -DOS=linux -DHW_X86=1 -DHW=x86
cinc := -I$(inc_dir) -I$(hw_source) -I$(os_source) -I$(co_source) -I$(dbinc) -I/usr/X11R6/include -I$(jdk)/include -I$(jdk)/include/linux
cinc := -I$(inc_dir) -I$(einc_dir) -I$(hw_source) -I$(os_source) -I$(co_source) -I$(dbinc) -I/usr/X11R6/include -I$(jdk)/include -I$(jdk)/include/linux
rm := rm
cp := cp
......@@ -110,6 +113,7 @@ ifeq ($(pwre_btype),rls)
cflags := -c -O3 -D_GNU_SOURCE -DPWR_NDEBUG -D_REENTRANT
cxxflags := $(cflags)
linkflags := -O3 -L/usr/local/lib -L$(lib_dir) -lm -lrt
elinkflags := -O3 -L/usr/local/lib -L$(elib_dir) -L$(libdir) -lm -lrt
clis = /lis=$(list)
dolist = /lis=$(list)
domap = -Xlinker -Map -Xlinker $(map)
......@@ -118,6 +122,7 @@ else
cxxflags := $(cflags) -Wno-deprecated
mmflags := -Wno-deprecated
linkflags := -g -L/usr/local/lib -L$(lib_dir) -lrt
elinkflags := -g -L/usr/local/lib -L$(elib_dir) -L$(lib_dir) -lrt
dolist = /lis=$(list)
clis :=
domap = -Xlinker -Map -Xlinker $(map)
......
......@@ -10,18 +10,18 @@ lib_generic_mk := 1
ifndef variables_mk
-include $(pwre_sroot)/tools/bld/src/$(os_name)/$(hw_name)/variables.mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/variables.mk
endif
ifndef variables_mk
include $(pwre_sroot)/tools/bld/src/$(os_name)/variables.mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/variables.mk
endif
ifndef rules_mk
-include $(pwre_sroot)/tools/bld/src/$(os_name)/$(hw_name)/rules.mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/rules.mk
endif
ifndef rules_mk
include $(pwre_sroot)/tools/bld/src/$(os_name)/rules.mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/rules.mk
endif
source_dirs = $(hw_source) $(os_source) $(co_source)
......@@ -39,6 +39,7 @@ vpath %.x $(hw_source):$(os_source):$(co_source)
vpath %.pdr $(hw_source):$(os_source):$(co_source)
vpath %.java $(hw_source):$(os_source):$(co_source)
vpath %.pwsg $(hw_source):$(os_source):$(co_source)
vpath %.meth $(hw_source):$(os_source):$(co_source)
source_dirs = $(hw_source) $(os_source) $(co_source)
......@@ -105,6 +106,15 @@ pwsg_sources := $(sort \
) \
)
meth_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.meth) \
), $(notdir $(file)) \
) \
)
xdr_includes := $(addprefix $(inc_dir)/,$(patsubst %.x, %.h, $(xdr_sources)))
xdr_objects := $(patsubst %.x, %_xdr.o, $(xdr_sources))
......@@ -116,6 +126,7 @@ export_includes := $(addprefix $(inc_dir)/,$(h_includes) $(hpp_includes))
export_includes += $(xdr_includes) $(pdr_includes)
export_pwsg := $(addprefix $(exe_dir)/,$(pwsg_sources))
export_meth := $(addprefix $(inc_dir)/,$(meth_sources))
clean_h_includes := $(patsubst %.h,clean_%.h, $(h_includes))
clean_hpp_includes := $(patsubst %.hpp,clean_%.hpp, $(hpp_includes))
......@@ -144,7 +155,7 @@ all : init copy lib exe
init : dirs
copy : $(export_includes) $(l_copy) $(export_pwsg)
copy : $(export_includes) $(l_copy) $(export_pwsg) $(export_meth)
lib : $(export_lib)
......
......@@ -9,22 +9,26 @@ ifndef mmi_generic_mk
mmi_generic_mk := 1
ifndef variables_mk
-include $(pwre_sroot)/tools/bld/src/$(os_name)/$(hw_name)/variables.mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/variables.mk
endif
ifndef variables_mk
include $(pwre_sroot)/tools/bld/src/$(os_name)/variables.mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/variables.mk
endif
ifndef rules_mk
-include $(pwre_sroot)/tools/bld/src/$(os_name)/$(hw_name)/rules.mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/rules.mk
endif
ifndef rules_mk
include $(pwre_sroot)/tools/bld/src/$(os_name)/rules.mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/rules.mk
endif
vpath %.uil $(hw_source):$(os_source):$(co_source)
vpath %.pwg $(hw_source):$(os_source):$(co_source)
vpath %.pwsg $(hw_source):$(os_source):$(co_source)
source_dirs := $(hw_source) $(os_source) $(co_source)
......@@ -37,13 +41,35 @@ uil_sources := $(sort \
) \
)
pwg_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/pwr_c_*.pwg) \
), $(notdir $(file)) \
) \
)
pwsg_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/$(comp_name)*.pwsg) \
), $(notdir $(file)) \
) \
)
export_uid := $(addprefix $(exe_dir)/, $(patsubst %.uil, %.uid, $(uil_sources)))
export_pwg := $(addprefix $(exe_dir)/, $(pwg_sources))
export_pwsg := $(addprefix $(exe_dir)/, $(pwsg_sources))
$(exe_dir)/%.uid : %.uil
@ $(log_uil_uid)
@ export -n LANG; uil -o $(target) $(source)
clean_uid := $(patsubst %.uil,clean_%.uid,$(uil_sources))
clean_pwg := $(patsubst %.pwg,clean_%.pwg,$(pwg_sources))
clean_pwsg := $(patsubst %.pwsg,clean_%.pwsg,$(pwsg_sources))
.PHONY : all init copy lib exe clean realclean\
dirs clean_bld clean_dirs $(clean_uid)
......@@ -52,13 +78,13 @@ all : init copy
init : dirs
copy : $(export_uid)
copy : $(export_uid) $(export_pwg) $(export_pwsg)
lib :
exe :
clean : $(clean_uid)
clean : $(clean_uid) $(clean_pwg) $(clean_pwsg)
realclean : clean
......@@ -68,5 +94,13 @@ $(clean_uid) : clean_%.uid : %.uil
@ echo "Removing uid"
@ $(rm) $(rmflags) $(exe_dir)/$*.uid
$(clean_pwg) : clean_%.pwg : %.pwg
@ echo "Removing pwg"
@ $(rm) $(rmflags) $(exe_dir)/$*.pwg
$(clean_pwsg) : clean_%.pwsg : %.pwsg
@ echo "Removing pwsg"
@ $(rm) $(rmflags) $(exe_dir)/$*.pwsg
endif
......@@ -228,4 +228,8 @@ $(doc_dir)/%.html : ../../%.html
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(inc_dir)/%.meth : %.meth
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
endif
# wbl_generic.mk -- generic make file for building wbl components
#
# PROVIEW/R
# Copyright (C) 1996 by Comator Process AB.
#
# <Description>
#
ifndef wbl_generic_mk
wbl_generic_mk := 1
ifndef variables_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/variables.mk
endif
ifndef variables_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/variables.mk
endif
ifndef rules_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/rules.mk
endif
ifndef rules_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/rules.mk
endif
vpath %.wb_load $(hw_source):$(os_source):$(co_source)
source_dirs := $(hw_source) $(os_source) $(co_source)
wblsources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.wb_load) \
), $(notdir $(file)) \
) \
)
flwsources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.flw) \
), $(notdir $(file)) \
) \
)
wbl_sources := $(filter %.wb_load,$(wblsources))
flw_sources := $(filter %.flw,$(flwsources))
export_wbl := $(addprefix $(load_dir)/, $(patsubst %.wb_load, %.dbs, $(wbl_sources)))
export_flw := $(patsubst %.flw,$(load_dir)/%.flw,$(flw_sources))
export_wbl_dbs := $(patsubst %.wb_load,$(load_dir)/%.dbs,$(wbl_sources))
export_wbl_h := $(patsubst %.wb_load,$(inc_dir)/pwr_%classes.h,$(wbl_sources))
export_wbl_hpp := $(patsubst %.wb_load,$(inc_dir)/pwr_%classes.hpp,$(wbl_sources))
export_wbl_xtthelp_en_us := $(patsubst %.wb_load,$(exe_dir)/en_us/%_xtthelp.dat,$(wbl_sources))
export_wbl_xtthelp_sv_se := $(patsubst %.wb_load,$(exe_dir)/sv_se/%_xtthelp.dat,$(wbl_sources))
export_wbl_html_en_us := $(patsubst %.wb_load,$(doc_dir)/en_us/orm/%_allclasses.html,$(wbl_sources))
export_wbl_html_sv_se := $(patsubst %.wb_load,$(doc_dir)/sv_se/orm/%_allclasses.html,$(wbl_sources))
export_wbl_ps_en_us := $(patsubst %.wb_load,$(doc_dir)/en_us/%.ps,$(wbl_sources))
export_wbl_ps_sv_se := $(patsubst %.wb_load,$(doc_dir)/sv_se/%.ps,$(wbl_sources))
clean_dbs := $(patsubst %.wb_load,clean_%.dbs,$(wbl_sources))
clean_h := $(patsubst %.wb_load,clean_%.h,$(wbl_sources))
clean_hpp := $(patsubst %.wb_load,clean_%.hpp,$(wbl_sources))
clean_xtthelp_sv_se := $(patsubst %.wb_load,clean_%_sv_se.xtthelp,$(wbl_sources))
clean_xtthelp_en_us := $(patsubst %.wb_load,clean_%_en_us.xtthelp,$(wbl_sources))
clean_html_sv_se := $(patsubst %.wb_load,clean_%_sv_se.html,$(wbl_sources))
clean_html_en_us := $(patsubst %.wb_load,clean_%_en_us.html,$(wbl_sources))
clean_ps_sv_se := $(patsubst %.wb_load,clean_%_sv_se.ps,$(wbl_sources))
clean_ps_en_us := $(patsubst %.wb_load,clean_%_en_us.ps,$(wbl_sources))
.SUFFIXES:
$(load_dir)/%.dbs : ../../%.wb_load
@ echo "Generating loadfile for $(source)"
@ export pwr_load=$(pwr_eload);\
wb_cmd -q -i create snapshot /file=\"$(source)\"/out=\"$(target)\"
@ chmod a+w $(target)
$(inc_dir)/pwr_%classes.h : ../../%.wb_load
@ echo "Generating struct files for $(source) classes..."
@ co_convert -s -d $(inc_dir) "$(source)"
$(inc_dir)/pwr_%classes.hpp : ../../%.wb_load
@ echo "Generating hpp files for $(source) classes..."
@ co_convert -po -d $(inc_dir) "$(source)"
$(doc_dir)/en_us/orm/%_allclasses.html : ../../%.wb_load
@ echo "Generating html files for $(source) classes en_us..."
@ co_convert -w -d $(doc_dir)/en_us/orm -g $(pwre_sroot)/wbl/mcomp/src/cnv_setup.dat "$(source)"
@ co_convert -c -d $(doc_dir)/en_us/orm $(inc_dir)/pwr_$(source)classes.h
@ co_convert -c -d $(doc_dir)/en_us/orm $(inc_dir)/pwr_$(source)classes.hpp
@ co_convert -k -d $(doc_dir)/en_us/orm -l en_us
$(doc_dir)/sv_se/orm/%_allclasses.html : ../../%.wb_load
@ echo "Generating html files for $(source) classes sv_se..."
@ co_convert -w -l sv_se -d $(doc_dir)/sv_se/orm -g $(pwre_sroot)/wbl/mcomp/src/cnv_setup.dat "$(source)"
@ co_convert -c -d $(doc_dir)/sv_se/orm $(inc_dir)/pwr_$(source)classes.h
@ co_convert -c -d $(doc_dir)/sv_se/orm $(inc_dir)/pwr_$(source)classes.hpp
@ co_convert -k -d $(doc_dir)/sv_se/orm -l sv_se
$(doc_dir)/en_us/%.ps : ../../%.wb_load
@ echo "Generating postscript file for $(source) classes en_us..."
@ co_convert -q -l en_us -d $(doc_dir)/en_us "$(source)"
$(doc_dir)/sv_se/%.ps : ../../%.wb_load
@ echo "Generating postscript file for $(source) classes sv_se..."
@ co_convert -q -l sv_se -d $(doc_dir)/sv_se "$(source)"
$(exe_dir)/en_us/%_xtthelp.dat : ../../%.wb_load
@ echo "Generating xtt help files for $(source) classes en_us"
@ co_convert -x -d $(exe_dir)/en_us "$(source)"
$(exe_dir)/sv_se/%_xtthelp.dat : ../../%.wb_load
@ echo "Generating xtt help files for $(source) classes sv_se"
@ co_convert -x -l sv_se -d $(exe_dir)/sv_se "$(source)"
$(exe_dir)/%.pwg : ../../%.pwg
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(exe_dir)/%.pwsg : ../../%.pwsg
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(load_dir)/%.flw : ../../%.flw
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
.PHONY : all init copy lib exe clean realclean\
$(clean_wbl)
all : init copy exe
init :
lib : $(export_wbl_dbs)
copy : $(export_wbl_h) \
$(export_wbl_hpp) \
$(export_pwg) \
$(export_pwsg) \
$(export_flw)
exe: $(export_wbl_xtthelp_en_us) \
$(export_wbl_xtthelp_sv_se) \
$(export_wbl_html_en_us) \
$(export_wbl_html_sv_se) \
$(export_wbl_ps_en_us) \
$(export_wbl_ps_sv_se)
clean : \
$(clean_xtthelp_sv_se) $(clean_xtthelp_en_us) \
$(clean_html_sv_se) $(clean_html_en_us) \
$(clean_ps_sv_se) $(clean_ps_en_us)
realclean : clean \
$(clean_dbs) \
$(clean_h) \
$(clean_hpp) \
$(clean_dbs) : clean_%.dbs : $(load_dir)/%.dbs
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
$(clean_h) : clean_%.h : $(inc_dir)/pwr_%classes.h
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
$(clean_hpp) : clean_%.hpp : $(inc_dir)/pwr_%classes.hpp
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
$(clean_ps_sv_se) : clean_%_sv_se.ps : $(doc_dir)/sv_se/%.ps
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
$(clean_ps_en_us) : clean_%_en_us.ps : $(doc_dir)/en_us/%.ps
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
$(clean_html_sv_se) : clean_%_sv_se.html : $(doc_dir)/sv_se/orm/%_allclasses.html
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
$(clean_html_en_us) : clean_%_en_us.html : $(doc_dir)/en_us/orm/%_allclasses.html
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
$(clean_xtthelp_sv_se) : clean_%_sv_se.xtthelp : $(exe_dir)/sv_se/%_xtthelp.dat
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
$(clean_xtthelp_en_us) : clean_%_en_us.xtthelp : $(exe_dir)/en_us/%_xtthelp.dat
@ echo "rm $(source)"
@ if [ -e $(source) ]; then \
$(rm) $(rmflags) $(source); \
fi
endif
This diff is collapsed.
#!/bin/bash
#
# pwre.source
#
......@@ -7,25 +8,51 @@
# is handled by pwre.perl
#
#
# Don't call pwre.perl if it is the init verb
#
env="$2"
local cmd
cmd="help"
if [ -z $1 ] || [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
$pwre_bin/pwre.pl $@
return
fi
cmd="init"
if [ $1 = $cmd ]; then
echo "init..."
if [ "$env" = "" ]; then
echo "++ init what?"
else
export pwre_module=kernel
export pwre_bmodule=kernel
if $pwre_bin/pwre.pl _exists $2; then
set_env `$pwre_bin/pwre.pl _print $2`
else
echo "++ Environment $2 doesn't exist"
fi
source $pwre_bin/pwre_function
fi
return
fi
if [ $# -eq 0 ] || echo "init" | grep $pwre_silent -v "^$1"; then
$pwre_bin/pwre.pl $@
elif [ "$env" = "" ]; then
echo "++ init what?"
else
if $pwre_bin/pwre.pl _exists $2; then
set_env `$pwre_bin/pwre.pl _print $2`
else
echo "++ Environment $2 doesn't exist"
fi
cmd="module"
if [ $1 = $cmd ]; then
echo "module..."
if [ -z $2 ]; then
export pwre_module="kernel"
export pwre_bmodule="kernel"
else
export pwre_module=$2
export pwre_bmodule=$2
fi
env=$pwre_env
set_env `$pwre_bin/pwre.pl _print $env`
return
fi
$pwre_bin/pwre.pl $@
#
# Proview build environment setup
#
# Environment variables
#
# $pwre_sroot Module source root, eg. pwr/ssabox
# $pwre_kroot Kernel source root, pwr/src
# $pwre_broot Common build root
# $pwre_module Module name in source tree, eg. 'ssabox'
# $pwre_bmodule Module name in build tree, eg. 'ssabox'
# $pwre_os Operating system, eg. 'os_linux'
# $pwre_hw Hardware, eg. 'hw_x86'
# $pwr_exe Exe directory for module build root, eg. ssabox/exe
# $pwr_load Load directory for module build root
# $pwr_inc Inc directory for module build root
# $pwr_obj Obj directory for module build root
# $pwr_lib Lib directory for module build root
# $pwr_eexe Exe directory for common build root, ex. exp/exe
# $pwr_eload Load directory for common build root
# $pwr_einc Inc directory for common build root
# $pwr_eobj Obj directory for common build root
# $pwr_elib Lib directory for common build root
pwre()
{
if [ "$HOSTTYPE" = "alpha" ]; then
......@@ -20,8 +43,19 @@ pwre()
set_env()
{
if [ "$pwr_eexe" != "" ]; then
export PATH=${PATH%:$pwr_eexe}
export PATH=${PATH%:$pwr_exe}
fi
module=$pwre_module
if [ $module = "kernel" ]; then
module=src
fi
sroot=${pwre_sroot%/*}
export pwre_sroot=$sroot/$module
export pwre_kroot=$sroot/src
export pwre_env="$env"
export pwre_sroot="$1"
export pwre_vmsinc="$2"
export pwre_broot="$3"
export pwre_btype="$4"
......@@ -29,26 +63,38 @@ set_env()
export pwre_hw="hw_$6"
export pwre_target="$pwre_os/$pwre_hw"
export pwre_bin="$pwre_sroot/tools/pwre/src/$pwre_os"
export pwre_bin="$pwre_kroot/tools/pwre/src/$pwre_os"
export pwre_dir_symbols="$pwre_bin/dir_symbols.mk"
export pwr_exe="$pwre_broot/$pwre_os/$pwre_hw/exp/exe"
export pwr_inc="$pwre_broot/$pwre_os/$pwre_hw/exp/inc"
export pwr_load="$pwre_broot/$pwre_os/$pwre_hw/exp/load"
export pwr_lib="$pwre_broot/$pwre_os/$pwre_hw/exp/lib"
export pwr_lis="$pwre_broot/$pwre_os/$pwre_hw/exp/lis"
export pwr_obj="$pwre_broot/$pwre_os/$pwre_hw/exp/obj"
export pwr_exe="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/exe"
export pwr_inc="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/inc"
export pwr_load="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/load"
export pwr_lib="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/lib"
export pwr_lis="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/lis"
export pwr_obj="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/obj"
# Common doc
export pwr_doc="$pwre_broot/$pwre_os/$pwre_hw/exp/doc"
export co_lib="$pwre_sroot/lib/co/src"
export op_lib="$pwre_sroot/lib/op/src"
export rt_lib="$pwre_sroot/lib/rt/src"
export wb_lib="$pwre_sroot/lib/wb/src"
export pwr_eexe="$pwre_broot/$pwre_os/$pwre_hw/exp/exe"
export pwr_einc="$pwre_broot/$pwre_os/$pwre_hw/exp/inc"
export pwr_eload="$pwre_broot/$pwre_os/$pwre_hw/exp/load"
export pwr_elib="$pwre_broot/$pwre_os/$pwre_hw/exp/lib"
export pwr_elis="$pwre_broot/$pwre_os/$pwre_hw/exp/lis"
export pwr_eobj="$pwre_broot/$pwre_os/$pwre_hw/exp/obj"
export pwr_edoc="$pwre_broot/$pwre_os/$pwre_hw/exp/doc"
export pwrp_load="./"
export pwrp_pop="./"
export co_lib="$pwre_kroot/lib/co/src"
export op_lib="$pwre_kroot/lib/op/src"
export rt_lib="$pwre_kroot/lib/rt/src"
export wb_lib="$pwre_kroot/lib/wb/src"
export exe="$pwre_sroot/exe"
export exe="$pwre_kroot/exe"
# PWR alias
alias pwr_root="cd $pwre_sroot"
alias pwr_root="cd $pwre_kroot"
alias pwr_exe="cd $pwr_exe"
alias pwr_inc="cd $pwr_inc"
......@@ -58,21 +104,21 @@ set_env()
alias pwr_obj="cd $pwr_obj"
alias co_lib="cd $pwre_sroot/lib/co/src"
alias op_lib="cd $pwre_sroot/lib/op/src"
alias rt_lib="cd $pwre_sroot/lib/rt/src"
alias wb_lib="cd $pwre_sroot/lib/wb/src"
alias co_lib="cd $pwre_kroot/lib/co/src"
alias op_lib="cd $pwre_kroot/lib/op/src"
alias rt_lib="cd $pwre_kroot/lib/rt/src"
alias wb_lib="cd $pwre_kroot/lib/wb/src"
alias db="cd $pwre_sroot/db"
alias exe="cd $pwre_sroot/exe"
alias exp="cd $pwre_sroot/exp"
alias inc="cd $pwre_sroot/exp/inc/src"
alias lib="cd $pwre_sroot/lib"
alias hlp="cd $pwre_sroot/hlp"
alias mmi="cd $pwre_sroot/mmi"
alias msg="cd $pwre_sroot/msg"
alias tools="cd $pwre_sroot/tools"
alias wbl="cd $pwre_sroot/wbl"
alias db="cd $pwre_kroot/db"
alias exe="cd $pwre_kroot/exe"
alias exp="cd $pwre_kroot/exp"
alias inc="cd $pwre_kroot/exp/inc/src"
alias lib="cd $pwre_kroot/lib"
alias hlp="cd $pwre_kroot/hlp"
alias mmi="cd $pwre_kroot/mmi"
alias msg="cd $pwre_kroot/msg"
alias tools="cd $pwre_kroot/tools"
alias wbl="cd $pwre_kroot/wbl"
alias hw="cd $pwre_target"
......@@ -87,6 +133,7 @@ set_env()
export PWRP_DB=$pwr_my_sqlserver":wb_template_"$pwr_dbversion
# export CLASSPATH=$pwre_broot/$pwre_os/$pwre_hw/bld/jpwr/rt:$pwre_broot/$pwre_os/$pwre_hw/bld/jpwr/jop:$pwre_broot/$pwre_os/$pwre_hw/bld/jpwr/beans
export CLASSPATH=$pwre_broot/$pwre_target/bld
export PATH=$PATH:$pwr_exe:$pwr_eexe
}
pwre_get_variables()
......@@ -98,8 +145,8 @@ pwre_get_variables()
mysql_socket="--socket $socket"
fi
if [ -n $pwre_sroot ]; then
pwr_dbversion=`eval cat $pwre_sroot/exp/inc/src/pwr_version.h | grep "\bpwrv_cWbdbVersionShortStr\b" | awk '{print $3}'`
if [ -n $pwre_kroot ]; then
pwr_dbversion=`eval cat $pwre_kroot/exp/inc/src/pwr_version.h | grep "\bpwrv_cWbdbVersionShortStr\b" | awk '{print $3}'`
if [ -z $pwr_dbversion ]; then
echo "Unable to get pwr db version"
......
#!/bin/bash
#
# Merge build tree for a module to common build tree
#
merge_dir_func()
{
local todir=$1
local fromdir=$2
files=`eval ls $fromdir 2>/dev/null`
if [ ! -z "$files" ]; then
for file in $files; do
if [ ! -d $fromdir/$file ]; then
if [ -e $todir/$file ]; then
if [ $todir/$file -ot $fromdir/$file ]; then
echo "Copy $fromdir/$file"
cp $fromdir/$file $todir
if [ ${file##*.} = "dbs" ]; then
# Change access on dbsfiles
chmod a+w $todir/$file
fi
fi
else
echo "Copy $fromdir/$file"
cp $fromdir/$file $todir
fi
fi
done
fi
}
fromroot=$1
toroot=$2
# Copy exe, load, obj and inc
merge_dir_func $toroot/exe $fromroot/exe
merge_dir_func $toroot/exe/sv_se $fromroot/exe/sv_se
merge_dir_func $toroot/exe/en_us $fromroot/exe/en_us
merge_dir_func $toroot/exe/de_de $fromroot/exe/de_de
merge_dir_func $toroot/inc $fromroot/inc
merge_dir_func $toroot/load $fromroot/load
merge_dir_func $toroot/obj $fromroot/obj
# Merge archives
cd ${toroot%/*}/tmp
libraries=`eval ls $fromroot/lib/* 2>/dev/null`
for lib in $libraries; do
arname=${lib##/*/}
if [ $arname = "libpwr_rt.a" ] || [ $arname = "libpwr_wb.a" ]; then
echo "Merge $lib"
modules=`eval ar -tf $lib`
ar -xf $lib
ar -rc $toroot/lib/$arname $modules
rm $modules
else
echo "Copy $lib"
cp $lib $toroot/lib/
fi
done
#Merge io methods
echo "-- Merge io methods"
co_merge io_base $pwr_einc/rt_io_\*.meth $pwr_elib/libpwr_rt.a
echo "-- Merge wb methods"
co_merge wb_base $pwr_einc/wb_\*.meth $pwr_elib/libpwr_wb.a
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: rt_io_m_ai_ai32up.c,v 1.1 2005-12-30 15:52:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_ai_ai32up.c -- io methods for ssab cards.
OS Linux
*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include "pwr.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "rt_errh.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_ssaboxclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
#include "qbus_io.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
#define IO_MAXCHAN 32
typedef struct {
unsigned int Address;
int Qbus_fp;
int ScanCount[IO_MAXCHAN];
} io_sLocal;
typedef struct {
int Qbus_fp;
} io_sRackLocal;
static pwr_tStatus AiRangeToCoef(
io_sChannel *chanp)
{
pwr_sClass_ChanAi *cop;
char buf[120];
pwr_tStatus sts;
pwr_tFloat32 PolyCoef1;
pwr_tFloat32 PolyCoef0;
cop = chanp->cop;
if ( cop)
{
cop->CalculateNewCoef = 0;
/* Coef for RawValue to SignalValue conversion */
cop->SigValPolyCoef0 = 0;
cop->SigValPolyCoef1 = cop->ChannelSigValRangeHigh / 30000;
/* Coef for SignalValue to ActualValue conversion */
if ( chanp->ChanClass != pwr_cClass_ChanAit && cop->SensorPolyType == 1)
{
if ( cop->SensorSigValRangeHigh != cop->SensorSigValRangeLow)
{
PolyCoef1 = (cop->ActValRangeHigh - cop->ActValRangeLow)/
(cop->SensorSigValRangeHigh - cop->SensorSigValRangeLow);
PolyCoef0 = cop->ActValRangeHigh - cop->SensorSigValRangeHigh *
PolyCoef1;
cop->SensorPolyCoef1 = cop->SigValPolyCoef1 * PolyCoef1;
cop->SensorPolyCoef0 = PolyCoef0 + PolyCoef1*
cop->SigValPolyCoef0;
}
else
{
sts = gdh_ObjidToName( chanp->ChanAref.Objid, buf, sizeof(buf),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
errh_Error( "Invalid SigValueRange in Ai channel %s", buf);
return IO__CHANRANGE;
}
}
}
return IO__SUCCESS;
}
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_sClass_Ai_AI32uP *op;
io_sLocal *local;
int i;
io_sChannel *chanp;
op = (pwr_sClass_Ai_AI32uP *) cp->op;
local = calloc( 1, sizeof(*local));
cp->Local = local;
local->Address = op->RegAddress;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
errh_Info( "Init of ai card '%s'", cp->Name);
/* Caluclate polycoeff */
chanp = cp->chanlist;
for ( i = 0; i < cp->ChanListSize; i++)
{
AiRangeToCoef( chanp);
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
errh_Info( "IO closing ai card '%s'", cp->Name);
local = (io_sLocal *) cp->Local;
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_tInt16 data = 0;
pwr_sClass_Ai_AI32uP *op;
int i;
pwr_tFloat32 actvalue;
io_sChannel *chanp;
pwr_sClass_ChanAi *cop;
pwr_sClass_Ai *sop;
int sts;
qbus_io_read rb;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ai_AI32uP *) cp->op;
chanp = &cp->chanlist[0];
for ( i = 0; i < cp->ChanListSize; i++)
{
if ( !chanp->cop)
{
chanp++;
continue;
}
cop = (pwr_sClass_ChanAi *) chanp->cop;
sop = (pwr_sClass_Ai *) chanp->sop;
if ( cop->CalculateNewCoef)
AiRangeToCoef( chanp);
if ( cop->ConversionOn)
{
if ( local->ScanCount[i] <= 1)
{
#if defined(OS_ELN)
vaxc$establish(machfailread);
#endif
rb.Address = local->Address + 2*i;
sts = read( local->Qbus_fp, &rb, sizeof(rb));
data = (unsigned short) rb.Data;
if ( sts == -1)
{
#if 0
/* Exceptionhandler was called */
if ( io_fatal_error)
{
/* Activate emergency break */
errh_Error( "Fatal read error, card '%s', IO is stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
#endif
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
chanp++;
continue;
}
/* Convert rawvalue to sigvalue and actualvalue */
sop->RawValue = data;
sop->SigValue = data * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
switch ( chanp->ChanClass)
{
case pwr_cClass_ChanAi:
io_ConvertAi( cop, data, &actvalue);
break;
case pwr_cClass_ChanAit:
io_ConvertAit( (pwr_sClass_ChanAit *) cop, data, &actvalue);
break;
}
/* Filter */
if ( sop->FilterType == 1 &&
sop->FilterAttribute[0] > 0 &&
sop->FilterAttribute[0] > ctx->ScanTime)
{
actvalue = *(pwr_tFloat32 *)chanp->vbp +
ctx->ScanTime / sop->FilterAttribute[0] *
(actvalue - *(pwr_tFloat32 *)chanp->vbp);
}
*(pwr_tFloat32 *) chanp->vbp = actvalue;
local->ScanCount[i] = cop->ScanInterval + 1;
}
local->ScanCount[i]--;
}
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Ai_AI32uP) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardRead),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_m_ai_hvai32.c,v 1.1 2005-12-30 15:52:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_ai_hvai32.c -- io methods for ssab cards.
OS Linux
*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include "pwr.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "rt_errh.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_ssaboxclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
#include "qbus_io.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
#define MASKAI 0xFFF /* No polling bit in output data */
#define READYAI 0x8000 /* AI-read polling ready */
#define RMAX 100 /* Number of AI-read polling */
#define IO_MAXCHAN 32
typedef struct {
unsigned int Address;
int Qbus_fp;
int ScanCount[IO_MAXCHAN];
} io_sLocal;
typedef struct {
int Qbus_fp;
} io_sRackLocal;
static pwr_tStatus AiRangeToCoef(
io_sChannel *chanp)
{
pwr_sClass_ChanAi *cop;
char buf[120];
pwr_tStatus sts;
pwr_tFloat32 PolyCoef1;
pwr_tFloat32 PolyCoef0;
cop = chanp->cop;
if ( cop)
{
cop->CalculateNewCoef = 0;
/* Coef for RawValue to SignalValue conversion */
cop->SigValPolyCoef0 = cop->ChannelSigValRangeHigh * 1.024;
cop->SigValPolyCoef1 = - cop->ChannelSigValRangeHigh / 2048 * 1.024;
/* Coef for RawValue to ActualValue conversion */
if ( chanp->ChanClass != pwr_cClass_ChanAit && cop->SensorPolyType == 1)
{
if ( cop->SensorSigValRangeHigh != cop->SensorSigValRangeLow)
{
PolyCoef1 = (cop->ActValRangeHigh - cop->ActValRangeLow)/
(cop->SensorSigValRangeHigh - cop->SensorSigValRangeLow);
PolyCoef0 = cop->ActValRangeHigh - cop->SensorSigValRangeHigh *
PolyCoef1;
cop->SensorPolyCoef1 = cop->SigValPolyCoef1 * PolyCoef1;
cop->SensorPolyCoef0 = PolyCoef0 + PolyCoef1*
cop->SigValPolyCoef0;
}
else
{
sts = gdh_ObjidToName( chanp->ChanAref.Objid, buf, sizeof(buf),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
errh_Error( "Invalid SigValueRange in Ai channel %s", buf);
return IO__CHANRANGE;
}
}
}
return IO__SUCCESS;
}
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_sClass_Ai_HVAI32 *op;
io_sLocal *local;
int i;
io_sChannel *chanp;
op = (pwr_sClass_Ai_HVAI32 *) cp->op;
local = calloc( 1, sizeof(*local));
cp->Local = local;
local->Address = op->RegAddress;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
errh_Info( "Init of ai card '%s'", cp->Name);
/* Caluclate polycoeff */
chanp = cp->chanlist;
for ( i = 0; i < cp->ChanListSize; i++)
{
AiRangeToCoef( chanp);
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
errh_Info( "IO closing ai card '%s'", cp->Name);
local = (io_sLocal *) cp->Local;
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_tUInt16 data = 0;
pwr_sClass_Ai_HVAI32 *op;
int i, j;
pwr_tFloat32 actvalue;
io_sChannel *chanp;
pwr_sClass_ChanAi *cop;
pwr_sClass_Ai *sop;
int sts;
qbus_io_read rb;
qbus_io_write wb;
int timeout;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ai_HVAI32 *) cp->op;
chanp = &cp->chanlist[0];
for ( i = 0; i < cp->ChanListSize; i++)
{
if ( !chanp->cop)
{
chanp++;
continue;
}
cop = (pwr_sClass_ChanAi *) chanp->cop;
sop = (pwr_sClass_Ai *) chanp->sop;
if ( cop->CalculateNewCoef)
AiRangeToCoef( chanp);
if ( cop->ConversionOn)
{
if ( local->ScanCount[i] <= 1)
{
#if defined(OS_ELN)
vaxc$establish(machfailread);
#endif
/* Write channel */
wb.Address = local->Address;
wb.Data = i;
sts = write( local->Qbus_fp, &wb, sizeof(wb));
if ( sts != -1)
{
/* Read until ready-bit is set */
rb.Address = local->Address;
timeout = 1;
for ( j = 0; j < RMAX; j++)
{
sts = read( local->Qbus_fp, &rb, sizeof(rb));
if ( sts == -1)
break;
data = (unsigned short) rb.Data;
if( data & READYAI || sts == -1)
{
timeout = 0;
break;
}
}
}
data &= MASKAI;
if ( sts == -1 || timeout)
{
#if 0
if ( io_fatal_error)
{
/* Activate emergency break */
errh_Error( "Fatal read error, card '%s', IO is stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
#endif
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
chanp++;
continue;
}
/* Convert rawvalue to sigvalue and actualvalue */
sop->RawValue = data;
switch ( chanp->ChanClass)
{
case pwr_cClass_ChanAi:
io_ConvertAi( cop, (pwr_tInt16) data, &actvalue);
break;
case pwr_cClass_ChanAit:
io_ConvertAit( (pwr_sClass_ChanAit *) cop, (pwr_tInt16) data,
&actvalue);
break;
}
/* Check max/min */
if (actvalue > cop->ActValRangeHigh && cop->ActValRangeHigh > cop->ActValRangeLow)
actvalue = cop->ActValRangeHigh;
if (actvalue < cop->ActValRangeLow && cop->ActValRangeHigh > cop->ActValRangeLow)
actvalue = cop->ActValRangeLow;
/* Filter */
if ( sop->FilterType == 1 &&
sop->FilterAttribute[0] > 0 &&
sop->FilterAttribute[0] > ctx->ScanTime)
{
actvalue = *(pwr_tFloat32 *)chanp->vbp +
ctx->ScanTime / sop->FilterAttribute[0] *
(actvalue - *(pwr_tFloat32 *)chanp->vbp);
}
*(pwr_tFloat32 *) chanp->vbp = actvalue;
local->ScanCount[i] = cop->ScanInterval + 1;
}
local->ScanCount[i]--;
}
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Ai_HVAI32) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardRead),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_m_ao_hvao4.c,v 1.1 2005-12-30 15:52:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_ao_hvao4.c -- io methods for ssab cards.
OS Linux
*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include "pwr.h"
#include "rt_errh.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_ssaboxclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_write.h"
#include "qbus_io.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
#define IO_MAXCHAN 8
typedef struct {
unsigned int Address;
int Qbus_fp;
pwr_tFloat32 OldValue[IO_MAXCHAN];
pwr_tBoolean OldTestOn[IO_MAXCHAN];
int WriteFirst;
} io_sLocal;
typedef struct {
int Qbus_fp;
} io_sRackLocal;
static pwr_tStatus AoRangeToCoef(
io_sChannel *chanp)
{
pwr_sClass_ChanAo *cop;
char buf[120];
pwr_tStatus sts;
pwr_tFloat32 PolyCoef1;
pwr_tFloat32 PolyCoef0;
cop = chanp->cop;
if ( cop)
{
cop->CalculateNewCoef = 0;
/* Coef for ActualValue to RawValue conversion */
if ( cop->ActValRangeHigh != cop->ActValRangeLow)
{
cop->SigValPolyCoef1 = (cop->SensorSigValRangeHigh - cop->SensorSigValRangeLow)/
(cop->ActValRangeHigh - cop->ActValRangeLow);
cop->SigValPolyCoef0 = cop->SensorSigValRangeHigh - cop->ActValRangeHigh *
cop->SigValPolyCoef1;
}
else
{
sts = gdh_ObjidToName( chanp->ChanAref.Objid, buf, sizeof(buf),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
errh_Error( "Invalid ActValueRange in Ao channel %s", buf);
return IO__CHANRANGE;
}
/* Coef for ActualValue to SignalValue conversion */
if ( cop->ChannelSigValRangeHigh != 0)
{
PolyCoef0 = 0;
PolyCoef1 = cop->RawValRangeHigh / cop->ChannelSigValRangeHigh;
cop->OutPolyCoef1 = cop->SigValPolyCoef1 * PolyCoef1;
cop->OutPolyCoef0 = PolyCoef0 + PolyCoef1*
cop->SigValPolyCoef0;
}
else
{
sts = gdh_ObjidToName( chanp->ChanAref.Objid, buf, sizeof(buf),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
errh_Error( "Invalid SigValueRange in Ao channel %s", buf);
return IO__CHANRANGE;
}
}
return IO__SUCCESS;
}
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_sClass_Ao_HVAO4 *op;
io_sChannel *chanp;
int i;
io_sLocal *local;
op = (pwr_sClass_Ao_HVAO4 *) cp->op;
local = calloc( 1, sizeof(*local));
local->Address = op->RegAddress;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
errh_Info( "Init of ao card '%s'", cp->Name);
/* Write the first 50 loops */
local->WriteFirst = 50;
cp->Local = local;
/* Caluclate polycoeff */
chanp = cp->chanlist;
for ( i = 0; i < cp->ChanListSize; i++)
{
AoRangeToCoef( chanp);
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
local = (io_sLocal *) cp->Local;
errh_Info( "IO closing ao card '%s'", cp->Name);
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_sClass_Ao_HVAO4 *op;
int i;
io_sChannel *chanp;
pwr_sClass_ChanAo *cop;
pwr_sClass_Ao *sop;
pwr_tFloat32 value;
int fixout;
pwr_tUInt16 data;
pwr_tFloat32 rawvalue;
qbus_io_write wb;
int sts;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ao_HVAO4 *) cp->op;
fixout = ctx->Node->EmergBreakTrue && ctx->Node->EmergBreakSelect == FIXOUT;
chanp = &cp->chanlist[0];
for ( i = 0; i < cp->ChanListSize; i++)
{
if ( !chanp->cop)
{
chanp++;
continue;
}
cop = (pwr_sClass_ChanAo *) chanp->cop;
sop = (pwr_sClass_Ao *) chanp->sop;
if ( *(pwr_tFloat32 *)chanp->vbp != local->OldValue[i] ||
local->WriteFirst > 0 ||
cop->CalculateNewCoef ||
fixout ||
cop->TestOn || local->OldTestOn[i] != cop->TestOn)
{
if ( fixout)
value = cop->FixedOutValue;
else if ( cop->TestOn)
value = cop->TestValue;
else
value = *(pwr_tFloat32 *) chanp->vbp;
if ( cop->CalculateNewCoef)
AoRangeToCoef( chanp);
/* Convert to rawvalue */
if ( value > cop->ActValRangeHigh)
value = cop->ActValRangeHigh;
else if ( value < cop->ActValRangeLow)
value = cop->ActValRangeLow;
rawvalue = cop->OutPolyCoef1 * value + cop->OutPolyCoef0;
if ( rawvalue > 0)
sop->RawValue = rawvalue + 0.5;
else
sop->RawValue = rawvalue - 0.5;
data = sop->RawValue;
#if defined(OS_ELN)
vaxc$establish(machfailwrite);
#endif
wb.Data = data;
wb.Address = local->Address + 2*i;
sts = write( local->Qbus_fp, &wb, sizeof(wb));
if ( sts == -1)
{
/* Exceptionhandler was called */
#if 0
if ( io_fatal_error)
{
/* Activate emergency break */
errh_Error( "Fatal write error, card '%s', IO is stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
#endif
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
chanp++;
continue;
}
else
local->OldValue[i] = value;
}
local->OldTestOn[i] = cop->TestOn;
chanp++;
}
if ( local->WriteFirst)
local->WriteFirst--;
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Ao_HVAO4) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
pwr_dExport pwr_BindIoMethods(Ao_AO8uP) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
This diff is collapsed.
/*
* Proview $Id: rt_io_m_di_dix2.c,v 1.1 2005-12-30 15:52:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_di_dix2.c -- io methods for ssab cards.
OS Linux
*/
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include "pwr.h"
#include "rt_errh.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_ssaboxclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_filter_di.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
#include "qbus_io.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
typedef struct {
unsigned int Address[2];
int Qbus_fp;
struct {
pwr_sClass_Di *sop[16];
void *Data[16];
pwr_tBoolean Found;
} Filter[2];
} io_sLocal;
typedef struct {
int Qbus_fp;
} io_sRackLocal;
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_sClass_Di_DIX2 *op;
io_sLocal *local;
int i, j;
op = (pwr_sClass_Di_DIX2 *) cp->op;
local = calloc( 1, sizeof(*local));
cp->Local = local;
errh_Info( "Init of di card '%s'", cp->Name);
local->Address[0] = op->RegAddress;
local->Address[1] = op->RegAddress + 2;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
/* Init filter */
for ( i = 0; i < 2; i++)
{
/* The filter handles one 16-bit word */
for ( j = 0; j < 16; j++)
local->Filter[i].sop[j] = cp->chanlist[i*16+j].sop;
io_InitDiFilter( local->Filter[i].sop, &local->Filter[i].Found,
local->Filter[i].Data, ctx->ScanTime);
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
int i;
local = (io_sLocal *) cp->Local;
errh_Info( "IO closing di card '%s'", cp->Name);
/* Free filter data */
for ( i = 0; i < 2; i++)
{
if ( local->Filter[i].Found)
io_CloseDiFilter( local->Filter[i].Data);
}
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_tUInt16 data = 0;
pwr_sClass_Di_DIX2 *op;
pwr_tUInt16 invmask;
pwr_tUInt16 convmask;
int i;
int sts;
qbus_io_read rb;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Di_DIX2 *) cp->op;
for ( i = 0; i < 2; i++)
{
if ( i == 0)
{
convmask = op->ConvMask1;
invmask = op->InvMask1;
}
else
{
convmask = op->ConvMask2;
invmask = op->InvMask2;
if ( !convmask)
break;
if ( op->MaxNoOfChannels == 16)
break;
}
rb.Address = local->Address[i];
sts = read( local->Qbus_fp, &rb, sizeof(rb));
data = (unsigned short) rb.Data;
if ( sts == -1)
{
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
continue;
}
/* Invert */
data = data ^ invmask;
/* Filter ... */
if ( local->Filter[i].Found)
io_DiFilter( local->Filter[i].sop, &data, local->Filter[i].Data);
/* Move data to valuebase */
io_DiUnpackWord( cp, data, convmask, i);
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Di_DIX2) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardRead),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_m_do_hvdo32.c,v 1.1 2005-12-30 15:52:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_do_hvdo32.c -- io methods for ssab cards.
OS Linux
*/
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include "pwr.h"
#include "rt_errh.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_ssaboxclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_filter_po.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_write.h"
#include "qbus_io.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
typedef struct {
unsigned int Address[2];
int Qbus_fp;
struct {
pwr_sClass_Po *sop[16];
void *Data[16];
pwr_tBoolean Found;
} Filter[2];
} io_sLocal;
typedef struct {
int Qbus_fp;
} io_sRackLocal;
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_sClass_Do_HVDO32 *op;
io_sLocal *local;
int i, j;
op = (pwr_sClass_Do_HVDO32 *) cp->op;
local = calloc( 1, sizeof(*local));
cp->Local = local;
errh_Info( "Init of do card '%s'", cp->Name);
local->Address[0] = op->RegAddress;
local->Address[1] = op->RegAddress + 2;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
/* Init filter for Po signals */
for ( i = 0; i < 2; i++)
{
/* The filter handles one 16-bit word */
for ( j = 0; j < 16; j++)
{
if ( cp->chanlist[i*16+j].SigClass == pwr_cClass_Po)
local->Filter[i].sop[j] = cp->chanlist[i*16+j].sop;
}
io_InitPoFilter( local->Filter[i].sop, &local->Filter[i].Found,
local->Filter[i].Data, ctx->ScanTime);
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
int i;
local = (io_sLocal *) cp->Local;
errh_Info( "IO closing do card '%s'", cp->Name);
/* Free filter data */
for ( i = 0; i < 2; i++)
{
if ( local->Filter[i].Found)
io_ClosePoFilter( local->Filter[i].Data);
}
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_tUInt16 data = 0;
pwr_sClass_Do_HVDO32 *op;
pwr_tUInt16 invmask;
pwr_tUInt16 testmask;
pwr_tUInt16 testvalue;
int i;
qbus_io_write wb;
int sts;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Do_HVDO32 *) cp->op;
#if defined(OS_ELN)
vaxc$establish(machfailwrite);
#endif
for ( i = 0; i < 2; i++)
{
if ( ctx->Node->EmergBreakTrue && ctx->Node->EmergBreakSelect == FIXOUT)
{
if ( i == 0)
data = op->FixedOutValue1;
else
data = op->FixedOutValue2;
}
else
io_DoPackWord( cp, &data, i);
if ( i == 0)
{
testmask = op->TestMask1;
invmask = op->InvMask1;
}
else
{
testmask = op->TestMask2;
invmask = op->InvMask2;
if ( op->MaxNoOfChannels == 16)
break;
}
/* Invert */
data = data ^ invmask;
/* Filter Po signals */
if ( local->Filter[i].Found)
io_PoFilter( local->Filter[i].sop, &data, local->Filter[i].Data);
/* Testvalues */
if ( testmask)
{
if ( i == 0)
testvalue = op->TestValue1;
else
testvalue = op->TestValue2;
data = (data & ~ testmask) | (testmask & testvalue);
}
wb.Data = data;
wb.Address = local->Address[i];
sts = write( local->Qbus_fp, &wb, sizeof(wb));
if ( sts == -1)
{
#if 0
/* Exceptionhandler was called */
if ( io_fatal_error)
{
/* Activate emergency break */
errh_Error( "Fatal write error, card '%s', IO is stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
#endif
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
continue;
}
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Do_HVDO32) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_m_rack_ssab.c,v 1.1 2005-12-30 15:52:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_rack_ssab.c -- io methods for ssab rack objects. */
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_ssaboxclasses.h"
#include "rt_io_base.h"
#include "rt_errh.h"
#include "rt_io_rack_init.h"
#include "rt_io_msg.h"
typedef struct {
int Qbus_fp;
} io_sRackLocal;
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoRackInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp
)
{
io_sRackLocal *local;
/* Open Qbus driver */
local = calloc( 1, sizeof(*local));
rp->Local = local;
local->Qbus_fp = open("/dev/qbus", O_RDWR);
if ( local->Qbus_fp == -1)
{
errh_Error( "Qbus initialization error, IO rack %s", rp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
errh_Info( "Init of IO rack %s", rp->Name);
return 1;
}
static pwr_tStatus IoRackClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp
)
{
io_sRackLocal *local;
/* Close Qbus driver */
local = rp->Local;
close( local->Qbus_fp);
free( (char *)local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Rack_SSAB) = {
pwr_BindIoMethod(IoRackInit),
pwr_BindIoMethod(IoRackClose),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_m_ssab_aiup.c,v 1.1 2005-12-30 15:52:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_ssab_ai.c -- io methods for ssab cards. */
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include "pwr.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "rt_errh.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_ssaboxclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
#include "qbus_io.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
#define IO_MAXCHAN 32
typedef struct {
unsigned int Address;
int Qbus_fp;
int ScanCount[IO_MAXCHAN];
} io_sLocal;
typedef struct {
int Qbus_fp;
} io_sRackLocal;
static pwr_tStatus AiRangeToCoef(
io_sChannel *chanp)
{
pwr_sClass_ChanAi *cop;
char buf[120];
pwr_tStatus sts;
pwr_tFloat32 PolyCoef1;
pwr_tFloat32 PolyCoef0;
cop = chanp->cop;
if ( cop)
{
cop->CalculateNewCoef = 0;
/* Coef for RawValue to SignalValue conversion */
cop->SigValPolyCoef0 = 0;
cop->SigValPolyCoef1 = cop->ChannelSigValRangeHigh / 30000;
/* Coef for SignalValue to ActualValue conversion */
if ( chanp->ChanClass != pwr_cClass_ChanAit && cop->SensorPolyType == 1)
{
if ( cop->SensorSigValRangeHigh != cop->SensorSigValRangeLow)
{
PolyCoef1 = (cop->ActValRangeHigh - cop->ActValRangeLow)/
(cop->SensorSigValRangeHigh - cop->SensorSigValRangeLow);
PolyCoef0 = cop->ActValRangeHigh - cop->SensorSigValRangeHigh *
PolyCoef1;
cop->SensorPolyCoef1 = cop->SigValPolyCoef1 * PolyCoef1;
cop->SensorPolyCoef0 = PolyCoef0 + PolyCoef1*
cop->SigValPolyCoef0;
}
else
{
sts = gdh_AttrrefToName( &chanp->ChanAref, buf, sizeof(buf),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
errh_Error( "Invalid SigValueRange in Ai channel %s", buf);
return IO__CHANRANGE;
}
}
}
return IO__SUCCESS;
}
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_sClass_Ssab_BaseACard *op;
io_sLocal *local;
int i;
io_sChannel *chanp;
op = (pwr_sClass_Ssab_BaseACard *) cp->op;
local = calloc( 1, sizeof(*local));
cp->Local = local;
local->Address = op->RegAddress;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
errh_Info( "Init of ai card '%s'", cp->Name);
/* Caluclate polycoeff */
chanp = cp->chanlist;
for ( i = 0; i < cp->ChanListSize; i++)
{
if ( chanp->sop)
AiRangeToCoef( chanp);
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
errh_Info( "IO closing ai card '%s'", cp->Name);
local = (io_sLocal *) cp->Local;
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_tInt16 data = 0;
pwr_sClass_Ssab_BaseACard *op;
int i;
pwr_tFloat32 actvalue;
io_sChannel *chanp;
pwr_sClass_ChanAi *cop;
pwr_sClass_Ai *sop;
int sts;
qbus_io_read rb;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ssab_BaseACard *) cp->op;
chanp = &cp->chanlist[0];
for ( i = 0; i < cp->ChanListSize; i++)
{
if ( !chanp->cop || !chanp->sop)
{
chanp++;
continue;
}
cop = (pwr_sClass_ChanAi *) chanp->cop;
sop = (pwr_sClass_Ai *) chanp->sop;
if ( cop->CalculateNewCoef)
AiRangeToCoef( chanp);
if ( cop->ConversionOn)
{
if ( local->ScanCount[i] <= 1)
{
#if defined(OS_ELN)
vaxc$establish(machfailread);
#endif
rb.Address = local->Address + 2*i;
sts = read( local->Qbus_fp, &rb, sizeof(rb));
data = (unsigned short) rb.Data;
if ( sts == -1)
{
#if 0
/* Exceptionhandler was called */
if ( io_fatal_error)
{
/* Activate emergency break */
errh_Error( "Fatal read error, card '%s', IO is stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
#endif
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
chanp++;
continue;
}
/* Convert rawvalue to sigvalue and actualvalue */
sop->RawValue = data;
sop->SigValue = data * cop->SigValPolyCoef1 + cop->SigValPolyCoef0;
switch ( chanp->ChanClass)
{
case pwr_cClass_ChanAi:
io_ConvertAi( cop, data, &actvalue);
break;
case pwr_cClass_ChanAit:
io_ConvertAit( (pwr_sClass_ChanAit *) cop, data, &actvalue);
break;
}
/* Filter */
if ( sop->FilterType == 1 &&
sop->FilterAttribute[0] > 0 &&
sop->FilterAttribute[0] > ctx->ScanTime)
{
actvalue = *(pwr_tFloat32 *)chanp->vbp +
ctx->ScanTime / sop->FilterAttribute[0] *
(actvalue - *(pwr_tFloat32 *)chanp->vbp);
}
*(pwr_tFloat32 *) chanp->vbp = actvalue;
local->ScanCount[i] = cop->ScanInterval + 1;
}
local->ScanCount[i]--;
}
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Ssab_AiuP) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardRead),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_m_ssab_aoup.c,v 1.1 2005-12-30 15:52:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_ssab_aoup.c -- io methods for ssab cards. */
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include "pwr.h"
#include "rt_errh.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_ssaboxclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_write.h"
#include "qbus_io.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
#define IO_MAXCHAN 8
typedef struct {
unsigned int Address;
int Qbus_fp;
pwr_tFloat32 OldValue[IO_MAXCHAN];
pwr_tBoolean OldTestOn[IO_MAXCHAN];
int WriteFirst;
} io_sLocal;
typedef struct {
int Qbus_fp;
} io_sRackLocal;
static pwr_tStatus AoRangeToCoef(
io_sChannel *chanp)
{
pwr_sClass_ChanAo *cop;
char buf[120];
pwr_tStatus sts;
pwr_tFloat32 PolyCoef1;
pwr_tFloat32 PolyCoef0;
cop = chanp->cop;
if ( cop)
{
cop->CalculateNewCoef = 0;
/* Coef for ActualValue to RawValue conversion */
if ( cop->ActValRangeHigh != cop->ActValRangeLow)
{
cop->SigValPolyCoef1 = (cop->SensorSigValRangeHigh - cop->SensorSigValRangeLow)/
(cop->ActValRangeHigh - cop->ActValRangeLow);
cop->SigValPolyCoef0 = cop->SensorSigValRangeHigh - cop->ActValRangeHigh *
cop->SigValPolyCoef1;
}
else
{
sts = gdh_AttrrefToName( &chanp->ChanAref, buf, sizeof(buf),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
errh_Error( "Invalid ActValueRange in Ao channel %s", buf);
return IO__CHANRANGE;
}
/* Coef for ActualValue to SignalValue conversion */
if ( cop->ChannelSigValRangeHigh != 0)
{
PolyCoef0 = 0;
PolyCoef1 = cop->RawValRangeHigh / cop->ChannelSigValRangeHigh;
cop->OutPolyCoef1 = cop->SigValPolyCoef1 * PolyCoef1;
cop->OutPolyCoef0 = PolyCoef0 + PolyCoef1*
cop->SigValPolyCoef0;
}
else
{
sts = gdh_AttrrefToName( &chanp->ChanAref, buf, sizeof(buf),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
errh_Error( "Invalid SigValueRange in Ao channel %s", buf);
return IO__CHANRANGE;
}
}
return IO__SUCCESS;
}
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_sClass_Ssab_BaseACard *op;
io_sChannel *chanp;
int i;
io_sLocal *local;
op = (pwr_sClass_Ssab_BaseACard *) cp->op;
local = calloc( 1, sizeof(*local));
local->Address = op->RegAddress;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
errh_Info( "Init of ao card '%s'", cp->Name);
/* Write the first 50 loops */
local->WriteFirst = 50;
cp->Local = local;
/* Caluclate polycoeff */
chanp = cp->chanlist;
for ( i = 0; i < cp->ChanListSize; i++)
{
if ( chanp->sop)
AoRangeToCoef( chanp);
chanp++;
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
local = (io_sLocal *) cp->Local;
errh_Info( "IO closing ao card '%s'", cp->Name);
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_sClass_Ssab_BaseACard *op;
int i;
io_sChannel *chanp;
pwr_sClass_ChanAo *cop;
pwr_sClass_Ao *sop;
pwr_tFloat32 value;
int fixout;
pwr_tUInt16 data;
pwr_tFloat32 rawvalue;
qbus_io_write wb;
int sts;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ssab_BaseACard *) cp->op;
fixout = ctx->Node->EmergBreakTrue && ctx->Node->EmergBreakSelect == FIXOUT;
chanp = &cp->chanlist[0];
for ( i = 0; i < cp->ChanListSize; i++)
{
if ( !chanp->cop || !chanp->sop)
{
chanp++;
continue;
}
cop = (pwr_sClass_ChanAo *) chanp->cop;
sop = (pwr_sClass_Ao *) chanp->sop;
if ( *(pwr_tFloat32 *)chanp->vbp != local->OldValue[i] ||
local->WriteFirst > 0 ||
cop->CalculateNewCoef ||
fixout ||
cop->TestOn || local->OldTestOn[i] != cop->TestOn)
{
if ( fixout)
value = cop->FixedOutValue;
else if ( cop->TestOn)
value = cop->TestValue;
else
value = *(pwr_tFloat32 *) chanp->vbp;
if ( cop->CalculateNewCoef)
AoRangeToCoef( chanp);
/* Convert to rawvalue */
if ( value > cop->ActValRangeHigh)
value = cop->ActValRangeHigh;
else if ( value < cop->ActValRangeLow)
value = cop->ActValRangeLow;
rawvalue = cop->OutPolyCoef1 * value + cop->OutPolyCoef0;
if ( rawvalue > 0)
sop->RawValue = rawvalue + 0.5;
else
sop->RawValue = rawvalue - 0.5;
data = sop->RawValue;
#if defined(OS_ELN)
vaxc$establish(machfailwrite);
#endif
wb.Data = data;
wb.Address = local->Address + 2*i;
sts = write( local->Qbus_fp, &wb, sizeof(wb));
if ( sts == -1)
{
/* Exceptionhandler was called */
#if 0
if ( io_fatal_error)
{
/* Activate emergency break */
errh_Error( "Fatal write error, card '%s', IO is stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
#endif
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
chanp++;
continue;
}
else
local->OldValue[i] = value;
}
local->OldTestOn[i] = cop->TestOn;
chanp++;
}
if ( local->WriteFirst)
local->WriteFirst--;
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Ssab_AouP) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
This diff is collapsed.
/*
* Proview $Id: rt_io_m_ssab_di.c,v 1.1 2005-12-30 15:52:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_ssab_di.c -- io methods for ssab cards.
OS Linux
*/
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include "pwr.h"
#include "rt_errh.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_ssaboxclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_filter_di.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
#include "qbus_io.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
typedef struct {
unsigned int Address[2];
int Qbus_fp;
struct {
pwr_sClass_Di *sop[16];
void *Data[16];
pwr_tBoolean Found;
} Filter[2];
} io_sLocal;
typedef struct {
int Qbus_fp;
} io_sRackLocal;
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_sClass_Ssab_BaseDiCard *op;
io_sLocal *local;
int i, j;
op = (pwr_sClass_Ssab_BaseDiCard *) cp->op;
local = calloc( 1, sizeof(*local));
cp->Local = local;
errh_Info( "Init of di card '%s'", cp->Name);
local->Address[0] = op->RegAddress;
local->Address[1] = op->RegAddress + 2;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
/* Init filter */
for ( i = 0; i < 2; i++)
{
/* The filter handles one 16-bit word */
for ( j = 0; j < 16; j++)
local->Filter[i].sop[j] = cp->chanlist[i*16+j].sop;
io_InitDiFilter( local->Filter[i].sop, &local->Filter[i].Found,
local->Filter[i].Data, ctx->ScanTime);
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
int i;
local = (io_sLocal *) cp->Local;
errh_Info( "IO closing di card '%s'", cp->Name);
/* Free filter data */
for ( i = 0; i < 2; i++)
{
if ( local->Filter[i].Found)
io_CloseDiFilter( local->Filter[i].Data);
}
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_tUInt16 data = 0;
pwr_sClass_Ssab_BaseDiCard *op;
pwr_tUInt16 invmask;
pwr_tUInt16 convmask;
int i;
int sts;
qbus_io_read rb;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ssab_BaseDiCard *) cp->op;
for ( i = 0; i < 2; i++)
{
if ( i == 0)
{
convmask = op->ConvMask1;
invmask = op->InvMask1;
}
else
{
convmask = op->ConvMask2;
invmask = op->InvMask2;
if ( !convmask)
break;
if ( op->MaxNoOfChannels == 16)
break;
}
rb.Address = local->Address[i];
sts = read( local->Qbus_fp, &rb, sizeof(rb));
data = (unsigned short) rb.Data;
if ( sts == -1)
{
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
continue;
}
/* Invert */
data = data ^ invmask;
/* Filter ... */
if ( local->Filter[i].Found)
io_DiFilter( local->Filter[i].sop, &data, local->Filter[i].Data);
/* Move data to valuebase */
io_DiUnpackWord( cp, data, convmask, i);
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Ssab_Di) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardRead),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_m_ssab_do.c,v 1.1 2005-12-30 15:52:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_ssab_do.c -- io methods for ssab cards.
OS Linux
*/
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include "pwr.h"
#include "rt_errh.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_ssaboxclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_io_filter_po.h"
#include "rt_io_ssab.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_write.h"
#include "qbus_io.h"
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
typedef struct {
unsigned int Address[2];
int Qbus_fp;
struct {
pwr_sClass_Po *sop[16];
void *Data[16];
pwr_tBoolean Found;
} Filter[2];
} io_sLocal;
typedef struct {
int Qbus_fp;
} io_sRackLocal;
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
pwr_sClass_Ssab_BaseDoCard *op;
io_sLocal *local;
int i, j;
op = (pwr_sClass_Ssab_BaseDoCard *) cp->op;
local = calloc( 1, sizeof(*local));
cp->Local = local;
errh_Info( "Init of do card '%s'", cp->Name);
local->Address[0] = op->RegAddress;
local->Address[1] = op->RegAddress + 2;
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
/* Init filter for Po signals */
for ( i = 0; i < 2; i++)
{
/* The filter handles one 16-bit word */
for ( j = 0; j < 16; j++)
{
if ( cp->chanlist[i*16+j].SigClass == pwr_cClass_Po)
local->Filter[i].sop[j] = cp->chanlist[i*16+j].sop;
}
io_InitPoFilter( local->Filter[i].sop, &local->Filter[i].Found,
local->Filter[i].Data, ctx->ScanTime);
}
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
int i;
local = (io_sLocal *) cp->Local;
errh_Info( "IO closing do card '%s'", cp->Name);
/* Free filter data */
for ( i = 0; i < 2; i++)
{
if ( local->Filter[i].Found)
io_ClosePoFilter( local->Filter[i].Data);
}
free( (char *) local);
return 1;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sLocal *local;
pwr_tUInt16 data = 0;
pwr_sClass_Ssab_BaseDoCard *op;
pwr_tUInt16 invmask;
pwr_tUInt16 testmask;
pwr_tUInt16 testvalue;
int i;
qbus_io_write wb;
int sts;
local = (io_sLocal *) cp->Local;
op = (pwr_sClass_Ssab_BaseDoCard *) cp->op;
#if defined(OS_ELN)
vaxc$establish(machfailwrite);
#endif
for ( i = 0; i < 2; i++)
{
if ( ctx->Node->EmergBreakTrue && ctx->Node->EmergBreakSelect == FIXOUT)
{
if ( i == 0)
data = op->FixedOutValue1;
else
data = op->FixedOutValue2;
}
else
io_DoPackWord( cp, &data, i);
if ( i == 0)
{
testmask = op->TestMask1;
invmask = op->InvMask1;
}
else
{
testmask = op->TestMask2;
invmask = op->InvMask2;
if ( op->MaxNoOfChannels == 16)
break;
}
/* Invert */
data = data ^ invmask;
/* Filter Po signals */
if ( local->Filter[i].Found)
io_PoFilter( local->Filter[i].sop, &data, local->Filter[i].Data);
/* Testvalues */
if ( testmask)
{
if ( i == 0)
testvalue = op->TestValue1;
else
testvalue = op->TestValue2;
data = (data & ~ testmask) | (testmask & testvalue);
}
wb.Data = data;
wb.Address = local->Address[i];
sts = write( local->Qbus_fp, &wb, sizeof(wb));
if ( sts == -1)
{
#if 0
/* Exceptionhandler was called */
if ( io_fatal_error)
{
/* Activate emergency break */
errh_Error( "Fatal write error, card '%s', IO is stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
#endif
/* Increase error count and check error limits */
op->ErrorCount++;
if ( op->ErrorCount == op->ErrorSoftLimit)
errh_Error( "IO Error soft limit reached on card '%s'", cp->Name);
if ( op->ErrorCount >= op->ErrorHardLimit)
{
errh_Error( "IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
continue;
}
}
return 1;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Ssab_Do) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
/*
* Proview $Id: rt_io_ssab.h,v 1.1 2005-12-30 15:52:05 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_ssab.h -- init, read and write ssab cards. */
typedef int DEVICE;
int ssab_close(
void *hv_device);
int ssabai_ini(
char *inidev,
void *adressini,
void *hv_device,
int relvec);
unsigned short ssabai_read(
void *reg_diP,
int grupp);
int ssabao_ini(
char *inidev,
void *adressini,
void *hv_device,
int relvec);
void ssabao_write(
short data,
void *reg_diP,
int channel);
int ssabd_ini(
char *inidev,
void *adressini,
void *hv_device,
int relvec);
unsigned short ssabdi_read(
void *reg_diP,
int grupp);
void ssabdo_write(
short data,
void *reg_diP,
int grupp);
void ssabco_read(
void *reg_diP,
int numofword,
int *co_id,
unsigned short *data,
int channel);
void ssabco_write(
unsigned short *data,
void *reg_P,
int channel);
unsigned short ssabaiup_read(
void *reg_diP,
int grupp);
Rack_SSAB
Ssab_AiuP
Ssab_AouP
Ssab_Di
Ssab_Do
Ssab_Co
Di_DIX2
Do_HVDO32
Ao_HVAO4
Ao_AO8uP
Ai_HVAI32
Ai_AI32uP
Co_PI24BO
Co_CO4uP
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
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Ai_HVAI32
Ai_AI32uP
Ao_HVAO4
Ao_AO8uP
Backup
Co_PI24BO
Co_CO4uP
Di_DIX2
Do_HVDO32
#
# Script to export all classgraphs to java
#
#
#
function int process( string graph)
open 'graph'
printf( "Exporting %s...\n", graph);
export java
endfunction
main()
process( "pwr_c_ssab_safetyswitch");
endmain
This diff is collapsed.
Volume Telemecanique $ClassVolume 0.0.250.4
Body SysBody 05-SEP-2005 17:51:40.00
Attr NextOix = "_X1"
Attr NextCix = "_X2"
EndBody
Object Class $ClassHier 1 05-SEP-2005 17:51:40.00
Object Dum2 $ClassDef 1 05-SEP-2005 17:51:40.00
Body SysBody 05-SEP-2005 17:51:40.00
Attr Editor = 0
Attr Method = 0
Attr Flags = 16
EndBody
Object RtBody $ObjBodyDef 1 05-SEP-2005 17:51:40.00
Body SysBody 05-SEP-2005 17:59:37.06
Attr StructName = "Dum2"
EndBody
EndObject
Object Template Dum2 2147975168 05-SEP-2005 17:51:40.00
Body RtBody 05-SEP-2005 17:51:40.00
EndBody
EndObject
EndObject
EndObject
EndVolume
ifndef link_rule_mk
link_rule_mk := 1
link = $(ldxx) $(linkflags) $(domap) -o $(export_exe) \
link = $(ldxx) $(elinkflags) $(domap) -o $(export_exe) \
$(export_obj) $(objects) $(wb_msg_objs) $(rt_msg_objs) \
$(pwr_obj)/rt_io_user.o $(pwr_obj)/wb_provider.o \
-L/usr/X11R6/lib -L/usr/local/BerkeleyDB.4.0/lib \
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment