Commit aa2abb46 authored by Claes Sjofors's avatar Claes Sjofors

Merge branch 'master' of pwrcvs:/data1/git/pwr

parents 93b7e501 60e10402
/*
* 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_agent.c -- I/O methods for class USB_Agent. */
#include "pwr.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_otherioclasses.h"
#include "rt_io_base.h"
#include "rt_io_agent_init.h"
#include "rt_io_agent_close.h"
#include "rt_io_msg.h"
#if defined PWRE_CONF_LIBUSB
#include <libusb-1.0/libusb.h>
#include "rt_io_m_usb_agent.h"
static pwr_tStatus IoAgentInit( io_tCtx ctx,
io_sAgent *ap)
{
io_sLocalUSB_Agent *local;
int sts;
pwr_sClass_USB_Agent *op = (pwr_sClass_USB_Agent *)ap->op;
local = (io_sLocalUSB_Agent *) calloc( 1, sizeof(io_sLocalUSB_Agent));
ap->Local = local;
sts = libusb_init( &local->libusb_ctx);
if ( sts != 0) {
op->Status = sts;
local->libusb_ctx = 0;
errh_Error( "Init of USB agent failed '%s'", ap->Name);
}
else {
op->Status = IO__SUCCESS;
errh_Info( "Init of USBIO agent '%s'", ap->Name);
}
return IO__SUCCESS;
}
static pwr_tStatus IoAgentClose( io_tCtx ctx,
io_sAgent *ap)
{
io_sLocalUSB_Agent *local = ap->Local;
pwr_sClass_USB_Agent *op = (pwr_sClass_USB_Agent *)ap->op;
libusb_exit( local->libusb_ctx);
op->Status = 0;
free( local);
return IO__SUCCESS;
}
#else
static pwr_tStatus IoAgentInit( io_tCtx ctx, io_sAgent *ap) { return 0;}
static pwr_tStatus IoAgentClose( io_tCtx ctx, io_sAgent *ap) { return 0;}
#endif
/* Every method should be registred here. */
pwr_dExport pwr_BindIoMethods(USB_Agent) = {
pwr_BindIoMethod(IoAgentInit),
pwr_BindIoMethod(IoAgentClose),
pwr_NullMethod
};
/* rt_io_m_usb_agent.h -- I/O methods for class USB_Agent. */
#ifndef ra_io_m_usb_agent_h
#define ra_io_m_usb_agent_h
#if defined PWRE_CONF_LIBUSB
typedef struct {
libusb_context *libusb_ctx;
} io_sLocalUSB_Agent;
#endif
#endif
/*
* Proview $Id$
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* rt_io_m_velleman_k8055_board.c -- I/O methods for class Velleman_K8055_Board. */
#include "pwr.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_otherioclasses.h"
#include "co_time.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_card_write.h"
#include "rt_io_msg.h"
#if defined PWRE_CONF_LIBUSB
#include <libusb-1.0/libusb.h>
#include "rt_io_m_usb_agent.h"
#include "rt_io_m_velleman_k8055_board.h"
static pwr_tStatus IoCardInit( io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp)
{
ssize_t devnum;
libusb_device **list;
libusb_device *device = 0;
int found = 0;
int i;
io_sLocalUSB_Agent *local_agent = (io_sLocalUSB_Agent *)ap->Local;
io_sLocal_K8055 *local;
pwr_sClass_Velleman_K8055_Board *op = (pwr_sClass_Velleman_K8055_Board *)cp->op;
int sts;
if ( !local_agent->libusb_ctx)
return IO__INITFAIL;
devnum = libusb_get_device_list( local_agent->libusb_ctx, &list);
if ( devnum > 0) {
for ( i = 0; i < devnum; i++) {
struct libusb_device_descriptor desc;
if ( libusb_get_device_descriptor( list[i], &desc) != 0)
continue;
if ( desc.idVendor == 0x10cf &&
desc.idProduct == 0x5500 + op->Super.Address) {
device = list[i];
found = 1;
break;
}
}
}
if ( !found) {
errh_Error( "Init Velleman K8055, device not found '%s'", cp->Name);
op->Status = IO__NODEVICE;
((pwr_sClass_Velleman_K8055 *)rp->op)->Status = op->Status;
return IO__INITFAIL;
}
local = (io_sLocal_K8055 *) calloc( 1, sizeof(io_sLocal_K8055));
cp->Local = local;
sts = libusb_open( device, &local->libusb_device);
if ( sts != 0) {
op->Status = IO__INITFAIL;
((pwr_sClass_Velleman_K8055 *)rp->op)->Status = op->Status;
local->libusb_device = 0;
return IO__INITFAIL;
}
if ( libusb_kernel_driver_active( local->libusb_device, 0) != 0)
libusb_detach_kernel_driver( local->libusb_device, 0);
sts = libusb_claim_interface( local->libusb_device, 0);
if ( sts < 0) {
errh_Error( "K8055 Claim interface failed, sts %d, '%s'", sts, ap->Name);
op->Status = IO__INITFAIL;
((pwr_sClass_Velleman_K8055 *)rp->op)->Status = op->Status;
return IO__INITFAIL;
}
for ( i = 0; i < 2; i++) {
if ( cp->chanlist[i].sop)
io_AiRangeToCoef( &cp->chanlist[i]);
}
for ( i = 0; i < 2; i++) {
if ( cp->chanlist[i+7].sop)
io_AoRangeToCoef( &cp->chanlist[i+7]);
}
errh_Info( "Init of Velleman K8055 '%s'", cp->Name);
op->Status = IO__SUCCESS;
// Rack has no methods, set status
if ( ((pwr_sClass_Velleman_K8055 *)rp->op)->Status == 0)
((pwr_sClass_Velleman_K8055 *)rp->op)->Status = op->Status;
return IO__SUCCESS;
}
static pwr_tStatus IoCardClose( io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp)
{
io_sLocalUSB_Agent *local_agent = (io_sLocalUSB_Agent *)ap->Local;
io_sLocal_K8055 *local = (io_sLocal_K8055 *)cp->Local;
if ( !local_agent->libusb_ctx)
return IO__SUCCESS;
if ( local->libusb_device)
libusb_close( local->libusb_device);
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_sLocal_K8055 *local = (io_sLocal_K8055 *)cp->Local;
pwr_sClass_Velleman_K8055_Board *op = (pwr_sClass_Velleman_K8055_Board *)cp->op;
unsigned char data[9];
char endpoint = 0x81;
int size = 8;
int tsize;
unsigned char m;
int sts;
int i;
pwr_tUInt32 error_count = op->Super.ErrorCount;
// You have to read twice to get the latest ?????
sts = libusb_interrupt_transfer( local->libusb_device, endpoint, data, 8, &tsize, 20);
sts = libusb_interrupt_transfer( local->libusb_device, endpoint, data, 8, &tsize, 20);
if ( sts != 0 || tsize != size) {
op->Super.ErrorCount++;
return IO__SUCCESS;
}
else {
// Handle Ai
for ( i = 0; i < 2; i++) {
if ( cp->chanlist[i].sop) {
io_sChannel *chanp = &cp->chanlist[i];
pwr_sClass_ChanAi *cop = (pwr_sClass_ChanAi *)chanp->cop;
pwr_sClass_Ai *sop = (pwr_sClass_Ai *)chanp->sop;
pwr_tFloat32 actvalue;
int ivalue = data[i+2];
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;
}
}
// Handle Di
for ( i = 0; i < 5; i++) {
switch ( i) {
case 0: m = 16; break;
case 1: m = 32; break;
case 2: m = 1; break;
case 3: m = 64; break;
case 4: m = 128; break;
}
if ( cp->chanlist[i+2].sop)
*(pwr_tBoolean *)cp->chanlist[i+2].vbp = ((data[0] & m) != 0);
}
}
if ( op->Super.ErrorCount >= op->Super.ErrorSoftLimit &&
error_count < op->Super.ErrorSoftLimit) {
errh_Warning( "IO Card ErrorSoftLimit reached, '%s'", cp->Name);
}
if ( op->Super.ErrorCount >= op->Super.ErrorHardLimit) {
errh_Error( "IO Card ErrorHardLimit reached '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
return IO__SUCCESS;
}
static pwr_tStatus IoCardWrite( io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp)
{
io_sLocal_K8055 *local = (io_sLocal_K8055 *)cp->Local;
pwr_sClass_Velleman_K8055_Board *op = (pwr_sClass_Velleman_K8055_Board *)cp->op;
unsigned char data[9];
char endpoint = 0x1;
int size = 8;
int tsize;
unsigned char m;
int i;
int sts;
pwr_tUInt32 error_count = op->Super.ErrorCount;
memset( data, 0, sizeof(data));
data[0] = 0x5;
// Handle Do
m = 1;
unsigned char do_value = 0;
for ( i = 0; i < 8; i++) {
if ( cp->chanlist[i+9].sop) {
if ( *(pwr_tBoolean *)cp->chanlist[i+9].vbp)
do_value |= m;
}
m = m << 1;
}
data[1] = do_value;
// Handle Ao
for ( i = 0; i < 2; i++) {
if ( cp->chanlist[i+7].sop) {
io_sChannel *chanp = &cp->chanlist[i+7];
pwr_sClass_ChanAo *cop = (pwr_sClass_ChanAo *)chanp->cop;
if ( cop->CalculateNewCoef)
// Request to calculate new coefficients
io_AoRangeToCoef( chanp);
float fvalue = *(pwr_tFloat32 *)chanp->vbp * cop->OutPolyCoef1 + cop->OutPolyCoef0;
int ivalue = (int)fvalue;
if ( ivalue < 0)
ivalue = 0;
else if (ivalue > 255)
ivalue = 255;
data[i+2] = ivalue;
}
}
sts = libusb_interrupt_transfer( local->libusb_device, endpoint, data, size, &tsize, 20);
if ( sts != 0 || tsize != size) {
op->Super.ErrorCount++;
return IO__SUCCESS;
}
if ( op->Super.ErrorCount >= op->Super.ErrorSoftLimit &&
error_count < op->Super.ErrorSoftLimit) {
errh_Warning( "IO Card ErrorSoftLimit reached, '%s'", cp->Name);
}
if ( op->Super.ErrorCount >= op->Super.ErrorHardLimit) {
errh_Error( "IO Card ErrorHardLimit reached '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
return IO__ERRDEVICE;
}
return IO__SUCCESS;
}
#else
static pwr_tStatus IoCardInit( io_tCtx ctx,io_sAgent *ap,io_sRack *rp,io_sCard *cp) {return 0;}
static pwr_tStatus IoCardClose( io_tCtx ctx,io_sAgent *ap,io_sRack *rp,io_sCard *cp) {return 0;}
static pwr_tStatus IoCardRead( io_tCtx ctx,io_sAgent *ap,io_sRack *rp,io_sCard *cp) {return 0;}
static pwr_tStatus IoCardWrite( io_tCtx ctx,io_sAgent *ap,io_sRack *rp,io_sCard *cp) {return 0;}
#endif
/* Every method should be registred here. */
pwr_dExport pwr_BindIoMethods(Velleman_K8055_Board) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardClose),
pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
/* rt_io_m_velleman_k8055_board.h -- I/O methods for class velleman_k8055_board. */
#ifndef ra_io_m_velleman_k8055_board_h
#define ra_io_m_velleman_k8055_board_h
#if defined PWRE_CONF_LIBUSB
typedef struct {
libusb_device_handle *libusb_device;
} io_sLocal_K8055;
#endif
#endif
......@@ -7,3 +7,5 @@ Modbus_TCP_Server
Modbus_TCP_ServerModule
GPIO
GPIO_Module
USB_Agent
Velleman_K8055_Board
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
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
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
/*
Dummy for libusb-1.0
*/
#include <sys/types.h>
#include <stdint.h>
struct libusb_context;
struct libusb_device;
struct libusb_device_handle;
typedef struct libusb_context libusb_context;
typedef struct libusb_device libusb_device;
typedef struct libusb_device_handle libusb_device_handle;
struct libusb_device_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint16_t bcdUSB;
uint8_t bDeviceClass;
uint8_t bDeviceSubClass;
uint8_t bDeviceProtocol;
uint8_t bMaxPacketSize0;
uint16_t idVendor;
uint16_t idProduct;
uint16_t bcdDevice;
uint8_t iManufacturer;
uint8_t iProduct;
uint8_t iSerialNumber;
uint8_t bNumConfigurations;
};
int libusb_init(libusb_context **ctx) {return 0;}
void libusb_exit(libusb_context *ctx) {}
ssize_t libusb_get_device_list(libusb_context *ctx,
libusb_device ***list) {return 0;}
void libusb_free_device_list(libusb_device **list, int unref_devices) {}
int libusb_open(libusb_device *dev, libusb_device_handle **handle) {return 0;}
void libusb_close(libusb_device_handle *dev_handle) {}
int libusb_interrupt_transfer(libusb_device_handle *dev_handle,
unsigned char endpoint, unsigned char *data, int length,
int *actual_length, unsigned int timeout) {return 0;}
int libusb_kernel_driver_active(libusb_device_handle *dev, int interface) {return 0;}
int libusb_detach_kernel_driver(libusb_device_handle *dev, int interface) {return 0;}
int libusb_claim_interface(libusb_device_handle *dev, int iface) {return 0;}
int libusb_get_device_descriptor(libusb_device *dev,
struct libusb_device_descriptor *desc) {return 0;}
Volume OtherIO $ClassVolume 0.0.250.10
Body SysBody 01-JAN-1970 01:00:00.00
Attr NextOix = "_X91"
Attr NextCix = "_X10"
Attr NextOix = "_X111"
Attr NextCix = "_X13"
Attr NextTix[0] = "_X5"
EndBody
Object Type $TypeHier 1 15-NOV-2007 14:35:37.90
......@@ -1463,18 +1463,35 @@ Volume OtherIO $ClassVolume 0.0.250.10
Attr StructName = "GPIO"
Attr NextAix = "_X17"
EndBody
!/**
! Optional description.
!*/
Object Description $Attribute 13 15-APR-2010 21:46:16.74
Body SysBody 15-APR-2010 21:46:16.74
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
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 14 15-APR-2010 21:46:16.74
Body SysBody 15-APR-2010 21:54:44.41
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 15 15-APR-2010 21:46:16.74
Body SysBody 15-APR-2010 21:46:16.74
Attr PgmName = "ThreadObject"
......@@ -1533,18 +1550,35 @@ Volume OtherIO $ClassVolume 0.0.250.10
Attr StructName = "GPIO_Module"
Attr NextAix = "_X15"
EndBody
!/**
! Optional description.
!*/
Object Description $Attribute 10 15-APR-2010 21:53:54.03
Body SysBody 15-APR-2010 21:54:16.96
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
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 11 15-APR-2010 21:54:37.62
Body SysBody 15-APR-2010 21:54:53.56
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 13 15-APR-2010 21:55:05.81
Body SysBody 15-APR-2010 21:55:05.81
Attr PgmName = "ThreadObject"
......@@ -1593,5 +1627,382 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndBody
EndObject
EndObject
!/**
! @Version 1.0
! @Group IO
! @Summary Agent object for USB devices.
! Agent object for USB devices.
!
! Agent object for USB devices that is connected by libusb in user space and
! not by a driver.
!*/
Object USB_Agent $ClassDef 10 23-MAY-2010 11:38:20.57
Body SysBody 23-MAY-2010 11:38:42.06
Attr Editor = 0
Attr Method = 0
Attr Flags = 6224
EndBody
Object RtBody $ObjBodyDef 1 23-MAY-2010 11:38:08.72
Body SysBody 23-MAY-2010 11:38:33.38
Attr StructName = "USB_Agent"
Attr NextAix = "_X21"
EndBody
!/**
! Optional description.
!*/
Object Description $Attribute 17 23-MAY-2010 11:38:08.72
Body SysBody 23-MAY-2010 11:38:08.72
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
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 18 23-MAY-2010 11:38:08.72
Body SysBody 23-MAY-2010 11:38:08.72
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 19 23-MAY-2010 11:38:08.72
Body SysBody 23-MAY-2010 11:38:08.72
Attr PgmName = "ThreadObject"
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
!/**
! Agent status.
!*/
Object Status $Attribute 20 23-MAY-2010 11:38:08.72
Body SysBody 23-MAY-2010 11:38:08.72
Attr PgmName = "Status"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$Status"
EndBody
EndObject
EndObject
Object ConfiguratorPoson $Menu 92 23-MAY-2010 11:38:08.72
Object Pointed $Menu 93 23-MAY-2010 11:38:08.72
Object Connect $MenuButton 94 23-MAY-2010 11:38:08.72
Body SysBody 23-MAY-2010 11:38:08.72
Attr ButtonName = "Connect PlcThread"
Attr MethodName = "$Objid-Connect"
Attr MethodArguments[0] = "ThreadObject"
Attr MethodArguments[1] = "PlcThread"
Attr FilterName = "$Objid-IsOkConnect"
Attr FilterArguments[0] = "ThreadObject"
Attr FilterArguments[1] = "PlcThread"
EndBody
EndObject
EndObject
EndObject
Object IoMethods $RtMethod 95 23-MAY-2010 11:38:08.72
Object IoAgentInit $Method 96 23-MAY-2010 11:38:59.12
Body SysBody 23-MAY-2010 11:39:14.06
Attr MethodName = "USB_Agent-IoAgentInit"
EndBody
EndObject
Object IoAgentClose $Method 97 23-MAY-2010 11:39:27.49
Body SysBody 23-MAY-2010 11:40:00.87
Attr MethodName = "USB_Agent-IoAgentClose"
EndBody
EndObject
EndObject
Object Template USB_Agent 2150334464 01-JAN-1970 01:00:00.00
Body RtBody 23-MAY-2010 20:28:40.31
Attr Process = 1
EndBody
EndObject
EndObject
!/**
! @Version 1.0
! @Group IO
! @Summary Rack object for USB board Velleman K8055/VM110
! Rack object for USB board Velleman K8055/VM110.
!
! The object is configured as a child to an USB_Agent object and
! as a parent to Velleman_K8055_Board objects.
!
! @b See also
! @classlink USB_Agent otherio_usb_agent.html
! @classlink Velleman_K8055_Board otherio_velleman_k8055_board.html
!*/
Object Velleman_K8055 $ClassDef 11 23-MAY-2010 11:43:40.18
Body SysBody 23-MAY-2010 11:43:07.03
Attr Editor = 0
Attr Method = 0
Attr Flags = 10320
EndBody
Object RtBody $ObjBodyDef 1 23-MAY-2010 11:43:07.03
Body SysBody 23-MAY-2010 11:45:38.50
Attr StructName = "Velleman_K8055"
Attr NextAix = "_X17"
EndBody
!/**
! Optional description.
!*/
Object Description $Attribute 13 23-MAY-2010 11:43:07.03
Body SysBody 23-MAY-2010 11:43:07.03
Attr PgmName = "Description"
Attr TypeRef = "pwrs:Type-$String80"
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 14 23-MAY-2010 11:43:07.03
Body SysBody 23-MAY-2010 11:43:07.03
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 15 23-MAY-2010 11:43:07.03
Body SysBody 23-MAY-2010 11:43:07.03
Attr PgmName = "ThreadObject"
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
!/**
! Rack status.
!*/
Object Status $Attribute 16 23-MAY-2010 11:43:07.03
Body SysBody 23-MAY-2010 11:45:18.68
Attr PgmName = "Status"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$Status"
EndBody
EndObject
EndObject
Object ConfiguratorPoson $Menu 98 23-MAY-2010 11:43:07.03
Object Pointed $Menu 99 23-MAY-2010 11:43:07.03
Object Connect $MenuButton 100 23-MAY-2010 11:43:07.03
Body SysBody 23-MAY-2010 11:43:07.03
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 Template Velleman_K8055 2150596608 01-JAN-1970 01:00:00.00
Body RtBody 23-MAY-2010 20:28:30.66
Attr Process = 1
EndBody
EndObject
EndObject
!/**
! @Version 1.0
! @Group IO
! @Summary Card object for USB board Velleman K8055/VM110
! Card object for USB board Velleman K8055/VM110.
!
! The object is configured as a child to a Velleman_K8055 object.
!
! The board has
! - 2 analog input channels.
! - 5 digital input channels.
! - 2 analog output channels.
! - 8 digital output channels.
!
! All channel object are specified as internal attributes.
! Only use channels has to be connected to signals.
!
! Four boards can be connected to a station. The address of the boards
! are set with jumpers, SK5 and SK6, and also has to be set in the
! Address attribute. The address is a value between 0 and 3.
!
! Address SK5 SK6
! -----------------
! 0 on on
! 1 off on
! 2 on off
! 3 off off
!
! @b See also
! @classlink USB_Agent otherio_usb_agent.html
! @classlink Velleman_K8055 otherio_velleman_k8055.html
!*/
Object Velleman_K8055_Board $ClassDef 12 23-MAY-2010 11:46:06.66
Body SysBody 23-MAY-2010 11:43:07.03
Attr Editor = 0
Attr Method = 0
Attr Flags = 18448
EndBody
Object RtBody $ObjBodyDef 1 23-MAY-2010 11:47:56.15
Body SysBody 23-MAY-2010 11:46:17.24
Attr StructName = "Velleman_K8055_Board"
Attr NextAix = "_X17"
EndBody
!/**
! Super class.
!*/
Object Super $Attribute 10 23-MAY-2010 11:43:07.03
Body SysBody 23-MAY-2010 11:43:07.03
Attr PgmName = "Super"
Attr Flags = 393216
Attr TypeRef = "BaseComponent:Class-BaseIOCard"
EndBody
EndObject
!/**
! Board status.
!*/
Object Status $Attribute 11 23-MAY-2010 11:43:07.03
Body SysBody 23-MAY-2010 11:47:51.85
Attr PgmName = "Status"
Attr Flags = 1040
Attr TypeRef = "pwrs:Type-$Status"
EndBody
EndObject
!/**
! Array of analog input channels.
!*/
Object ChAi $Attribute 13 23-MAY-2010 11:51:21.44
Body SysBody 23-MAY-2010 11:53:02.11
Attr PgmName = "ChAi"
Attr Flags = 131074
Attr Elements = 2
Attr TypeRef = "pwrb:Class-ChanAi"
EndBody
EndObject
!/**
! Array of digital input channels.
!*/
Object ChDi $Attribute 14 23-MAY-2010 11:51:27.84
Body SysBody 23-MAY-2010 11:53:07.07
Attr PgmName = "ChDi"
Attr Flags = 131074
Attr Elements = 5
Attr TypeRef = "pwrb:Class-ChanDi"
EndBody
EndObject
!/**
! Array of analog output channels.
!*/
Object ChAo $Attribute 15 23-MAY-2010 11:51:32.07
Body SysBody 23-MAY-2010 11:53:13.45
Attr PgmName = "ChAo"
Attr Flags = 131074
Attr Elements = 2
Attr TypeRef = "pwrb:Class-ChanAo"
EndBody
EndObject
!/**
! Array of digital output channels.
!*/
Object ChDo $Attribute 16 23-MAY-2010 11:51:46.23
Body SysBody 23-MAY-2010 11:53:24.70
Attr PgmName = "ChDo"
Attr Flags = 131074
Attr Elements = 8
Attr TypeRef = "pwrb:Class-ChanDo"
EndBody
EndObject
EndObject
Object ConfiguratorPoson $Menu 109 23-MAY-2010 11:49:21.57
Object Pointed $Menu 110 23-MAY-2010 11:49:21.57
Object Connect $MenuButton 111 23-MAY-2010 11:49:21.57
Body SysBody 23-MAY-2010 11:49:21.57
Attr ButtonName = "Connect PlcThread"
Attr MethodName = "$Objid-Connect"
Attr MethodArguments[0] = "ThreadObject"
Attr MethodArguments[1] = "PlcThread"
Attr FilterName = "$Objid-IsOkConnect"
Attr FilterArguments[0] = "ThreadObject"
Attr FilterArguments[1] = "PlcThread"
EndBody
EndObject
EndObject
EndObject
Object IoMethods $RtMethod 104 23-MAY-2010 11:43:07.03
Object IoCardInit $Method 105 23-MAY-2010 11:43:07.03
Body SysBody 23-MAY-2010 11:46:49.51
Attr MethodName = "Velleman_K8055_Board-IoCardInit"
EndBody
EndObject
Object IoCardClose $Method 106 23-MAY-2010 11:43:07.03
Body SysBody 23-MAY-2010 11:47:00.34
Attr MethodName = "Velleman_K8055_Board-IoCardClose"
EndBody
EndObject
Object IoCardRead $Method 107 23-MAY-2010 11:43:07.03
Body SysBody 23-MAY-2010 11:47:07.48
Attr MethodName = "Velleman_K8055_Board-IoCardRead"
EndBody
EndObject
Object IoCardWrite $Method 108 23-MAY-2010 11:43:07.03
Body SysBody 23-MAY-2010 11:47:14.39
Attr MethodName = "Velleman_K8055_Board-IoCardWrite"
EndBody
EndObject
EndObject
Object Template Velleman_K8055_Board 2150858752 01-JAN-1970 01:00:00.00
Body RtBody 23-MAY-2010 20:33:40.04
Attr Super.Process = 1
Attr Super.ErrorSoftLimit = 50
Attr Super.ErrorHardLimit = 100
Attr Super.MaxNoOfChannels = 17
Attr ChAi[0].ConversionOn = 1
Attr ChAi[0].ScanInterval = 1
Attr ChAi[0].RawValRangeHigh = 2.550000e+02
Attr ChAi[0].ChannelSigValRangeHigh = 5.000000e+00
Attr ChAi[0].SigValueUnit = "V"
Attr ChAi[0].SensorPolyType = 1
Attr ChAi[0].SensorSigValRangeHigh = 5.000000e+00
Attr ChAi[0].ActValRangeHigh = 1.000000e+02
Attr ChAi[1].ConversionOn = 1
Attr ChAi[1].ScanInterval = 1
Attr ChAi[1].RawValRangeHigh = 2.550000e+02
Attr ChAi[1].ChannelSigValRangeHigh = 5.000000e+00
Attr ChAi[1].SigValueUnit = "V"
Attr ChAi[1].SensorPolyType = 1
Attr ChAi[1].SensorSigValRangeHigh = 5.000000e+00
Attr ChAi[1].ActValRangeHigh = 1.000000e+02
Attr ChDi[0].ConversionOn = 1
Attr ChDi[1].ConversionOn = 1
Attr ChDi[2].ConversionOn = 1
Attr ChDi[3].ConversionOn = 1
Attr ChDi[4].ConversionOn = 1
Attr ChAo[0].OutPolyType = 1
Attr ChAo[0].ActValRangeHigh = 1.000000e+02
Attr ChAo[0].SensorSigValRangeHigh = 5.000000e+00
Attr ChAo[0].SigValueUnit = "V"
Attr ChAo[0].ChannelSigValRangeHigh = 5.000000e+00
Attr ChAo[0].RawValRangeHigh = 2.550000e+02
Attr ChAo[1].OutPolyType = 1
Attr ChAo[1].ActValRangeHigh = 1.000000e+02
Attr ChAo[1].SensorSigValRangeHigh = 5.000000e+00
Attr ChAo[1].SigValueUnit = "V"
Attr ChAo[1].ChannelSigValRangeHigh = 5.000000e+00
Attr ChAo[1].RawValRangeHigh = 2.550000e+02
EndBody
EndObject
EndObject
EndObject
EndVolume
......@@ -5,11 +5,11 @@ ifeq ($(export_type),exp)
link = $(ld) $(explinkflags) $(domap) -o $(export_exe) \
$(export_obj) $(objects) $(rt_msg_objs) \
$(pwr_obj)/rt_io_user.o \
-lpwr_rt -lpwr_co -lpwr_msg_dummy -lpwr_usbio_dummy -lpthread -lm
-lpwr_rt -lpwr_co -lpwr_msg_dummy -lpwr_usbio_dummy -lpwr_usb_dummy -lpthread -lm
else
link = $(ld) $(elinkflags) $(domap) -o $(export_exe) \
$(export_obj) $(objects) $(rt_msg_objs) \
$(pwr_obj)/rt_io_user.o \
-lpwr_rt -lpwr_co -lpwr_msg_dummy -lpwr_usbio_dummy -lpthread -lm
-lpwr_rt -lpwr_co -lpwr_msg_dummy -lpwr_usbio_dummy -lpwr_usb_dummy -lpthread -lm
endif
endif
......@@ -100,6 +100,7 @@ connectedclass <Incorrect class of connected object> /error
replaced <Symbol is replaced> /info
normal <Normal operating state> /succ
initfail <Initialization failed> /error
nodevice <Device not found> /error
.end
......@@ -109,10 +109,18 @@ else
linkgtk :=
endif
ifeq ($(pwre_conf_libusb),1)
clibusb := -DPWRE_CONF_LIBUSB=1
linklibusb := -lusb-1.0
else
clibusb :=
linklibusb :=
endif
log_done =
csetos := -DOS_LINUX=1 -DOS=linux -D_LINUX -DHW_X86=1 -DHW=x86
cinc := -I$(inc_dir) -I$(einc_dir) -I$(hw_source) -I$(os_source) -I$(co_source) -I/usr/X11R6/include -I$(jdk)/include -I$(jdk)/include/linux \
`pkg-config --cflags gtk+-2.0` -DPREFIX=\"/usr/local\" -DSYSCONFDIR=\"/etc\" -DDATADIR=\"/usr/share\" -DLIBDIR=\"/usr/lib\" $(cmysql) $(cgtk)
`pkg-config --cflags gtk+-2.0` -DPREFIX=\"/usr/local\" -DSYSCONFDIR=\"/etc\" -DDATADIR=\"/usr/share\" -DLIBDIR=\"/usr/lib\" $(cmysql) $(cgtk) $(clibusb)
rm := rm
cp := cp
cpflags :=
......
......@@ -109,10 +109,18 @@ else
linkgtk :=
endif
ifeq ($(pwre_conf_libusb),1)
clibusb := -DPWRE_CONF_LIBUSB=1
linklibusb := -lusb-1.0
else
clibusb :=
linklibusb :=
endif
log_done =
csetos := -DOS_LINUX=1 -DOS=linux -D_LINUX -DHW_X86_64=1 -DHW=x86_64
cinc := -I$(inc_dir) -I$(einc_dir) -I$(hw_source) -I$(os_source) -I$(co_source) -I/usr/X11R6/include -I$(jdk)/include -I$(jdk)/include/linux \
`pkg-config --cflags gtk+-2.0` -DPREFIX=\"/usr/local\" -DSYSCONFDIR=\"/etc\" -DDATADIR=\"/usr/share\" -DLIBDIR=\"/usr/lib\" $(cmysql) $(cgtk)
`pkg-config --cflags gtk+-2.0` -DPREFIX=\"/usr/local\" -DSYSCONFDIR=\"/etc\" -DDATADIR=\"/usr/share\" -DLIBDIR=\"/usr/lib\" $(cmysql) $(cgtk) $(clibusb)
rm := rm
cp := cp
cpflags :=
......
......@@ -158,6 +158,13 @@ set_env()
export pwre_conf_gtk=0
fi
# libusb
if [ -e /usr/lib/libusb-1.0.so ]; then
export pwre_conf_libusb=1
else
export pwre_conf_libusb=0
fi
export pwre_conf_alsa=1
}
......
......@@ -167,7 +167,7 @@ CompileRtNode()
ld_opt_tmp="`cat $pwrp_exe/$FileName.opt`"
ld_opt="`eval echo $ld_opt_tmp`"
else
ld_opt="`eval echo $pwr_obj/rt_io_user.o -lpwr_rt -lpwr_usbio_dummy`"
ld_opt="`eval echo $pwr_obj/rt_io_user.o -lpwr_rt -lpwr_usbio_dummy -lpwr_usb_dummy`"
fi
if $ldxx $link_debug -L/lib/thread -L$pwrp_lib -L$pwrp_cmn/x86_linux/lib -L$pwr_lib \
......
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