Commit 1c2285d6 authored by Claes Sjofors's avatar Claes Sjofors

Merge branch 'master' of newton:/data1/x0-0-0/pwr

parents d640e350 e8241052
......@@ -801,6 +801,7 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
pwr_sClass_Modbus_TCP_Server* op;
int i;
unsigned short port;
io_sCard *cardp;
// Ignore SIGPIPE signal
signal(SIGPIPE, signal_callback_handler);
......@@ -819,6 +820,12 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
if (op->DisableServer)
return IO__SUCCESS;
for ( cardp = rp->cardlist; cardp; cardp = cardp->next)
io_bus_card_area_size( ctx, cardp, &local->inputs_size, &local->outputs_size);
local->inputs = calloc(1, local->inputs_size);
local->outputs = calloc(1, local->output_size);
/* Create socket, store in local struct */
uid_t ruid;
ruid = getuid();
......@@ -893,23 +900,29 @@ static pwr_tStatus mb_init_channels(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
cardp = rp->cardlist;
unsigned int prev_input_area_offset = 0;
unsigned int prev_output_area_offset = 0;
unsigned int input_area_offset = 0;
unsigned int output_area_offset = 0;
unsigned int input_area_chansize = 0;
unsigned int output_area_chansize = 0;
unsigned int card_input_area_offset = 0;
unsigned int card_output_area_offset = 0;
while (cardp) {
while(cardp) {
local_card = calloc(1, sizeof(*local_card));
cardp->Local = local_card;
local_card->input_area
= (void*)&(op->Inputs) + input_area_offset + input_area_chansize;
local_card->output_area
= (void*)&(op->Outputs) + output_area_offset + output_area_chansize;
card_input_area_offset += input_area_offset + input_area_chansize;
card_output_area_offset += output_area_offset + output_area_chansize;
input_area_offset = 0;
output_area_offset = 0;
input_area_chansize = 0;
output_area_chansize = 0;
local_card->input_area = (char *)local->inputs + card_input_area_offset;
local_card->output_area = (char *)local->outputs + card_output_area_offset;
io_bus_card_init(ctx, cardp, &input_area_offset, &input_area_chansize,
io_bus_card_init( ctx, cardp, &input_area_offset, &input_area_chansize,
&output_area_offset, &output_area_chansize,
pwr_eByteOrderingEnum_BigEndian, io_eAlignment_Packed);
......@@ -917,7 +930,7 @@ static pwr_tStatus mb_init_channels(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
chanp = &cardp->chanlist[i];
switch (chanp->ChanClass) {
case pwr_cClass_ChanDi: {
pwr_sClass_ChanDi* chan_di = (pwr_sClass_ChanDi*)chanp->cop;
pwr_sClass_ChanDi *chan_di = (pwr_sClass_ChanDi *) chanp->cop;
if (local_card->di_size == 0)
local_card->di_offset = chanp->offset;
......@@ -927,7 +940,7 @@ static pwr_tStatus mb_init_channels(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
break;
}
case pwr_cClass_ChanDo: {
pwr_sClass_ChanDo* chan_do = (pwr_sClass_ChanDo*)chanp->cop;
pwr_sClass_ChanDo *chan_do = (pwr_sClass_ChanDo *) chanp->cop;
if (local_card->do_size == 0)
local_card->do_offset = chanp->offset;
......@@ -937,13 +950,14 @@ static pwr_tStatus mb_init_channels(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
break;
}
case pwr_cClass_ChanD: {
pwr_sClass_ChanD* chan_d = (pwr_sClass_ChanD*)chanp->cop;
if (chan_d->Type == pwr_eDChanTypeEnum_Di) {
pwr_sClass_ChanD *chan_d = (pwr_sClass_ChanD *) chanp->cop;
if ( chan_d->Type == pwr_eDChanTypeEnum_Di) {
if (local_card->di_size == 0)
local_card->di_offset = chanp->offset;
if (chan_d->Number == 0 || local_card->di_size == 0)
local_card->di_size += GetChanSize(chan_d->Representation);
} else {
}
else {
if (local_card->do_size == 0)
local_card->do_offset = chanp->offset;
if (chan_d->Number == 0 || local_card->do_size == 0)
......@@ -954,19 +968,15 @@ static pwr_tStatus mb_init_channels(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
}
}
local_card->input_size
= input_area_offset + input_area_chansize - prev_input_area_offset;
local_card->output_size
= output_area_offset + output_area_chansize - prev_output_area_offset;
prev_input_area_offset = input_area_offset + input_area_chansize;
prev_output_area_offset = output_area_offset + output_area_chansize;
local_card->input_size = input_area_offset + input_area_chansize;
local_card->output_size = output_area_offset + output_area_chansize;
cardp = cardp->next;
}
local->input_size = input_area_offset + input_area_chansize;
local->output_size = output_area_offset + output_area_chansize;
local->input_size = card_input_area_offset + input_area_offset + input_area_chansize;
local->output_size = card_output_area_offset + output_area_offset + output_area_chansize;
return IO__SUCCESS;
}
......@@ -1041,6 +1051,11 @@ void mb_shift_read(unsigned char* in, unsigned char* out, int sh, int quant)
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoRackRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
{
io_sServerLocal *local = rp->Local;
pwr_sClass_Modbus_TCP_Server *op = (pwr_sClass_Modbus_TCP_Server *) rp->op;
/* For display */
memcpy( op->Inputs, local->inputs, MIN(sizeof(op->Inputs), local->inputs_size));
return IO__SUCCESS;
}
......@@ -1049,6 +1064,11 @@ static pwr_tStatus IoRackRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoRackWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
{
io_sServerLocal *local = rp->Local;
pwr_sClass_Modbus_TCP_Server *op = (pwr_sClass_Modbus_TCP_Server *) rp->op;
/* For display */
memcpy( op->Outputs, local->outputs, MIN(sizeof(op->Outputs), local->outputs_size));
return IO__SUCCESS;
}
......
......@@ -138,6 +138,10 @@ typedef struct {
int output_size;
thread_sMutex mutex;
io_sServerConnection connections[MB_MAX_CONNECTIONS];
void *inputs;
void *outputs;
unsigned int inputs_size;
unsigned int outputs_size;
} io_sServerLocal;
typedef struct {
......
......@@ -505,6 +505,72 @@ pwr_tStatus io_bus_card_init(io_tCtx ctx, io_sCard* cp,
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Get channel area size for a bus card.
\*----------------------------------------------------------------------------*/
void io_bus_card_area_size( io_tCtx ctx,
io_sCard *cp,
unsigned int *input_area_size,
unsigned int *output_area_size)
{
int i;
for ( i = 0; i < cp->ChanListSize; i++) {
io_sChannel *chanp = &cp->chanlist[i];
switch (chanp->ChanClass) {
case pwr_cClass_ChanDi:
if ( ((pwr_sClass_ChanDi *)chanp->cop)->Number == 0)
*input_area_size += GetChanSize( ((pwr_sClass_ChanDi *)chanp->cop)->Representation);
break;
case pwr_cClass_ChanAi:
*input_area_size += GetChanSize(((pwr_sClass_ChanAi *)chanp->cop)->Representation);
break;
case pwr_cClass_ChanAit:
*input_area_size += GetChanSize(((pwr_sClass_ChanAit *)chanp->cop)->Representation);
break;
case pwr_cClass_ChanIi:
*input_area_size += GetChanSize(((pwr_sClass_ChanIi *)chanp->cop)->Representation);
break;
case pwr_cClass_ChanBi:
*input_area_size += ((pwr_sClass_ChanBi *)chanp->cop)->Size;
break;
case pwr_cClass_ChanBo:
*output_area_size += ((pwr_sClass_ChanBo *)chanp->cop)->Size;
break;
case pwr_cClass_ChanBiBlob:
*input_area_size += ((pwr_sClass_ChanBiBlob *)chanp->cop)->Size;
break;
case pwr_cClass_ChanBoBlob:
*output_area_size += ((pwr_sClass_ChanBoBlob *)chanp->cop)->Size;
break;
case pwr_cClass_ChanDo:
if (((pwr_sClass_ChanDo *)chanp->cop)->Number == 0)
*output_area_size += GetChanSize( ((pwr_sClass_ChanDo *)chanp->cop)->Representation);
break;
case pwr_cClass_ChanAo:
*output_area_size += GetChanSize(((pwr_sClass_ChanAo *)chanp->cop)->Representation);
break;
case pwr_cClass_ChanIo:
*output_area_size += GetChanSize(((pwr_sClass_ChanIo *)chanp->cop)->Representation);
break;
case pwr_cClass_ChanD: {
pwr_sClass_ChanD *chan_d = (pwr_sClass_ChanD *) chanp->cop;
if ( chan_d->Type == pwr_eDChanTypeEnum_Di) {
if (chan_d->Number == 0)
*input_area_size += GetChanSize( chan_d->Representation);
}
else {
if (chan_d->Number == 0)
*output_area_size += GetChanSize( chan_d->Representation);
}
break;
}
}
}
}
/*----------------------------------------------------------------------------*\
Read method for bus-card
\*----------------------------------------------------------------------------*/
......
......@@ -77,6 +77,11 @@ pwr_tStatus io_bus_card_init(io_tCtx ctx, io_sCard* cp,
unsigned int* output_area_offset, unsigned int* output_area_chansize,
pwr_tByteOrderingEnum byte_order, io_eAlignment alignment);
void io_bus_card_area_size( io_tCtx ctx,
io_sCard *cp,
unsigned int *input_area_size,
unsigned int *output_area_size);
void io_bus_card_read(io_tCtx ctx, io_sRack* rp, io_sCard* cp, void* input_area,
void* diag_area, pwr_tByteOrderingEnum byte_order,
pwr_tFloatRepEnum float_rep);
......
......@@ -64,13 +64,24 @@ png_sources := $(sort \
) \
)
css_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.css) \
), $(notdir $(file)) \
) \
)
export_js := $(addprefix $(web_dir)/,$(js_sources))
export_html := $(addprefix $(web_dir)/,$(html_sources))
export_png := $(addprefix $(web_dir)/,$(png_sources))
export_css := $(addprefix $(web_dir)/,$(css_sources))
clean_js := $(patsubst %.js,clean_%.js, $(js_sources))
clean_html := $(patsubst %.html,clean_%.html, $(html_sources))
clean_png := $(patsubst %.png,clean_%.png, $(png_sources))
clean_css := $(patsubst %.css,clean_%.css, $(css_sources))
.PHONY : all init copy lib exe clean realclean
......@@ -78,13 +89,13 @@ all : init copy lib exe | silent
init :
copy : $(export_js) $(export_html) $(export_png) | silent
copy : $(export_js) $(export_html) $(export_png) $(export_css) | silent
lib :
exe :
clean : $(clean_js) $(clean_html) $(clean_png)
clean : $(clean_js) $(clean_html) $(clean_png) $(clean_css)
clean_copy: $(clean)
......@@ -106,6 +117,10 @@ $(clean_png) : clean_%.png : %.png
@ echo "Removing png: $(web_dir)/$*.png"
@ $(rm) $(rmflags) $(web_dir)/$*.png
$(clean_css) : clean_%.css : %.css
@ echo "Removing png: $(web_dir)/$*.css"
@ $(rm) $(rmflags) $(web_dir)/$*.css
-include $(source_dependencies)
......
......@@ -284,6 +284,10 @@ $(web_dir)/%.html : ../../%.html
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(web_dir)/%.css : ../../%.css
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(web_dir)/%.js : ../../%.js
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
......
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