Commit e2cdbfb4 authored by Claes Sjofors's avatar Claes Sjofors

IO support for USB joystick added

parent 1709f81c
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
ifndef link_rule_mk
link_rule_mk := 1
link = $(ldxx) $(elinkflags) $(domap) -o $(export_exe) \
$(export_obj) \
$(pwre_conf_libdir) $(pwre_conf_libpwrrt) $(pwre_conf_lib)
endif
/*
* Proview $Id$
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_usb_joystick.c -- I/O methods for USB joysticks. */
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/types.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include "pwr.h"
#include "co_time.h"
#include "co_cdh.h"
#include <linux/input.h>
#include <linux/joystick.h>
#include <errno.h>
typedef struct {
int fd;
int axis_map[ABS_MAX + 1];
int button_map[KEY_MAX - BTN_MISC + 1];
} io_sLocalUSB_Joystick;
static char *axis_names[ABS_MAX + 1] = {
"X", "Y", "Z", "Rx", "Ry", "Rz", "Throttle", "Rudder",
"Wheel", "Gas", "Brake", "?", "?", "?", "?", "?",
"Hat0X", "Hat0Y", "Hat1X", "Hat1Y", "Hat2X", "Hat2Y", "Hat3X", "Hat3Y",
"?", "?", "?", "?", "?", "?", "?", 0,
};
static char *button_names[KEY_MAX - BTN_MISC + 1] = {
"Btn0", "Btn1", "Btn2", "Btn3", "Btn4", "Btn5", "Btn6", "Btn7",
"Btn8", "Btn9", "?", "?", "?", "?", "?", "?",
"LeftBtn", "RightBtn", "MiddleBtn", "SideBtn", "ExtraBtn", "ForwardBtn", "BackBtn", "TaskBtn",
"?", "?", "?", "?", "?", "?", "?", "?",
"Trigger", "ThumbBtn", "ThumbBtn2", "TopBtn", "TopBtn2", "PinkieBtn", "BaseBtn", "BaseBtn2",
"BaseBtn3", "BaseBtn4", "BaseBtn5", "BaseBtn6", "BtnDead", "BtnA", "BtnB", "BtnC",
"BtnX", "BtnY", "BtnZ", "BtnTL", "BtnTR", "BtnTL2", "BtnTR2", "BtnSelect",
"BtnStart", "BtnMode", "BtnThumbL", "BtnThumbR", "?", "?", "?", "?",
"?", "?", "?", "?", "?", "?", "?", "?",
"?", "?", "?", "?", "?", "WheelBtn", "Gear up", 0,
};
#define NAME_LENGTH 128
static void usage()
{
printf( "\n\
Show joystick axes and button configuration\n\n\
Argument:\n\
device, eg /dev/input/js0\n\n\
> rt_joystick /dev/input/js0\n\n");
}
int main (int argc, char **argv)
{
if ( argc < 2) {
usage();
exit(0);
}
if ( strcmp( argv[1], "-h") == 0) {
usage();
exit(0);
}
int i;
int fd;
unsigned char axes = 2;
unsigned char buttons = 2;
uint8_t axmap[ABS_MAX + 1];
uint16_t btnmap[KEY_MAX - BTN_MISC + 1];
char name[NAME_LENGTH] = "Unknown";
fd = open( argv[1], O_RDONLY);
if ( fd == -1) {
printf( "USB_Joystick, unable to attach device, sts %d, '%s'\n", errno, argv[1]);
exit(0);
}
ioctl( fd, JSIOCGNAME(NAME_LENGTH), name);
ioctl( fd, JSIOCGAXES, &axes);
ioctl( fd, JSIOCGBUTTONS, &buttons);
ioctl( fd, JSIOCGAXMAP, axmap);
ioctl( fd, JSIOCGBTNMAP, btnmap);
printf( "\nAxes and button configuration\n\n");
printf( "Joystick: %s\n", name);
printf( "\nAxes:\n\n");
for (i = 0; i < axes; i++)
printf("%d %s\n", i+1, axis_names[axmap[i]]);
printf( "\nButtons:\n\n");
for (i = 0; i < buttons; i++)
printf("%d %s\n", i+1, button_names[btnmap[i] - BTN_MISC]);
printf( "\n");
return 0;
}
/*
* Proview $Id$
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_usb_joystick.c -- I/O methods for USB joysticks. */
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/types.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include "pwr.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_otherioclasses.h"
#include "co_time.h"
#include "co_cdh.h"
#include "rt_io_base.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
#include "rt_io_msg.h"
#include <linux/input.h>
#include <linux/joystick.h>
#include <errno.h>
typedef struct {
int fd;
int axis_map[ABS_MAX + 1];
int button_map[KEY_MAX - BTN_MISC + 1];
} io_sLocalUSB_Joystick;
static char *axis_names[ABS_MAX + 1] = {
"X", "Y", "Z", "Rx", "Ry", "Rz", "Throttle", "Rudder",
"Wheel", "Gas", "Brake", "?", "?", "?", "?", "?",
"Hat0X", "Hat0Y", "Hat1X", "Hat1Y", "Hat2X", "Hat2Y", "Hat3X", "Hat3Y",
"?", "?", "?", "?", "?", "?", "?", 0,
};
static char *button_names[KEY_MAX - BTN_MISC + 1] = {
"Btn0", "Btn1", "Btn2", "Btn3", "Btn4", "Btn5", "Btn6", "Btn7",
"Btn8", "Btn9", "?", "?", "?", "?", "?", "?",
"LeftBtn", "RightBtn", "MiddleBtn", "SideBtn", "ExtraBtn", "ForwardBtn", "BackBtn", "TaskBtn",
"?", "?", "?", "?", "?", "?", "?", "?",
"Trigger", "ThumbBtn", "ThumbBtn2", "TopBtn", "TopBtn2", "PinkieBtn", "BaseBtn", "BaseBtn2",
"BaseBtn3", "BaseBtn4", "BaseBtn5", "BaseBtn6", "BtnDead", "BtnA", "BtnB", "BtnC",
"BtnX", "BtnY", "BtnZ", "BtnTL", "BtnTR", "BtnTL2", "BtnTR2", "BtnSelect",
"BtnStart", "BtnMode", "BtnThumbL", "BtnThumbR", "?", "?", "?", "?",
"?", "?", "?", "?", "?", "?", "?", "?",
"?", "?", "?", "?", "?", "WheelBtn", "Gear up", 0,
};
static pwr_tStatus IoCardInit( io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp)
{
io_sLocalUSB_Joystick *local;
pwr_sClass_USB_Joystick *op = (pwr_sClass_USB_Joystick *)cp->op;
int i, j, k;
int fd;
unsigned char axes = 2;
unsigned char buttons = 2;
uint8_t axmap[ABS_MAX + 1];
uint16_t btnmap[KEY_MAX - BTN_MISC + 1];
fd = open( op->Device, O_RDONLY);
if ( fd == -1) {
errh_Error( "USB_Joystick, unable to attach device, sts %d, '%s'", errno, cp->Name);
op->Status = IO__INITFAIL;
return IO__INITFAIL;
}
local = (io_sLocalUSB_Joystick *) calloc( 1, sizeof(io_sLocalUSB_Joystick));
cp->Local = local;
local->fd = fd;
ioctl( local->fd, JSIOCGAXES, &axes);
ioctl( local->fd, JSIOCGBUTTONS, &buttons);
ioctl( local->fd, JSIOCGAXMAP, axmap);
ioctl( local->fd, JSIOCGBTNMAP, btnmap);
fcntl( local->fd, F_SETFL, O_NONBLOCK);
int map_found = 0;
int name_found = 0;
for ( i = 0; i < IO_CHANLIST_SIZE; i++) {
if ( cp->chanlist[i].sop) {
switch ( cp->chanlist[i].ChanClass) {
case pwr_cClass_ChanAi: {
pwr_sClass_ChanAi *cop = (pwr_sClass_ChanAi *)cp->chanlist[i].cop;
/* Map channel */
for ( j = 0; j < ABS_MAX; j++) {
if ( axis_names[j] == 0)
break;
if ( cdh_NoCaseStrcmp( axis_names[j], cop->Identity) == 0) {
for ( k = 0; k < axes; k++) {
if ( axmap[k] == j) {
local->axis_map[k] = i;
map_found = 1;
break;
}
}
if ( !map_found) {
errh_Error( "USB_Joystick, on such axis on this device '%s', '%s'", cop->Identity, cp->Name);
op->Status = IO__INITFAIL;
return IO__INITFAIL;
}
name_found = 1;
break;
}
}
if ( !name_found) {
errh_Error( "USB_Joystick, axis name doesn't exist '%s', '%s'", cop->Identity, cp->Name);
op->Status = IO__INITFAIL;
return IO__INITFAIL;
}
io_AiRangeToCoef( &cp->chanlist[i]);
break;
}
case pwr_cClass_ChanIi: {
pwr_sClass_ChanIi *cop = (pwr_sClass_ChanIi *)cp->chanlist[i].cop;
/* Map channel */
for ( j = 0; j < ABS_MAX; j++) {
if ( cdh_NoCaseStrcmp( axis_names[j], cop->Identity) == 0) {
for ( k = 0; k < axes; k++) {
if ( axmap[k] == j) {
local->axis_map[k] = i;
map_found = 1;
break;
}
}
if ( !map_found) {
errh_Error( "USB_Joystick, on such axis on this device '%s', '%s'", cop->Identity, cp->Name);
op->Status = IO__INITFAIL;
return IO__INITFAIL;
}
name_found = 1;
break;
}
}
if ( !name_found) {
errh_Error( "USB_Joystick, axis name doesn't exist '%s', '%s'", cop->Identity, cp->Name);
op->Status = IO__INITFAIL;
return IO__INITFAIL;
}
break;
}
case pwr_cClass_ChanDi: {
pwr_sClass_ChanDi *cop = (pwr_sClass_ChanDi *)cp->chanlist[i].cop;
/* Map channel */
for ( j = 0; j < KEY_MAX - BTN_MISC; j++) {
if ( button_names[j] == 0)
break;
if ( cdh_NoCaseStrcmp( button_names[j], cop->Identity) == 0) {
for ( k = 0; k < buttons; k++) {
if ( btnmap[k] - BTN_MISC == j) {
local->button_map[k] = i;
map_found = 1;
break;
}
}
if ( !map_found) {
errh_Error( "USB_Joystick, on such button on this device '%s', '%s'", cop->Identity, cp->Name);
op->Status = IO__INITFAIL;
return IO__INITFAIL;
}
name_found = 1;
break;
}
}
if ( !name_found) {
errh_Error( "USB_Joystick, button name doesn't exist '%s', '%s'", cop->Identity, cp->Name);
op->Status = IO__INITFAIL;
return IO__INITFAIL;
}
break;
}
default:
errh_Error( "USB_Joystick, channel type error, '%s'", cp->Name);
op->Status = IO__INITFAIL;
return IO__INITFAIL;
}
}
}
errh_Info( "Init of USB_Joystick '%s'", cp->Name);
op->Status = IO__SUCCESS;
return IO__SUCCESS;
}
static pwr_tStatus IoCardClose( io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp)
{
io_sLocalUSB_Joystick *local = (io_sLocalUSB_Joystick *)cp->Local;
close( local->fd);
if ( cp->Local)
free( cp->Local);
return IO__SUCCESS;
}
static pwr_tStatus IoCardRead( io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp)
{
io_sLocalUSB_Joystick *local = (io_sLocalUSB_Joystick *)cp->Local;
pwr_sClass_USB_Joystick *op = (pwr_sClass_USB_Joystick *)cp->op;
struct js_event js;
int idx;
int value;
while (1) {
while ( read( local->fd, &js, sizeof(struct js_event)) == sizeof(struct js_event)) {
// printf("Event: type %d, time %d, number %d, value %d\n", js.type, js.time, js.number, js.value);
switch ( js.type) {
case 129:
case 1:
/* Buttons */
idx = js.number;
if ( js.number < KEY_MAX - BTN_MISC)
idx = local->button_map[js.number];
else
break;
*(pwr_tBoolean *)cp->chanlist[idx].vbp = (js.value != 0);
break;
case 130:
case 2: {
io_sChannel *chanp;
pwr_sClass_ChanAi *cop;
pwr_sClass_Ai *sop;
pwr_tFloat32 actvalue;
int ivalue;
/* Axes */
idx = js.number;
value = js.value;
if ( js.number < ABS_MAX) {
idx = local->axis_map[js.number];
ivalue = js.value;
}
else
break;
chanp = &cp->chanlist[idx];
cop = (pwr_sClass_ChanAi *)chanp->cop;
sop = (pwr_sClass_Ai *)chanp->sop;
if ( cop->CalculateNewCoef)
// Request to calculate new coefficients
io_AiRangeToCoef( chanp);
io_ConvertAi( cop, ivalue, &actvalue);
// 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;
sop->SigValue = cop->SigValPolyCoef1 * ivalue + cop->SigValPolyCoef0;
sop->RawValue = ivalue;
break;
}
}
}
if (errno != EAGAIN) {
op->ErrorCount++;
}
}
if ( op->ErrorCount == op->ErrorSoftLimit) {
errh_Warning( "IO Card ErrorSoftLimit reached, '%s'", cp->Name);
}
if ( op->ErrorCount >= op->ErrorHardLimit) {
errh_Error( "IO Card ErrorHardLimit reached '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
return IO__SUCCESS;
}
/* Every method should be registred here. */
pwr_dExport pwr_BindIoMethods(USB_Joystick) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardRead),
pwr_NullMethod
};
......@@ -14,4 +14,5 @@ USB_Agent
Velleman_K8055_Board
Hilscher_cifX_Master
Hilscher_cifX_Module
USB_Joystick
#endif
\ No newline at end of file
Volume OtherIO $ClassVolume 0.0.250.10
Body SysBody 01-JAN-1970 01:00:00.00
Attr NextOix = "_X212"
Attr NextCix = "_X21"
Attr NextOix = "_X224"
Attr NextCix = "_X23"
Attr NextTix[0] = "_X10"
EndBody
Object Type $TypeHier 1 15-NOV-2007 14:35:37.90
......@@ -2624,9 +2624,9 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndBody
EndObject
!/**
! @Summary Error count of the board.
! ErrorCount will increase when a communication error or error status is received.
! When ErrorCount reaches the ErrorLimit all inputs are reset to zero.
! Error counter, incremented for every failed read operation of the card.
! When the error counter reaches ErrorSoftLimit, a message is sent to the console log.
! When it reaches ErrorHardLimit, all IO handling is aborted.
!*/
Object ErrorCount $Attribute 18 13-DEC-2010 21:52:48.18
Body SysBody 13-DEC-2010 21:52:57.58
......@@ -2635,9 +2635,7 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndBody
EndObject
!/**
! @Summary Error limit of the server.
! ErrorCount will increase every cycle if status is not MB__NORMAL.
! When ErrorCount reaches the ErrorLimit all inputs are reset to zero.
! Value of the error counter, when a message is sent to the console log.
!*/
Object ErrorSoftLimit $Attribute 19 13-DEC-2010 21:53:15.14
Body SysBody 13-DEC-2010 21:53:20.46
......@@ -2645,6 +2643,9 @@ Volume OtherIO $ClassVolume 0.0.250.10
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Value of the error counter, when all IO handling is aborted.
!*/
Object ErrorHardLimit $Attribute 20 13-DEC-2010 21:53:29.66
Body SysBody 13-DEC-2010 21:53:34.59
Attr PgmName = "ErrorHardLimit"
......@@ -2744,6 +2745,21 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndBody
EndObject
EndObject
Object ConfiguratorPoson $Menu 222 13-MAY-2011 13:09:08.36
Object Pointed $Menu 223 13-MAY-2011 13:09:08.36
Object Connect $MenuButton 224 13-MAY-2011 13:09:08.36
Body SysBody 13-MAY-2011 13:09:08.36
Attr ButtonName = "Connect PlcThread"
Attr MethodName = "$Objid-Connect"
Attr MethodArguments[0] = "ThreadObject"
Attr MethodArguments[1] = "PlcThread"
Attr FilterName = "$Objid-IsOkConnect"
Attr FilterArguments[0] = "ThreadObject"
Attr FilterArguments[1] = "PlcThread"
EndBody
EndObject
EndObject
EndObject
Object PostCreate $DbCallBack 149 13-DEC-2010 21:36:40.01
Body SysBody 13-DEC-2010 21:36:40.01
Attr MethodName = "BaseIOCard-PostCreate"
......@@ -2786,13 +2802,15 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndObject
Object FirmwareName $Attribute 15 11-MAR-2011 11:13:13.95
Body SysBody 11-MAR-2011 11:13:29.65
Attr Flags = 16778240
Attr PgmName = "FirmwareName"
Attr Flags = 1024
Attr TypeRef = "pwrs:Type-$String40"
EndBody
EndObject
Object FirmwareVersion $Attribute 16 11-MAR-2011 11:13:42.31
Body SysBody 11-MAR-2011 11:13:32.93
Attr Flags = 16778240
Attr PgmName = "FirmwareVersion"
Attr Flags = 1024
Attr TypeRef = "pwrs:Type-$String40"
EndBody
EndObject
......@@ -2945,6 +2963,11 @@ Volume OtherIO $ClassVolume 0.0.250.10
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
!/**
! Error counter, incremented for every failed read operation of the card.
! When the error counter reaches ErrorSoftLimit, a message is sent to the console log.
! When it reaches ErrorHardLimit, all IO handling is aborted.
!*/
Object ErrorCount $Attribute 8 07-MAR-2011 08:39:54.17
Body SysBody 07-MAR-2011 08:40:02.94
Attr PgmName = "ErrorCount"
......@@ -2958,12 +2981,18 @@ Volume OtherIO $ClassVolume 0.0.250.10
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Value of the error counter, when a message is sent to the console log.
!*/
Object ErrorSoftLimit $Attribute 9 07-MAR-2011 08:40:26.77
Body SysBody 07-MAR-2011 08:40:28.83
Attr PgmName = "ErrorSoftLimit"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Value of the error counter, when all IO handling is aborted.
!*/
Object ErrorHardLimit $Attribute 10 07-MAR-2011 08:40:39.64
Body SysBody 07-MAR-2011 08:40:40.71
Attr PgmName = "ErrorHardLimit"
......@@ -3220,5 +3249,414 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndBody
EndObject
EndObject
!/**
! @Version 1.0
! @Group IO
! @Summary Card object for USB Joystick
! Card object for USB Joystick.
!
! The object is configured as a child to a generic Rack object,
! eg BaseIORack.
!
! Channel objects configuring the axes and buttons of the joystick
! are placed as children to the USB_Joystick object. The USB_Joystick
! can also work as a super class to joystick classes containg the channel
! objects as internal objects.
!
! The axes are configured by ChanAi or ChanIi objects, and the buttons by
! ChanDi objects. The Identity attribute in each channel should be set to
! the name of the corresponding axis or button.
!
! Use the program rt_joystick to examine the configuration of the joystick.
!
! The following identity names are supported:
! Axes: X, Y, Z, Rx, Ry, Rz, Throttle, Rudder, Wheel, Gas, Brake,
! Hat0X, Hat0Y, Hat1X, Hat1Y, Hat2X, Hat2Y, Hat3X, Hat3Y
! Buttons: Btn0, Btn1, Btn2, Btn3, Btn4, Btn5, Btn6, Btn7, Btn8, Btn9
! LeftBtn, RightBtn, MiddleBtn, SideBtn, ExtraBtn, ForwardBtn,
! BackBtn, TaskBtn, Trigger, ThumbBtn, ThumbBtn2, TopBtn, TopBtn2,
! PinkieBtn, BaseBtn, BaseBtn2, BaseBtn3, BaseBtn4, BaseBtn5,
! BaseBtn6, BtnDead, BtnA, BtnB, BtnC, BtnX, BtnY, BtnZ, BtnTL,
! BtnTR, BtnTL2, BtnTR2, BtnSelect, BtnStart, BtnMode, BtnThumbL,
! BtnThumbR", WheelBtn, Gear up.
!
! @b See also
! @classlink BaseIORack basecomponent_baseiorack.html
!*/
Object USB_Joystick $ClassDef 21 13-MAY-2011 13:05:09.22
Body SysBody 13-MAY-2011 13:04:51.42
Attr Editor = 0
Attr Method = 0
Attr Flags = 51280
EndBody
Object RtBody $ObjBodyDef 1 13-MAY-2011 13:04:51.42
Body SysBody 13-MAY-2011 13:05:27.96
Attr StructName = "USB_Joystick"
Attr NextAix = "_X40"
EndBody
!/**
! Optional description.
!*/
Object Description $Attribute 25 13-MAY-2011 13:04:51.42
Body SysBody 13-MAY-2011 13:04:51.42
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Specification of the joystick.
!*/
Object Specification $Attribute 26 13-MAY-2011 13:04:51.42
Body SysBody 13-MAY-2011 13:04:51.42
Attr PgmName = "Specification"
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Datasheet URL.
!*/
Object DataSheet $Attribute 27 13-MAY-2011 13:04:51.42
Body SysBody 13-MAY-2011 13:04:51.42
Attr PgmName = "DataSheet"
Attr TypeRef = "pwrs:Type-$URL"
EndBody
EndObject
!/**
! Device name of the USB joystick, e.g. /dev/input/js0.
!*/
Object Device $Attribute 28 13-MAY-2011 13:04:51.42
Body SysBody 13-MAY-2011 13:04:51.42
Attr PgmName = "Device"
Attr TypeRef = "pwrs:Type-$String40"
EndBody
EndObject
!/**
! @Summary Process that handles the module. Plc(1), rt_io_comm(2) or application process(4).
! Process that handles the module.
!
! 1: The module is read by the plc process, and is handled by a specific
! thread in the plc, which is specified in the ThreadObject attribute.
! 2: The module is read by the rt_io_comm process.
! 4: The module is handled by an application program.
!*/
Object Process $Attribute 29 13-MAY-2011 13:04:51.42
Body SysBody 13-MAY-2011 13:04:51.42
Attr PgmName = "Process"
Attr TypeRef = "pwrb:Type-IoProcessMask"
EndBody
EndObject
!/**
! @Summary Plc thread that handles the card.
! The PlcThread object of the plc thread that handles the card.
! The card is read with the scantime of the thread.
!*/
Object ThreadObject $Attribute 30 13-MAY-2011 13:04:51.42
Body SysBody 13-MAY-2011 13:04:51.42
Attr PgmName = "ThreadObject"
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
!/**
! Error counter, incremented for every failed read operation of the card.
! When the error counter reaches ErrorSoftLimit, a message is sent to the console log.
! When it reaches ErrorHardLimit, all IO handling is aborted.
!*/
Object ErrorCount $Attribute 31 13-MAY-2011 13:04:51.42
Body SysBody 13-MAY-2011 13:04:51.42
Attr PgmName = "ErrorCount"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Value of the error counter, when a message is sent to the console log.
!*/
Object ErrorSoftLimit $Attribute 32 13-MAY-2011 13:04:51.42
Body SysBody 13-MAY-2011 13:04:51.42
Attr PgmName = "ErrorSoftLimit"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Value of the error counter, when all IO handling is aborted.
!*/
Object ErrorHardLimit $Attribute 33 13-MAY-2011 13:04:51.42
Body SysBody 13-MAY-2011 13:04:51.42
Attr PgmName = "ErrorHardLimit"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Current status of the joystick communication.
!*/
Object Status $Attribute 34 13-MAY-2011 13:04:51.42
Body SysBody 13-MAY-2011 13:06:42.48
Attr PgmName = "Status"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
EndObject
Object IoMethods $RtMethod 213 13-MAY-2011 13:04:51.42
Object IoCardInit $Method 214 13-MAY-2011 13:04:51.42
Body SysBody 13-MAY-2011 13:08:13.33
Attr MethodName = "USB_Joystick-IoCardInit"
EndBody
EndObject
Object IoCardClose $Method 215 13-MAY-2011 13:04:51.42
Body SysBody 13-MAY-2011 13:08:23.97
Attr MethodName = "USB_Joystick-IoCardClose"
EndBody
EndObject
Object IoCardRead $Method 216 13-MAY-2011 13:04:51.42
Body SysBody 13-MAY-2011 13:08:30.14
Attr MethodName = "USB_Joystick-IoCardRead"
EndBody
EndObject
EndObject
Object ConfiguratorPoson $Menu 219 13-MAY-2011 13:08:50.00
Object Pointed $Menu 220 13-MAY-2011 13:08:50.00
Object Connect $MenuButton 221 13-MAY-2011 13:08:50.00
Body SysBody 13-MAY-2011 13:08:50.00
Attr ButtonName = "Connect PlcThread"
Attr MethodName = "$Objid-Connect"
Attr MethodArguments[0] = "ThreadObject"
Attr MethodArguments[1] = "PlcThread"
Attr FilterName = "$Objid-IsOkConnect"
Attr FilterArguments[0] = "ThreadObject"
Attr FilterArguments[1] = "PlcThread"
EndBody
EndObject
EndObject
EndObject
Object PostCreate $DbCallBack 218 13-MAY-2011 13:04:51.42
Body SysBody 13-MAY-2011 13:04:51.42
Attr MethodName = "BaseIOCard-PostCreate"
EndBody
EndObject
Object Template USB_Joystick 2153218048 01-JAN-1970 01:00:00.00
Body RtBody 01-JAN-1970 01:00:00.00
EndBody
EndObject
EndObject
!/**
! @Version 1.0
! @Group IO
! @Summary Card object for USB Joystick Code Mercanaries JoyWarrior
! Card object for USB Joystick Code Marcenaries JoyWarrior with
! 3 axes and 8 buttons.
!
! The object is configured as a child to a generic Rack object.
!
! @b See also
! @classlink USB_Joystick otherio_usb_joystick.html
! @classlink BaseIORack basecomponent_baseiorack.html
!*/
Object CodeMerc_JoyWarriorA3B8 $ClassDef 22 13-MAY-2011 17:19:23.80
Body SysBody 13-MAY-2011 17:19:48.09
Attr Editor = 0
Attr Method = 0
Attr Flags = 18448
EndBody
Object RtBody $ObjBodyDef 1 13-MAY-2011 17:19:38.74
Body SysBody 13-MAY-2011 17:19:38.74
Attr StructName = "CodeMerc_JoyWarriorA3B8"
Attr NextAix = "_X13"
EndBody
!/**
! Super object.
!*/
Object Super $Attribute 1 13-MAY-2011 17:19:58.91
Body SysBody 13-MAY-2011 17:20:14.58
Attr PgmName = "Super"
Attr Flags = 393216
Attr TypeRef = "OtherIO:Class-USB_Joystick"
EndBody
EndObject
!/**
! Ai channel for axis X.
!*/
Object AiX $Attribute 2 13-MAY-2011 17:20:55.28
Body SysBody 13-MAY-2011 17:21:09.93
Attr PgmName = "AiX"
Attr Flags = 131072
Attr TypeRef = "pwrb:Class-ChanAi"
EndBody
EndObject
!/**
! Ai channel for axis Y.
!*/
Object AiY $Attribute 4 13-MAY-2011 17:21:20.84
Body SysBody 13-MAY-2011 17:21:14.27
Attr PgmName = "AiY"
Attr Flags = 131072
Attr TypeRef = "pwrb:Class-ChanAi"
EndBody
EndObject
!/**
! Ai channel for axis Z.
!*/
Object AiZ $Attribute 3 13-MAY-2011 17:21:30.36
Body SysBody 13-MAY-2011 17:21:13.24
Attr PgmName = "AiZ"
Attr Flags = 131072
Attr TypeRef = "pwrb:Class-ChanAi"
EndBody
EndObject
!/**
! Di channel for button Trigger.
!*/
Object Di1 $Attribute 5 13-MAY-2011 17:53:59.29
Body SysBody 13-MAY-2011 17:54:00.33
Attr PgmName = "Di1"
Attr Flags = 131072
Attr TypeRef = "pwrb:Class-ChanDi"
EndBody
EndObject
!/**
! Di channel for button ThumbBtn.
!*/
Object Di2 $Attribute 6 13-MAY-2011 17:53:53.66
Body SysBody 13-MAY-2011 17:53:55.30
Attr PgmName = "Di2"
Attr Flags = 131072
Attr TypeRef = "pwrb:Class-ChanDi"
EndBody
EndObject
!/**
! Di channel for button ThumbBtn2.
!*/
Object Di3 $Attribute 7 13-MAY-2011 17:53:44.08
Body SysBody 13-MAY-2011 17:53:46.78
Attr PgmName = "Di3"
Attr Flags = 131072
Attr TypeRef = "pwrb:Class-ChanDi"
EndBody
EndObject
!/**
! Di channel for button TopBtn.
!*/
Object Di4 $Attribute 8 13-MAY-2011 17:53:34.34
Body SysBody 13-MAY-2011 17:53:38.23
Attr PgmName = "Di4"
Attr Flags = 131072
Attr TypeRef = "pwrb:Class-ChanDi"
EndBody
EndObject
!/**
! Di channel for button TopBtn2.
!*/
Object Di5 $Attribute 9 13-MAY-2011 17:53:29.14
Body SysBody 13-MAY-2011 17:53:30.49
Attr PgmName = "Di5"
Attr Flags = 131072
Attr TypeRef = "pwrb:Class-ChanDi"
EndBody
EndObject
!/**
! Di channel for button PinkieBtn.
!*/
Object Di6 $Attribute 10 13-MAY-2011 17:53:10.76
Body SysBody 13-MAY-2011 17:53:12.72
Attr PgmName = "Di6"
Attr Flags = 131072
Attr TypeRef = "pwrb:Class-ChanDi"
EndBody
EndObject
!/**
! Di channel for button BaseBtn.
!*/
Object Di7 $Attribute 11 13-MAY-2011 17:53:02.95
Body SysBody 13-MAY-2011 17:53:04.10
Attr PgmName = "Di7"
Attr Flags = 131072
Attr TypeRef = "pwrb:Class-ChanDi"
EndBody
EndObject
!/**
! Di channel for button BaseBtn2.
!*/
Object Di8 $Attribute 12 13-MAY-2011 17:52:56.04
Body SysBody 13-MAY-2011 17:52:57.21
Attr PgmName = "Di8"
Attr Flags = 131072
Attr TypeRef = "pwrb:Class-ChanDi"
EndBody
EndObject
EndObject
Object Template CodeMerc_JoyWarriorA3B8 2153480192 01-JAN-1970 01:00:00.00
Body RtBody 13-MAY-2011 17:54:50.23
Attr Super.Specification = "Joystick Code Mercenaries JoyWarrior"
Attr Super.Process = 1
Attr Super.ErrorSoftLimit = 25
Attr Super.ErrorHardLimit = 50
Attr AiX.Description = "Axis X"
Attr AiX.Identity = "X"
Attr AiX.ConversionOn = 1
Attr AiX.ScanInterval = 1
Attr AiX.RawValRangeLow = -3.276800e+04
Attr AiX.RawValRangeHigh = 3.276700e+04
Attr AiX.ChannelSigValRangeLow = -5.000000e+00
Attr AiX.ChannelSigValRangeHigh = 5.000000e+00
Attr AiX.SigValueUnit = "V"
Attr AiX.SensorPolyType = 1
Attr AiX.SensorSigValRangeLow = -5.000000e+00
Attr AiX.SensorSigValRangeHigh = 5.000000e+00
Attr AiX.ActValRangeLow = -1.000000e+02
Attr AiX.ActValRangeHigh = 1.000000e+02
Attr AiY.Description = "Axis Y"
Attr AiY.Identity = "Y"
Attr AiY.ConversionOn = 1
Attr AiY.ScanInterval = 1
Attr AiY.RawValRangeLow = -3.276800e+04
Attr AiY.RawValRangeHigh = 3.276700e+04
Attr AiY.ChannelSigValRangeLow = -5.000000e+00
Attr AiY.ChannelSigValRangeHigh = 5.000000e+00
Attr AiY.SigValueUnit = "V"
Attr AiY.SensorPolyType = 1
Attr AiY.SensorSigValRangeLow = -5.000000e+00
Attr AiY.SensorSigValRangeHigh = 5.000000e+00
Attr AiY.ActValRangeLow = -1.000000e+02
Attr AiY.ActValRangeHigh = 1.000000e+02
Attr AiZ.Description = "Axis Z"
Attr AiZ.Identity = "Z"
Attr AiZ.ConversionOn = 1
Attr AiZ.ScanInterval = 1
Attr AiZ.RawValRangeLow = -3.276800e+04
Attr AiZ.RawValRangeHigh = 3.276700e+04
Attr AiZ.ChannelSigValRangeLow = -5.000000e+00
Attr AiZ.ChannelSigValRangeHigh = 5.000000e+00
Attr AiZ.SigValueUnit = "V"
Attr AiZ.SensorPolyType = 1
Attr AiZ.SensorSigValRangeLow = -5.000000e+00
Attr AiZ.SensorSigValRangeHigh = 5.000000e+00
Attr AiZ.ActValRangeLow = -1.000000e+02
Attr AiZ.ActValRangeHigh = 1.000000e+02
Attr Di1.Description = "Button Trigger"
Attr Di1.Identity = "Trigger"
Attr Di1.ConversionOn = 1
Attr Di2.Description = "Thumb button"
Attr Di2.Identity = "ThumbBtn"
Attr Di2.ConversionOn = 1
Attr Di3.Description = "Thumb button 2"
Attr Di3.Identity = "ThumbBtn2"
Attr Di3.ConversionOn = 1
Attr Di4.Description = "Top button"
Attr Di4.Identity = "TopBtn"
Attr Di4.ConversionOn = 1
Attr Di5.Description = "Top Button 2"
Attr Di5.Identity = "TopBtn2"
Attr Di5.ConversionOn = 1
Attr Di6.Description = "Pinkie button"
Attr Di6.Identity = "PinkieBtn"
Attr Di6.ConversionOn = 1
Attr Di7.Description = "Base button"
Attr Di7.Identity = "BaseBtn"
Attr Di7.ConversionOn = 1
Attr Di8.Description = "Base button 2"
Attr Di8.Identity = "BaseBtn2"
Attr Di8.ConversionOn = 1
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