Commit eb991f97 authored by Claes Sjofors's avatar Claes Sjofors

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

parents 74b3416a fb2b8db9
......@@ -39,6 +39,8 @@ int i;
int j;
int aiList[32];
int aiCnt;
int aoList[32];
int aoCnt;
byte msgType;
byte msgId;
byte msgSize;
......@@ -52,9 +54,10 @@ const int debug = 0;
const int MSG_TYPE_WRITE = 1;
const int MSG_TYPE_DIREAD = 2;
const int MSG_TYPE_AIREAD = 3;
const int MSG_TYPE_CONFIGURE = 4;
const int MSG_TYPE_STATUS = 5;
const int MSG_TYPE_DEBUG = 6;
const int MSG_TYPE_AOWRITE = 4;
const int MSG_TYPE_CONFIGURE = 5;
const int MSG_TYPE_STATUS = 6;
const int MSG_TYPE_DEBUG = 7;
const int ARD__SUCCESS = 1;
const int ARD__DICONFIG = 2;
......@@ -79,14 +82,14 @@ void sendDebug( byte sts)
//
void resetOutput()
{
if ( msgSize == doSize) {
for ( i = 0; i < doSize; i++) {
for ( j = 0; j < 8; j++) {
if ( ((1 << j) & doMask[i]) != 0)
digitalWrite( i * 8 + j, LOW);
}
for ( i = 0; i < doSize; i++) {
for ( j = 0; j < 8; j++) {
if ( ((1 << j) & doMask[i]) != 0)
digitalWrite( i * 8 + j, LOW);
}
}
for ( i = 0; i < aoCnt; i++)
analogWrite( aoList[i], 0);
}
//
......@@ -176,6 +179,19 @@ void loop()
sts = ARD__COMMERROR;
}
}
else if ( msgType == MSG_TYPE_AOWRITE) {
// Write analog outputs
if ( msgSize == aoSize) {
for ( i = 0; i < aoCnt; i++)
analogWrite( aoList[i], msgData[i]);
sts = ARD__SUCCESS;
}
else {
sts = ARD__COMMERROR;
}
}
else if ( msgType == MSG_TYPE_DIREAD) {
// Read Digital inputs
smsg[0] = diSize + 3;
......@@ -296,6 +312,17 @@ void loop()
}
}
}
// Create list of configured Ao
aoCnt = 0;
for ( i = 0; i < aoSize; i++) {
for ( j = 0; j < 8; j++) {
if ( ((1 << j) & aoMask[i]) != 0) {
aoList[aoCnt] = i * 8 + j;
aoCnt++;
}
}
}
}
// Send configuration status
......
......@@ -51,6 +51,7 @@ typedef struct {
int DiPollId;
int DiPendingPoll;
int AiIntervalCnt;
int AoIntervalCnt;
io_sChannel *DChanList[D_MAX_SIZE * 8];
io_sChannel *AiChanList[AI_MAX_SIZE * 8];
io_sChannel *AoChanList[AO_MAX_SIZE * 8];
......@@ -66,8 +67,9 @@ typedef struct {
#include <termios.h>
static FILE *fp;
// static FILE *fp;
#if 0
static void logg( const char *str)
{
pwr_tTime t;
......@@ -79,14 +81,16 @@ static void logg( const char *str)
fprintf( fp, "%s%04lld %s\n", timstr, t.tv_nsec/100000, str);
}
#endif
typedef enum {
ard_eMsgType_Write = 1,
ard_eMsgType_DiRead = 2,
ard_eMsgType_AiRead = 3,
ard_eMsgType_Configure = 4,
ard_eMsgType_Status = 5,
ard_eMsgType_Debug = 6
ard_eMsgType_AoWrite = 4,
ard_eMsgType_Configure = 5,
ard_eMsgType_Status = 6,
ard_eMsgType_Debug = 7
} ard_eMsgType;
#define ARD__SUCCESS 1
......@@ -121,7 +125,7 @@ static int receive( int fd, int id, ard_sMsg *rmsg, int size)
msize = 0;
msize += read( fd, rmsg, 1);
logg( "Receive read");
// logg( "Receive read");
while ( msize < rmsg->size) {
sts = select(fd+1, &rfd, NULL, NULL, &tv);
......@@ -129,7 +133,7 @@ static int receive( int fd, int id, ard_sMsg *rmsg, int size)
msize += read( fd, (char *)rmsg + msize, rmsg->size - msize);
logg( "Receive read ++");
// logg( "Receive read ++");
}
......@@ -157,7 +161,7 @@ static int poll_di( ard_sMsg *msg, io_sLocal *local)
msg->id = local->IdCnt++;
msg->type = ard_eMsgType_DiRead;
logg( "Poll Di");
// logg( "Poll Di");
sts = write( local->fd, msg, msg->size);
local->DiPollId = msg->id;
local->DiPendingPoll = 1;
......@@ -178,7 +182,7 @@ static pwr_tStatus IoCardInit( io_tCtx ctx,
unsigned char wdg;
struct termios tty_attributes;
fp = fopen( "/home/claes/ard.log", "w"); // Test
// fp = fopen( "/home/claes/ard.log", "w"); // Test
local = (io_sLocal *) calloc( 1, sizeof(io_sLocal));
cp->Local = local;
......@@ -396,6 +400,8 @@ static pwr_tStatus IoCardInit( io_tCtx ctx,
else {
errh_Error( "IO Init Card '%s', config error: %d", cp->Name, sts);
op->Status = sts;
if ( sts == pwr_eArduino_StatusEnum_NoMessage)
sts = pwr_eArduino_StatusEnum_ConnectionTimeout;
return IO__INITFAIL;
printf( "Config read error %d\n", sts);
}
......@@ -415,7 +421,7 @@ static pwr_tStatus IoCardClose( io_tCtx ctx,
close( local->fd);
free( cp->Local);
fclose(fp); //Test
// fclose(fp); //Test
return IO__SUCCESS;
}
......@@ -447,7 +453,7 @@ static pwr_tStatus IoCardRead( io_tCtx ctx,
msg.id = local->IdCnt++;
msg.type = ard_eMsgType_DiRead;
logg( "Poll Di");
// logg( "Poll Di");
sts = write( local->fd, &msg, msg.size);
#endif
......@@ -497,6 +503,7 @@ static pwr_tStatus IoCardRead( io_tCtx ctx,
if ( EVEN(sts)) {
}
else {
int ai_cnt = 0;
for ( i = 0; i < local->AiSize; i++) {
for ( j = 0; j < 8; j++) {
m = 1 << j;
......@@ -509,7 +516,7 @@ static pwr_tStatus IoCardRead( io_tCtx ctx,
// Request to calculate new coefficients
io_AiRangeToCoef( chanp);
ivalue = rmsg.data[(i*8+j)*2] * 256 + rmsg.data[(i*8+j)*2+1];
ivalue = rmsg.data[ai_cnt*2] * 256 + rmsg.data[ai_cnt*2+1];
io_ConvertAi( cop, ivalue, &actvalue);
// Filter
......@@ -523,6 +530,7 @@ static pwr_tStatus IoCardRead( io_tCtx ctx,
*(pwr_tFloat32 *)chanp->vbp = actvalue;
sop->SigValue = cop->SigValPolyCoef1 * ivalue + cop->SigValPolyCoef0;
sop->RawValue = ivalue;
ai_cnt++;
}
}
}
......@@ -574,10 +582,66 @@ static pwr_tStatus IoCardWrite( io_tCtx ctx,
}
logg( "Write Do");
// logg( "Write Do");
sts = write( local->fd, &msg, msg.size);
}
if ( local->AoSize) {
int skip_ao = 0;
if ( op->AoScanInterval > 1) {
skip_ao = local->AoIntervalCnt;
local->AoIntervalCnt++;
if ( local->AoIntervalCnt >= op->AoScanInterval)
local->AoIntervalCnt = 0;
}
if ( !skip_ao) {
ard_sMsg msg;
int value;
memset( &msg, 0, sizeof(msg));
msg.size = local->AoNum + 3;
msg.id = local->IdCnt++;
msg.type = ard_eMsgType_AoWrite;
int ao_cnt = 0;
for ( i = 0; i < local->AoSize; i++) {
for ( j = 0; j < 8; j++) {
m = 1 << j;
if ( local->AoMask[i] & m) {
io_sChannel *chanp = local->AoChanList[i*8+j];
pwr_sClass_ChanAo *cop = (pwr_sClass_ChanAo *)chanp->cop;
pwr_sClass_Ao *sop = (pwr_sClass_Ao *)chanp->sop;
if ( cop->CalculateNewCoef)
// Request to calculate new coefficients
io_AoRangeToCoef( chanp);
value = *(pwr_tFloat32 *)chanp->vbp * cop->OutPolyCoef1 +
cop->OutPolyCoef0 + 0.49;
if ( value < 0)
value = 0;
else if (value > 255)
value = 255;
msg.data[ao_cnt] = value;
sop->SigValue = cop->SigValPolyCoef1 * *(pwr_tFloat32 *)chanp->vbp +
cop->SigValPolyCoef0;
sop->RawValue = value;
ao_cnt++;
}
}
}
// logg( "Write Ao");
sts = write( local->fd, &msg, msg.size);
}
}
if ( op->ErrorCount >= op->ErrorSoftLimit &&
error_count < op->ErrorSoftLimit) {
errh_Warning( "IO Card ErrorSoftLimit reached, '%s'", cp->Name);
......
Volume OtherIO $ClassVolume 0.0.250.10
Body SysBody 01-JAN-1970 01:00:00.00
Attr NextOix = "_X170"
Attr NextOix = "_X171"
Attr NextCix = "_X17"
Attr NextTix[0] = "_X8"
EndBody
......@@ -374,6 +374,13 @@ Volume OtherIO $ClassVolume 0.0.250.10
Attr Value = 20
EndBody
EndObject
Object ConnectionTimeout $Value 171 17-JAN-2011 18:13:00.46
Body SysBody 17-JAN-2011 18:13:05.37
Attr Text = "ConnectionTimeout"
Attr PgmName = "ConnectionTimeout"
Attr Value = 22
EndBody
EndObject
EndObject
Object Arduino_BaudRateEnum $TypeDef 6 03-JAN-2011 21:16:43.20
Body SysBody 03-JAN-2011 21:07:09.34
......@@ -2478,7 +2485,7 @@ Volume OtherIO $ClassVolume 0.0.250.10
Object RtBody $ObjBodyDef 1 13-DEC-2010 21:36:40.01
Body SysBody 13-DEC-2010 21:39:07.38
Attr StructName = "Arduino_Uno"
Attr NextAix = "_X24"
Attr NextAix = "_X25"
EndBody
!/**
! Optional description.
......@@ -2594,7 +2601,7 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndObject
!/**
! Baud rate of the USB connection.
! For fast scantimes the baud rate has to be increased.
! For fast scantimes the baud rate has to be increased.
!*/
Object BaudRate $Attribute 21 03-JAN-2011 21:18:39.87
Body SysBody 03-JAN-2011 21:19:00.44
......@@ -2604,7 +2611,7 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndObject
!/**
! Options.
! If OptimizedDiPoll is set the poll message for Di values are sent
! If OptimizedDiPoll is set the poll message for Di values are sent
! at the end of the execution of the prevoius scan, instead of at
! the start of the execution.
!*/
......@@ -2627,6 +2634,20 @@ Volume OtherIO $ClassVolume 0.0.250.10
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Specifies, in relation to the scantime of the thread, how often
! the Ao channels of the board are handled. If AoScanInterval is 1 or 0,
! the Ao are handled every scan. If AoScanInterval is for example 10, they
! are handled every 10'th scan, i.e. the scantime for the module
! will be AoScanInterval times the scantime of the thread.
!*/
Object AoScanInterval $Attribute 24 19-JAN-2011 18:24:34.75
Body SysBody 19-JAN-2011 18:24:35.83
Attr PgmName = "AoScanInterval"
Attr Flags = 16777216
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
EndObject
Object IoMethods $RtMethod 144 13-DEC-2010 21:36:40.01
Object IoCardInit $Method 145 13-DEC-2010 21:36:40.01
......
......@@ -67,12 +67,12 @@
# define SET_VERSION(a, b, c, d) ((pwr_tVersion)((a << 24) + (a << 16) + (a << 8) + a))
#endif
#define pwrv_cBuildTimeStr "27-AUG-2010 12:00:00"
#define pwrv_cBuildTimeStr "14-JAN-2011 20:00:00"
#define pwrv_cPwrVersionStr "V4.8.0"
#define pwrv_cPwrVersion SET_VERSION('V', 4, 8, 0)
#define pwrv_cPwrVersionStr "V4.8.1"
#define pwrv_cPwrVersion SET_VERSION('V', 4, 8, 1)
#define pwrv_cWbdbVersionShortStr "V48"
#define pwrv_cPwrCopyright "Copyright (C) 2005-2010 SSAB Oxelsund"
#define pwrv_cPwrCopyright "Copyright (C) 2005-2011 SSAB Oxelsund"
#endif
Package: pwr48
Version: 4.8.0-1
Version: 4.8.1-0.1
Section: base
Priority: optional
Architecture: i386
......@@ -9,3 +9,7 @@ Maintainer: Proview <postmaster@proview.se>
Description: Proview development and runtime environment package
Proview development and runtime environment
4.8.0-1 Base release
4.8.1-0.1 Beta release
- I/O support for Arduino USB board.
- Remote support for Websphere Message Queue.
- Operator event logging and replay.
Package: pwr48
Version: 4.8.0-1
Version: 4.8.1-0.2
Section: base
Priority: optional
Architecture: i386
......@@ -9,3 +9,7 @@ Maintainer: Proview <postmaster@proview.se>
Description: Proview development and runtime environment package
Proview development and runtime environment
4.8.0-1 Base release
4.8.1-0.1 Beta release
- I/O support for Arduino USB board.
- Remote support for Websphere Message Queue.
- Operator event logging and replay.
......@@ -152,8 +152,6 @@ WbGtk::WbGtk( int argc, char *argv[]) : mainwindow(0)
exit(0);
}
Lng::set( argv[i+1]);
setlocale( LC_ALL, "en_US");
setlocale( LC_NUMERIC, "en_US");
i++;
break;
case 'f':
......
......@@ -33,5 +33,8 @@ if [ -z $database ]; then
return
fi
export LC_TIME="en_US.UTF-8"
export LC_NUMERIC="POSIX"
echo "-- Opening volume '$database'"
wb -q "$username" "$password" $database
......@@ -25,6 +25,9 @@ username=$1
password=$2
volume=$3
export LC_TIME="en_US.UTF-8"
export LC_NUMERIC="POSIX"
wb $username $password $volume $4 $5 $6 $7
......
......@@ -319,6 +319,11 @@ palette NavigatorPalette
menu USB
{
class USB_Agent
menu Arduino
{
class Arduino_USB
class Arduino_Uno
}
menu Velleman_K8055
{
class Velleman_K8055
......
......@@ -1286,6 +1286,8 @@ class Graph {
else return 1;
}
//! Enable event logging
static void eventlog_enable( int enable) { grow_EventLogEnable( enable);}
//
// Command module
......
......@@ -591,9 +591,8 @@ int GlowDrawGtk::event_handler( GdkEvent event)
if ( event.any.window == m_wind.window || event.type == GDK_KEY_PRESS) {
#if defined PWRE_EVENTLOGGING_ENABLED
log_event( &event);
#endif
if ( GlowCtx::eventlog_enabled)
log_event( &event);
switch ( event.type) {
case GDK_KEY_PRESS : {
......
......@@ -46,6 +46,8 @@
#include "glow_msg.h"
int GlowCtx::eventlog_enabled = 0;
GlowCtx::GlowCtx( const char *ctx_name, double zoom_fact, int offs_x, int offs_y)
: ctx_type(glow_eCtxType_Glow),
mw( zoom_fact, zoom_fact, zoom_fact, offs_x, offs_y),
......
......@@ -826,6 +826,7 @@ class GlowCtx {
glow_eHotIndication hot_indication; //!< Specification of how hots object should be drawn.
int tiptext_size; //!< Size of tooltip text
glow_tEventLogCb eventlog_callback; //!< Callback function to log events.
static int eventlog_enabled; //!< Event logging enabled.
//! Register scrollbar callback function
/*!
......
......@@ -4699,6 +4699,11 @@ void grow_EventExec( grow_tCtx ctx, void *event, unsigned int size)
ctx->gdraw->event_exec( event, size);
}
void grow_EventLogEnable( int enable)
{
GlowCtx::eventlog_enabled = enable;
}
/*@}*/
......
......@@ -2974,6 +2974,7 @@ extern "C" {
int grow_GetDimension( char *filename, int *width, int *height);
void grow_SetTextCoding( grow_tCtx ctx, glow_eTextCoding coding);
void grow_EventExec( grow_tCtx ctx, void *event, unsigned int size);
void grow_EventLogEnable( int enable);
/*@}*/
#if defined __cplusplus
......
......@@ -36,6 +36,11 @@
#include "ge_graph.h"
#include "xtt_log.h"
void XttGe::eventlog_enable( int enable)
{
Graph::eventlog_enable( enable);
}
void XttGe::graph_init_cb( void *client_data)
{
XttGe *ge = (XttGe *) client_data;
......
......@@ -92,6 +92,7 @@ class XttGe {
int **is_alist);
static void ge_eventlog_cb( void *ge_ctx, void *value, unsigned int size);
static void message_cb( void *ctx, char severity, const char *msg);
static void eventlog_enable( int enable);
};
#endif
......
......@@ -130,7 +130,7 @@ static int xnav_ev_sound_cb( void *xnav, pwr_sAttrRef *arp);
static void xnav_ev_pop_cb( void *xnav);
static void xnav_ev_update_info_cb( void *xnav);
static int xnav_ge_sound_cb( void *xnav, pwr_sAttrRef *arp);
static void xnav_ge_eventlog_cb( void *xnav, void *gectx, void *value, unsigned int size);
static void xnav_ge_eventlog_cb( void *xnav, void *gectx, int type, void *data, unsigned int size);
static void xnav_ge_display_in_xnav_cb( void *xnav, pwr_sAttrRef *arp);
static int xnav_ge_is_authorized_cb( void *xnav, unsigned int access);
static int xnav_attribute_func (
......@@ -5583,6 +5583,9 @@ static int xnav_oplog_func(void *client_data,
strcpy( file_str, xttlog_cLogFile);
}
if ( event)
XttGe::eventlog_enable( 1);
XttLog *log = new XttLog( file_str, event);
XttLog::delete_default();
log->set_default();
......
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