Commit 4a587916 authored by U-pluto\Claes's avatar U-pluto\Claes

Cygwin work

parent cfd57d5c
......@@ -71,12 +71,12 @@ static pwr_tStatus IoCardInit (
io_sCard *cp
)
{
io_sCardLocal *local;
io_sCardLocalMsg *local;
pwr_sClass_Modbus_Module *op;
int i;
op = (pwr_sClass_Modbus_Module *) cp->op;
local = (io_sCardLocal *) cp->Local;
local = ((io_sCardLocal *) cp->Local)->msg;
for (i = 0; i < IO_MAXCHAN; i++) {
local->scancount[i] = 0;
......@@ -98,12 +98,12 @@ static pwr_tStatus IoCardRead (
io_sCard *cp
)
{
io_sCardLocal *local;
io_sCardLocalMsg *local;
pwr_sClass_Modbus_Module *op;
pwr_sClass_Modbus_TCP_Slave *slave;
op = (pwr_sClass_Modbus_Module *) cp->op;
local = (io_sCardLocal *) cp->Local;
local = ((io_sCardLocal *) cp->Local)->msg;
slave = (pwr_sClass_Modbus_TCP_Slave *) rp->op;
if ( op->ScanInterval > 1) {
......@@ -118,7 +118,7 @@ static pwr_tStatus IoCardRead (
}
if (slave->Status == MB__NORMAL) {
io_bus_card_read(ctx, rp, cp, local->input_area, NULL, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
io_bus_card_read(ctx, rp, cp, slave->Inputs, NULL, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
}
// printf("Method Modbus_Module-IoCardRead\n");
return IO__SUCCESS;
......@@ -135,13 +135,13 @@ static pwr_tStatus IoCardWrite (
io_sCard *cp
)
{
io_sCardLocal *local;
io_sCardLocalMsg *local;
pwr_sClass_Modbus_Module *op;
pwr_sClass_Modbus_TCP_Slave *slave;
op = (pwr_sClass_Modbus_Module *) cp->op;
local = (io_sCardLocal *) cp->Local;
local = ((io_sCardLocal *) cp->Local)->msg;
slave = (pwr_sClass_Modbus_TCP_Slave *) rp->op;
if ( op->ScanInterval > 1) {
......@@ -159,7 +159,7 @@ static pwr_tStatus IoCardWrite (
}
if (slave->Status == MB__NORMAL) {
io_bus_card_write(ctx, cp, local->output_area, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
io_bus_card_write(ctx, cp, slave->Outputs, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
}
// printf("Method Modbus_Module-IoCardWrite\n");
return IO__SUCCESS;
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* 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 Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <math.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_otherioclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_errh.h"
#include "rt_io_bus.h"
#include "rt_mb_msg.h"
#include "rt_io_mb_locals.h"
/*----------------------------------------------------------------------------*\
Init method for the Modbus module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sCardLocal *local;
pwr_sClass_Modbus_ModuleReadWrite *op;
int i;
op = (pwr_sClass_Modbus_ModuleReadWrite *) cp->op;
local = (io_sCardLocal *) cp->Local;
for (i = 0; i < IO_MAXCHAN; i++) {
local->msg[0].scancount[i] = 0;
local->msg[1].scancount[i] = 0;
}
op->Read.Status = pwr_eModbusModule_StatusEnum_StatusUnknown;
op->Write.Status = pwr_eModbusModule_StatusEnum_StatusUnknown;
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Read method for the Pb module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sCardLocal *local;
pwr_sClass_Modbus_ModuleReadWrite *op;
pwr_sClass_Modbus_TCP_Slave *slave;
op = (pwr_sClass_Modbus_ModuleReadWrite *) cp->op;
local = (io_sCardLocal *) cp->Local;
slave = (pwr_sClass_Modbus_TCP_Slave *) rp->op;
if ( op->Read.ScanInterval > 1) {
local->msg[0].has_read_method = 1;
if ( local->msg[0].interval_cnt != 0) {
local->msg[0].interval_cnt++;
if ( local->msg[0].interval_cnt >= op->Read.ScanInterval)
local->msg[0].interval_cnt = 0;
return IO__SUCCESS;
}
local->msg[0].interval_cnt++;
}
if (slave->Status == MB__NORMAL) {
io_bus_card_read(ctx, rp, cp, slave->Inputs, NULL, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
}
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Write method for the Pb module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sCardLocal *local;
pwr_sClass_Modbus_ModuleReadWrite *op;
pwr_sClass_Modbus_TCP_Slave *slave;
op = (pwr_sClass_Modbus_ModuleReadWrite *) cp->op;
local = (io_sCardLocal *) cp->Local;
slave = (pwr_sClass_Modbus_TCP_Slave *) rp->op;
if ( op->Write.ScanInterval > 1) {
if ( !local->msg[1].has_read_method) {
if ( local->msg[1].interval_cnt != 0) {
local->msg[1].interval_cnt++;
if ( local->msg[1].interval_cnt >= op->Write.ScanInterval)
local->msg[1].interval_cnt = 0;
return IO__SUCCESS;
}
local->msg[1].interval_cnt++;
}
else if ( local->msg[1].interval_cnt != 1)
return IO__SUCCESS;
}
if (slave->Status == MB__NORMAL) {
io_bus_card_write(ctx, cp, slave->Outputs, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
}
// printf("Method Modbus_Module-IoCardWrite\n");
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Modbus_ModuleReadWrite) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
This diff is collapsed.
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* 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 Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <math.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_otherioclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_errh.h"
#include "rt_io_bus.h"
#include "rt_mb_msg.h"
#include "rt_io_mb_rtu.h"
/*----------------------------------------------------------------------------*\
Init method for the Modbus module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sCardLocalMsg *local;
pwr_sClass_Modbus_RTU_Module *op;
int i;
op = (pwr_sClass_Modbus_RTU_Module *) cp->op;
local = ((io_sCardLocal *) cp->Local)->msg;
for (i = 0; i < IO_MAXCHAN; i++) {
local->scancount[i] = 0;
}
op->Status = pwr_eModbusModule_StatusEnum_StatusUnknown;
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Read method for the Modbus RTU module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sCardLocalMsg *local;
io_sRackLocal *local_rack = (io_sRackLocal *)rp->Local;
pwr_sClass_Modbus_RTU_Module *op;
pwr_sClass_Modbus_RTU_Slave *slave;
op = (pwr_sClass_Modbus_RTU_Module *) cp->op;
local = ((io_sCardLocal *) cp->Local)->msg;
slave = (pwr_sClass_Modbus_RTU_Slave *) rp->op;
if ( op->ScanInterval > 1) {
local->has_read_method = 1;
if ( local->interval_cnt != 0) {
local->interval_cnt++;
if ( local->interval_cnt >= op->ScanInterval)
local->interval_cnt = 0;
return IO__SUCCESS;
}
local->interval_cnt++;
}
if (slave->Status == MB__NORMAL || local_rack->reset_inputs) {
io_bus_card_read(ctx, rp, cp, slave->Inputs, NULL, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
}
// printf("Method Modbus_RTU_Module-IoCardRead\n");
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Write method for the Modbus RTU module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sCardLocalMsg *local;
pwr_sClass_Modbus_RTU_Module *op;
pwr_sClass_Modbus_RTU_Slave *slave;
op = (pwr_sClass_Modbus_RTU_Module *) cp->op;
local = ((io_sCardLocal *) cp->Local)->msg;
slave = (pwr_sClass_Modbus_RTU_Slave *) rp->op;
if ( op->ScanInterval > 1) {
if ( !local->has_read_method) {
if ( local->interval_cnt != 0) {
local->interval_cnt++;
if ( local->interval_cnt >= op->ScanInterval)
local->interval_cnt = 0;
return IO__SUCCESS;
}
local->interval_cnt++;
}
else if ( local->interval_cnt != 1)
return IO__SUCCESS;
}
if (slave->Status == MB__NORMAL) {
io_bus_card_write(ctx, cp, slave->Outputs, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
}
// printf("Method Modbus_RTU_Module-IoCardWrite\n");
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Modbus_RTU_Module) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
This diff is collapsed.
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* 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 Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <math.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <unistd.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_otherioclasses.h"
#include "rt_io_base.h"
#include "rt_io_msg.h"
#include "rt_errh.h"
#include "rt_io_bus.h"
#include "rt_mb_msg.h"
#include "rt_io_mb_rtu.h"
#include "co_time.h"
/*----------------------------------------------------------------------------*\
Init method for the Modbus server module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sServerModuleLocal *local;
pwr_sClass_Modbus_RTU_ServerModule *op;
int i;
op = (pwr_sClass_Modbus_RTU_ServerModule *) cp->op;
local = (io_sServerModuleLocal *) cp->Local;
for (i = 0; i < IO_MAXCHAN; i++) {
local->scancount[i] = 0;
}
op->Status = pwr_eModbusModule_StatusEnum_StatusUnknown;
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Read method for the Modbus RTU server module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sServerModuleLocal *local;
io_sServerLocal *local_server;
pwr_sClass_Modbus_RTU_ServerModule *op;
pwr_sClass_Modbus_RTU_Server *server;
op = (pwr_sClass_Modbus_RTU_ServerModule *) cp->op;
local = (io_sServerModuleLocal *) cp->Local;
server = (pwr_sClass_Modbus_RTU_Server *) rp->op;
local_server = (io_sServerLocal *) rp->Local;
if ( server->DisableServer || !local)
return IO__SUCCESS;
if (server->Status == MB__NORMAL) {
thread_MutexLock( &local_server->mutex);
io_bus_card_read(ctx, rp, cp, local->input_area, NULL, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
thread_MutexUnlock( &local_server->mutex);
}
// printf("Method Modbus_Module-IoCardRead\n");
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Write method for the Modbus RTU server module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
io_sServerModuleLocal *local;
io_sServerLocal *local_server;
pwr_sClass_Modbus_RTU_ServerModule *op;
pwr_sClass_Modbus_RTU_Server *server;
op = (pwr_sClass_Modbus_RTU_ServerModule *) cp->op;
local = (io_sServerModuleLocal *) cp->Local;
server = (pwr_sClass_Modbus_RTU_Server *) rp->op;
local_server = (io_sServerLocal *) rp->Local;
if ( server->DisableServer || !local)
return IO__SUCCESS;
if (server->Status == MB__NORMAL) {
thread_MutexLock( &local_server->mutex);
io_bus_card_write(ctx, cp, local->output_area, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
thread_MutexUnlock( &local_server->mutex);
}
// printf("Method Modbus_Module-IoCardWrite\n");
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Modbus_RTU_ServerModule) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardWrite),
pwr_NullMethod
};
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* 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 Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/* rt_io_m_mb_rtu_slave.c -- io methods for a Modbus RTU slave */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include "pwr.h"
#include "co_cdh.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_otherioclasses.h"
#include "rt_gdh.h"
#include "rt_io_base.h"
#include "rt_io_bus.h"
#include "rt_io_msg.h"
#include "rt_errh.h"
#include "co_cdh.h"
#include "co_time.h"
#include "rt_mb_msg.h"
#include "rt_io_mb_rtu.h"
/*----------------------------------------------------------------------------*\
Init method for the Modbus_TCP slave
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoRackInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp
)
{
io_sCardLocal *local_card;
io_sCard *cardp;
io_sRackLocal *local;
int no_di;
int no_do;
pwr_sClass_Modbus_RTU_Slave *op;
char name[196];
pwr_tStatus sts;
pwr_tCid cid;
io_sChannel *chanp;
int i;
sts = gdh_ObjidToName(rp->Objid, (char *) &name, sizeof(name), cdh_mNName);
errh_Info( "Init of Modbus TCP Slave and Modules %s", name);
op = (pwr_sClass_Modbus_RTU_Slave *) rp->op;
rp->Local = calloc(1, sizeof(io_sRackLocal));
local = rp->Local;
op->Status = MB__NORMAL;
/* Do configuration check and initialize modules. */
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;
while(cardp) {
local_card = calloc(1, sizeof(*local_card));
cid = cardp->Class;
/* Find the super class */
while ( ODD( gdh_GetSuperClass( cid, &cid, cardp->Objid))) ;
switch (cid) {
case pwr_cClass_Modbus_RTU_Module: {
pwr_sClass_Modbus_RTU_Module *modulep;
cardp->Local = local_card;
no_di = 0;
no_do = 0;
local_card->msg[0].input_area = (void *) &(op->Inputs) + input_area_offset +
input_area_chansize;
local_card->msg[0].output_area = (void *) &(op->Outputs) + output_area_offset +
output_area_chansize;
modulep = (pwr_sClass_Modbus_RTU_Module *) cardp->op;
modulep->Status = pwr_eModbusModule_StatusEnum_StatusUnknown;
io_bus_card_init( ctx, cardp, &input_area_offset, &input_area_chansize,
&output_area_offset, &output_area_chansize,
pwr_eByteOrderingEnum_BigEndian);
/* Count number of di and do */
for (i = 0; i < cardp->ChanListSize; i++) {
chanp = &cardp->chanlist[i];
switch (chanp->ChanClass) {
case pwr_cClass_ChanDi:
no_di++;
break;
case pwr_cClass_ChanDo:
no_do++;
break;
}
}
local_card->msg[0].input_size = input_area_offset + input_area_chansize -
prev_input_area_offset;
local_card->msg[0].output_size = output_area_offset + output_area_chansize -
prev_output_area_offset;
local_card->msg[0].no_di = no_di;
local_card->msg[0].no_do = no_do;
break;
}
} /* End - switch ... */
prev_input_area_offset = input_area_offset + input_area_chansize;
prev_output_area_offset = 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;
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Read method for the Modbus_TCP slave
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoRackRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp
)
{
#if 0
io_sRackLocal *local;
pwr_sClass_Modbus_TCP_Slave *sp;
pwr_tStatus sts;
pwr_tTime now;
pwr_tDeltaTime dt;
local = rp->Local;
sp = (pwr_sClass_Modbus_TCP_Slave *) rp->op;
/* Receive data */
if ((sp->Status == MB__NORMAL) && !sp->SingleOp) {
sts = mb_recv_data(local, rp, sp);
}
if (sp->DisableSlave != 1) {
if (sp->Status == MB__NORMAL) {
sp->ErrorCount = 0;
}
else {
sp->ErrorCount++;
}
if (sp->ErrorCount > sp->ErrorLimit) {
memset(&sp->Inputs, 0, local->input_size);
}
}
else {
sp->ErrorCount = 0;
sp->Status = MB__DISABLED;
}
#endif
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Write method for the Modbus_TCP slave
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoRackWrite (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp
)
{
#if 0
io_sRackLocal *local;
pwr_sClass_Modbus_TCP_Slave *sp;
pwr_tStatus sts;
local = rp->Local;
sp = (pwr_sClass_Modbus_TCP_Slave *) rp->op;
local->expected_msgs = 0;
if (sp->Status == MB__NORMAL && sp->DisableSlave != 1) {
sts = mb_send_data( rp, ap->Local, local, ap->op, sp, mb_mSendMask_WriteReq);
}
if (sp->DisableSlave == 1) sp->Status = MB__DISABLED;
#endif
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoRackClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp
)
{
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Modbus_RTU_Slave) = {
pwr_BindIoMethod(IoRackInit),
pwr_BindIoMethod(IoRackRead),
pwr_BindIoMethod(IoRackWrite),
pwr_BindIoMethod(IoRackClose),
pwr_NullMethod
};
......@@ -852,26 +852,12 @@ static pwr_tStatus mb_init_channels( io_tCtx ctx, io_sAgent *ap, io_sRack *rp)
io_sServerModuleLocal *local_card;
io_sCard *cardp;
io_sServerLocal *local;
short input_counter;
short output_counter;
short card_input_counter;
short card_output_counter;
pwr_sClass_Modbus_TCP_Server *op;
pwr_sClass_Modbus_TCP_ServerModule *mp;
char name[196];
pwr_tStatus sts;
pwr_tCid cid;
io_sChannel *chanp;
int i, latent_input_counter, latent_output_counter;
pwr_tInt32 chan_size;
pwr_sClass_ChanDi *chan_di;
pwr_sClass_ChanDo *chan_do;
pwr_sClass_ChanAi *chan_ai;
pwr_sClass_ChanAit *chan_ait;
pwr_sClass_ChanIi *chan_ii;
pwr_sClass_ChanAo *chan_ao;
pwr_sClass_ChanIo *chan_io;
int i;
sts = gdh_ObjidToName(rp->Objid, (char *) &name, sizeof(name), cdh_mNName);
......@@ -885,169 +871,83 @@ static pwr_tStatus mb_init_channels( io_tCtx ctx, io_sAgent *ap, io_sRack *rp)
cardp = rp->cardlist;
input_counter = 0;
output_counter = 0;
card_input_counter = 0;
card_output_counter = 0;
latent_input_counter = 0;
latent_output_counter = 0;
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;
while(cardp) {
local_card = calloc(1, sizeof(*local_card));
cardp->Local = local_card;
input_counter = input_counter + card_input_counter + latent_input_counter;
output_counter = output_counter + card_output_counter + latent_output_counter;
local_card->input_area = (void *) &(op->Inputs) + input_counter;
local_card->output_area = (void *) &(op->Outputs) + output_counter;
card_input_counter = 0;
card_output_counter = 0;
latent_input_counter = 0;
latent_output_counter = 0;
/* From v4.1.3 we can have subclasses, find the super class */
cid = cardp->Class;
while ( ODD( gdh_GetSuperClass( cid, &cid, cardp->Objid))) ;
switch (cid) {
case pwr_cClass_Modbus_TCP_ServerModule:
mp = (pwr_sClass_Modbus_TCP_ServerModule *) cardp->op;
mp->Status = pwr_eModbusModule_StatusEnum_StatusUnknown;
for (i = 0; i < cardp->ChanListSize; i++) {
chanp = &cardp->chanlist[i];
if ( is_diag( &chanp->ChanAref)) {
chanp->udata |= PB_UDATA_DIAG;
switch (chanp->ChanClass) {
case pwr_cClass_ChanIi:
chanp->offset = ((pwr_sClass_ChanIi *)chanp->cop)->Number;
chanp->size = GetChanSize( ((pwr_sClass_ChanIi *)chanp->cop)->Representation);
break;
default:
errh_Error( "Diagnostic channel class, card %s", cardp->Name);
}
continue;
}
if (chanp->ChanClass != pwr_cClass_ChanDi) {
card_input_counter += latent_input_counter;
latent_input_counter = 0;
}
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;
if (chanp->ChanClass != pwr_cClass_ChanDo) {
card_output_counter += latent_output_counter;
latent_output_counter = 0;
}
switch (chanp->ChanClass) {
case pwr_cClass_ChanDi:
chan_di = (pwr_sClass_ChanDi *) chanp->cop;
if (chan_di->Number == 0) {
card_input_counter += latent_input_counter;
latent_input_counter = 0;
}
chanp->offset = card_input_counter;
chanp->mask = 1 << chan_di->Number;
if (chan_di->Representation == pwr_eDataRepEnum_Bit16)
chanp->mask = swap16(chanp->mask);
if (chan_di->Representation == pwr_eDataRepEnum_Bit32)
chanp->mask = swap32((unsigned short) chanp->mask);
if (chan_di->Number == 0) latent_input_counter = GetChanSize(chan_di->Representation);
if (local_card->di_size == 0)
local_card->di_offset = chanp->offset;
if (chan_di->Number == 0 || local_card->di_size == 0)
local_card->di_size += GetChanSize(chan_di->Representation);
// printf("Di channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_di->Number, chanp->offset);
break;
case pwr_cClass_ChanAi:
chan_ai = (pwr_sClass_ChanAi *) chanp->cop;
chanp->offset = card_input_counter;
chan_size = GetChanSize(chan_ai->Representation);
chanp->size = chan_size;
chanp->mask = 0;
card_input_counter += chan_size;
io_AiRangeToCoef(chanp);
// printf("Ai channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_ai->Number, chanp->offset);
break;
case pwr_cClass_ChanAit:
chan_ait = (pwr_sClass_ChanAit *) chanp->cop;
chanp->offset = card_input_counter;
chan_size = GetChanSize(chan_ait->Representation);
chanp->size = chan_size;
chanp->mask = 0;
card_input_counter += chan_size;
io_AiRangeToCoef(chanp);
break;
case pwr_cClass_ChanIi:
chan_ii = (pwr_sClass_ChanIi *) chanp->cop;
chanp->offset = card_input_counter;
chan_size = GetChanSize(chan_ii->Representation);
chanp->size = chan_size;
chanp->mask = 0;
card_input_counter += chan_size;
// printf("Ii channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_ii->Number, chanp->offset);
break;
case pwr_cClass_ChanDo:
chan_do = (pwr_sClass_ChanDo *) chanp->cop;
if (chan_do->Number == 0) {
card_output_counter += latent_output_counter;
latent_output_counter = 0;
}
chanp->offset = card_output_counter;
chan_size = GetChanSize(chan_do->Representation);
chanp->mask = 1 << chan_do->Number;
if (chan_do->Representation == pwr_eDataRepEnum_Bit16)
chanp->mask = swap16(chanp->mask);
if (chan_do->Representation == pwr_eDataRepEnum_Bit32)
chanp->mask = swap32((unsigned short) chanp->mask);
if (chan_do->Number == 0) latent_output_counter = GetChanSize(chan_do->Representation);
if (local_card->do_size == 0)
local_card->do_offset = chanp->offset;
if (chan_do->Number == 0 || local_card->do_size == 0)
local_card->do_size += GetChanSize(chan_do->Representation);
// printf("Do channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_do->Number, chanp->offset);
break;
case pwr_cClass_ChanAo:
chan_ao = (pwr_sClass_ChanAo *) chanp->cop;
chanp->offset = card_output_counter;
chan_size = GetChanSize(chan_ao->Representation);
chanp->size = chan_size;
chanp->mask = 0;
card_output_counter += chan_size;
io_AoRangeToCoef(chanp);
// printf("Ao channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_ao->Number, chanp->offset);
break;
case pwr_cClass_ChanIo:
chan_io = (pwr_sClass_ChanIo *) chanp->cop;
chanp->offset = card_output_counter;
chan_size = GetChanSize(chan_io->Representation);
chanp->size = chan_size;
chanp->mask = 0;
card_output_counter += chan_size;
// printf("Io channel found in %s, Number %d, Offset %d\n", cardp->Name, chan_io->Number, chanp->offset);
break;
}
} /* End - for ... */
break;
} /* End - switch ... */
local_card->input_size = card_input_counter + latent_input_counter;
local_card->output_size = card_output_counter + latent_output_counter;
io_bus_card_init( ctx, cardp, &input_area_offset, &input_area_chansize,
&output_area_offset, &output_area_chansize,
pwr_eByteOrderingEnum_BigEndian);
for (i = 0; i < cardp->ChanListSize; i++) {
chanp = &cardp->chanlist[i];
switch (chanp->ChanClass) {
case pwr_cClass_ChanDi: {
pwr_sClass_ChanDi *chan_di = (pwr_sClass_ChanDi *) chanp->cop;
if (local_card->di_size == 0)
local_card->di_offset = chanp->offset;
if (chan_di->Number == 0 || local_card->di_size == 0)
local_card->di_size += GetChanSize(chan_di->Representation);
break;
}
case pwr_cClass_ChanDo: {
pwr_sClass_ChanDo *chan_do = (pwr_sClass_ChanDo *) chanp->cop;
if (local_card->do_size == 0)
local_card->do_offset = chanp->offset;
if (chan_do->Number == 0 || local_card->do_size == 0)
local_card->do_size += GetChanSize(chan_do->Representation);
break;
}
case pwr_cClass_ChanD: {
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 {
if (local_card->do_size == 0)
local_card->do_offset = chanp->offset;
if (chan_d->Number == 0 || local_card->do_size == 0)
local_card->do_size += GetChanSize(chan_d->Representation);
}
break;
}
}
}
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;
cardp = cardp->next;
}
local->input_size = input_counter + card_input_counter + latent_input_counter;
local->output_size = output_counter + card_output_counter + latent_output_counter;
local->input_size = input_area_offset + input_area_chansize;
local->output_size = output_area_offset + output_area_chansize;
return IO__SUCCESS;
}
......
......@@ -112,6 +112,10 @@ typedef struct {
short int no_do;
int interval_cnt;
int has_read_method;
} io_sCardLocalMsg;
typedef struct {
io_sCardLocalMsg msg[2];
} io_sCardLocal;
typedef struct {
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* 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 Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#ifndef pwr_class_h
#include "pwr_class.h"
#endif
#define IO_MAXCHAN 96
#define MAX_MSGS_LOST 5
// These constants are obsolete from V4.1, except for the old style
// (Pb_Di, Pb_Do etc)
#define PB_MODULE_STATE_NOTINIT 0
#define PB_MODULE_STATE_OPERATE 1
#define PB_NUMREP_UNSIGNEDINT 0
#define PB_NUMREP_SIGNEDINT 1
#define PB_NUMREP_FLOATIEEE 2
#define PB_NUMREP_FLOATVAX 3
#define PB_NUMREP_FLOATINTEL 4
#define PB_ORIENTATION_BYTE 8
#define PB_ORIENTATION_WORD 16
#define PB_ORIENTATION_DWORD 32
#define PB_UDATA_DIAG 1
#define MB_MAX_CONNECTIONS 20
typedef pwr_tMask mb_tSendMask;
typedef enum {
mb_mSendMask_ReadReq = 1,
mb_mSendMask_WriteReq = 2,
} mb_mSendMask;
typedef struct {
int initialized;
int fd;
} io_sAgentLocal;
typedef struct {
int initialized;
short int trans_id;
int input_size;
int output_size;
int msgs_lost;
pwr_tTime last_try_connect_time;
int reset_inputs;
} io_sRackLocal;
typedef struct {
void *input_area;
void *output_area;
int scancount[IO_MAXCHAN];
int trans_id;
int input_size;
int output_size;
short int no_di;
short int no_do;
int interval_cnt;
int has_read_method;
} io_sCardLocalMsg;
typedef struct {
io_sCardLocalMsg msg[2];
} io_sCardLocal;
typedef struct {
int initialized;
int fd;
int input_size;
int output_size;
pwr_tTime last_req_time;
thread_sMutex mutex;
thread_s receive_thread;
} io_sServerLocal;
typedef struct {
void *input_area;
void *output_area;
int scancount[IO_MAXCHAN];
int trans_id;
int input_size;
int output_size;
int no_di;
int no_do;
int di_offset;
int do_offset;
int di_size;
int do_size;
} io_sServerModuleLocal;
#pragma pack(1)
typedef struct _read_req {
unsigned char unit_id;
unsigned char fc;
short int addr;
short int quant;
short int crc;
} read_req;
typedef struct _rec_buf {
unsigned char unit_id;
unsigned char fc;
unsigned char buf[255];
} rec_buf;
typedef struct _write_single_req {
unsigned char unit_id;
unsigned char fc;
short int addr;
short int value;
short int crc;
} write_single_req;
typedef struct _write_reg_req {
unsigned char unit_id;
unsigned char fc;
short int addr;
short int quant;
unsigned char bc;
short int reg[125];
short int crc;
} write_reg_req;
typedef struct _write_coils_req {
unsigned char unit_id;
unsigned char fc;
short int addr;
short int quant;
unsigned char bc;
unsigned char reg[247];
short int crc;
} write_coils_req;
typedef struct _read_dev_id_req {
unsigned char unit_id;
unsigned char fc;
unsigned char mei_type;
unsigned char id_code;
unsigned char object_id;
short int crc;
} read_dev_id_req;
typedef struct _res_write {
unsigned char unit_id;
unsigned char fc;
short int addr;
short int quant;
unsigned char buf[248];
short int crc;
} res_write;
typedef struct _res_read {
unsigned char unit_id;
unsigned char fc;
unsigned char bc;
unsigned char buf[251];
short int crc;
} res_read;
typedef struct _res_fault {
unsigned char unit_id;
unsigned char fc;
unsigned char ec;
short int crc;
} res_fault;
typedef struct _rsp_fault {
unsigned char unit_id;
unsigned char fc;
unsigned char ec;
short int crc;
} rsp_fault;
typedef struct _rsp_read {
unsigned char unit_id;
unsigned char fc;
unsigned char bc;
unsigned char buf[250];
short int crc;
} rsp_read;
typedef struct _rsp_write {
unsigned char unit_id;
unsigned char fc;
short int addr;
short int quant;
short int crc;
} rsp_write;
typedef struct _rsp_single_write {
unsigned char unit_id;
unsigned char fc;
short int addr;
short int value;
short int crc;
} rsp_single_write;
typedef struct _rsp_dev_id {
unsigned char unit_id;
unsigned char fc;
unsigned char mei_type;
unsigned char id_code;
unsigned char conformity_level;
unsigned char more_follows;
unsigned char next_object_id;
unsigned char number_of_objects;
unsigned char list[80];
short int crc;
} rsp_dev_id;
#pragma pack(0)
pwr_tStatus mb_recv_data(io_sRackLocal *local,
io_sRack *rp,
pwr_sClass_Modbus_TCP_Slave *sp);
pwr_tStatus mb_send_data(io_sRackLocal *local,
io_sRack *rp,
pwr_sClass_Modbus_TCP_Slave *sp,
mb_tSendMask mask);
......@@ -153,11 +153,24 @@ init (
exit(sts);
}
#if defined OS_CYGWIN
qcom_sQattr qAttr;
qcom_sQid qid = qcom_cQnacp;
qAttr.type = qcom_eQtype_private;
qAttr.quota = 100;
if (!qcom_CreateQ(&sts, &qid, &qAttr, "nacp")) {
errh_Error("Failed to create QCOM que\n%m", sts);
errh_SetStatus( PWR__SRVTERM);
exit(sts);
}
#else
if (!qcom_AttachQ(&sts, &qcom_cQnacp)) {
errh_Fatal("qcom_AttachQ, %m", sts);
errh_SetStatus( PWR__SRVTERM);
exit(sts);
}
#endif
*myQid = qcom_cQnacp;
if (!qcom_Bind(&sts, myQid, &qcom_cQini)) {
......
......@@ -35,19 +35,36 @@
# General Public License plus this exception.
#
kill -9 `ps ax | grep "rt_neth_acp" | awk '{ print $1}'`
kill -9 `ps ax | grep "rt_neth" | awk '{ print $1}'`
kill -9 `ps ax | grep "rt_qmon" | awk '{ print $1}'`
kill -9 `ps ax | grep "rt_emon" | awk '{ print $1}'`
kill -9 `ps ax | grep "rt_tmon" | awk '{ print $1}'`
kill -9 `ps ax | grep "rt_\|/pwr/exe/rs" | awk '{ print $1}'`
kill -9 `ps ax | grep "\[rt_" | awk '{ print $1}'`
kill -9 `ps ax | grep "plc_" | awk '{ print $1}'`
kill -9 `ps ax | grep "jpwr.rt" | awk '{ print $1}'`
kill -9 `ps ax | grep "rs_nmps" | awk '{ print $1}'`
kill -9 `ps ax | grep "rs_remote" | awk '{ print $1}'`
kill -9 `ps ax | grep "sev_server" | awk '{ print $1}'`
kill -9 `ps ax | grep "opc_server" | awk '{ print $1}'`
pwrp_kill_rt()
{
OLD_IFS=$IFS
IFS=$(echo -en "\n\b")
a=`ps ax | grep $1`
for b in $a
do
c=`echo ${b:1} | awk '{ print $1}'`
kill -9 $c
done
# kill -9 `ps ax | grep "rt_neth_acp" | awk '{ print $2}'`
IFS=$OLD_IFS
}
pwrp_kill_rt "rt_neth_acp"
pwrp_kill_rt "rt_neth"
pwrp_kill_rt "rt_qmon"
pwrp_kill_rt "rt_emon"
pwrp_kill_rt "rt_tmon"
pwrp_kill_rt "exe/rt_"
pwrp_kill_rt "exe/rs_"
pwrp_kill_rt "\[rt_"
pwrp_kill_rt "plc_"
pwrp_kill_rt "jpwr.rt"
pwrp_kill_rt "rs_nmps"
pwrp_kill_rt "rs_remote"
pwrp_kill_rt "sev_server"
pwrp_kill_rt "opc_server"
if [ -u $pwr_exe/rt_ini ]; then
user=`ls -al $pwr_exe/rt_ini | awk '{ print $3}'`
else
......
......@@ -491,7 +491,7 @@ pwrc_create_func()
local proot
local bname
local pname
local platforms="x86_linux x86_64_linux arm_linux x86_64_macos"
local platforms="x86_cygwin"
let argc=$#
cmd="project"
......
......@@ -753,7 +753,7 @@ get_name (char *name, int size)
{
int len = strlen(UNKNOWN_PROGRAM_NAME);
strncat(name, UNKNOWN_PROGRAM_NAME, MIN(size, len));
strncpy(name, UNKNOWN_PROGRAM_NAME, MIN(size, len));
name[MIN(size, len)] = '\0';
......
......@@ -276,7 +276,9 @@ qini_BuildDb (
addQueue(ap, qcom_cImhAllOutunits, "allOutunits", qdb_eQue_forward, qdb_mQue_broadcast);
addQueue(ap, qcom_cIhdServer, "hdServer", qdb_eQue_forward, qdb_mQue_broadcast);
addQueue(ap, qcom_cIhdClient, "hdClient", qdb_eQue_forward, qdb_mQue_broadcast);
#if !defined OS_CYGWIN
addQueue(NULL, qcom_cInacp, "nacp", qdb_eQue_private, qdb_mQue_system);
#endif
addQueue(ap, qcom_cIini, "ini", qdb_eQue_forward, qdb_mQue_system | qdb_mQue_event);
} qdb_ScopeUnlock;
......
# port/package comment, name, category, and maintainer.
COMMENT= Proview development and runtime package
DISTNAME= pwr48-4.8.3
CATEGORIES= misc
MAINTAINER= Proview <postmaster@proview.se>
# Mandatory licensing variables.
PERMIT_PACKAGE_CDROM= NO
PERMIT_PACKAGE_FTP= NO
PERMIT_DISTFILES_CDROM= NO
PERMIT_DISTFILES_FTP= NO
# Don't build or run regress tests; specify all architectures.
NO_BUILD= Yes
NO_REGRESS= Yes
PKG_ARCH= amd64
# Install under /usr/local/.
do-install:
${INSTALL_SCRIPT} ${WRKSRC}/bin/* ${PREFIX}/bin/
${INSTALL_DATA_DIR} ${PREFIX}/share/myscripts/
${INSTALL_DATA} ${WRKSRC}/share/pwr48/* ${PREFIX}/share/pwr48/
# Include the BSD port system.
.include <bsd.port.mk>
#!/bin/bash
aroot="/usr/pwrp/adm"
# Get version
if [ -e $pwr_inc/pwr_version.h ]; then
ver=`eval cat $pwr_inc/pwr_version.h | grep "\bpwrv_cWbdbVersionShortStr\b" | awk '{print $3}'`
if [ -z $ver ]; then
echo "Unable to get pwr version"
ver="V00"
fi
ver=${ver:2:2}
fi
# Generate version help file
{
if [ ! -e $pwre_sroot/tools/pkg/cygwin/pwr/control ]; then
echo "Controlfile not found"
exit 1
fi
datfile=$pwre_sroot/tools/pkg/cygwin/pwr/control
echo "<topic> version"
d=`eval date +\"%F %X\"`
{
let printout=0
while read line; do
if [ "${line:0:9}" = "Package: " ]; then
package=${line#Package: }
fi
if [ "${line:0:9}" = "Version: " ]; then
version=${line#Version: }
fi
if [ "${line:0:14}" = "Architecture: " ]; then
arch=${line#Architecture: }
fi
if [ "${line:0:12}" = "Description:" ]; then
echo ""
echo "<image> pwr_logga.gif"
echo ""
echo ""
echo ""
echo "<b>Proview V${version:0:3}"
echo "Version V$version"
echo ""
echo "Copyright 2004-${d:0:4} SSAB Oxelsund AB"
echo ""
echo "This program is free software; you can redistribute it and/or"
echo "modify it under the terms of the GNU General Public License as"
echo "published by the Free Software Foundation, either version 2 of"
echo "the License, or (at your option) any later version."
echo ""
echo "This program is distributed in the hope that it will be useful"
echo "but WITHOUT ANY WARRANTY; without even the implied warranty of"
echo "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
echo "For more details, see the"
echo "GNU General Public License. <weblink> http://www.proview.se/gpllicense.html"
echo ""
echo "E-mail postmaster@proview.se"
echo "Internet www.proview.se <link> http://www.proview.se/index.html"
echo ""
echo ""
echo "<b>Package"
echo "Package $package""_""$version""_""$arch"
echo "Build date $d"
echo "Package description:"
echo ""
printout=1
else
if [ $printout -eq 1 ]; then
echo $line
fi
fi
done
} < $datfile
echo "</topic>"
} > $pwr_eexe/wtt_version_help.dat
# Convert to html
co_convert -t -d $pwr_doc $pwr_eexe/wtt_version_help.dat
{
echo "<html><head>"
echo "<meta http-equiv=\"Refresh\" content=\"5;../wtt_version_help_version.html\">"
echo "</head></html>"
} > $pwr_doc/en_us/package_version.html
if [ "$1" == "-v" ]; then
exit
fi
pkgroot=$pwre_broot/$pwre_target/bld/pkg/pwr$ver
pkgsrc=$pwre_sroot/tools/pkg/cygwin/pwr
packagename=pwr$ver-$version.tar.gz
echo "-- Building pwr$ver"
# Create directories
mkdir -p $pkgroot/etc/pwr$ver
mkdir -p $pkgroot/usr/share/doc/pwr$ver
mkdir -p $pkgroot/usr/pwrp
mkdir -p $pkgroot/etc
find $pkgroot -type d | xargs chmod 755
# copyright
cp $pkgsrc/copyright $pkgroot/usr/share/doc/pwr$ver
# changelog
cp $pkgsrc/changelog $pkgroot/usr/share/doc/pwr$ver
gzip -fq --best $pkgroot/usr/share/doc/pwr$ver/changelog
# Man pages
mkdir -p $pkgroot/usr/share/man/man1
cp $pkgsrc/pwr.1 $pkgroot/usr/share/man/man1/pwr.1
gzip -fq --best $pkgroot/usr/share/man/man1/pwr.1
# Copy proview
mkdir $pkgroot/usr/pwr$ver
currentdir="`eval pwd`"
tarfile=$pwre_broot/$pwre_target/bld/pkg/pwrtmp.tar
cd $pwre_broot
echo "-- copy release to package tree"
tar -cf $tarfile $pwre_target/exp
cd $pkgroot/usr/pwr$ver
tar -xf $tarfile
rm $tarfile
cd $currentdir
# Remove not needed libraries
rm $pkgroot/usr/pwr$ver/$pwre_target/exp/lib/libpwr_flow.a
rm $pkgroot/usr/pwr$ver/$pwre_target/exp/lib/libpwr_ge.a
rm $pkgroot/usr/pwr$ver/$pwre_target/exp/lib/libpwr_glow.a
rm $pkgroot/usr/pwr$ver/$pwre_target/exp/lib/libpwr_tlog.a
rm $pkgroot/usr/pwr$ver/$pwre_target/exp/lib/libpwr_wb.a
rm $pkgroot/usr/pwr$ver/$pwre_target/exp/lib/libpwr_xtt.a
# Copy configuration files to cnf
cp $pkgsrc/proview.cnf $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf
cp $pkgsrc/pwrp_profile $pkgroot/etc
chmod a+x $pkgroot/etc/pwrp_profile
# Copy adm files to cnf
cp $pwre_sroot/tools/pkg/deb/adm/pwr_setup.sh $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf
echo "pwrp set base V${ver:0:1}.${ver:1:1}" >> $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf/pwr_setup.sh
chmod a+x $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf/pwr_setup.sh
cp $pwre_sroot/tools/pkg/deb/adm/pwra_env.sh $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf
chmod a+x $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf/pwra_env.sh
cp $pwre_sroot/tools/pkg/deb/adm/pwr_volumelist.dat $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf
cp $pwre_sroot/tools/pkg/deb/adm/pwr_user2.dat $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf
cp $pwre_sroot/tools/pkg/deb/adm/proview_icon.png $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf
# Copy user to cnf
mkdir $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf/user
cp $pwre_sroot/tools/pkg/cygwin/user/.bashrc $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf/user
echo "source $aroot/db/pwr_setup.sh" >> $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf/user/.bashrc
cp $pwre_sroot/tools/pkg/deb/user/.bash_profile $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf/user
cp $pwre_sroot/tools/pkg/deb/user/.rtt_start $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf/user
cp $pwre_sroot/tools/pkg/deb/user/.xtt_start $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf/user
cp $pwre_sroot/tools/pkg/deb/user/wtt_init.pwr_com $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf/user
cp $pwre_sroot/tools/pkg/deb/user/wtt_init1.pwr_com $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf/user
cp $pwre_sroot/tools/pkg/cygwin/user/Proview.lnk $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf/user
cp $pwre_sroot/tools/pkg/cygwin/user/proview_icon.ico $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf/user
# Generate startscript
{
echo "#!/bin/bash"
echo "export PATH=/usr/local/bin:/usr/bin"
echo "export pwra_db=$aroot/db"
echo "source \$pwra_db/pwr_setup.sh"
echo "source \$pwra_db/pwra_env.sh set base V""${version:0:3}"""
echo "source \$pwra_db/pwra_env.sh set bus"
echo "export DISPLAY=127.0.0.1:0"
echo "wb_gtk -p pwrp pwrp"
} > $pkgroot/usr/pwr$ver/$pwre_target/exp/cnf/user/pwrstart
# Create package
echo "-- Building package"
mkdir -p $pkgroot/etc/pwr$ver
cd $pkgroot
find * -type f -exec echo "rm -f /{}" \; > $pkgroot/etc/pwr$ver/rmfiles.sh
echo "rm -r /usr/pwr$ver" >> $pkgroot/etc/pwr$ver/rmfiles.sh
# control
cp $pkgsrc/control $pkgroot/etc/pwr$ver
cp $pkgsrc/prerm $pkgroot/etc/pwr$ver
cp $pkgsrc/postinst $pkgroot/etc/pwr$ver
tar -czf ../$packagename *
rm -r $pkgroot
Proview V3.4b (3.4.1-1)
\ No newline at end of file
This diff is collapsed.
Proview
Copyright: SSAB Oxelsund AB <ssabox.com>
2003-11-21
The home page of Proview is at:
http://www.proview.se
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Proview V3.4b (3.4.1-1)
\ No newline at end of file
Proview. See also normal changelog file.
\ No newline at end of file
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.
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.
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.
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