merge
This commit is contained in:
@@ -48,12 +48,6 @@ doxygen
|
||||
|
||||
make runtests
|
||||
|
||||
./bin/${EPICS_HOST_ARCH}/testServer &
|
||||
./bin/${EPICS_HOST_ARCH}/testRemoteClientImpl
|
||||
|
||||
# Clean up testServer
|
||||
kill $!
|
||||
|
||||
###########################################
|
||||
# Create distribution
|
||||
|
||||
|
||||
@@ -543,3 +543,381 @@ testApp/utils/testHexDump.cpp
|
||||
testApp/utils/testInetAddressUtils.cpp
|
||||
testApp/utils/transportRegistryTest.cpp
|
||||
pvtoolsSrc/pvlist.cpp
|
||||
configure/O.darwin-x86/Makefile
|
||||
configure/Makefile
|
||||
include/pv/baseChannelRequester.h
|
||||
include/pv/beaconEmitter.h
|
||||
include/pv/beaconHandler.h
|
||||
include/pv/beaconServerStatusProvider.h
|
||||
include/pv/blockingTCP.h
|
||||
include/pv/blockingUDP.h
|
||||
include/pv/caChannel.h
|
||||
include/pv/caProvider.h
|
||||
include/pv/channelSearchManager.h
|
||||
include/pv/clientContextImpl.h
|
||||
include/pv/clientFactory.h
|
||||
include/pv/codec.h
|
||||
include/pv/configuration.h
|
||||
include/pv/hexDump.h
|
||||
include/pv/inetAddressUtil.h
|
||||
include/pv/introspectionRegistry.h
|
||||
include/pv/likely.h
|
||||
include/pv/logger.h
|
||||
include/pv/namedLockPattern.h
|
||||
include/pv/pvAccess.h
|
||||
include/pv/pvAccessMB.h
|
||||
include/pv/pvaConstants.h
|
||||
include/pv/pvaVersion.h
|
||||
include/pv/referenceCountingLock.h
|
||||
include/pv/remote.h
|
||||
include/pv/responseHandlers.h
|
||||
include/pv/rpcClient.h
|
||||
include/pv/rpcServer.h
|
||||
include/pv/rpcService.h
|
||||
include/pv/security.h
|
||||
include/pv/serializationHelper.h
|
||||
include/pv/serverChannelImpl.h
|
||||
include/pv/serverContext.h
|
||||
include/pv/simpleChannelSearchManagerImpl.h
|
||||
include/pv/syncChannelFind.h
|
||||
include/pv/transportRegistry.h
|
||||
include/pv/wildcard.h
|
||||
pvtoolsSrc/O.darwin-x86/Makefile
|
||||
pvtoolsSrc/eget.cpp
|
||||
pvtoolsSrc/Makefile
|
||||
pvtoolsSrc/pvget.cpp
|
||||
pvtoolsSrc/pvinfo.cpp
|
||||
pvtoolsSrc/pvlist.cpp
|
||||
pvtoolsSrc/pvput.cpp
|
||||
pvtoolsSrc/pvutils.cpp
|
||||
pvtoolsSrc/pvutils.h
|
||||
src/ca/caChannel.cpp
|
||||
src/ca/caChannel.h
|
||||
src/ca/caProvider.cpp
|
||||
src/ca/caProvider.h
|
||||
src/ca/Makefile
|
||||
src/client/Makefile
|
||||
src/client/pvAccess.cpp
|
||||
src/client/pvAccess.h
|
||||
src/factory/ChannelAccessFactory.cpp
|
||||
src/factory/Makefile
|
||||
src/mb/Makefile
|
||||
src/mb/pvAccessMB.cpp
|
||||
src/mb/pvAccessMB.h
|
||||
src/O.darwin-x86/Makefile
|
||||
src/pva/clientFactory.cpp
|
||||
src/pva/clientFactory.h
|
||||
src/pva/Makefile
|
||||
src/pva/pvaConstants.h
|
||||
src/pva/pvaVersion.cpp
|
||||
src/pva/pvaVersion.h
|
||||
src/remote/abstractResponseHandler.cpp
|
||||
src/remote/beaconHandler.cpp
|
||||
src/remote/beaconHandler.h
|
||||
src/remote/blockingTCP.h
|
||||
src/remote/blockingTCPAcceptor.cpp
|
||||
src/remote/blockingTCPConnector.cpp
|
||||
src/remote/blockingUDP.h
|
||||
src/remote/blockingUDPConnector.cpp
|
||||
src/remote/blockingUDPTransport.cpp
|
||||
src/remote/channelSearchManager.h
|
||||
src/remote/codec.cpp
|
||||
src/remote/codec.h
|
||||
src/remote/Makefile
|
||||
src/remote/remote.h
|
||||
src/remote/security.cpp
|
||||
src/remote/security.h
|
||||
src/remote/serializationHelper.cpp
|
||||
src/remote/serializationHelper.h
|
||||
src/remote/simpleChannelSearchManagerImpl.cpp
|
||||
src/remote/simpleChannelSearchManagerImpl.h
|
||||
src/remote/transportRegistry.cpp
|
||||
src/remote/transportRegistry.h
|
||||
src/remoteClient/clientContextImpl.cpp
|
||||
src/remoteClient/clientContextImpl.h
|
||||
src/remoteClient/Makefile
|
||||
src/rpcClient/Makefile
|
||||
src/rpcClient/rpcClient.cpp
|
||||
src/rpcClient/rpcClient.h
|
||||
src/rpcService/Makefile
|
||||
src/rpcService/rpcServer.cpp
|
||||
src/rpcService/rpcServer.h
|
||||
src/rpcService/rpcService.cpp
|
||||
src/rpcService/rpcService.h
|
||||
src/server/baseChannelRequester.cpp
|
||||
src/server/baseChannelRequester.h
|
||||
src/server/beaconEmitter.cpp
|
||||
src/server/beaconEmitter.h
|
||||
src/server/beaconServerStatusProvider.cpp
|
||||
src/server/beaconServerStatusProvider.h
|
||||
src/server/Makefile
|
||||
src/server/responseHandlers.cpp
|
||||
src/server/responseHandlers.h
|
||||
src/server/serverChannelImpl.cpp
|
||||
src/server/serverChannelImpl.h
|
||||
src/server/serverContext.cpp
|
||||
src/server/serverContext.h
|
||||
src/utils/configuration.cpp
|
||||
src/utils/configuration.h
|
||||
src/utils/hexDump.cpp
|
||||
src/utils/hexDump.h
|
||||
src/utils/inetAddressUtil.cpp
|
||||
src/utils/inetAddressUtil.h
|
||||
src/utils/introspectionRegistry.cpp
|
||||
src/utils/introspectionRegistry.h
|
||||
src/utils/likely.h
|
||||
src/utils/logger.cpp
|
||||
src/utils/logger.h
|
||||
src/utils/Makefile
|
||||
src/utils/namedLockPattern.h
|
||||
src/utils/referenceCountingLock.cpp
|
||||
src/utils/referenceCountingLock.h
|
||||
src/utils/wildcard.cpp
|
||||
src/utils/wildcard.h
|
||||
src/v3ioc/Makefile
|
||||
src/v3ioc/PVAClientRegister.cpp
|
||||
src/v3ioc/PVAServerRegister.cpp
|
||||
src/v3ioc/syncChannelFind.h
|
||||
src/Makefile
|
||||
testApp/client/O.darwin-x86/Makefile
|
||||
testApp/client/Makefile
|
||||
testApp/client/MockClientImpl.cpp
|
||||
testApp/client/testChannelAccessFactory.cpp
|
||||
testApp/client/testMockClient.cpp
|
||||
testApp/client/testStartStop.cpp
|
||||
testApp/remote/O.darwin-x86/Makefile
|
||||
testApp/remote/channelAccessIFTest.cpp
|
||||
testApp/remote/channelAccessIFTest.h
|
||||
testApp/remote/epicsv4Grayscale.h
|
||||
testApp/remote/Makefile
|
||||
testApp/remote/rpcClientExample.cpp
|
||||
testApp/remote/rpcServiceExample.cpp
|
||||
testApp/remote/rpcWildServiceExample.cpp
|
||||
testApp/remote/syncTestRequesters.h
|
||||
testApp/remote/testADCSim.cpp
|
||||
testApp/remote/testBeaconEmitter.cpp
|
||||
testApp/remote/testBeaconHandler.cpp
|
||||
testApp/remote/testBlockingTCPClnt.cpp
|
||||
testApp/remote/testBlockingTCPSrv.cpp
|
||||
testApp/remote/testBlockingUDPClnt.cpp
|
||||
testApp/remote/testBlockingUDPSrv.cpp
|
||||
testApp/remote/testChannelAccess.cpp
|
||||
testApp/remote/testChannelConnect.cpp
|
||||
testApp/remote/testChannelSearchManager.cpp
|
||||
testApp/remote/testCodec.cpp
|
||||
testApp/remote/testGetPerformance.cpp
|
||||
testApp/remote/testMonitorPerformance.cpp
|
||||
testApp/remote/testNTImage.cpp
|
||||
testApp/remote/testRemoteClientImpl.cpp
|
||||
testApp/remote/testServer.cpp
|
||||
testApp/remote/testServerContext.cpp
|
||||
testApp/utils/O.darwin-x86/Makefile
|
||||
testApp/utils/configurationTest.cpp
|
||||
testApp/utils/introspectionRegistryTest.cpp
|
||||
testApp/utils/loggerTest.cpp
|
||||
testApp/utils/Makefile
|
||||
testApp/utils/namedLockPatternTest.cpp
|
||||
testApp/utils/testAtomicBoolean.cpp
|
||||
testApp/utils/testHexDump.cpp
|
||||
testApp/utils/testInetAddressUtils.cpp
|
||||
testApp/utils/transportRegistryTest.cpp
|
||||
testApp/Makefile
|
||||
Makefile
|
||||
configure/O.darwin-x86/Makefile
|
||||
configure/Makefile
|
||||
include/pv/baseChannelRequester.h
|
||||
include/pv/beaconEmitter.h
|
||||
include/pv/beaconHandler.h
|
||||
include/pv/beaconServerStatusProvider.h
|
||||
include/pv/blockingTCP.h
|
||||
include/pv/blockingUDP.h
|
||||
include/pv/caChannel.h
|
||||
include/pv/caProvider.h
|
||||
include/pv/channelSearchManager.h
|
||||
include/pv/clientContextImpl.h
|
||||
include/pv/clientFactory.h
|
||||
include/pv/codec.h
|
||||
include/pv/configuration.h
|
||||
include/pv/hexDump.h
|
||||
include/pv/inetAddressUtil.h
|
||||
include/pv/introspectionRegistry.h
|
||||
include/pv/likely.h
|
||||
include/pv/logger.h
|
||||
include/pv/namedLockPattern.h
|
||||
include/pv/pvAccess.h
|
||||
include/pv/pvAccessMB.h
|
||||
include/pv/pvaConstants.h
|
||||
include/pv/pvaVersion.h
|
||||
include/pv/referenceCountingLock.h
|
||||
include/pv/remote.h
|
||||
include/pv/responseHandlers.h
|
||||
include/pv/rpcClient.h
|
||||
include/pv/rpcServer.h
|
||||
include/pv/rpcService.h
|
||||
include/pv/security.h
|
||||
include/pv/serializationHelper.h
|
||||
include/pv/serverChannelImpl.h
|
||||
include/pv/serverContext.h
|
||||
include/pv/simpleChannelSearchManagerImpl.h
|
||||
include/pv/syncChannelFind.h
|
||||
include/pv/transportRegistry.h
|
||||
include/pv/wildcard.h
|
||||
pvtoolsSrc/O.darwin-x86/Makefile
|
||||
pvtoolsSrc/eget.cpp
|
||||
pvtoolsSrc/Makefile
|
||||
pvtoolsSrc/pvget.cpp
|
||||
pvtoolsSrc/pvinfo.cpp
|
||||
pvtoolsSrc/pvlist.cpp
|
||||
pvtoolsSrc/pvput.cpp
|
||||
pvtoolsSrc/pvutils.cpp
|
||||
pvtoolsSrc/pvutils.h
|
||||
src/ca/caChannel.cpp
|
||||
src/ca/caChannel.h
|
||||
src/ca/caProvider.cpp
|
||||
src/ca/caProvider.h
|
||||
src/ca/Makefile
|
||||
src/client/Makefile
|
||||
src/client/pvAccess.cpp
|
||||
src/client/pvAccess.h
|
||||
src/factory/ChannelAccessFactory.cpp
|
||||
src/factory/Makefile
|
||||
src/mb/Makefile
|
||||
src/mb/pvAccessMB.cpp
|
||||
src/mb/pvAccessMB.h
|
||||
src/O.darwin-x86/Makefile
|
||||
src/pva/clientFactory.cpp
|
||||
src/pva/clientFactory.h
|
||||
src/pva/Makefile
|
||||
src/pva/pvaConstants.h
|
||||
src/pva/pvaVersion.cpp
|
||||
src/pva/pvaVersion.h
|
||||
src/remote/abstractResponseHandler.cpp
|
||||
src/remote/beaconHandler.cpp
|
||||
src/remote/beaconHandler.h
|
||||
src/remote/blockingTCP.h
|
||||
src/remote/blockingTCPAcceptor.cpp
|
||||
src/remote/blockingTCPConnector.cpp
|
||||
src/remote/blockingUDP.h
|
||||
src/remote/blockingUDPConnector.cpp
|
||||
src/remote/blockingUDPTransport.cpp
|
||||
src/remote/channelSearchManager.h
|
||||
src/remote/codec.cpp
|
||||
src/remote/codec.h
|
||||
src/remote/Makefile
|
||||
src/remote/remote.h
|
||||
src/remote/security.cpp
|
||||
src/remote/security.h
|
||||
src/remote/serializationHelper.cpp
|
||||
src/remote/serializationHelper.h
|
||||
src/remote/simpleChannelSearchManagerImpl.cpp
|
||||
src/remote/simpleChannelSearchManagerImpl.h
|
||||
src/remote/transportRegistry.cpp
|
||||
src/remote/transportRegistry.h
|
||||
src/remoteClient/clientContextImpl.cpp
|
||||
src/remoteClient/clientContextImpl.h
|
||||
src/remoteClient/Makefile
|
||||
src/rpcClient/Makefile
|
||||
src/rpcClient/rpcClient.cpp
|
||||
src/rpcClient/rpcClient.h
|
||||
src/rpcService/Makefile
|
||||
src/rpcService/rpcServer.cpp
|
||||
src/rpcService/rpcServer.h
|
||||
src/rpcService/rpcService.cpp
|
||||
src/rpcService/rpcService.h
|
||||
src/server/baseChannelRequester.cpp
|
||||
src/server/baseChannelRequester.h
|
||||
src/server/beaconEmitter.cpp
|
||||
src/server/beaconEmitter.h
|
||||
src/server/beaconServerStatusProvider.cpp
|
||||
src/server/beaconServerStatusProvider.h
|
||||
src/server/Makefile
|
||||
src/server/responseHandlers.cpp
|
||||
src/server/responseHandlers.h
|
||||
src/server/serverChannelImpl.cpp
|
||||
src/server/serverChannelImpl.h
|
||||
src/server/serverContext.cpp
|
||||
src/server/serverContext.h
|
||||
src/utils/configuration.cpp
|
||||
src/utils/configuration.h
|
||||
src/utils/hexDump.cpp
|
||||
src/utils/hexDump.h
|
||||
src/utils/inetAddressUtil.cpp
|
||||
src/utils/inetAddressUtil.h
|
||||
src/utils/introspectionRegistry.cpp
|
||||
src/utils/introspectionRegistry.h
|
||||
src/utils/likely.h
|
||||
src/utils/logger.cpp
|
||||
src/utils/logger.h
|
||||
src/utils/Makefile
|
||||
src/utils/namedLockPattern.h
|
||||
src/utils/referenceCountingLock.cpp
|
||||
src/utils/referenceCountingLock.h
|
||||
src/utils/wildcard.cpp
|
||||
src/utils/wildcard.h
|
||||
src/v3ioc/Makefile
|
||||
src/v3ioc/PVAClientRegister.cpp
|
||||
src/v3ioc/PVAServerRegister.cpp
|
||||
src/v3ioc/syncChannelFind.h
|
||||
src/Makefile
|
||||
testApp/O.darwin-x86/Makefile
|
||||
testApp/remote/O.darwin-x86/Makefile
|
||||
testApp/remote/channelAccessIFTest.cpp
|
||||
testApp/remote/channelAccessIFTest.h
|
||||
testApp/remote/epicsv4Grayscale.h
|
||||
testApp/remote/Makefile
|
||||
testApp/remote/rpcClientExample.cpp
|
||||
testApp/remote/rpcServiceExample.cpp
|
||||
testApp/remote/rpcWildServiceExample.cpp
|
||||
testApp/remote/syncTestRequesters.h
|
||||
testApp/remote/testADCSim.cpp
|
||||
testApp/remote/testChannelAccess.cpp
|
||||
testApp/remote/testChannelConnect.cpp
|
||||
testApp/remote/testCodec.cpp
|
||||
testApp/remote/testGetPerformance.cpp
|
||||
testApp/remote/testMonitorPerformance.cpp
|
||||
testApp/remote/testNTImage.cpp
|
||||
testApp/remote/testRemoteClientImpl.cpp
|
||||
testApp/remote/testServer.cpp
|
||||
testApp/remote/testServerContext.cpp
|
||||
testApp/utils/O.darwin-x86/Makefile
|
||||
testApp/utils/configurationTest.cpp
|
||||
testApp/utils/introspectionRegistryTest.cpp
|
||||
testApp/utils/loggerTest.cpp
|
||||
testApp/utils/Makefile
|
||||
testApp/utils/namedLockPatternTest.cpp
|
||||
testApp/utils/testAtomicBoolean.cpp
|
||||
testApp/utils/testHexDump.cpp
|
||||
testApp/utils/testInetAddressUtils.cpp
|
||||
testApp/utils/transportRegistryTest.cpp
|
||||
testApp/Makefile
|
||||
testApp/pvAccessAllTests.c
|
||||
Makefile
|
||||
testApp/remote/channelAccessIFTest.cpp
|
||||
testApp/remote/channelAccessIFTest.h
|
||||
testApp/remote/epicsv4Grayscale.h
|
||||
testApp/remote/rpcClientExample.cpp
|
||||
testApp/remote/rpcServiceExample.cpp
|
||||
testApp/remote/rpcWildServiceExample.cpp
|
||||
testApp/remote/syncTestRequesters.h
|
||||
testApp/remote/testADCSim.cpp
|
||||
testApp/remote/testChannelAccess.cpp
|
||||
testApp/remote/testChannelConnect.cpp
|
||||
testApp/remote/testCodec.cpp
|
||||
testApp/remote/testGetPerformance.cpp
|
||||
testApp/remote/testMonitorPerformance.cpp
|
||||
testApp/remote/testNTImage.cpp
|
||||
testApp/remote/testRemoteClientImpl.cpp
|
||||
testApp/remote/testServer.cpp
|
||||
testApp/remote/testServerContext.cpp
|
||||
testApp/utils/configurationTest.cpp
|
||||
testApp/utils/introspectionRegistryTest.cpp
|
||||
testApp/utils/loggerTest.cpp
|
||||
testApp/utils/namedLockPatternTest.cpp
|
||||
testApp/utils/testAtomicBoolean.cpp
|
||||
testApp/utils/testHexDump.cpp
|
||||
testApp/utils/testInetAddressUtils.cpp
|
||||
testApp/utils/transportRegistryTest.cpp
|
||||
testApp/pvAccessAllTests.c
|
||||
testApp/rtemsConfig.c
|
||||
testApp/rtemsNetworking.h
|
||||
testApp/rtemsTestHarness.c
|
||||
|
||||
@@ -10,3 +10,4 @@
|
||||
/home/msekoranja/epicsV4/pvAccessCPP/testApp/remote
|
||||
/home/msekoranja/epicsV4/pvAccessCPP/testApp/client
|
||||
/home/msekoranja/epicsV4/pvAccessCPP/testApp/utils
|
||||
testApp
|
||||
|
||||
@@ -204,7 +204,10 @@ operator<<(pvutil_ostream& o, const epics::pvData::PVStructureArray::shared_poin
|
||||
|
||||
epics::pvData::PVStructureArray::const_svector data(value->view());
|
||||
for (size_t i = 0; i < length; i++)
|
||||
o << data[i];
|
||||
if (data[i].get() == NULL)
|
||||
o << epics::pvData::format::indent() << "(none)" << std::endl;
|
||||
else
|
||||
o << data[i];
|
||||
}
|
||||
|
||||
return o;
|
||||
@@ -223,7 +226,10 @@ operator<<(pvutil_ostream& o, const epics::pvData::PVUnionArray::shared_pointer
|
||||
|
||||
epics::pvData::PVUnionArray::const_svector data(value->view());
|
||||
for (size_t i = 0; i < length; i++)
|
||||
o << data[i];
|
||||
if (data[i].get() == NULL)
|
||||
o << epics::pvData::format::indent() << "(none)" << std::endl;
|
||||
else
|
||||
o << data[i];
|
||||
}
|
||||
|
||||
return o;
|
||||
|
||||
+25
-4
@@ -1,6 +1,27 @@
|
||||
# Makefile for the pvAccess tests
|
||||
|
||||
TOP = ..
|
||||
include $(TOP)/configure/CONFIG
|
||||
DIRS += utils
|
||||
DIRS += client
|
||||
DIRS += remote
|
||||
include $(TOP)/configure/RULES_DIRS
|
||||
|
||||
PVACCESS_TEST = $(TOP)/testApp
|
||||
|
||||
PROD_LIBS += pvAccess pvData pvMB Com
|
||||
|
||||
include $(PVACCESS_TEST)/utils/Makefile
|
||||
include $(PVACCESS_TEST)/remote/Makefile
|
||||
|
||||
# The testHarness runs all the test programs in a known working order.
|
||||
testHarness_SRCS += pvAccessAllTests.c
|
||||
|
||||
PROD_vxWorks = vxTestHarness
|
||||
vxTestHarness_SRCS += $(testHarness_SRCS)
|
||||
TESTSPEC_vxWorks = vxTestHarness.$(MUNCH_SUFFIX); pvAccessAllTests
|
||||
|
||||
PROD_RTEMS += rtemsTestHarness
|
||||
rtemsTestHarness_SRCS += rtemsTestHarness.c rtemsConfig.c
|
||||
rtemsTestHarness_SRCS += $(testHarness_SRCS)
|
||||
TESTSPEC_RTEMS = rtemsTestHarness.$(MUNCH_SUFFIX); pvAccessAllTests
|
||||
|
||||
TESTSCRIPTS_HOST += $(TESTS:%=%.t)
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
TOP=../..
|
||||
|
||||
include $(TOP)/configure/CONFIG
|
||||
|
||||
#PROD_HOST += testChannelAccessFactory
|
||||
testChannelAccessFactory_SRCS = testChannelAccessFactory.cpp
|
||||
testChannelAccessFactory_LIBS = pvAccess pvData Com
|
||||
|
||||
#PROD_HOST += testMockClient
|
||||
testMockClient_SRCS = testMockClient.cpp MockClientImpl.cpp
|
||||
testMockClient_LIBS = pvAccess pvData Com
|
||||
|
||||
PROD_HOST += testStartStop
|
||||
testStartStop_SRCS = testStartStop.cpp
|
||||
testStartStop_LIBS = pvAccess pvData pvMB Com
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
#----------------------------------------
|
||||
# ADD RULES AFTER THIS LINE
|
||||
|
||||
@@ -1,965 +0,0 @@
|
||||
/* MockClientImpl.cpp */
|
||||
/* Author: Matej Sekoranja Date: 2010.12.18 */
|
||||
|
||||
|
||||
#include <epicsExit.h>
|
||||
#include <pv/pvAccess.h>
|
||||
#include <iostream>
|
||||
#include <pv/lock.h>
|
||||
#include <pv/standardPVField.h>
|
||||
|
||||
using namespace epics::pvData;
|
||||
using namespace epics::pvAccess;
|
||||
|
||||
|
||||
|
||||
PVACCESS_REFCOUNT_MONITOR_DEFINE(mockChannelProcess);
|
||||
|
||||
class MockChannelProcess : public ChannelProcess
|
||||
{
|
||||
private:
|
||||
ChannelProcessRequester* m_channelProcessRequester;
|
||||
PVStructure* m_pvStructure;
|
||||
PVScalar* m_valueField;
|
||||
|
||||
private:
|
||||
~MockChannelProcess()
|
||||
{
|
||||
PVACCESS_REFCOUNT_MONITOR_DESTRUCT(mockChannelProcess);
|
||||
}
|
||||
|
||||
public:
|
||||
MockChannelProcess(ChannelProcessRequester* channelProcessRequester, PVStructure *pvStructure, PVStructure *pvRequest) :
|
||||
m_channelProcessRequester(channelProcessRequester), m_pvStructure(pvStructure)
|
||||
{
|
||||
PVACCESS_REFCOUNT_MONITOR_CONSTRUCT(mockChannelProcess);
|
||||
|
||||
PVField* field = pvStructure->getSubField(std::string("value"));
|
||||
if (field == 0)
|
||||
{
|
||||
Status noValueFieldStatus(Status::STATUSTYPE_ERROR, "no 'value' field");
|
||||
m_channelProcessRequester->channelProcessConnect(noValueFieldStatus, this);
|
||||
|
||||
// NOTE client must destroy this instance...
|
||||
// do not access any fields and return ASAP
|
||||
return;
|
||||
}
|
||||
|
||||
if (field->getField()->getType() != scalar)
|
||||
{
|
||||
Status notAScalarStatus(Status::STATUSTYPE_ERROR, "'value' field not scalar type");
|
||||
m_channelProcessRequester->channelProcessConnect(notAScalarStatus, this);
|
||||
|
||||
// NOTE client must destroy this instance….
|
||||
// do not access any fields and return ASAP
|
||||
return;
|
||||
}
|
||||
|
||||
m_valueField = static_cast<PVScalar*>(field);
|
||||
|
||||
// TODO pvRequest
|
||||
m_channelProcessRequester->channelProcessConnect(Status::OK, this);
|
||||
}
|
||||
|
||||
virtual void process(bool lastRequest)
|
||||
{
|
||||
switch (m_valueField->getScalar()->getScalarType())
|
||||
{
|
||||
case pvBoolean:
|
||||
{
|
||||
// negate
|
||||
PVBoolean *pvBoolean = static_cast<PVBoolean*>(m_valueField);
|
||||
pvBoolean->put(!pvBoolean->get());
|
||||
break;
|
||||
}
|
||||
case pvByte:
|
||||
{
|
||||
// increment by one
|
||||
PVByte *pvByte = static_cast<PVByte*>(m_valueField);
|
||||
pvByte->put(pvByte->get() + 1);
|
||||
break;
|
||||
}
|
||||
case pvShort:
|
||||
{
|
||||
// increment by one
|
||||
PVShort *pvShort = static_cast<PVShort*>(m_valueField);
|
||||
pvShort->put(pvShort->get() + 1);
|
||||
break;
|
||||
}
|
||||
case pvInt:
|
||||
{
|
||||
// increment by one
|
||||
PVInt *pvInt = static_cast<PVInt*>(m_valueField);
|
||||
pvInt->put(pvInt->get() + 1);
|
||||
break;
|
||||
}
|
||||
case pvLong:
|
||||
{
|
||||
// increment by one
|
||||
PVLong *pvLong = static_cast<PVLong*>(m_valueField);
|
||||
pvLong->put(pvLong->get() + 1);
|
||||
break;
|
||||
}
|
||||
case pvFloat:
|
||||
{
|
||||
// increment by one
|
||||
PVFloat *pvFloat = static_cast<PVFloat*>(m_valueField);
|
||||
pvFloat->put(pvFloat->get() + 1.0f);
|
||||
break;
|
||||
}
|
||||
case pvDouble:
|
||||
{
|
||||
// increment by one
|
||||
PVDouble *pvDouble = static_cast<PVDouble*>(m_valueField);
|
||||
pvDouble->put(pvDouble->get() + 1.0);
|
||||
break;
|
||||
}
|
||||
case pvString:
|
||||
{
|
||||
// increment by one
|
||||
PVString *pvString = static_cast<PVString*>(m_valueField);
|
||||
string val = pvString->get();
|
||||
if (val.empty())
|
||||
pvString->put("gen0");
|
||||
else
|
||||
{
|
||||
char c = val[0];
|
||||
c++;
|
||||
pvString->put("gen" + c);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// noop
|
||||
break;
|
||||
|
||||
}
|
||||
m_channelProcessRequester->processDone(Status::OK);
|
||||
|
||||
if (lastRequest)
|
||||
destroy();
|
||||
}
|
||||
|
||||
virtual void destroy()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
PVACCESS_REFCOUNT_MONITOR_DEFINE(mockChannelGet);
|
||||
|
||||
class MockChannelGet : public ChannelGet
|
||||
{
|
||||
private:
|
||||
ChannelGetRequester* m_channelGetRequester;
|
||||
PVStructure* m_pvStructure;
|
||||
BitSet* m_bitSet;
|
||||
bool m_first;
|
||||
|
||||
private:
|
||||
~MockChannelGet()
|
||||
{
|
||||
PVACCESS_REFCOUNT_MONITOR_DESTRUCT(mockChannelGet);
|
||||
}
|
||||
|
||||
public:
|
||||
MockChannelGet(ChannelGetRequester* channelGetRequester, PVStructure *pvStructure, PVStructure *pvRequest) :
|
||||
m_channelGetRequester(channelGetRequester), m_pvStructure(pvStructure),
|
||||
m_bitSet(new BitSet(pvStructure->getNumberFields())), m_first(true)
|
||||
{
|
||||
PVACCESS_REFCOUNT_MONITOR_CONSTRUCT(mockChannelGet);
|
||||
|
||||
// TODO pvRequest
|
||||
m_channelGetRequester->channelGetConnect(Status::OK, this, m_pvStructure, m_bitSet);
|
||||
}
|
||||
|
||||
virtual void get(bool lastRequest)
|
||||
{
|
||||
m_channelGetRequester->getDone(Status::OK);
|
||||
if (m_first)
|
||||
{
|
||||
m_first = false;
|
||||
m_bitSet->set(0); // TODO
|
||||
}
|
||||
|
||||
if (lastRequest)
|
||||
destroy();
|
||||
}
|
||||
|
||||
virtual void destroy()
|
||||
{
|
||||
delete m_bitSet;
|
||||
delete this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
PVACCESS_REFCOUNT_MONITOR_DEFINE(mockChannelPut);
|
||||
|
||||
class MockChannelPut : public ChannelPut
|
||||
{
|
||||
private:
|
||||
ChannelPutRequester* m_channelPutRequester;
|
||||
PVStructure* m_pvStructure;
|
||||
BitSet* m_bitSet;
|
||||
bool m_first;
|
||||
|
||||
private:
|
||||
~MockChannelPut()
|
||||
{
|
||||
PVACCESS_REFCOUNT_MONITOR_DESTRUCT(mockChannelPut);
|
||||
}
|
||||
|
||||
public:
|
||||
MockChannelPut(ChannelPutRequester* channelPutRequester, PVStructure *pvStructure, PVStructure *pvRequest) :
|
||||
m_channelPutRequester(channelPutRequester), m_pvStructure(pvStructure),
|
||||
m_bitSet(new BitSet(pvStructure->getNumberFields())), m_first(true)
|
||||
{
|
||||
PVACCESS_REFCOUNT_MONITOR_CONSTRUCT(mockChannelPut);
|
||||
|
||||
// TODO pvRequest
|
||||
m_channelPutRequester->channelPutConnect(Status::OK, this, m_pvStructure, m_bitSet);
|
||||
}
|
||||
|
||||
virtual void put(bool lastRequest)
|
||||
{
|
||||
m_channelPutRequester->putDone(Status::OK);
|
||||
if (lastRequest)
|
||||
destroy();
|
||||
}
|
||||
|
||||
virtual void get()
|
||||
{
|
||||
m_channelPutRequester->getDone(Status::OK);
|
||||
}
|
||||
|
||||
virtual void destroy()
|
||||
{
|
||||
delete m_bitSet;
|
||||
delete this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
PVACCESS_REFCOUNT_MONITOR_DEFINE(mockMonitor);
|
||||
|
||||
class MockMonitor : public Monitor, public MonitorElement
|
||||
{
|
||||
private:
|
||||
MonitorRequester* m_monitorRequester;
|
||||
PVStructure* m_pvStructure;
|
||||
BitSet* m_changedBitSet;
|
||||
BitSet* m_overrunBitSet;
|
||||
bool m_first;
|
||||
Mutex m_lock;
|
||||
int m_count;
|
||||
|
||||
private:
|
||||
~MockMonitor()
|
||||
{
|
||||
PVACCESS_REFCOUNT_MONITOR_DESTRUCT(mockMonitor);
|
||||
}
|
||||
|
||||
public:
|
||||
MockMonitor(MonitorRequester* monitorRequester, PVStructure *pvStructure, PVStructure *pvRequest) :
|
||||
m_monitorRequester(monitorRequester), m_pvStructure(pvStructure),
|
||||
m_changedBitSet(new BitSet(pvStructure->getNumberFields())),
|
||||
m_overrunBitSet(new BitSet(pvStructure->getNumberFields())),
|
||||
m_first(true),
|
||||
m_lock(),
|
||||
m_count(0)
|
||||
{
|
||||
PVACCESS_REFCOUNT_MONITOR_CONSTRUCT(mockMonitor);
|
||||
|
||||
m_changedBitSet->set(0);
|
||||
|
||||
// TODO pvRequest
|
||||
m_monitorRequester->monitorConnect(Status::OK, this, m_pvStructure->getStructure());
|
||||
}
|
||||
|
||||
virtual Status start()
|
||||
{
|
||||
// fist monitor
|
||||
m_monitorRequester->monitorEvent(this);
|
||||
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
virtual Status stop()
|
||||
{
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
virtual MonitorElement* poll()
|
||||
{
|
||||
Lock xx(m_lock);
|
||||
if (m_count)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_count++;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void release(MonitorElement* monitorElement)
|
||||
{
|
||||
Lock xx(m_lock);
|
||||
if (m_count)
|
||||
m_count--;
|
||||
}
|
||||
|
||||
virtual void destroy()
|
||||
{
|
||||
stop();
|
||||
|
||||
delete m_overrunBitSet;
|
||||
delete m_changedBitSet;
|
||||
delete this;
|
||||
}
|
||||
|
||||
// ============ MonitorElement ============
|
||||
|
||||
virtual PVStructure* getPVStructure()
|
||||
{
|
||||
return m_pvStructure;
|
||||
}
|
||||
|
||||
virtual BitSet* getChangedBitSet()
|
||||
{
|
||||
return m_changedBitSet;
|
||||
}
|
||||
|
||||
virtual BitSet* getOverrunBitSet()
|
||||
{
|
||||
return m_overrunBitSet;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
PVACCESS_REFCOUNT_MONITOR_DEFINE(mockChannel);
|
||||
|
||||
class MockChannel : public Channel {
|
||||
private:
|
||||
ChannelProvider* m_provider;
|
||||
ChannelRequester* m_requester;
|
||||
string m_name;
|
||||
string m_remoteAddress;
|
||||
|
||||
PVStructure* m_pvStructure;
|
||||
|
||||
private:
|
||||
~MockChannel()
|
||||
{
|
||||
PVACCESS_REFCOUNT_MONITOR_DESTRUCT(mockChannel);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
MockChannel(
|
||||
ChannelProvider* provider,
|
||||
ChannelRequester* requester,
|
||||
string name,
|
||||
string remoteAddress) :
|
||||
m_provider(provider),
|
||||
m_requester(requester),
|
||||
m_name(name),
|
||||
m_remoteAddress(remoteAddress)
|
||||
{
|
||||
PVACCESS_REFCOUNT_MONITOR_CONSTRUCT(mockChannel);
|
||||
|
||||
|
||||
ScalarType stype = pvDouble;
|
||||
string allProperties("alarm,timeStamp,display,control,valueAlarm");
|
||||
|
||||
m_pvStructure = getStandardPVField()->scalar(
|
||||
0,name,stype,allProperties);
|
||||
PVDouble *pvField = m_pvStructure->getDoubleField(std::string("value"));
|
||||
pvField->put(1.123);
|
||||
|
||||
|
||||
// already connected, report state
|
||||
m_requester->channelStateChange(this, CONNECTED);
|
||||
}
|
||||
|
||||
virtual void destroy()
|
||||
{
|
||||
delete m_pvStructure;
|
||||
delete this;
|
||||
};
|
||||
|
||||
virtual string getRequesterName()
|
||||
{
|
||||
return getChannelName();
|
||||
};
|
||||
|
||||
virtual void message(std::string const & message,MessageType messageType)
|
||||
{
|
||||
std::cout << "[" << getRequesterName() << "] message(" << message << ", " << messageTypeName[messageType] << ")" << std::endl;
|
||||
}
|
||||
|
||||
virtual ChannelProvider* getProvider()
|
||||
{
|
||||
return m_provider;
|
||||
}
|
||||
|
||||
virtual std::string getRemoteAddress()
|
||||
{
|
||||
return m_remoteAddress;
|
||||
}
|
||||
|
||||
virtual std::string getChannelName()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
virtual ChannelRequester* getChannelRequester()
|
||||
{
|
||||
return m_requester;
|
||||
}
|
||||
|
||||
virtual ConnectionState getConnectionState()
|
||||
{
|
||||
return CONNECTED;
|
||||
}
|
||||
|
||||
virtual bool isConnected()
|
||||
{
|
||||
return getConnectionState() == CONNECTED;
|
||||
}
|
||||
|
||||
virtual AccessRights getAccessRights(epics::pvData::PVField *pvField)
|
||||
{
|
||||
return readWrite;
|
||||
}
|
||||
|
||||
virtual void getField(GetFieldRequester *requester,std::string subField)
|
||||
{
|
||||
requester->getDone(Status::OK,m_pvStructure->getSubField(subField)->getField());
|
||||
}
|
||||
|
||||
virtual ChannelProcess* createChannelProcess(
|
||||
ChannelProcessRequester *channelProcessRequester,
|
||||
epics::pvData::PVStructure *pvRequest)
|
||||
{
|
||||
return new MockChannelProcess(channelProcessRequester, m_pvStructure, pvRequest);
|
||||
}
|
||||
|
||||
virtual ChannelGet* createChannelGet(
|
||||
ChannelGetRequester *channelGetRequester,
|
||||
epics::pvData::PVStructure *pvRequest)
|
||||
{
|
||||
return new MockChannelGet(channelGetRequester, m_pvStructure, pvRequest);
|
||||
}
|
||||
|
||||
virtual ChannelPut* createChannelPut(
|
||||
ChannelPutRequester *channelPutRequester,
|
||||
epics::pvData::PVStructure *pvRequest)
|
||||
{
|
||||
return new MockChannelPut(channelPutRequester, m_pvStructure, pvRequest);
|
||||
}
|
||||
|
||||
virtual ChannelPutGet* createChannelPutGet(
|
||||
ChannelPutGetRequester *channelPutGetRequester,
|
||||
epics::pvData::PVStructure *pvRequest)
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual ChannelRPC* createChannelRPC(ChannelRPCRequester *channelRPCRequester,
|
||||
epics::pvData::PVStructure *pvRequest)
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual epics::pvData::Monitor* createMonitor(
|
||||
epics::pvData::MonitorRequester *monitorRequester,
|
||||
epics::pvData::PVStructure *pvRequest)
|
||||
{
|
||||
return new MockMonitor(monitorRequester, m_pvStructure, pvRequest);
|
||||
}
|
||||
|
||||
virtual ChannelArray* createChannelArray(
|
||||
ChannelArrayRequester *channelArrayRequester,
|
||||
epics::pvData::PVStructure *pvRequest)
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void printInfo() {
|
||||
string info;
|
||||
printInfo(&info);
|
||||
std::cout << info.c_str() << std::endl;
|
||||
}
|
||||
|
||||
virtual void printInfo(epics::pvData::StringBuilder out) {
|
||||
//std::ostringstream ostr;
|
||||
//static string emptyString;
|
||||
|
||||
out->append( "CHANNEL : "); out->append(m_name);
|
||||
out->append("\nSTATE : "); out->append(ConnectionStateNames[getConnectionState()]);
|
||||
if (isConnected())
|
||||
{
|
||||
out->append("\nADDRESS : "); out->append(getRemoteAddress());
|
||||
//out->append("\nRIGHTS : "); out->append(getAccessRights());
|
||||
}
|
||||
out->append("\n");
|
||||
}
|
||||
};
|
||||
|
||||
class MockChannelProvider;
|
||||
|
||||
class MockChannelFind : public ChannelFind
|
||||
{
|
||||
public:
|
||||
MockChannelFind(ChannelProvider* provider) : m_provider(provider)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void destroy()
|
||||
{
|
||||
// one instance for all, do not delete at all
|
||||
}
|
||||
|
||||
virtual ChannelProvider* getChannelProvider()
|
||||
{
|
||||
return m_provider;
|
||||
};
|
||||
|
||||
virtual void cancel()
|
||||
{
|
||||
throw std::runtime_error("not supported");
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// only to be destroyed by it
|
||||
friend class MockChannelProvider;
|
||||
virtual ~MockChannelFind() {}
|
||||
|
||||
ChannelProvider* m_provider;
|
||||
};
|
||||
|
||||
class MockChannelProvider : public ChannelProvider {
|
||||
public:
|
||||
|
||||
MockChannelProvider() : m_mockChannelFind(new MockChannelFind(this)) {
|
||||
}
|
||||
|
||||
virtual std::string getProviderName()
|
||||
{
|
||||
return "MockChannelProvider";
|
||||
}
|
||||
|
||||
virtual void destroy()
|
||||
{
|
||||
delete m_mockChannelFind;
|
||||
delete this;
|
||||
}
|
||||
|
||||
virtual ChannelFind* channelFind(
|
||||
std::string channelName,
|
||||
ChannelFindRequester *channelFindRequester)
|
||||
{
|
||||
channelFindRequester->channelFindResult(Status::OK, m_mockChannelFind, true);
|
||||
return m_mockChannelFind;
|
||||
}
|
||||
|
||||
virtual Channel* createChannel(
|
||||
std::string channelName,
|
||||
ChannelRequester *channelRequester,
|
||||
short priority)
|
||||
{
|
||||
return createChannel(channelName, channelRequester, priority, "local");
|
||||
}
|
||||
|
||||
virtual Channel* createChannel(
|
||||
std::string channelName,
|
||||
ChannelRequester *channelRequester,
|
||||
short priority,
|
||||
std::string address)
|
||||
{
|
||||
if (address == "local")
|
||||
{
|
||||
Channel* channel = new MockChannel(this, channelRequester, channelName, address);
|
||||
channelRequester->channelCreated(Status::OK, channel);
|
||||
return channel;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status errorStatus(Status::STATUSTYPE_ERROR, "only local supported");
|
||||
channelRequester->channelCreated(errorStatus, 0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
~MockChannelProvider() {};
|
||||
|
||||
MockChannelFind* m_mockChannelFind;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class MockClientContext : public ClientContext
|
||||
{
|
||||
public:
|
||||
|
||||
MockClientContext() : m_version(new Version("Mock PVA Client", "cpp", 1, 0, 0, 0))
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
|
||||
virtual Version* getVersion() {
|
||||
return m_version;
|
||||
}
|
||||
|
||||
virtual ChannelProvider* getProvider() {
|
||||
return m_provider;
|
||||
}
|
||||
|
||||
virtual void initialize() {
|
||||
m_provider = new MockChannelProvider();
|
||||
}
|
||||
|
||||
virtual void printInfo() {
|
||||
string info;
|
||||
printInfo(&info);
|
||||
std::cout << info.c_str() << std::endl;
|
||||
}
|
||||
|
||||
virtual void printInfo(epics::pvData::StringBuilder out) {
|
||||
out->append(m_version->getVersionString());
|
||||
}
|
||||
|
||||
virtual void destroy()
|
||||
{
|
||||
m_provider->destroy();
|
||||
delete m_version;
|
||||
delete this;
|
||||
}
|
||||
|
||||
virtual void dispose()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
private:
|
||||
~MockClientContext() {};
|
||||
|
||||
Version* m_version;
|
||||
MockChannelProvider* m_provider;
|
||||
};
|
||||
|
||||
|
||||
class ChannelFindRequesterImpl : public ChannelFindRequester
|
||||
{
|
||||
virtual void channelFindResult(const epics::pvData::Status& status,ChannelFind *channelFind,bool wasFound)
|
||||
{
|
||||
std::cout << "[ChannelFindRequesterImpl] channelFindResult("
|
||||
<< status.toString() << ", ..., " << wasFound << ")" << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
class ChannelRequesterImpl : public ChannelRequester
|
||||
{
|
||||
virtual string getRequesterName()
|
||||
{
|
||||
return "ChannelRequesterImpl";
|
||||
};
|
||||
|
||||
virtual void message(std::string const & message,MessageType messageType)
|
||||
{
|
||||
std::cout << "[" << getRequesterName() << "] message(" << message << ", " << messageTypeName[messageType] << ")" << std::endl;
|
||||
}
|
||||
|
||||
virtual void channelCreated(const epics::pvData::Status& status, Channel *channel)
|
||||
{
|
||||
std::cout << "channelCreated(" << status.toString() << ", "
|
||||
<< (channel ? channel->getChannelName() : "(null)") << ")" << std::endl;
|
||||
}
|
||||
|
||||
virtual void channelStateChange(Channel *c, Channel::ConnectionState connectionState)
|
||||
{
|
||||
std::cout << "channelStateChange(" << c->getChannelName() << ", " << Channel::ConnectionStateNames[connectionState] << ")" << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
class GetFieldRequesterImpl : public GetFieldRequester
|
||||
{
|
||||
virtual string getRequesterName()
|
||||
{
|
||||
return "GetFieldRequesterImpl";
|
||||
};
|
||||
|
||||
virtual void message(std::string const & message,MessageType messageType)
|
||||
{
|
||||
std::cout << "[" << getRequesterName() << "] message(" << message << ", " << messageTypeName[messageType] << ")" << std::endl;
|
||||
}
|
||||
|
||||
virtual void getDone(const epics::pvData::Status& status,epics::pvData::FieldConstPtr field)
|
||||
{
|
||||
std::cout << "getDone(" << status.toString() << ", ";
|
||||
if (field)
|
||||
{
|
||||
string str;
|
||||
field->toString(&str);
|
||||
std::cout << str;
|
||||
}
|
||||
else
|
||||
std::cout << "(null)";
|
||||
std::cout << ")" << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
class ChannelGetRequesterImpl : public ChannelGetRequester
|
||||
{
|
||||
ChannelGet *m_channelGet;
|
||||
epics::pvData::PVStructure *m_pvStructure;
|
||||
epics::pvData::BitSet *m_bitSet;
|
||||
|
||||
virtual string getRequesterName()
|
||||
{
|
||||
return "ChannelGetRequesterImpl";
|
||||
};
|
||||
|
||||
virtual void message(std::string const & message,MessageType messageType)
|
||||
{
|
||||
std::cout << "[" << getRequesterName() << "] message(" << message << ", " << messageTypeName[messageType] << ")" << std::endl;
|
||||
}
|
||||
|
||||
virtual void channelGetConnect(const epics::pvData::Status& status,ChannelGet *channelGet,
|
||||
epics::pvData::PVStructure *pvStructure,epics::pvData::BitSet *bitSet)
|
||||
{
|
||||
std::cout << "channelGetConnect(" << status.toString() << ")" << std::endl;
|
||||
|
||||
// TODO sync
|
||||
m_channelGet = channelGet;
|
||||
m_pvStructure = pvStructure;
|
||||
m_bitSet = bitSet;
|
||||
}
|
||||
|
||||
virtual void getDone(const epics::pvData::Status& status)
|
||||
{
|
||||
std::cout << "getDone(" << status.toString() << ")" << std::endl;
|
||||
string str;
|
||||
m_pvStructure->toString(&str);
|
||||
std::cout << str;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
class ChannelPutRequesterImpl : public ChannelPutRequester
|
||||
{
|
||||
ChannelPut *m_channelPut;
|
||||
epics::pvData::PVStructure *m_pvStructure;
|
||||
epics::pvData::BitSet *m_bitSet;
|
||||
|
||||
virtual string getRequesterName()
|
||||
{
|
||||
return "ChannelPutRequesterImpl";
|
||||
};
|
||||
|
||||
virtual void message(std::string const & message,MessageType messageType)
|
||||
{
|
||||
std::cout << "[" << getRequesterName() << "] message(" << message << ", " << messageTypeName[messageType] << ")" << std::endl;
|
||||
}
|
||||
|
||||
virtual void channelPutConnect(const epics::pvData::Status& status,ChannelPut *channelPut,
|
||||
epics::pvData::PVStructure *pvStructure,epics::pvData::BitSet *bitSet)
|
||||
{
|
||||
std::cout << "channelPutConnect(" << status.toString() << ")" << std::endl;
|
||||
|
||||
// TODO sync
|
||||
m_channelPut = channelPut;
|
||||
m_pvStructure = pvStructure;
|
||||
m_bitSet = bitSet;
|
||||
}
|
||||
|
||||
virtual void getDone(const epics::pvData::Status& status)
|
||||
{
|
||||
std::cout << "getDone(" << status.toString() << ")" << std::endl;
|
||||
string str;
|
||||
m_pvStructure->toString(&str);
|
||||
std::cout << str;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
virtual void putDone(const epics::pvData::Status& status)
|
||||
{
|
||||
std::cout << "putDone(" << status.toString() << ")" << std::endl;
|
||||
string str;
|
||||
m_pvStructure->toString(&str);
|
||||
std::cout << str;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class MonitorRequesterImpl : public MonitorRequester
|
||||
{
|
||||
virtual string getRequesterName()
|
||||
{
|
||||
return "MonitorRequesterImpl";
|
||||
};
|
||||
|
||||
virtual void message(std::string const & message,MessageType messageType)
|
||||
{
|
||||
std::cout << "[" << getRequesterName() << "] message(" << message << ", " << messageTypeName[messageType] << ")" << std::endl;
|
||||
}
|
||||
|
||||
virtual void monitorConnect(const Status& status, Monitor* monitor, StructureConstPtr structure)
|
||||
{
|
||||
std::cout << "monitorConnect(" << status.toString() << ")" << std::endl;
|
||||
if (structure)
|
||||
{
|
||||
string str;
|
||||
structure->toString(&str);
|
||||
std::cout << str << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void monitorEvent(Monitor* monitor)
|
||||
{
|
||||
std::cout << "monitorEvent" << std::endl;
|
||||
|
||||
MonitorElement* element = monitor->poll();
|
||||
|
||||
string str("changed/overrun ");
|
||||
element->getChangedBitSet()->toString(&str);
|
||||
str += '/';
|
||||
element->getOverrunBitSet()->toString(&str);
|
||||
str += '\n';
|
||||
element->getPVStructure()->toString(&str);
|
||||
std::cout << str << std::endl;
|
||||
|
||||
monitor->release(element);
|
||||
}
|
||||
|
||||
virtual void unlisten(Monitor* monitor)
|
||||
{
|
||||
std::cout << "unlisten" << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class ChannelProcessRequesterImpl : public ChannelProcessRequester
|
||||
{
|
||||
ChannelProcess *m_channelProcess;
|
||||
|
||||
virtual string getRequesterName()
|
||||
{
|
||||
return "ProcessRequesterImpl";
|
||||
};
|
||||
|
||||
virtual void message(std::string const & message,MessageType messageType)
|
||||
{
|
||||
std::cout << "[" << getRequesterName() << "] message(" << message << ", " << messageTypeName[messageType] << ")" << std::endl;
|
||||
}
|
||||
|
||||
virtual void channelProcessConnect(const epics::pvData::Status& status,ChannelProcess *channelProcess)
|
||||
{
|
||||
std::cout << "channelProcessConnect(" << status.toString() << ")" << std::endl;
|
||||
|
||||
// TODO sync
|
||||
m_channelProcess = channelProcess;
|
||||
}
|
||||
|
||||
virtual void processDone(const epics::pvData::Status& status)
|
||||
{
|
||||
std::cout << "processDone(" << status.toString() << ")" << std::endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
MockClientContext* context = new MockClientContext();
|
||||
context->printInfo();
|
||||
|
||||
|
||||
ChannelFindRequesterImpl findRequester;
|
||||
context->getProvider()->channelFind("something", &findRequester);
|
||||
|
||||
ChannelRequesterImpl channelRequester;
|
||||
//Channel* noChannel
|
||||
context->getProvider()->createChannel("test", &channelRequester, ChannelProvider::PRIORITY_DEFAULT, "over the rainbow");
|
||||
|
||||
Channel* channel = context->getProvider()->createChannel("test", &channelRequester);
|
||||
channel->printInfo();
|
||||
|
||||
GetFieldRequesterImpl getFieldRequesterImpl;
|
||||
channel->getField(&getFieldRequesterImpl, "timeStamp.secondsPastEpoch");
|
||||
|
||||
ChannelGetRequesterImpl channelGetRequesterImpl;
|
||||
ChannelGet* channelGet = channel->createChannelGet(&channelGetRequesterImpl, 0);
|
||||
channelGet->get(false);
|
||||
channelGet->destroy();
|
||||
|
||||
ChannelPutRequesterImpl channelPutRequesterImpl;
|
||||
ChannelPut* channelPut = channel->createChannelPut(&channelPutRequesterImpl, 0);
|
||||
channelPut->get();
|
||||
channelPut->put(false);
|
||||
channelPut->destroy();
|
||||
|
||||
|
||||
MonitorRequesterImpl monitorRequesterImpl;
|
||||
Monitor* monitor = channel->createMonitor(&monitorRequesterImpl, 0);
|
||||
|
||||
Status status = monitor->start();
|
||||
std::cout << "monitor->start() = " << status.toString() << std::endl;
|
||||
|
||||
|
||||
ChannelProcessRequesterImpl channelProcessRequester;
|
||||
ChannelProcess* channelProcess = channel->createChannelProcess(&channelProcessRequester, 0);
|
||||
channelProcess->process(false);
|
||||
channelProcess->destroy();
|
||||
|
||||
|
||||
status = monitor->stop();
|
||||
std::cout << "monitor->stop() = " << status.toString() << std::endl;
|
||||
|
||||
|
||||
monitor->destroy();
|
||||
|
||||
channel->destroy();
|
||||
|
||||
context->destroy();
|
||||
|
||||
//std::cout << "-----------------------------------------------------------------------" << std::endl;
|
||||
//epicsExitCallAtExits();
|
||||
return(0);
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/* testChannelAccessFactory.cpp */
|
||||
/* Author: Matej Sekoranja Date: 2010.11.03 */
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <pv/pvAccess.h>
|
||||
|
||||
|
||||
#include <epicsAssert.h>
|
||||
|
||||
using namespace epics::pvData;
|
||||
using namespace epics::pvAccess;
|
||||
|
||||
class DummyChannelProvider : public ChannelProvider {
|
||||
private:
|
||||
string m_name;
|
||||
public:
|
||||
DummyChannelProvider(std::string name) : m_name(name) {};
|
||||
void destroy() {};
|
||||
string getProviderName() { return m_name; };
|
||||
|
||||
ChannelFind* channelFind(std::string channelName,ChannelFindRequester *channelFindRequester)
|
||||
{ return 0; }
|
||||
|
||||
Channel* createChannel(std::string channelName,ChannelRequester *channelRequester,short priority)
|
||||
{ return 0; }
|
||||
|
||||
Channel* createChannel(std::string channelName,ChannelRequester *channelRequester,short priority,String address)
|
||||
{ return 0; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
void testChannelAccessFactory() {
|
||||
printf("testChannelAccessFactory... ");
|
||||
|
||||
ChannelAccess* ca = getChannelProviderRegistry();
|
||||
assert(ca);
|
||||
|
||||
// empty
|
||||
std::vector<String>* providers = ca->getProviderNames();
|
||||
assert(providers);
|
||||
assert(providers->size() == 0);
|
||||
delete providers;
|
||||
|
||||
// register 2
|
||||
ChannelProvider* cp1 = new DummyChannelProvider("dummy1");
|
||||
registerChannelProvider(cp1);
|
||||
|
||||
ChannelProvider* cp2 = new DummyChannelProvider("dummy2");
|
||||
registerChannelProvider(cp2);
|
||||
|
||||
providers = ca->getProviderNames();
|
||||
assert(providers);
|
||||
assert(providers->size() == 2);
|
||||
assert(providers->at(0) == "dummy1");
|
||||
assert(providers->at(1) == "dummy2");
|
||||
|
||||
assert(ca->getProvider("dummy1") == cp1);
|
||||
assert(ca->getProvider("dummy2") == cp2);
|
||||
|
||||
delete providers;
|
||||
|
||||
|
||||
// unregister first
|
||||
unregisterChannelProvider(cp1);
|
||||
|
||||
providers = ca->getProviderNames();
|
||||
assert(providers);
|
||||
assert(providers->size() == 1);
|
||||
assert(providers->at(0) == "dummy2");
|
||||
assert(ca->getProvider("dummy2") == cp2);
|
||||
delete providers;
|
||||
|
||||
printf("PASSED\n");
|
||||
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
testChannelAccessFactory();
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
/* testMockClient.cpp */
|
||||
@@ -1,14 +0,0 @@
|
||||
#include <iostream>
|
||||
#include <pv/clientFactory.h>
|
||||
|
||||
int main() {
|
||||
std::cout << "to start pvAccess ClientFactory" << std::endl;
|
||||
::epics::pvAccess::ClientFactory::start();
|
||||
std::cout << "do nothing after starting pvAccess ClientFactory" << std::endl;
|
||||
|
||||
std::cout << "to stop pvAccess ClientFactory" << std::endl;
|
||||
::epics::pvAccess::ClientFactory::stop();
|
||||
std::cout << "finish test" << std::endl;
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Run pvData tests as a batch.
|
||||
*
|
||||
* Do *not* include performance measurements here, they don't help to
|
||||
* prove functionality (which is the point of this convenience routine).
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <epicsThread.h>
|
||||
#include <epicsUnitTest.h>
|
||||
|
||||
/* utils */
|
||||
int testAtomicBoolean(void);
|
||||
int testHexDump(void);
|
||||
int testInetAddressUtils(void);
|
||||
|
||||
/* remote */
|
||||
int testCodec(void);
|
||||
int testChannelAccess(void);
|
||||
|
||||
void pvAccessAllTests(void)
|
||||
{
|
||||
testHarness();
|
||||
|
||||
/* utils */
|
||||
runTest(testAtomicBoolean);
|
||||
runTest(testHexDump);
|
||||
runTest(testInetAddressUtils);
|
||||
|
||||
/* remote */
|
||||
runTest(testCodec);
|
||||
runTest(testChannelAccess);
|
||||
|
||||
}
|
||||
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
qemu-system-i386 --kernel O.RTEMS-pc386/rtemsTestHarness -netdev user,id=mynet0 -device ne2k_isa,netdev=mynet0 -redir tcp:5075::5075 -redir udp:5076::5076 -m 1024 --no-reboot -curses
|
||||
+19
-60
@@ -1,84 +1,43 @@
|
||||
TOP=../..
|
||||
# This is a Makefile fragment, see ../Makefile
|
||||
|
||||
include $(TOP)/configure/CONFIG
|
||||
|
||||
#PROD_HOST += testBlockingUDPSrv
|
||||
testBlockingUDPSrv_SRCS += testBlockingUDPSrv.cpp
|
||||
testBlockingUDPSrv_LIBS += pvAccess pvData pvMB Com
|
||||
|
||||
#PROD_HOST += testBlockingUDPClnt
|
||||
testBlockingUDPClnt_SRCS += testBlockingUDPClnt.cpp
|
||||
testBlockingUDPClnt_LIBS += pvAccess pvData pvMB Com
|
||||
|
||||
PROD_HOST += testRemoteClientImpl
|
||||
testRemoteClientImpl_SRCS += testRemoteClientImpl.cpp
|
||||
testRemoteClientImpl_LIBS += pvAccess pvData pvMB Com
|
||||
|
||||
PROD_HOST += testChannelConnect
|
||||
testChannelConnect_SRCS += testChannelConnect.cpp
|
||||
testChannelConnect_LIBS += pvAccess pvData pvMB Com
|
||||
|
||||
#PROD_HOST += testBeaconEmitter
|
||||
testBeaconEmitter_SRCS += testBeaconEmitter.cpp
|
||||
testBeaconEmitter_LIBS += pvAccess pvData Com
|
||||
|
||||
#PROD_HOST += testBeaconHandler
|
||||
testBeaconHandler_SRCS += testBeaconHandler.cpp
|
||||
testBeaconHandler_LIBS += pvAccess pvData Com
|
||||
|
||||
#PROD_HOST += testChannelSearchManager
|
||||
#testChannelSearchManager_SRCS += testChannelSearchManager.cpp
|
||||
#testChannelSearchManager_LIBS += pvAccess pvData Com
|
||||
|
||||
#PROD_HOST += testBlockingTCPSrv
|
||||
testBlockingTCPSrv_SRCS += testBlockingTCPSrv.cpp
|
||||
testBlockingTCPSrv_LIBS += pvAccess pvData pvMB Com
|
||||
|
||||
#PROD_HOST += testBlockingTCPClnt
|
||||
testBlockingTCPClnt_SRCS += testBlockingTCPClnt.cpp
|
||||
testBlockingTCPClnt_LIBS += pvAccess pvData pvMB Com
|
||||
|
||||
PROD_HOST += testServerContext
|
||||
testServerContext_SRCS += testServerContext.cpp
|
||||
testServerContext_LIBS += pvAccess pvData pvMB Com
|
||||
|
||||
PROD_HOST += testServer
|
||||
testServer_SRCS += testServer.cpp
|
||||
testServer_LIBS += pvAccess pvData pvMB Com
|
||||
SRC_DIRS += $(PVACCESS_TEST)/remote
|
||||
|
||||
TESTPROD_HOST += testChannelAccess
|
||||
testChannelAccess_SRCS = testChannelAccess channelAccessIFTest
|
||||
testChannelAccess_LIBS += pvAccess pvData pvMB Com
|
||||
testHarness_SRCS += testChannelAccess.cpp channelAccessIFTest.cpp
|
||||
TESTS += testChannelAccess
|
||||
|
||||
TESTPROD_HOST += testCodec
|
||||
testCodec_SRCS = testCodec
|
||||
testCodec_LIBS += pvAccess pvData pvMB Com
|
||||
testHarness_SRCS += testCodec.cpp
|
||||
TESTS += testCodec
|
||||
|
||||
|
||||
TESTPROD_HOST += testRemoteClientImpl
|
||||
testRemoteClientImpl_SRCS += testRemoteClientImpl.cpp
|
||||
|
||||
TESTPROD_HOST += testChannelConnect
|
||||
testChannelConnect_SRCS += testChannelConnect.cpp
|
||||
|
||||
TESTPROD_HOST += testServerContext
|
||||
testServerContext_SRCS += testServerContext.cpp
|
||||
|
||||
|
||||
|
||||
PROD_HOST += testServer
|
||||
testServer_SRCS += testServer.cpp
|
||||
|
||||
PROD_HOST += testGetPerformance
|
||||
testGetPerformance_SRCS += testGetPerformance.cpp
|
||||
testGetPerformance_LIBS += pvAccess pvData pvMB Com
|
||||
|
||||
PROD_HOST += testMonitorPerformance
|
||||
testMonitorPerformance_SRCS += testMonitorPerformance.cpp
|
||||
testMonitorPerformance_LIBS += pvAccess pvData pvMB Com
|
||||
|
||||
PROD_HOST += rpcServiceExample
|
||||
rpcServiceExample_SRCS += rpcServiceExample.cpp
|
||||
rpcServiceExample_LIBS += pvAccess pvData pvMB Com
|
||||
|
||||
PROD_HOST += rpcWildServiceExample
|
||||
rpcWildServiceExample_SRCS += rpcWildServiceExample.cpp
|
||||
rpcWildServiceExample_LIBS += pvAccess pvData pvMB Com
|
||||
|
||||
PROD_HOST += rpcClientExample
|
||||
rpcClientExample_SRCS += rpcClientExample.cpp
|
||||
rpcClientExample_LIBS += pvAccess pvData pvMB Com
|
||||
|
||||
TESTSCRIPTS_HOST += $(TESTS:%=%.t)
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
#----------------------------------------
|
||||
# ADD RULES AFTER THIS LINE
|
||||
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* testBeaconEmitter.cpp
|
||||
*/
|
||||
|
||||
#include <pv/remote.h>
|
||||
#include <pv/blockingUDP.h>
|
||||
#include <pv/beaconEmitter.h>
|
||||
#include <pv/inetAddressUtil.h>
|
||||
|
||||
#include <osiSock.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
|
||||
using namespace epics::pvAccess;
|
||||
using namespace epics::pvData;
|
||||
|
||||
class DummyResponseHandler : public ResponseHandler
|
||||
{
|
||||
public:
|
||||
DummyResponseHandler(Context* ctx) : ResponseHandler() {}
|
||||
|
||||
virtual void handleResponse(osiSockAddr* responseFrom,
|
||||
Transport* transport, int8 version, int8 command, int payloadSize,
|
||||
ByteBuffer* payloadBuffer)
|
||||
{
|
||||
cout << "DummyResponseHandler::handleResponse" << endl;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class ContextImpl : public Context {
|
||||
public:
|
||||
ContextImpl() :
|
||||
_tr(new TransportRegistry()), _timer(new Timer("server thread",
|
||||
lowPriority)), _conf(new SystemConfigurationImpl()) {
|
||||
}
|
||||
virtual ~ContextImpl() {
|
||||
delete _tr;
|
||||
delete _timer;
|
||||
}
|
||||
virtual Timer* getTimer() { return _timer; }
|
||||
virtual TransportRegistry* getTransportRegistry() { return _tr; }
|
||||
virtual Channel* getChannel(epics::pvAccess::pvAccessID) { return 0; }
|
||||
virtual Transport* getSearchTransport() { return 0; }
|
||||
virtual Configuration* getConfiguration() { return _conf; }
|
||||
virtual void acquire() {}
|
||||
virtual void release() {}
|
||||
private:
|
||||
TransportRegistry* _tr;
|
||||
Timer* _timer;
|
||||
Configuration* _conf;
|
||||
};
|
||||
|
||||
|
||||
void testBeaconEmitter()
|
||||
{
|
||||
ContextImpl ctx;
|
||||
DummyResponseHandler drh(&ctx);
|
||||
|
||||
SOCKET socket = epicsSocketCreate(AF_INET, SOCK_DGRAM, 0);
|
||||
auto_ptr<InetAddrVector> broadcastAddresses(getBroadcastAddresses(socket, 5067));
|
||||
epicsSocketDestroy (socket);
|
||||
|
||||
BlockingUDPConnector connector(true, true);
|
||||
|
||||
osiSockAddr bindAddr;
|
||||
bindAddr.ia.sin_family = AF_INET;
|
||||
bindAddr.ia.sin_port = htons(5066);
|
||||
bindAddr.ia.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
|
||||
BlockingUDPTransport* transport = (BlockingUDPTransport*)connector.connect(NULL, &drh, bindAddr, 1, 50);
|
||||
transport->setBroadcastAddresses(broadcastAddresses.get());
|
||||
|
||||
cout<<"Sending beacons"<<endl;
|
||||
BeaconEmitter beaconEmitter(transport, transport->getRemoteAddress());
|
||||
beaconEmitter.start();
|
||||
|
||||
epicsThreadSleep (60.0);
|
||||
|
||||
delete transport;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
testBeaconEmitter();
|
||||
return (0);
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
/*
|
||||
* testBeaconEmitter.cpp
|
||||
*/
|
||||
|
||||
#include <pv/remote.h>
|
||||
#include <pv/blockingUDP.h>
|
||||
#include <pv/beaconHandler.h>
|
||||
#include <pv/inetAddressUtil.h>
|
||||
#include <pv/introspectionRegistry.h>
|
||||
|
||||
#include <osiSock.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
|
||||
using namespace epics::pvAccess;
|
||||
using namespace epics::pvData;
|
||||
using namespace std;
|
||||
|
||||
class BeaconResponseHandler : public ResponseHandler
|
||||
{
|
||||
public:
|
||||
BeaconResponseHandler(Context* ctx) : ResponseHandler()
|
||||
{
|
||||
_pvDataCreate = getPVDataCreate();
|
||||
}
|
||||
|
||||
virtual void handleResponse(osiSockAddr* responseFrom,
|
||||
Transport* transport, int8 version, int8 command, int payloadSize,
|
||||
ByteBuffer* payloadBuffer)
|
||||
{
|
||||
cout << "BeaconResponseHandler::handleResponse" << endl;
|
||||
|
||||
// reception timestamp
|
||||
TimeStamp timestamp;
|
||||
timestamp.getCurrent();
|
||||
|
||||
//TODO
|
||||
//super.handleResponse(responseFrom, transport, version, command, payloadSize, payloadBuffer);
|
||||
|
||||
transport->ensureData((2*sizeof(int16)+2*sizeof(int32)+128)/sizeof(int8));
|
||||
|
||||
/*const int32 sequentalID = */ payloadBuffer->getShort();
|
||||
const TimeStamp startupTimestamp(payloadBuffer->getInt(),payloadBuffer->getInt());
|
||||
|
||||
// 128-bit IPv6 address
|
||||
osiSockAddr address;
|
||||
decodeFromIPv6Address(payloadBuffer, &address);
|
||||
|
||||
// get port
|
||||
const int32 port = payloadBuffer->getShort();
|
||||
address.ia.sin_port = ntohs(port);
|
||||
|
||||
// accept given address if explicitly specified by sender
|
||||
if (!ipv4AddressToInt(address))
|
||||
{
|
||||
responseFrom->ia.sin_port = port;
|
||||
}
|
||||
else
|
||||
{
|
||||
responseFrom->ia.sin_port = port;
|
||||
responseFrom->ia.sin_addr.s_addr = address.ia.sin_addr.s_addr;
|
||||
}
|
||||
|
||||
//org.epics.ca.client.impl.remote.BeaconHandler beaconHandler = context.getBeaconHandler(responseFrom);
|
||||
// currently we care only for servers used by this context
|
||||
//if (beaconHandler == null)
|
||||
// return;
|
||||
|
||||
// extra data
|
||||
PVFieldPtr data = NULL;
|
||||
const FieldConstPtr field = IntrospectionRegistry::deserializeFull(payloadBuffer, transport);
|
||||
if (field != NULL)
|
||||
{
|
||||
data = _pvDataCreate->createPVField(NULL, field);
|
||||
data->deserialize(payloadBuffer, transport);
|
||||
}
|
||||
|
||||
// notify beacon handler
|
||||
//beaconHandler.beaconNotify(responseFrom, version, timestamp, startupTimestamp, sequentalID, data);
|
||||
}
|
||||
|
||||
private:
|
||||
PVDataCreate* _pvDataCreate;
|
||||
BeaconHandler* _beaconHandler;
|
||||
};
|
||||
|
||||
|
||||
class ContextImpl : public Context {
|
||||
public:
|
||||
ContextImpl() :
|
||||
_tr(new TransportRegistry()), _timer(new Timer("server thread",
|
||||
lowPriority)), _conf(new SystemConfigurationImpl()) {
|
||||
}
|
||||
virtual ~ContextImpl() {
|
||||
delete _tr;
|
||||
delete _timer;
|
||||
}
|
||||
virtual Timer* getTimer() { return _timer; }
|
||||
virtual TransportRegistry* getTransportRegistry() { return _tr; }
|
||||
virtual Channel* getChannel(epics::pvAccess::pvAccessID) { return 0; }
|
||||
virtual Transport* getSearchTransport() { return 0; }
|
||||
virtual Configuration* getConfiguration() { return _conf; }
|
||||
virtual void acquire() {}
|
||||
virtual void release() {}
|
||||
|
||||
private:
|
||||
TransportRegistry* _tr;
|
||||
Timer* _timer;
|
||||
Configuration* _conf;
|
||||
};
|
||||
|
||||
|
||||
void testBeaconHandler()
|
||||
{
|
||||
ContextImpl ctx;
|
||||
BeaconResponseHandler brh(&ctx);
|
||||
BlockingUDPConnector connector(false, true);
|
||||
|
||||
osiSockAddr bindAddr;
|
||||
bindAddr.ia.sin_family = AF_INET;
|
||||
bindAddr.ia.sin_port = htons(5067);
|
||||
bindAddr.ia.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
Transport* transport = connector.connect(NULL, &brh, bindAddr, 1, 50);
|
||||
(static_cast<BlockingUDPTransport*>(transport))->start();
|
||||
|
||||
epicsThreadSleep (60.0);
|
||||
|
||||
delete transport;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
testBeaconHandler();
|
||||
return (0);
|
||||
}
|
||||
@@ -1,178 +0,0 @@
|
||||
/*
|
||||
* testBlockingTCPClnt.cpp
|
||||
*
|
||||
* Created on: Jan 6, 2011
|
||||
* Author: Miha Vitorovic
|
||||
*/
|
||||
|
||||
#include <pv/remote.h>
|
||||
#include <pv/blockingTCP.h>
|
||||
#include <pv/logger.h>
|
||||
#include <pv/inetAddressUtil.h>
|
||||
#include <pv/pvaConstants.h>
|
||||
|
||||
#include <pv/timer.h>
|
||||
#include <pv/epicsException.h>
|
||||
#include <pv/pvType.h>
|
||||
|
||||
#include <osiSock.h>
|
||||
#include <epicsThread.h>
|
||||
#include <pv/logger.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
|
||||
using std::tr1::static_pointer_cast;
|
||||
|
||||
using namespace epics::pvAccess;
|
||||
using namespace epics::pvData;
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using std::sscanf;
|
||||
|
||||
|
||||
class ContextImpl : public Context {
|
||||
public:
|
||||
ContextImpl() :
|
||||
_tr(new TransportRegistry()), _timer(new Timer("server thread",
|
||||
lowPriority)), _conf(new SystemConfigurationImpl())
|
||||
{}
|
||||
|
||||
virtual ~ContextImpl() {
|
||||
}
|
||||
virtual Timer::shared_pointer getTimer() {
|
||||
return _timer;
|
||||
}
|
||||
virtual std::tr1::shared_ptr<TransportRegistry> getTransportRegistry() {
|
||||
return _tr;
|
||||
}
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel(epics::pvAccess::pvAccessID) {
|
||||
return std::tr1::shared_ptr<Channel>();
|
||||
}
|
||||
virtual Transport::shared_pointer getSearchTransport() {
|
||||
return Transport::shared_pointer();
|
||||
}
|
||||
virtual Configuration::shared_pointer getConfiguration() {
|
||||
return _conf;
|
||||
}
|
||||
virtual void acquire() {}
|
||||
virtual void release() {}
|
||||
virtual void newServerDetected() {}
|
||||
|
||||
private:
|
||||
std::tr1::shared_ptr<TransportRegistry> _tr;
|
||||
Timer::shared_pointer _timer;
|
||||
Configuration::shared_pointer _conf;
|
||||
};
|
||||
|
||||
class DummyResponseHandler : public ResponseHandler {
|
||||
public:
|
||||
DummyResponseHandler() :
|
||||
ResponseHandler() {
|
||||
}
|
||||
|
||||
virtual void handleResponse(osiSockAddr* /*responseFrom*/,
|
||||
Transport::shared_pointer const & transport, int8 /*version*/, int8 command, std::size_t /*payloadSize*/,
|
||||
ByteBuffer* /*payloadBuffer*/) {
|
||||
|
||||
if(command==CMD_CONNECTION_VALIDATION) transport->verified();
|
||||
}
|
||||
};
|
||||
|
||||
class DummyTransportClient : public TransportClient {
|
||||
public:
|
||||
DummyTransportClient() {
|
||||
}
|
||||
virtual ~DummyTransportClient() {
|
||||
}
|
||||
virtual void transportUnresponsive() {
|
||||
LOG(logLevelInfo, "unresponsive");
|
||||
}
|
||||
virtual void transportResponsive(Transport::shared_pointer const & /*transport*/) {
|
||||
LOG(logLevelInfo, "responsive");
|
||||
}
|
||||
virtual void transportChanged() {
|
||||
LOG(logLevelInfo, "changed");
|
||||
}
|
||||
virtual void transportClosed() {
|
||||
LOG(logLevelInfo, "closed");
|
||||
}
|
||||
virtual void acquire() {};
|
||||
virtual void release() {};
|
||||
virtual pvAccessID getID() {return 0;};
|
||||
};
|
||||
|
||||
class DummyTransportSender : public TransportSender {
|
||||
public:
|
||||
DummyTransportSender() {
|
||||
for(int i = 0; i<20; i++)
|
||||
data[i] = (char)(i+1);
|
||||
count = 0;
|
||||
}
|
||||
|
||||
virtual void send(ByteBuffer* buffer, TransportSendControl* control) {
|
||||
// send the packet
|
||||
count++;
|
||||
// using invalid command to force msg dump
|
||||
control->startMessage(0xC0, count);
|
||||
buffer->put(data, 0, count);
|
||||
//control->endMessage();
|
||||
}
|
||||
|
||||
virtual void lock() {
|
||||
}
|
||||
virtual void unlock() {
|
||||
}
|
||||
virtual void acquire() {
|
||||
}
|
||||
virtual void release() {
|
||||
}
|
||||
private:
|
||||
char data[20];
|
||||
int count;
|
||||
};
|
||||
|
||||
void testBlockingTCPSender() {
|
||||
Context::shared_pointer ctx(new ContextImpl());
|
||||
BlockingTCPConnector connector(ctx, 1024, 1.0);
|
||||
|
||||
TransportClient::shared_pointer dtc(new DummyTransportClient());
|
||||
TransportSender::shared_pointer dts(new DummyTransportSender());
|
||||
std::auto_ptr<ResponseHandler> drh(new DummyResponseHandler());
|
||||
|
||||
osiSockAddr srvAddr;
|
||||
|
||||
//srvAddr.ia.sin_family = AF_INET;
|
||||
if(aToIPAddr("localhost", PVA_SERVER_PORT, &srvAddr.ia)<0) {
|
||||
cout<<"error in aToIPAddr(...)"<<endl;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Transport::shared_pointer transport(connector.connect(dtc, drh, srvAddr,
|
||||
PVA_VERSION, PVA_DEFAULT_PRIORITY));
|
||||
|
||||
cout<<"Sending 10 messages..."<<endl;
|
||||
|
||||
for(int i = 0; i<10; i++) {
|
||||
cout<<" Message: "<<i+1<<endl;
|
||||
if(!transport->isClosed())
|
||||
transport->enqueueSendRequest(dts);
|
||||
else
|
||||
break;
|
||||
epicsThreadSleep(1.0);
|
||||
}
|
||||
} catch(std::exception& e) {
|
||||
cout<<e.what()<<endl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
createFileLogger("testBlockingTCPClnt.log");
|
||||
|
||||
testBlockingTCPSender();
|
||||
return 0;
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* testBlockingTCPSrv.cpp
|
||||
*
|
||||
* Created on: Jan 6, 2011
|
||||
* Author: Miha Vitorovic
|
||||
*/
|
||||
|
||||
#include <pv/blockingTCP.h>
|
||||
#include <pv/remote.h>
|
||||
#include <pv/logger.h>
|
||||
#include <pv/configuration.h>
|
||||
#include <pv/serverContext.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace epics::pvData;
|
||||
using namespace epics::pvAccess;
|
||||
using namespace std;
|
||||
|
||||
class ContextImpl : public ServerContextImpl {
|
||||
public:
|
||||
ContextImpl() :
|
||||
_tr(new TransportRegistry()),
|
||||
_timer(new Timer("server thread", lowPriority)),
|
||||
_conf(new SystemConfigurationImpl()) {}
|
||||
Timer::shared_pointer getTimer() { return _timer; }
|
||||
std::tr1::shared_ptr<TransportRegistry> getTransportRegistry() { return _tr; }
|
||||
Channel::shared_pointer getChannel(epics::pvAccess::pvAccessID) { return Channel::shared_pointer(); }
|
||||
Transport::shared_pointer getSearchTransport() { return Transport::shared_pointer(); }
|
||||
Configuration::shared_pointer getConfiguration() { return _conf; }
|
||||
virtual void acquire() {}
|
||||
virtual void release() {}
|
||||
|
||||
private:
|
||||
std::tr1::shared_ptr<TransportRegistry> _tr;
|
||||
Timer::shared_pointer _timer;
|
||||
Configuration::shared_pointer _conf;
|
||||
};
|
||||
|
||||
class DummyResponseHandler : public ResponseHandler {
|
||||
public:
|
||||
virtual void handleResponse(osiSockAddr* /*responseFrom*/,
|
||||
Transport::shared_pointer const & /*transport*/, int8 /*version*/, int8 /*command*/, std::size_t /*payloadSize*/,
|
||||
ByteBuffer* /*payloadBuffer*/) {
|
||||
cout << "DummyResponseHandler::handleResponse" << endl;
|
||||
}
|
||||
};
|
||||
|
||||
class DummyResponseHandlerFactory : public ResponseHandlerFactory
|
||||
{
|
||||
public:
|
||||
std::auto_ptr<ResponseHandler> createResponseHandler() {return std::auto_ptr<ResponseHandler>(new DummyResponseHandler());};
|
||||
};
|
||||
|
||||
|
||||
void testServerConnections() {
|
||||
Context::shared_pointer ctx(new ContextImpl());
|
||||
ResponseHandlerFactory::shared_pointer rhf(new DummyResponseHandlerFactory());
|
||||
|
||||
BlockingTCPAcceptor* srv = new BlockingTCPAcceptor(ctx, rhf, PVA_SERVER_PORT, 1024);
|
||||
|
||||
cout<<"Press any key to stop the server...";
|
||||
cin.peek();
|
||||
|
||||
delete srv;
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
createFileLogger("testBlockingTCPSrv.log");
|
||||
|
||||
testServerConnections();
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
/*
|
||||
* testBlockingUDPClnt.cpp
|
||||
*
|
||||
* Created on: Dec 28, 2010
|
||||
* Author: Miha Vitorovic
|
||||
*/
|
||||
|
||||
#include <pv/remote.h>
|
||||
#include <pv/blockingUDP.h>
|
||||
#include <pv/logger.h>
|
||||
#include <pv/inetAddressUtil.h>
|
||||
|
||||
//#include <pv/CDRMonitor.h>
|
||||
|
||||
#include <osiSock.h>
|
||||
#include <epicsThread.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
|
||||
#define SRV_IP "127.0.0.1"
|
||||
|
||||
using namespace epics::pvAccess;
|
||||
using namespace epics::pvData;
|
||||
using std::tr1::static_pointer_cast;
|
||||
using namespace std;
|
||||
|
||||
static osiSockAddr sendTo;
|
||||
|
||||
class ContextImpl : public Context {
|
||||
public:
|
||||
ContextImpl() {}
|
||||
|
||||
virtual ~ContextImpl() {
|
||||
}
|
||||
virtual Timer::shared_pointer getTimer() {
|
||||
return Timer::shared_pointer();
|
||||
}
|
||||
virtual std::tr1::shared_ptr<TransportRegistry> getTransportRegistry() {
|
||||
return std::tr1::shared_ptr<TransportRegistry>();
|
||||
}
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel(epics::pvAccess::pvAccessID) {
|
||||
return std::tr1::shared_ptr<Channel>();
|
||||
}
|
||||
virtual Transport::shared_pointer getSearchTransport() {
|
||||
return Transport::shared_pointer();
|
||||
}
|
||||
virtual Configuration::shared_pointer getConfiguration() {
|
||||
return Configuration::shared_pointer();
|
||||
}
|
||||
virtual void acquire() {}
|
||||
virtual void release() {}
|
||||
virtual void newServerDetected() {}
|
||||
};
|
||||
|
||||
class DummyResponseHandler : public ResponseHandler {
|
||||
public:
|
||||
DummyResponseHandler(Context* /*ctx*/)
|
||||
{ }
|
||||
|
||||
virtual ~DummyResponseHandler() {}
|
||||
|
||||
virtual void handleResponse(osiSockAddr* /*responseFrom*/,
|
||||
Transport::shared_pointer const & /*transport*/, int8 /*version*/, int8 /*command*/, std::size_t /*payloadSize*/,
|
||||
ByteBuffer* /*payloadBuffer*/) {
|
||||
}
|
||||
};
|
||||
|
||||
class DummyTransportSender : public TransportSender {
|
||||
public:
|
||||
typedef std::tr1::shared_ptr<DummyTransportSender> shared_pointer;
|
||||
typedef std::tr1::shared_ptr<const DummyTransportSender> const_pointer;
|
||||
|
||||
DummyTransportSender() {
|
||||
for(int i = 0; i<20; i++)
|
||||
data[i] = (char)(i+1);
|
||||
count = 0;
|
||||
}
|
||||
|
||||
virtual void send(ByteBuffer* buffer, TransportSendControl* control) {
|
||||
control->setRecipient(sendTo);
|
||||
|
||||
// send the packet
|
||||
count++;
|
||||
control->startMessage((int8)(count+0x10), 0);
|
||||
buffer->put(data, 0, count);
|
||||
//control->endMessage();
|
||||
}
|
||||
|
||||
virtual void lock() {
|
||||
}
|
||||
virtual void unlock() {
|
||||
}
|
||||
virtual void acquire() {
|
||||
}
|
||||
virtual void release() {
|
||||
}
|
||||
private:
|
||||
char data[20];
|
||||
int count;
|
||||
};
|
||||
|
||||
void testBlockingUDPSender() {
|
||||
BlockingUDPConnector connector(false, true);
|
||||
ContextImpl ctx;
|
||||
|
||||
|
||||
auto_ptr<ResponseHandler> drh(new DummyResponseHandler(&ctx));
|
||||
TransportSender::shared_pointer dts(new DummyTransportSender());
|
||||
|
||||
osiSockAddr bindAddr;
|
||||
|
||||
bindAddr.ia.sin_family = AF_INET;
|
||||
bindAddr.ia.sin_port = htons(65001);
|
||||
bindAddr.ia.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
|
||||
TransportClient::shared_pointer nullPointer;
|
||||
Transport::shared_pointer transport(connector.connect(nullPointer, drh, bindAddr, 1, 50));
|
||||
|
||||
// SRV_IP defined at the top of the this file
|
||||
if(aToIPAddr(SRV_IP, 65000, &sendTo.ia)<0) {
|
||||
cout<<"error in aToIPAddr(...)"<<endl;
|
||||
return;
|
||||
}
|
||||
|
||||
cout<<"Sending 10 packets..."<<endl;
|
||||
|
||||
|
||||
for(int i = 0; i<10; i++) {
|
||||
cout<<" Packet: "<<i+1<<endl;
|
||||
transport->enqueueSendRequest(dts);
|
||||
epicsThreadSleep(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
// createFileLogger("testBlockingUDPClnt.log");
|
||||
|
||||
testBlockingUDPSender();
|
||||
|
||||
// std::cout << "-----------------------------------------------------------------------" << std::endl;
|
||||
// getShowConstructDestruct()->constuctDestructTotals(stdout);
|
||||
return (0);
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
/*
|
||||
* blockingUDPTest.cpp
|
||||
*
|
||||
* Created on: Dec 28, 2010
|
||||
* Author: Miha Vitorovic
|
||||
*/
|
||||
|
||||
#include <pv/remote.h>
|
||||
#include <pv/blockingUDP.h>
|
||||
#include <pv/logger.h>
|
||||
#include <pv/hexDump.h>
|
||||
|
||||
#include <osiSock.h>
|
||||
#include <epicsThread.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
using namespace epics::pvAccess;
|
||||
using namespace epics::pvData;
|
||||
using namespace std;
|
||||
using std::tr1::static_pointer_cast;
|
||||
|
||||
class ContextImpl : public Context {
|
||||
public:
|
||||
ContextImpl() {}
|
||||
|
||||
virtual ~ContextImpl() {
|
||||
}
|
||||
virtual Timer::shared_pointer getTimer() {
|
||||
return Timer::shared_pointer();
|
||||
}
|
||||
virtual std::tr1::shared_ptr<TransportRegistry> getTransportRegistry() {
|
||||
return std::tr1::shared_ptr<TransportRegistry>();
|
||||
}
|
||||
virtual std::tr1::shared_ptr<Channel> getChannel(epics::pvAccess::pvAccessID) {
|
||||
return std::tr1::shared_ptr<Channel>();
|
||||
}
|
||||
virtual Transport::shared_pointer getSearchTransport() {
|
||||
return Transport::shared_pointer();
|
||||
}
|
||||
virtual Configuration::shared_pointer getConfiguration() {
|
||||
return Configuration::shared_pointer();
|
||||
}
|
||||
virtual void acquire() {}
|
||||
virtual void release() {}
|
||||
virtual void newServerDetected() {}
|
||||
};
|
||||
|
||||
class DummyResponseHandler : public ResponseHandler {
|
||||
public:
|
||||
DummyResponseHandler(Context* /*context*/)
|
||||
: packets(0) {
|
||||
}
|
||||
|
||||
virtual ~DummyResponseHandler() {}
|
||||
|
||||
int getPackets() {
|
||||
return packets;
|
||||
}
|
||||
|
||||
virtual void handleResponse(osiSockAddr* responseFrom,
|
||||
Transport::shared_pointer const &, int8 version, int8 command, std::size_t payloadSize,
|
||||
ByteBuffer* payloadBuffer);
|
||||
private:
|
||||
int packets;
|
||||
};
|
||||
|
||||
void DummyResponseHandler::handleResponse(osiSockAddr* responseFrom,
|
||||
Transport::shared_pointer const &, int8 version, int8 command, std::size_t payloadSize,
|
||||
ByteBuffer* payloadBuffer) {
|
||||
std::ostringstream os;
|
||||
|
||||
cout<<"Received new UDP datagram["<<packets+1<<"]..."<<endl;
|
||||
|
||||
char ipAddressStr[24];
|
||||
|
||||
ipAddrToDottedIP(&responseFrom->ia, ipAddressStr, sizeof(ipAddressStr));
|
||||
|
||||
cout<<"From: "<<ipAddressStr<<endl;
|
||||
cout<<"Version: 0x"<<hex<<(int)version<<endl;
|
||||
cout<<"Command: 0x"<<hex<<(int)command<<endl;
|
||||
cout<<"Payload size: "<<dec<<payloadSize<<endl;
|
||||
|
||||
char payload[50];
|
||||
|
||||
for(std::size_t i = 0; i<payloadSize;) {
|
||||
int dataCount = payloadSize-i<50 ? payloadSize-i : 50;
|
||||
payloadBuffer->get(payload, 0, dataCount);
|
||||
os<<"Payload ("<<i<<"-"<<(dataCount-1)<<")";
|
||||
hexDump(os.str(), (int8*)payload, dataCount);
|
||||
i += dataCount;
|
||||
}
|
||||
|
||||
cout<<endl<<endl;
|
||||
|
||||
packets++;
|
||||
}
|
||||
|
||||
void testBlockingUDPConnector() {
|
||||
BlockingUDPConnector connector(false, true);
|
||||
ContextImpl ctx;
|
||||
|
||||
DummyResponseHandler* drh = new DummyResponseHandler(&ctx);
|
||||
auto_ptr<ResponseHandler> rh(static_cast<ResponseHandler*>(drh));
|
||||
|
||||
osiSockAddr bindAddr;
|
||||
|
||||
bindAddr.ia.sin_family = AF_INET;
|
||||
bindAddr.ia.sin_port = htons(65000);
|
||||
bindAddr.ia.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
|
||||
TransportClient::shared_pointer nullPointer;
|
||||
Transport::shared_pointer transport(connector.connect(nullPointer,rh, bindAddr, 1, 50));
|
||||
|
||||
static_pointer_cast<BlockingUDPTransport>(transport)->start();
|
||||
|
||||
cout<<"Waiting for 10 packets..."<<endl;
|
||||
|
||||
//TODO drh can be deleted in connector!
|
||||
while(drh->getPackets()<10) {
|
||||
epicsThreadSleep(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
// createFileLogger("testBlockingUDPSrv.log");
|
||||
|
||||
testBlockingUDPConnector();
|
||||
return (0);
|
||||
}
|
||||
@@ -6,6 +6,10 @@
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
|
||||
// TODO not nice
|
||||
// disable buggy boost enable_shared_from_this assert code
|
||||
#define BOOST_DISABLE_ASSERTS
|
||||
|
||||
#define TESTSERVERNOMAIN
|
||||
|
||||
#include <epicsExit.h>
|
||||
@@ -87,7 +91,7 @@ class ChannelAccessIFRemoteTest: public ChannelAccessIFTest {
|
||||
};
|
||||
|
||||
|
||||
MAIN(testChannelProvider)
|
||||
MAIN(testChannelAccess)
|
||||
{
|
||||
SET_LOG_LEVEL(logLevelError);
|
||||
ChannelAccessIFRemoteTest caRemoteTest;
|
||||
|
||||
@@ -1,203 +0,0 @@
|
||||
/* testChannelSearcManager.cpp */
|
||||
|
||||
#include <epicsExit.h>
|
||||
#include <epicsThread.h>
|
||||
#include <epicsMessageQueue.h>
|
||||
#include <pv/channelSearchManager.h>
|
||||
#include <sstream>
|
||||
|
||||
epicsMessageQueueId join1;
|
||||
epicsMessageQueueId join2;
|
||||
|
||||
using std::string;
|
||||
using namespace epics::pvData;
|
||||
using namespace epics::pvAccess;
|
||||
|
||||
//TODO this will be deleted
|
||||
class ChannelImpl;
|
||||
|
||||
class ContextImpl : public Context
|
||||
{
|
||||
public:
|
||||
ContextImpl(): _timer(new Timer("krneki",lowPriority))
|
||||
{
|
||||
|
||||
}
|
||||
virtual Version* getVersion()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
virtual ChannelProvider* getProvider()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
Timer::shared_pointer getTimer()
|
||||
{
|
||||
return _timer;
|
||||
}
|
||||
virtual void initialize()
|
||||
{
|
||||
}
|
||||
virtual void printInfo()
|
||||
{
|
||||
}
|
||||
virtual void printInfo(epics::pvData::StringBuilder out)
|
||||
{
|
||||
}
|
||||
virtual void destroy()
|
||||
{
|
||||
}
|
||||
virtual void dispose()
|
||||
{
|
||||
}
|
||||
Transport::shared_pointer getSearchTransport()
|
||||
{
|
||||
return Transport::shared_pointer();
|
||||
}
|
||||
std::tr1::shared_ptr<Channel> getChannel(pvAccessID channelID)
|
||||
{
|
||||
return std::tr1::shared_ptr<Channel>();
|
||||
}
|
||||
Configuration::shared_pointer getConfiguration()
|
||||
{
|
||||
return Configuration::shared_pointer();
|
||||
}
|
||||
std::tr1::shared_ptr<TransportRegistry> getTransportRegistry()
|
||||
{
|
||||
return std::tr1::shared_ptr<TransportRegistry>();
|
||||
}
|
||||
void beaconAnomalyNotify() {};
|
||||
private:
|
||||
Timer::shared_pointer _timer;
|
||||
void loadConfiguration() { }
|
||||
void internalInitialize() { }
|
||||
void initializeUDPTransport() { }
|
||||
void internalDestroy() { }
|
||||
void destroyAllChannels() { }
|
||||
void checkChannelName(std::string const & name) {}
|
||||
void checkState() { }
|
||||
pvAccessID generateCID()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
void freeCID(int cid)
|
||||
{
|
||||
}
|
||||
Transport* getTransport(TransportClient* client, osiSockAddr* serverAddress, int minorRevision, int priority)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
Channel* createChannelInternal(std::string name, ChannelRequester* requester, short priority,
|
||||
InetAddrVector* addresses)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
void destroyChannel(ChannelImpl* channel, bool force) {
|
||||
}
|
||||
ChannelSearchManager* getChannelSearchManager() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual void acquire() {}
|
||||
virtual void release() {}
|
||||
};
|
||||
|
||||
class TestSearcInstance : public BaseSearchInstance
|
||||
{
|
||||
public:
|
||||
TestSearcInstance(string channelName, pvAccessID channelID): _channelID(channelID), _channelName(channelName) {}
|
||||
pvAccessID getSearchInstanceID() { return _channelID;};
|
||||
string getSearchInstanceName() {return _channelName;};
|
||||
void searchResponse(int8 minorRevision, osiSockAddr* serverAddress) {};
|
||||
void acquire() {};
|
||||
void release() {};
|
||||
private:
|
||||
pvAccessID _channelID;
|
||||
string _channelName;
|
||||
};
|
||||
|
||||
static const int max_channels = 100;
|
||||
ContextImpl* context = new ContextImpl();
|
||||
ChannelSearchManager* manager = new ChannelSearchManager(static_cast<Context*>(context));
|
||||
TestSearcInstance** chanArray = new TestSearcInstance*[max_channels];
|
||||
|
||||
void testWorker1(void* p)
|
||||
{
|
||||
for(int i = 0; i < 1000; i++)
|
||||
{
|
||||
for(int j = 0; j < max_channels/2; j++)
|
||||
{
|
||||
manager->unregisterChannel(chanArray[j]);
|
||||
epicsThreadSleep(100e-6);
|
||||
manager->registerChannel(chanArray[j]);
|
||||
}
|
||||
}
|
||||
int dummy = 1;
|
||||
epicsMessageQueueSend(join1, &dummy, 1);
|
||||
}
|
||||
|
||||
|
||||
void testWorker2(void* p)
|
||||
{
|
||||
for(int i = 0; i < 1000; i++)
|
||||
{
|
||||
for(int j = max_channels/2; j < max_channels; j++)
|
||||
{
|
||||
manager->unregisterChannel(chanArray[j]);
|
||||
epicsThreadSleep(100e-6);
|
||||
manager->registerChannel(chanArray[j]);
|
||||
manager->beaconAnomalyNotify();
|
||||
}
|
||||
}
|
||||
|
||||
int dummy = 2;
|
||||
epicsMessageQueueSend(join1, &dummy, 1);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
epicsThreadId _worker1Id;
|
||||
epicsThreadId _worker2Id;
|
||||
|
||||
std::ostringstream obuffer;
|
||||
for(int i = 0; i < max_channels; i++)
|
||||
{
|
||||
obuffer.clear();
|
||||
obuffer.str("");
|
||||
obuffer << i;
|
||||
string name = "chan" + obuffer.str();
|
||||
chanArray[i] = new TestSearcInstance(name.c_str(), i);
|
||||
manager->registerChannel(chanArray[i]);
|
||||
}
|
||||
|
||||
join1 = epicsMessageQueueCreate(1, 1);
|
||||
join2 = epicsMessageQueueCreate(1, 1);
|
||||
|
||||
//create two threads
|
||||
_worker1Id = epicsThreadCreate("worker1", epicsThreadPriorityMedium, epicsThreadGetStackSize(epicsThreadStackMedium),
|
||||
testWorker1, NULL);
|
||||
assert(_worker1Id != NULL);
|
||||
|
||||
_worker2Id = epicsThreadCreate("worker2", epicsThreadPriorityMedium, epicsThreadGetStackSize(epicsThreadStackMedium),
|
||||
testWorker2, NULL);
|
||||
assert(_worker1Id != NULL);
|
||||
|
||||
int dummy;
|
||||
epicsMessageQueueReceive(join1, &dummy, 1);
|
||||
epicsMessageQueueReceive(join2, &dummy, 1);
|
||||
|
||||
manager->cancel();
|
||||
|
||||
|
||||
context->destroy();
|
||||
//epicsExitCallAtExits();
|
||||
|
||||
for(int i = 0; i < max_channels; i++)
|
||||
{
|
||||
if(chanArray[i]) delete chanArray[i];
|
||||
}
|
||||
if(chanArray) delete [] chanArray;
|
||||
if(manager) delete manager;
|
||||
if(context) delete context;
|
||||
return(0);
|
||||
}
|
||||
@@ -6,6 +6,10 @@
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
|
||||
// TODO not nice
|
||||
// disable buggy boost enable_shared_from_this assert code
|
||||
#define BOOST_DISABLE_ASSERTS
|
||||
|
||||
#include <pv/serverContext.h>
|
||||
#include <pv/clientContextImpl.h>
|
||||
#include <epicsExit.h>
|
||||
@@ -25,7 +29,6 @@
|
||||
// TODO temp
|
||||
#include "testADCSim.cpp"
|
||||
|
||||
|
||||
using namespace epics::pvAccess;
|
||||
using namespace epics::pvData;
|
||||
using namespace std;
|
||||
@@ -1872,7 +1875,7 @@ private:
|
||||
MonitorRequester::shared_pointer m_monitorRequester;
|
||||
bool m_continuous;
|
||||
PVStructure::shared_pointer m_pvStructure;
|
||||
PVStructure::shared_pointer m_copy;
|
||||
PVStructure::shared_pointer m_ccopy;
|
||||
BitSet::shared_pointer m_changedBitSet;
|
||||
BitSet::shared_pointer m_overrunBitSet;
|
||||
Mutex m_lock;
|
||||
@@ -1891,7 +1894,7 @@ protected:
|
||||
m_monitorRequester(monitorRequester),
|
||||
m_continuous(false),
|
||||
m_pvStructure(getRequestedStructure(pvStructure, pvRequest)),
|
||||
m_copy(getPVDataCreate()->createPVStructure(m_pvStructure->getStructure())),
|
||||
m_ccopy(getPVDataCreate()->createPVStructure(m_pvStructure->getStructure())),
|
||||
m_changedBitSet(new BitSet(m_pvStructure->getNumberFields())),
|
||||
m_overrunBitSet(new BitSet(m_pvStructure->getNumberFields())),
|
||||
m_lock(),
|
||||
@@ -1907,7 +1910,7 @@ protected:
|
||||
// we always send all
|
||||
m_changedBitSet->set(0);
|
||||
|
||||
m_thisPtr->pvStructurePtr = m_copy;
|
||||
m_thisPtr->pvStructurePtr = m_ccopy;
|
||||
m_thisPtr->changedBitSet = m_changedBitSet;
|
||||
m_thisPtr->overrunBitSet = m_overrunBitSet;
|
||||
}
|
||||
@@ -1941,7 +1944,7 @@ public:
|
||||
{
|
||||
{
|
||||
lock();
|
||||
getConvert()->copyStructure(m_pvStructure, m_copy);
|
||||
getConvert()->copyStructure(m_pvStructure, m_ccopy);
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
@@ -2283,6 +2286,20 @@ protected:
|
||||
m_pvStructure = getPVDataCreate()->createPVStructure(s);
|
||||
m_pvStructure->getSubField<PVArray>("value")->setLength(8);
|
||||
}
|
||||
else if (m_name == "testStructureArray" )
|
||||
{
|
||||
epics::pvData::StructureConstPtr s =
|
||||
getFieldCreate()->createFieldBuilder()->
|
||||
add("value", getFieldCreate()->createStructureArray(getStandardField()->alarm()))->
|
||||
createStructure();
|
||||
m_pvStructure = getPVDataCreate()->createPVStructure(s);
|
||||
|
||||
PVStructureArray::svector data(5);
|
||||
data[1] = getPVDataCreate()->createPVStructure(getStandardField()->alarm());
|
||||
data[4] = getPVDataCreate()->createPVStructure(getStandardField()->alarm());
|
||||
|
||||
m_pvStructure->getSubField<PVStructureArray>("value")->replace(freeze(data));
|
||||
}
|
||||
else
|
||||
{
|
||||
string allProperties("alarm,timeStamp,display,control,valueAlarm");
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Saskatchewan
|
||||
* EPICS BASE Versions 3.13.7
|
||||
* and higher are distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
/*
|
||||
* RTEMS configuration for EPICS
|
||||
* Revision-Id: anj@aps.anl.gov-20101005192737-disfz3vs0f3fiixd
|
||||
* Author: W. Eric Norum
|
||||
* norume@aps.anl.gov
|
||||
* (630) 252-4793
|
||||
*/
|
||||
|
||||
#include <rtems.h>
|
||||
|
||||
/*
|
||||
***********************************************************************
|
||||
* RTEMS CONFIGURATION *
|
||||
***********************************************************************
|
||||
*/
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#if __RTEMS_MAJOR__>4 || (__RTEMS_MAJOR__==4 && __RTEMS_MINOR__>9) || (__RTEMS_MAJOR__==4 && __RTEMS_MINOR__==9 && __RTEMS_REVISION__==99)
|
||||
# define CONFIGURE_UNIFIED_WORK_AREAS
|
||||
#else
|
||||
# define CONFIGURE_EXECUTIVE_RAM_SIZE (2000*1024)
|
||||
#endif
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS rtems_resource_unlimited(30)
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES rtems_resource_unlimited(500)
|
||||
#define CONFIGURE_MAXIMUM_TIMERS rtems_resource_unlimited(20)
|
||||
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES rtems_resource_unlimited(5)
|
||||
#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
|
||||
|
||||
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 150
|
||||
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
|
||||
#define CONFIGURE_MAXIMUM_DRIVERS 8
|
||||
|
||||
#define CONFIGURE_MICROSECONDS_PER_TICK 20000
|
||||
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY 80
|
||||
|
||||
#define CONFIGURE_MALLOC_STATISTICS 1
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
|
||||
RTEMS_NO_TIMESLICE | \
|
||||
RTEMS_NO_ASR | \
|
||||
RTEMS_INTERRUPT_LEVEL(0))
|
||||
#define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_FLOATING_POINT | RTEMS_LOCAL)
|
||||
#define CONFIGURE_INIT_TASK_STACK_SIZE (16*1024)
|
||||
rtems_task Init (rtems_task_argument argument);
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
|
||||
#define CONFIGURE_FILESYSTEM_NFS
|
||||
#define CONFIGURE_FILESYSTEM_IMFS
|
||||
|
||||
/*
|
||||
* This should be made BSP dependent, not CPU dependent but I know of no
|
||||
* appropriate conditionals to use.
|
||||
* The new general time support makes including the RTC driverr less important.
|
||||
*/
|
||||
#if !defined(mpc604) && !defined(__mc68040__) && !defined(__mcf5200__) && !defined(mpc7455) && !defined(__arm__) /* don't have RTC code */
|
||||
#define CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER
|
||||
#endif
|
||||
|
||||
|
||||
#include <bsp.h>
|
||||
#include <rtems/confdefs.h>
|
||||
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
* Network configuration -- QEMU NOT using DHCP
|
||||
*
|
||||
************************************************************
|
||||
* EDIT THIS FILE TO REFLECT YOUR NETWORK CONFIGURATION *
|
||||
* BEFORE RUNNING ANY RTEMS PROGRAMS WHICH USE THE NETWORK! *
|
||||
************************************************************
|
||||
*
|
||||
* The dynamic probing is based upon the EPICS network
|
||||
* configuration file written by:
|
||||
* W. Eric Norum
|
||||
* eric.norum@usask.ca
|
||||
* (306) 966-5394
|
||||
*/
|
||||
|
||||
#ifndef _RTEMS_NETWORKCONFIG_H_
|
||||
#define _RTEMS_NETWORKCONFIG_H_
|
||||
|
||||
/* #define USE_LIBBSDPORT */
|
||||
|
||||
#if defined(USE_LIBBSDPORT)
|
||||
#include <bsp/libbsdport_api.h>
|
||||
#define CONFIGURE_MAXIMUM_TIMERS 10
|
||||
#endif
|
||||
/*
|
||||
* For TFTP test application
|
||||
*/
|
||||
#if (defined (RTEMS_USE_BOOTP))
|
||||
#define RTEMS_TFTP_TEST_HOST_NAME "BOOTP_HOST"
|
||||
#define RTEMS_TFTP_TEST_FILE_NAME "BOOTP_FILE"
|
||||
#else
|
||||
#define RTEMS_TFTP_TEST_HOST_NAME "XXX.YYY.ZZZ.XYZ"
|
||||
#define RTEMS_TFTP_TEST_FILE_NAME "tftptest"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* For NFS test application
|
||||
*
|
||||
* NFS mount and a directory to ls once mounted
|
||||
*/
|
||||
#define RTEMS_NFS_SERVER "192.168.1.210"
|
||||
#define RTEMS_NFS_SERVER_PATH "/home"
|
||||
#define RTEMS_NFS_LS_PATH "/mnt/nfstest"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This file can be copied to an application source dirctory
|
||||
* and modified to override the values shown below.
|
||||
*
|
||||
* The following CPP symbols may be passed from the Makefile:
|
||||
*
|
||||
* symbol default description
|
||||
*
|
||||
* NETWORK_TASK_PRIORITY 150 can be read by app from public
|
||||
* var 'gesysNetworkTaskPriority'
|
||||
* FIXED_IP_ADDR <undefined> hardcoded IP address (e.g.,
|
||||
* "192.168.0.10"); disables BOOTP;
|
||||
* must also define FIXED_NETMASK
|
||||
* FIXED_NETMASK <undefined> IP netmask string
|
||||
* (e.g. "255.255.255.0")
|
||||
* MULTI_NETDRIVER <undefined> ugly hack; if defined try to probe
|
||||
* a variety of PCI and ISA drivers
|
||||
* (i386 ONLY) use is discouraged!
|
||||
* NIC_NAME <undefined> Ethernet driver name (e.g. "pcn1");
|
||||
* must also define NIC_ATTACH
|
||||
* NIC_ATTACH <undefined> Ethernet driver attach function
|
||||
* (e.g., rtems_fxp_attach).
|
||||
* If these are undefined then
|
||||
* a) MULTI_NETDRIVER is used
|
||||
* (if defined)
|
||||
* b) RTEMS_BSP_NETWORK_DRIVER_NAME/
|
||||
* RTEMS_BSP_NETWORK_DRIVER_ATTACH
|
||||
* are tried
|
||||
* MEMORY_CUSTOM <undefined> Allocate the defined amount of
|
||||
* memory for mbufs and mbuf clusters,
|
||||
* respectively. Define to a comma ','
|
||||
* separated pair of two numerical
|
||||
* values, e.g: 100*1024,200*1024
|
||||
* MEMORY_SCARCE <undefined> Allocate few memory for mbufs
|
||||
* (hint for how much memory the
|
||||
* board has)
|
||||
* MEMORY_HUGE <undefined> Allocate a lot of memory for mbufs
|
||||
* (hint for how much memory the
|
||||
* board has)
|
||||
* If none of MEMORY_CUSTOM/
|
||||
* MEMORY_SCARCE/MEMORY_HUGE are
|
||||
* defined then a medium amount of
|
||||
* memory is allocated for mbufs.
|
||||
*/
|
||||
|
||||
#include <rtems/bspIo.h>
|
||||
#include <bsp.h>
|
||||
#include <rtems/rtems_bsdnet.h>
|
||||
|
||||
#if 0
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#else
|
||||
#include "verscheck.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//#define MULTI_NETDRIVER
|
||||
//#define RTEMS_BSP_NETWORK_DRIVER_NAME 1
|
||||
|
||||
#define FIXED_IP_ADDR "192.168.1.249"
|
||||
#define FIXED_NETMASK "255.255.255.0"
|
||||
|
||||
#ifndef NETWORK_TASK_PRIORITY
|
||||
#define NETWORK_TASK_PRIORITY 150 /* within EPICS' range */
|
||||
#endif
|
||||
|
||||
/* make publicily available for startup scripts... */
|
||||
const int gesysNetworkTaskPriority = NETWORK_TASK_PRIORITY;
|
||||
|
||||
#ifdef FIXED_IP_ADDR
|
||||
#define RTEMS_DO_BOOTP 0
|
||||
#else
|
||||
#define RTEMS_DO_BOOTP rtems_bsdnet_do_bootp
|
||||
#define FIXED_IP_ADDR 0
|
||||
#undef FIXED_NETMASK
|
||||
#define FIXED_NETMASK 0
|
||||
#endif
|
||||
|
||||
#if !defined(NIC_NAME)
|
||||
|
||||
#ifdef MULTI_NETDRIVER
|
||||
|
||||
#if 0
|
||||
#if RTEMS_VERSION_ATLEAST(4,6,99)
|
||||
#define pcib_init pci_initialize
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern int rtems_3c509_driver_attach (struct rtems_bsdnet_ifconfig *, int);
|
||||
extern int rtems_fxp_attach (struct rtems_bsdnet_ifconfig *, int);
|
||||
extern int rtems_elnk_driver_attach (struct rtems_bsdnet_ifconfig *, int);
|
||||
extern int rtems_dec21140_driver_attach (struct rtems_bsdnet_ifconfig *, int);
|
||||
|
||||
/* these don't probe and will be used even if there's no device :-( */
|
||||
extern int rtems_ne_driver_attach (struct rtems_bsdnet_ifconfig *, int);
|
||||
extern int rtems_wd_driver_attach (struct rtems_bsdnet_ifconfig *, int);
|
||||
|
||||
static struct rtems_bsdnet_ifconfig isa_netdriver_config[] = {
|
||||
{
|
||||
"ep0", rtems_3c509_driver_attach, isa_netdriver_config + 1,
|
||||
},
|
||||
{
|
||||
"ne1", rtems_ne_driver_attach, 0, irno: 9 /* qemu cannot configure irq-no :-(; has it hardwired to 9 */
|
||||
},
|
||||
};
|
||||
|
||||
static struct rtems_bsdnet_ifconfig pci_netdriver_config[]={
|
||||
{
|
||||
"dc1", rtems_dec21140_driver_attach, pci_netdriver_config+1,
|
||||
},
|
||||
#if !defined(USE_LIBBSDPORT)
|
||||
{
|
||||
"fxp1", rtems_fxp_attach, pci_netdriver_config+2,
|
||||
},
|
||||
#else
|
||||
{
|
||||
"", libbsdport_netdriver_attach, pci_netdriver_config+2,
|
||||
},
|
||||
#endif
|
||||
{
|
||||
"elnk1", rtems_elnk_driver_attach, isa_netdriver_config,
|
||||
},
|
||||
};
|
||||
|
||||
static int pci_check(struct rtems_bsdnet_ifconfig *ocfg, int attaching)
|
||||
{
|
||||
struct rtems_bsdnet_ifconfig *cfg;
|
||||
int if_index_pre;
|
||||
extern int if_index;
|
||||
if ( attaching ) {
|
||||
cfg = pci_initialize() ?
|
||||
isa_netdriver_config : pci_netdriver_config;
|
||||
}
|
||||
while ( cfg ) {
|
||||
printk("Probing '%s'", cfg->name);
|
||||
/* unfortunately, the return value is unreliable - some drivers report
|
||||
* success even if they fail.
|
||||
* Check if they chained an interface (ifnet) structure instead
|
||||
*/
|
||||
if_index_pre = if_index;
|
||||
cfg->attach(cfg, attaching);
|
||||
if ( if_index > if_index_pre ) {
|
||||
/* assume success */
|
||||
printk(" .. seemed to work\n");
|
||||
ocfg->name = cfg->name;
|
||||
ocfg->attach = cfg->attach;
|
||||
return 0;
|
||||
}
|
||||
printk(" .. failed\n");
|
||||
cfg = cfg->next;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
#define NIC_NAME "dummy"
|
||||
#define NIC_ATTACH pci_check
|
||||
|
||||
#else
|
||||
|
||||
#if defined(RTEMS_BSP_NETWORK_DRIVER_NAME) /* Use NIC provided by BSP */
|
||||
|
||||
/* force ne2k_isa on i386 for qemu */
|
||||
#if defined(__i386__)
|
||||
# define NIC_NAME BSP_NE2000_NETWORK_DRIVER_NAME
|
||||
# define NIC_ATTACH BSP_NE2000_NETWORK_DRIVER_ATTACH
|
||||
|
||||
#else
|
||||
|
||||
# define NIC_NAME RTEMS_BSP_NETWORK_DRIVER_NAME
|
||||
# define NIC_ATTACH RTEMS_BSP_NETWORK_DRIVER_ATTACH
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* ifdef MULTI_NETDRIVER */
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef NIC_NAME
|
||||
|
||||
extern int NIC_ATTACH();
|
||||
|
||||
#if RTEMS_BSP_NETWORK_DRIVER_ATTACH == BSP_NE2000_NETWORK_DRIVER_ATTACH
|
||||
static char ethernet_address[6] = { 0x00, 0xab, 0xcd, 0xef, 0x12, 0x34 };
|
||||
#endif
|
||||
|
||||
static struct rtems_bsdnet_ifconfig netdriver_config[1] = {{
|
||||
NIC_NAME, /* name */
|
||||
(int (*)(struct rtems_bsdnet_ifconfig*,int))NIC_ATTACH, /* attach function */
|
||||
0, /* link to next interface */
|
||||
FIXED_IP_ADDR,
|
||||
FIXED_NETMASK
|
||||
#if RTEMS_BSP_NETWORK_DRIVER_ATTACH == BSP_NE2000_NETWORK_DRIVER_ATTACH
|
||||
,
|
||||
ethernet_address,
|
||||
irno:9,
|
||||
port:0xc100
|
||||
#endif
|
||||
}};
|
||||
#else
|
||||
#warning "NO KNOWN NETWORK DRIVER FOR THIS BSP -- YOU MAY HAVE TO EDIT networkconfig.h"
|
||||
#endif
|
||||
|
||||
struct rtems_bsdnet_config rtems_bsdnet_config = {
|
||||
#ifdef NIC_NAME
|
||||
netdriver_config, /* link to next interface */
|
||||
RTEMS_DO_BOOTP, /* Use BOOTP to get network configuration */
|
||||
#else
|
||||
0,
|
||||
0,
|
||||
#endif
|
||||
NETWORK_TASK_PRIORITY, /* Network task priority */
|
||||
#if defined(MEMORY_CUSTOM)
|
||||
MEMORY_CUSTOM,
|
||||
#elif defined(MEMORY_SCARCE)
|
||||
100*1024, /* MBUF space */
|
||||
200*1024, /* MBUF cluster space */
|
||||
#elif defined(MEMORY_HUGE)
|
||||
2*1024*1024, /* MBUF space */
|
||||
5*1024*1024, /* MBUF cluster space */
|
||||
#else
|
||||
180*1024, /* MBUF space */
|
||||
350*1024, /* MBUF cluster space */
|
||||
#endif
|
||||
#if (!defined (RTEMS_USE_BOOTP)) && defined(ON_RTEMS_LAB_WINSYSTEMS)
|
||||
"rtems", /* Host name */
|
||||
"nodomain.com", /* Domain name */
|
||||
"192.168.1.14", /* Gateway */
|
||||
"192.168.1.1", /* Log host */
|
||||
{"89.212.75.6" }, /* Name server(s) */
|
||||
{"192.168.1.1" }, /* NTP server(s) */
|
||||
#else
|
||||
NULL, /* Host name */
|
||||
NULL, /* Domain name */
|
||||
NULL, /* Gateway */
|
||||
NULL, /* Log host */
|
||||
{ NULL }, /* Name server(s) */
|
||||
{ NULL }, /* NTP server(s) */
|
||||
#endif /* !RTEMS_USE_BOOTP */
|
||||
0, /* efficiency */
|
||||
0, /* udp TX buffer */
|
||||
0, /* udp RX buffer */
|
||||
0, /* tcp TX buffer */
|
||||
0, /* tcp RX buffer */
|
||||
};
|
||||
#endif /* _RTEMS_NETWORKCONFIG_H_ */
|
||||
@@ -0,0 +1,37 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <rtems/rtems_bsdnet.h>
|
||||
#include <rtems/error.h>
|
||||
|
||||
#include "rtemsNetworking.h"
|
||||
|
||||
#include <epicsExit.h>
|
||||
#include <osdTime.h>
|
||||
|
||||
rtems_task
|
||||
Init (rtems_task_argument ignored)
|
||||
{
|
||||
rtems_bsdnet_initialize_network ();
|
||||
//rtems_bsdnet_show_if_stats ();
|
||||
|
||||
rtems_time_of_day timeOfDay;
|
||||
if (rtems_clock_get(RTEMS_CLOCK_GET_TOD,&timeOfDay) != RTEMS_SUCCESSFUL) {
|
||||
timeOfDay.year = 2014;
|
||||
timeOfDay.month = 1;
|
||||
timeOfDay.day = 1;
|
||||
timeOfDay.hour = 0;
|
||||
timeOfDay.minute = 0;
|
||||
timeOfDay.second = 0;
|
||||
timeOfDay.ticks = 0;
|
||||
|
||||
rtems_status_code ret = rtems_clock_set(&timeOfDay);
|
||||
if (ret != RTEMS_SUCCESSFUL) {
|
||||
printf("**** Can't set time %s\n", rtems_status_text(ret));
|
||||
}
|
||||
}
|
||||
osdTimeRegister();
|
||||
|
||||
extern void pvAccessAllTests(void);
|
||||
pvAccessAllTests();
|
||||
epicsExit(0);
|
||||
}
|
||||
+20
-18
@@ -1,15 +1,15 @@
|
||||
TOP=../..
|
||||
# This is a Makefile fragment, see ../Makefile
|
||||
|
||||
include $(TOP)/configure/CONFIG
|
||||
|
||||
PROD_LIBS += pvAccess pvData pvMB Com
|
||||
SRC_DIRS += $(PVACCESS_TEST)/utils
|
||||
|
||||
TESTPROD_HOST += testAtomicBoolean
|
||||
testAtomicBoolean_SRCS = testAtomicBoolean.cpp
|
||||
testHarness_SRCS += testAtomicBoolean.cpp
|
||||
TESTS += testAtomicBoolean
|
||||
|
||||
TESTPROD_HOST += testHexDump
|
||||
testHexDump = testHexDump.cpp
|
||||
testHarness_SRCS += testHexDump.cpp
|
||||
TESTS += testHexDump
|
||||
|
||||
TESTPROD_HOST += testInetAddressUtils
|
||||
@@ -19,30 +19,32 @@ testInetAddressUtils = testInetAddressUtils.cpp
|
||||
testInetAddressUtils_CXXFLAGS = -O0
|
||||
# needed for 64-bit Windows
|
||||
testInetAddressUtils_SYS_LIBS_WIN32 += ws2_32
|
||||
testHarness_SRCS += testInetAddressUtils.cpp
|
||||
TESTS += testInetAddressUtils
|
||||
|
||||
TESTSCRIPTS_HOST += $(TESTS:%=%.t)
|
||||
|
||||
#PROD_HOST += loggerTest
|
||||
#TESTPROD_HOST += loggerTest
|
||||
#loggerTest_SRCS += loggerTest.cpp
|
||||
#loggerTest_LIBS += pvAccess pvData Com
|
||||
#testHarness_SRCS += loggerTest.cpp
|
||||
#TESTS += loggerTest
|
||||
|
||||
#PROD_HOST += introspectionRegisterTest
|
||||
#TESTPROD_HOST += introspectionRegisterTest
|
||||
#introspectionRegisterTest_SRCS += introspectionRegistryTest.cpp
|
||||
#introspectionRegisterTest_LIBS += pvAccess Com pvData
|
||||
#testHarness_SRCS += introspectionRegistryTest.cpp
|
||||
#TESTS += introspectionRegistryTest
|
||||
|
||||
#PROD_HOST += transportRegisterTest
|
||||
#TESTPROD_HOST += transportRegisterTest
|
||||
#transportRegisterTest_SRCS += transportRegistryTest.cpp
|
||||
#transportRegisterTest_LIBS += pvAccess Com pvData
|
||||
#testHarness_SRCS += transportRegistryTest.cpp
|
||||
#TESTS += transportRegistryTest
|
||||
|
||||
#PROD_HOST += namedLockPatternTest
|
||||
#TESTPROD_HOST += namedLockPatternTest
|
||||
#namedLockPatternTest_SRCS += namedLockPatternTest.cpp
|
||||
#namedLockPatternTest_LIBS += pvAccess Com pvData
|
||||
#testHarness_SRCS += namedLockPatternTest.cpp
|
||||
#TESTS += namedLockPatternTest
|
||||
|
||||
#PROD_HOST += configurationTest
|
||||
#TESTPROD_HOST += configurationTest
|
||||
#configurationTest_SRCS += configurationTest.cpp
|
||||
#configurationTest_LIBS += pvAccess Com pvData
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
#----------------------------------------
|
||||
# ADD RULES AFTER THIS LINE
|
||||
#testHarness_SRCS += configurationTest.cpp
|
||||
#TESTS += configurationTest
|
||||
|
||||
Reference in New Issue
Block a user