Imported CSS files

This commit is contained in:
Sakbe
2019-10-21 16:02:55 +01:00
parent 22146b8413
commit 87401e8c95
365 changed files with 1092613 additions and 0 deletions

View File

@@ -0,0 +1,585 @@
Version = "$Id: MARTe-WaterTank.cfg,v 1.5 2010/04/20 15:42:02 ppcc_dev Exp $"
LoggerAddress = "localhost"
DefaultCPUs = 1
+WEB = {
Class = HttpGroupResource
+BROWSE = {
Title = "Http Object Browser"
Class = HttpGCRCBrowser
AddReference = {MARTe StateMachine OBJBROWSE THRBROWSE CFGUpload HTTPSignalServer MatlabSignalServer}
}
+RGRAPH_LIB_DIR = {
Class = HttpDirectoryResource
BaseDir = "../../3rdPartyLibs/RGraph/libraries"
}
}
+HTTPSERVER = {
Class = HttpService
Port = 8084
HttpRelayURL = "ignore.me:1234"
VerboseLevel = 10
Root = WEB
}
+OBJBROWSE = {
Class = HttpClassListResource
}
+THRBROWSE = {
Class = HttpThreadListResource
}
+MatlabSignalServer = {
Class = MATLABHandler
}
+HTTPSignalServer={
Class = SignalServer
}
+CFGUpload = {
Class = CFGUploader
}
+TCPMessageHandler = {
Class = TCPMessageHandler
ServerPort = 9090
CPUMask = 1
}
+StateMachine = {
Class = StateMachine
VerboseLevel = 10
+INITIAL = {
Class = StateMachineState
StateCode = 0x0
+START = {
Class = StateMachineEvent
NextState = WAITING_FOR_PULSE
Value = START
+STARTALL = {
Class = MessageDeliveryRequest
Sender = StateMachine
Destinations = "HTTPSERVER MARTe"
MsecTimeOut = 1000
Flags = NoReply
Message = {
Class = Message
Content = START
}
}
}
}
+WAITING_FOR_PULSE = {
Class = StateMachineState
StateCode = 0x500
+PULSE = {
Class = StateMachineEvent
Code = 0x701
NextState = WAITING_FOR_TRIGGER
+NOTIFY = {
Class = MessageEnvelope
Sender = StateMachine
Destination = MARTe
+MESSAGE = {
Class = Message
Content = PREPULSECHECK
}
}
+UPDATE_MSS = {
Class = MessageEnvelope
Destination = MatlabSignalServer
+MESSAGE = {
Class = Message
Content = AUTODETECT
}
}
+UPDATE_SS = {
Class = MessageEnvelope
Destination = HTTPSignalServer
+MESSAGE = {
Class = Message
Content = AUTODETECT
}
}
}
+INHIBIT = {
Class = StateMachineEvent
Code = 0x704
NextState = INHIBIT
}
+ACTIVATE = {
Class = StateMachineEvent
Code = 0x705
NextState = SAMESTATE
}
+UNRECOVERABLE = {
Class = StateMachineEvent
Code = 0x776
NextState = UNRECOVERABLE
}
+CONFIG_ERROR = {
Class = StateMachineEvent
Code = 0x777
NextState = CONFIG_ERROR
}
+CONFIG_OK = {
Class = StateMachineEvent
Code = 0x778
NextState = SAMESTATE
+NOTIFY = {
Class = MessageEnvelope
Sender = StateMachine
Destination = COULD.BE.A.MIMIC
+SENDSTATE = {
Class = Message
Code = 0x500
}
}
}
+STOP = {
Class = StateMachineEvent
NextState = WAITING_FOR_PULSE
Value = STOP
Code = 0x005
+STOPALL = {
Class = MessageDeliveryRequest
Sender = StateMachine
Destinations = "HTTPSERVER MARTe"
MsecTimeOut = 1000
Flags = NoReply
Message = {
Class = Message
Content = STOP
}
}
}
}
+WAITING_FOR_TRIGGER = {
Class = StateMachineState
StateCode = 0x504
+TRIGGER = {
Class = StateMachineEvent
Code = 0x708
NextState = PULSING
+NOTIFY = {
Class = MessageEnvelope
Sender = StateMachine
Destination = MARTe
+MESSAGE = {
Class = Message
Content = PULSESTART
}
}
}
+ABORT = {
Class = StateMachineEvent
Code = 0x702
NextState = WAITING_FOR_PULSE
+NOTIFY = {
Class = MessageEnvelope
Sender = StateMachine
Destination = MARTe
+MESSAGE = {
Class = Message
Content = PULSESTOP
}
}
}
+COLLECTION_COMPLETED = {
Class = StateMachineEvent
Code = 0x703
NextState = COMM_ERROR
}
}
+PULSING = {
Class = StateMachineState
StateCode = 0x505
+ENTER = {
Class = MessageEnvelope
Destination = COULD.BE.A.MIMIC
+SENDSTATE = {
Class = Message
}
}
+ABORT = {
Class = StateMachineEvent
Code = 0x702
NextState = WAITING_FOR_PULSE
+NOTIFY = {
Class = MessageEnvelope
Sender = StateMachine
Destination = MARTe
+MESSAGE = {
Class = Message
Content = PULSESTOP
}
}
}
+END_PULSE = {
Class = StateMachineEvent
Code = 0x709
NextState = POST_PULSE
+NOTIFY = {
Class = MessageEnvelope
Sender = StateMachine
Destination = MARTe
+MESSAGE = {
Class = Message
Content = PULSESTOP
}
}
}
}
+POST_PULSE = {
Class = StateMachineState
StateCode = 0x507
+ENTER = {
Class = MessageEnvelope
Destination = COULD.BE.A.MIMIC
+SENDSTATE = {
Class = Message
}
}
+COLLECTION_COMPLETED = {
Class = StateMachineEvent
Code = 0x703
NextState = WAITING_FOR_PULSE
+NOTIFY = {
Class = MessageEnvelope
Sender = StateMachine
Destination = MARTe
+MESSAGE = {
Class = Message
Content = COLLECTIONCOMPLETED
}
}
}
}
+INHIBIT = {
Class = StateMachineState
StateCode = 0x508
+ACTIVATE = {
Class = StateMachineEvent
Code = 0x705
NextState = WAITING_FOR_PULSE
}
}
+ERROR = {
Class = StateMachineState
StateCode = 0x601
+ACTIVATE = {
Class = StateMachineEvent
Code = 0x705
NextState = WAITING_FOR_PULSE
}
+COLLECTION_COMPLETED = {
Class = StateMachineEvent
Code = 0x703
NextState = WAITING_FOR_PULSE
}
}
+CONFIG_ERROR = {
Class = StateMachineState
StateCode = 0x601
+ENTER = {
Class = MessageEnvelope
Destination = COULD.BE.A.MIMIC
+SENDSTATE = {
Class = Message
}
}
+ACTIVATE = {
Class = StateMachineEvent
Code = 0x705
NextState = WAITING_FOR_PULSE
}
+CONFIG_OK = {
Class = StateMachineEvent
Code = 0x778
NextState = WAITING_FOR_PULSE
+NOTIFY = {
Class = MessageEnvelope
Sender = StateMachine
Destination = COULD.BE.A.MIMIC
+SENDSTATE = {
Class = Message
Code = 0x500
}
}
}
+CONFIG_ERROR = {
Class = StateMachineEvent
Code = 0x777
NextState = CONFIG_ERROR
}
}
+UNRECOVERABLE = {
Class = StateMachineState
StateCode = 0x601
+DEFAULT = {
Class = StateMachineEvent
UserCode = 0
NextState = UNRECOVERABLE
}
}
+COMM_ERROR = {
StateCode = 0x601
Class = StateMachineState
+ABORT = {
Class = StateMachineEvent
Code = 0x702
NextState = SAMESTATE
}
}
+DEFAULT = {
Class = StateMachineState
StateCode = 0x601
+ABORT = {
Class = StateMachineEvent
Code = 0x702
NextState = WAITING_FOR_PULSE
}
+TRIGGER = {
Class = StateMachineEvent
Code = 0x708
NextState = SAMESTATE
}
+END_PULSE = {
Class = StateMachineEvent
Code = 0x709
NextState = SAMESTATE
}
}
}
+MARTeMenu = {
Class = MarteSupLib::MARTeMenu
Title = "MARTe Menu"
+MenuA = {
Class = MenuContainer
Title = "State Machine"
+ABORT = {
Class = SendMessageMenuEntry
Title = Abort
Envelope = {
Class = MessageEnvelope
Sender = MARTeMenu
Destination = StateMachine
+Message = {
Class = Message
Code = 0x702
Content = ABORT
}
}
}
+INHIBIT = {
Class = SendMessageMenuEntry
Title = Inhibit
Envelope = {
Class = MessageEnvelope
Sender = MARTeMenu
Destination = StateMachine
+Message = {
Class = Message
Code = 0x704
Content = Inhibit
}
}
}
+ACTIVATE = {
Class = SendMessageMenuEntry
Title = Activate
Envelope = {
Class = MessageEnvelope
Sender = MARTeMenu
Destination = StateMachine
+Message = {
Class = Message
Code = 0x705
Content = Activate
}
}
}
+PULSESETUPCOMPLETE = {
Class = SendMessageMenuEntry
Title = "Pulse Setup Complete"
Envelope = {
Class = MessageEnvelope
Sender = MARTeMenu
Destination = StateMachine
+Message = {
Class = Message
Code = 0x701
Content = WAITING_FOR_PULSE
}
}
}
+TRIGGER = {
Class = SendMessageMenuEntry
Title = "Pulse Start"
Envelope = {
Class = MessageEnvelope
Sender = MARTeMenu
Destination = StateMachine
+Message = {
Class = Message
Code = 0x708
Content = TRIGGER
}
}
}
+END_PULSE = {
Class = SendMessageMenuEntry
Title = "Pulse End"
Envelope = {
Class = MessageEnvelope
Sender = MARTeMenu
Destination = StateMachine
+Message = {
Class = Message
Code = 0x709
Content = END_PULSE
}
}
}
+COLLECTION_COMPLETED = {
Class = SendMessageMenuEntry
Title = "Collection Completed"
Envelope = {
Class = MessageEnvelope
Sender = MARTeMenu
Destination = StateMachine
+Message = {
Class = Message
Code = 0x703
Content = POSTPULSE
}
}
}
}
AddReference = MARTe.MARTe
}
+MARTe = {
Class = MARTeContainer
StateMachineName = StateMachine
Level1Name = LEVEL1
MenuContainerName = MARTe
+MARTe = {
Class = MenuContainer
}
+DriverPool = {
Class = GCReferenceContainer
+TimerBoard = {
Class = GenericTimerDrv
NumberOfInputs = 2
NumberOfOutputs = 0
TimerUsecPeriod = 10000
SynchronizationMethod = Synchronizing
CPUMask = 1
}
}
+Messages = {
Class = GCReferenceContainer
+FatalErrorMessage = {
Class = MessageDeliveryRequest
Destinations = StateMachine
MsecTimeOut = 1000
Flags = NoReply
Message = {
Class = Message
Code = 0x776
Content = UNRECOVERABLE
}
}
+ConfigLoadErrorMessage = {
Class = MessageDeliveryRequest
Destinations = StateMachine
MsecTimeOut = 1000
Flags = NoReply
Message = {
Class = Message
Code = 0x777
Content = CONFIG_ERROR
}
}
+ConfigLoadOKMessage = {
Class = MessageDeliveryRequest
Destinations = StateMachine
MsecTimeOut = 1000
Flags = NoReply
Message = {
Class = Message
Code = 0x778
Content = CONFIG_OK
}
}
+SafetyErrorMessage = {
Class = MessageDeliveryRequest
Destinations = MARTe
MsecTimeOut = 1000
Flags = NoReply
Message = {
Class = Message
Content = ERROR
}
}
}
+ExternalTimeTriggeringService = {
Class = InterruptDrivenTTS
TsOnlineUsecPeriod = 10000
TsOnlineUsecPhase = 0
TsOfflineUsecPeriod = 10000
TsOfflineUsecPhase = 0
TimeModule = {
BoardName = TimerBoard
}
}
+Thread_1 = {
Class = RealTimeThread
ThreadPriority = 28
RunOnCPU = 2
RTStatusChangeMsecTimeout = 1000
SMStatusChangeMsecTimeout = 1000
OfflineSemaphoreTimeout = 50
TriggeringServiceName = MARTe.ExternalTimeTriggeringService
SafetyMsecSleep = 1
+DDB = {
Class = DDB
}
+Timer = {
Class = IOGAMs::TimeInputGAM
TriggeringServiceName = ExternalTimeTriggeringService
BoardName = TimerBoard
Signals = {
time = {
SignalName = usecTime
SignalType = uint32
}
counter = {
SignalName = counter
SignalType = int32
}
}
}
+Statistic = {
Class = WebStatisticGAM
Verbose = True
FrequencyOfVerbose = 2000000
Signals = {
SignalU = {
SignalName = usecTime
SignalType = uint32
}
Signal0 = {
SignalName = CycleUsecTime
SignalType = float
}
Signal9 = {
SignalName = StatisticAbsoluteUsecTime
SignalType = float
}
Signal15 = {
SignalName = StatisticRelativeUsecTime
SignalType = float
}
}
}
Online = "Timer Statistic"
Offline = "Timer Statistic"
}
}
ReloadAll = 0

View File

@@ -0,0 +1,78 @@
#############################################################
#
# Copyright 2011 EFDA | European Fusion Development Agreement
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id$
#
#############################################################
#Start-up script for the MARTe WaterTank example
#!/bin/sh
if [ -z "$1" ]; then
echo "Please specify the location of the configuration file"
exit
else
echo "Going to start MARTe with the configuration specified in: " $1
fi
target=`uname`
case ${target} in
Darwin)
TARGET=macosx
;;
SunOS)
TARGET=solaris
;;
*)
TARGET=linux
;;
esac
echo "Target is $TARGET"
BASEDIR=/DCS/Develop/DCS3/marte-dcs/marte/Base/trunk
CODE_DIRECTORY=$BASEDIR
LD_LIBRARY_PATH=.:$CODE_DIRECTORY/BaseLib2/${TARGET}/
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CODE_DIRECTORY/MARTe/MARTeSupportLib/${TARGET}/
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CODE_DIRECTORY/IOGAMs/${TARGET}/
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CODE_DIRECTORY/IOGAMs/${TARGET}Timer/${TARGET}/
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CODE_DIRECTORY/IOGAMs/GenericTimerDriver/${TARGET}/
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CODE_DIRECTORY/GAMs/WebStatisticGAM/${TARGET}/
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CODE_DIRECTORY/Interfaces/HTTP/CFGUploader/${TARGET}/
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CODE_DIRECTORY/Interfaces/HTTP/SignalHandler/${TARGET}/
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CODE_DIRECTORY/Interfaces/HTTP/MATLABHandler/${TARGET}/
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CODE_DIRECTORY/Interfaces/HTTP/FlotPlot/${TARGET}/
#LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CODE_DIRECTORY/Examples/TCPMessageHandler/${TARGET}/
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./${TARGET}/
if [ ${TARGET} == "macosx" ]; then
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$LD_LIBRARY_PATH
echo $DYLD_LIBRARY_PATH
else
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH
echo $LD_LIBRARY_PATH
fi
$CODE_DIRECTORY/MARTe/${TARGET}/MARTe.ex $1
#cgdb --args $CODE_DIRECTORY/MARTe/${TARGET}/MARTe.ex $1

View File

@@ -0,0 +1,49 @@
#############################################################
#
# Copyright 2011 EFDA | European Fusion Development Agreement
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=
BASEDIR=/opt/MARTe
MAKEDEFAULTDIR=$(BASEDIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
CFLAGS+= -I.
CFLAGS+= -I$(BASEDIR)/BaseLib2/Level0
CFLAGS+= -I$(BASEDIR)/BaseLib2/Level1
CFLAGS+= -I$(BASEDIR)/BaseLib2/Level2
CFLAGS+= -I$(BASEDIR)/BaseLib2/Level3
CFLAGS+= -I$(BASEDIR)/BaseLib2/Level4
CFLAGS+= -I$(BASEDIR)/BaseLib2/Level5
CFLAGS+= -I$(BASEDIR)/BaseLib2/Level6
CFLAGS+= -I$(BASEDIR)/BaseLib2/LoggerService
CFLAGS+= -I$(BASEDIR)/MARTe/MARTeSupportLib
all: $(OBJS) \
$(TARGET)/TCPMessageHandler$(DLLEXT)
echo $(OBJS)
include depends.$(TARGET)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)

View File

@@ -0,0 +1,49 @@
#############################################################
#
# Copyright 2011 EFDA | European Fusion Development Agreement
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
OBJSX=
BASEDIR=/DCS/Develop/DCS3/marte-dcs/marte/Base/trunk
MAKEDEFAULTDIR=$(BASEDIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
CFLAGS+= -I.
CFLAGS+= -I$(BASEDIR)/BaseLib2/Level0
CFLAGS+= -I$(BASEDIR)/BaseLib2/Level1
CFLAGS+= -I$(BASEDIR)/BaseLib2/Level2
CFLAGS+= -I$(BASEDIR)/BaseLib2/Level3
CFLAGS+= -I$(BASEDIR)/BaseLib2/Level4
CFLAGS+= -I$(BASEDIR)/BaseLib2/Level5
CFLAGS+= -I$(BASEDIR)/BaseLib2/Level6
CFLAGS+= -I$(BASEDIR)/BaseLib2/LoggerService
CFLAGS+= -I$(BASEDIR)/MARTe/MARTeSupportLib
all: $(OBJS) \
$(TARGET)/TCPMessageHandler$(DLLEXT)
echo $(OBJS)
include depends.$(TARGET)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)

View File

@@ -0,0 +1,32 @@
#############################################################
#
# Copyright 2011 EFDA | European Fusion Development Agreement
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.linux 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
TARGET=linux
include Makefile.inc
LIBRARIES += -L$(BASEDIR)/BaseLib2/$(TARGET) -lBaseLib2 -L$(BASEDIR)/MARTe/MARTeSupportLib/$(TARGET) -lMARTeSupLib
OPTIM=

View File

@@ -0,0 +1,34 @@
#############################################################
#
# Copyright 2011 EFDA | European Fusion Development Agreement
#
# Licensed under the EUPL, Version 1.1 or - as soon they
# will be approved by the European Commission - subsequent
# versions of the EUPL (the "Licence");
# You may not use this work except in compliance with the
# Licence.
# You may obtain a copy of the Licence at:
#
# http://ec.europa.eu/idabc/eupl
#
# Unless required by applicable law or agreed to in
# writing, software distributed under the Licence is
# distributed on an "AS IS" basis,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied.
# See the Licence for the specific language governing
# permissions and limitations under the Licence.
#
# $Id: Makefile.linux 3 2012-01-15 16:26:07Z aneto $
#
#############################################################
TARGET=linux
BASEDIR=/DCS/Develop/DCS3/marte-dcs/marte/Base/trunk
include Makefile.inc
LIBRARIES += -L$(BASEDIR)/BaseLib2/$(TARGET) -lBaseLib2 -L$(BASEDIR)/MARTe/MARTeSupportLib/$(TARGET) -lMARTeSupLib
OPTIM=

View File

@@ -0,0 +1,216 @@
/*
* Copyright 2011 EFDA | European Fusion Development Agreement
*
* Licensed under the EUPL, Version 1.1 or - as soon they
will be approved by the European Commission - subsequent
versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the
Licence.
* You may obtain a copy of the Licence at:
*
* http://ec.europa.eu/idabc/eupl
*
* Unless required by applicable law or agreed to in
writing, software distributed under the Licence is
distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied.
* See the Licence for the specific language governing
permissions and limitations under the Licence.
*
* $Id: MessageTriggeringTimeService.h 3 2012-01-15 16:26:07Z aneto $
*
**/
#include "TCPMessageHandler.h"
#include "MessageDispatcher.h"
void ConnectionHandlerFn(TCPMessageHandler &tcpmh){
while(tcpmh.keepAlive){
tcpmh.ConnectionHandler();
CStaticAssertErrorCondition(FatalError, "Lost server connection");
if(tcpmh.keepAlive){
CStaticAssertErrorCondition(FatalError, "Retrying in 10 seconds");
SleepSec(10.0);
}
}
//Just to signal that we have shutdown
tcpmh.keepAlive = True;
}
TCPMessageHandler::TCPMessageHandler(){
serverPort = -1;
serverTID = 0;
cpuMask = 0;
keepAlive = False;
msgTimeout = TTInfiniteWait;
}
TCPMessageHandler::~TCPMessageHandler(){
keepAlive = False;
//Open a connection to the server to force the shutdown
FString host = "localhost";
TCPSocket client;
//Open the socket
if(!client.Open()){
AssertErrorCondition(FatalError, "%s: failed to shutdown server. Waited for 1 second.", Name());
return;
}
//Connect to the server
if(!client.Connect(host.Buffer(), serverPort)){
CStaticAssertErrorCondition(FatalError, "%s: Failed to connect to %s:%d", Name(), host.Buffer(), serverPort);
client.Close();
}
//Write a line
FString line = "";
uint32 size = line.Size();
if(!client.Write(line.Buffer(), size)){
CStaticAssertErrorCondition(FatalError, "Failed to write to socket");
}
//Housekeeping
client.Close();
int32 exitCounter = 0;
while(!keepAlive){
exitCounter++;
SleepMsec(10);
if(exitCounter > 100){
AssertErrorCondition(FatalError, "%s: failed to shutdown server. Waited for 1 second.", Name());
break;
}
}
if(exitCounter > 100){
Threads::Kill(serverTID);
}
serverTID = 0;
}
bool TCPMessageHandler::ConnectionHandler(){
//Open the server connection
if(!server.Open()){
AssertErrorCondition(FatalError, "%s: Failed to open the server socket", Name());
return False;
}
//Set in server mode
if(!server.Listen(serverPort)){
CStaticAssertErrorCondition(FatalError, "Failed to create server running in port %d", serverPort);
server.Close();
return False;
}
//Wait for a connection
TCPSocket *client = NULL;
while(keepAlive){
client = server.WaitConnection();
if(client == NULL){
AssertErrorCondition(FatalError, "%s: Failed waiting for a connection in port %d", serverPort, Name());
server.Close();
return False;
}
//Set the client in blocking mode for the read
client->SetBlocking(True);
//Print information from the client
FString hostname;
client->Source().HostName(hostname);
AssertErrorCondition(Information, "%s: Accepted a connection from %s", Name(), hostname.Buffer());
ClientHandler(client);
}
server.Close();
return True;
}
void TCPMessageHandler::ClientHandler(TCPSocket *client){
//Read a line from the client socket
FString line;
bool ret = False;
line.SetSize(0);
while(client->GetLine(line)){
ret = HandleRequest(line, client);
line.SetSize(0);
if(!ret){
client->Printf("Failed\n");
}
}
}
bool TCPMessageHandler::HandleRequest(FString &req, TCPSocket *client){
FString destination;
FString code;
FString content;
req.Seek(0);
printf("%s\n", req.Buffer());
if(!req.GetToken(destination, "|")){
AssertErrorCondition(FatalError, "%s: HandleRequest: Could not read the message destination", Name());
return False;
}
if(!req.GetToken(code, "|")){
AssertErrorCondition(FatalError, "%s: HandleRequest: Could not read the message code", Name());
return False;
}
if(!req.GetToken(content, "|")){
AssertErrorCondition(FatalError, "%s: HandleRequest: Could not read the message content", Name());
return False;
}
AssertErrorCondition(Information, "%s: HandleRequest : D=%s,C=%s,CT=%s", Name(), destination.Buffer(), code.Buffer(), content.Buffer());
GCRTemplate<Message> msg(GCFT_Create);
if(!msg.IsValid()){
AssertErrorCondition(FatalError, "%s: HandleRequest: Failed to create message", Name());
return False;
}
GCRTemplate<MessageEnvelope> env(GCFT_Create);
if (!env.IsValid()){
AssertErrorCondition(FatalError, "%s: HandleRequest: Failed to creating envelope", Name());
return False;
}
msg->Init(atoi(code.Buffer()), content.Buffer());
env->PrepareMessageEnvelope(msg, destination.Buffer(), MDRF_ManualReply, this);
GCRTemplate<MessageEnvelope> reply;
MessageHandler::SendMessageAndWait(env, reply, msgTimeout);
if(!reply.IsValid()){
AssertErrorCondition(FatalError, "%s: HandleRequest: Received an invalid reply", Name());
return False;
}
GCRTemplate<Message> replyMessage = reply->GetMessage();
if(!replyMessage.IsValid()){
AssertErrorCondition(FatalError, "%s: HandleRequest: Received an invalid reply message", Name());
return False;
}
AssertErrorCondition(Information, "%s: HandleRequest: Received a reply with code=%d and content=%s", Name(), replyMessage->GetMessageCode().Code(), replyMessage->Content());
client->Printf("Success with code=%d and content=%s\n", replyMessage->GetMessageCode().Code(), replyMessage->Content());
return True;
}
bool TCPMessageHandler::ObjectLoadSetup(ConfigurationDataBase &cdb, StreamInterface *err){
if(!GCNamedObject::ObjectLoadSetup(cdb, err)){
AssertErrorCondition(FatalError, "%s::ObjectLoadSetup: ObjectLoadSetup of GCNamedObject failed", Name());
return False;
}
CDBExtended cdbe(cdb);
if(!cdbe.ReadInt32(serverPort, "ServerPort")){
AssertErrorCondition(FatalError, "%s::ObjectLoadSetup: PulseNumberMessageCode is compulsory when PulseNumberMessageDestinations are set", Name());
}
//CPU mask for the thread
if(!cdbe.ReadInt32(cpuMask, "CPUMask", 0x1)){
AssertErrorCondition(Warning, "%s::ObjectLoadSetup: CPUMask was not specified. Using default: %d", Name(), cpuMask);
}
//The msg send timeout, default is infinite
int32 msgTimeoutMS = 0;
if(cdbe.ReadInt32(msgTimeoutMS, "MSGTimeout")){
msgTimeout = msgTimeoutMS;
}
keepAlive = True;
serverTID = Threads::BeginThread((void (__thread_decl *)(void *))&ConnectionHandlerFn,this, THREADS_DEFAULT_STACKSIZE, Name(), XH_NotHandled, cpuMask);
return True;
}
OBJECTLOADREGISTER(TCPMessageHandler, "$Id: TCPMessageHandler.cpp,v 1.2 2011/12/07 13:55:43 aneto Exp $")

View File

@@ -0,0 +1,102 @@
/*
* Copyright 2011 EFDA | European Fusion Development Agreement
*
* Licensed under the EUPL, Version 1.1 or - as soon they
will be approved by the European Commission - subsequent
versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the
Licence.
* You may obtain a copy of the Licence at:
*
* http://ec.europa.eu/idabc/eupl
*
* Unless required by applicable law or agreed to in
writing, software distributed under the Licence is
distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied.
* See the Licence for the specific language governing
permissions and limitations under the Licence.
*
* $Id: MessageTriggeringTimeService.h 3 2012-01-15 16:26:07Z aneto $
*
**/
/**
* @file
* Forwards text messages received using a TCP interface to a BaseLib2/MARTe object
* The syntax of the message is: DESTINATION|CODE|CONTENT
*/
#ifndef TCP_MESSAGE_HANDLER_H
#define TCP_MESSAGE_HANDLER_H
#include "GCReferenceContainer.h"
#include "CDBExtended.h"
#include "TCPSocket.h"
#include "MessageHandler.h"
OBJECT_DLL(TCPMessageHandler)
class TCPMessageHandler : public GCNamedObject, public MessageHandler{
OBJECT_DLL_STUFF(TCPMessageHandler)
private:
/**
* Handle connection requests
*/
friend void ConnectionHandlerFn(TCPMessageHandler &tcpmh);
bool ConnectionHandler();
/**
* Handle the client requests and forward as messages
**/
void ClientHandler(TCPSocket *client);
/**
* Parse the client request and send the message
*/
bool HandleRequest(FString &msg, TCPSocket *client);
/**
* This flag is true while the TCP server is supposed to be running
*/
bool keepAlive;
/**
* TCP server port
*/
int32 serverPort;
/**
* The server socket
*/
TCPSocket server;
/**
* The TCP server thread identifier
*/
int32 serverTID;
/**
* The TCP server cpu mask
*/
int32 cpuMask;
/**
* Timeout to send the messages
*/
TimeoutType msgTimeout;
public:
TCPMessageHandler();
virtual ~TCPMessageHandler();
/**
* @sa Object::ObjectLoadSetup
*/
virtual bool ObjectLoadSetup(
ConfigurationDataBase & info,
StreamInterface * err);
};
#endif

View File

@@ -0,0 +1,7 @@
telnet localhost 9090
StateMachine|1793|PULSE
StateMachine|1800|TRIGGER
StateMachine|1801|END_PULSE
StateMachine|1795|COLLECTION_COMPLETED

View File

@@ -0,0 +1,95 @@
linux/TCPMessageHandler.o: TCPMessageHandler.cpp TCPMessageHandler.h \
/opt/MARTe/BaseLib2/Level1/GCReferenceContainer.h \
/opt/MARTe/BaseLib2/Level0/LinkedListable.h \
/opt/MARTe/BaseLib2/Level0/System.h \
/opt/MARTe/BaseLib2/Level0/SystemMSC.h \
/opt/MARTe/BaseLib2/Level0/SystemLinux.h \
/opt/MARTe/BaseLib2/Level0/GenDefs.h \
/opt/MARTe/BaseLib2/Level0/SystemVX5100.h \
/opt/MARTe/BaseLib2/Level0/SystemVX5500.h \
/opt/MARTe/BaseLib2/Level0/SystemV6X5100.h \
/opt/MARTe/BaseLib2/Level0/SystemV6X5500.h \
/opt/MARTe/BaseLib2/Level0/SystemVX68k.h \
/opt/MARTe/BaseLib2/Level0/SystemRTAI.h \
/opt/MARTe/BaseLib2/Level0/SystemSolaris.h \
/opt/MARTe/BaseLib2/Level0/SystemMacOSX.h \
/opt/MARTe/BaseLib2/Level0/Memory.h \
/opt/MARTe/BaseLib2/Level0/Iterators.h \
/opt/MARTe/BaseLib2/Level1/GCRTemplate.h \
/opt/MARTe/BaseLib2/Level1/GCReference.h \
/opt/MARTe/BaseLib2/Level0/Atomic.h /opt/MARTe/BaseLib2/Level0/Sleep.h \
/opt/MARTe/BaseLib2/Level0/FastMath.h /opt/MARTe/BaseLib2/Level0/HRT.h \
/opt/MARTe/BaseLib2/Level0/Processor.h \
/opt/MARTe/BaseLib2/Level1/ObjectRegistryDataBase.h \
/opt/MARTe/BaseLib2/Level0/StreamInterface.h \
/opt/MARTe/BaseLib2/Level0/TimeoutType.h \
/opt/MARTe/BaseLib2/Level1/GarbageCollectable.h \
/opt/MARTe/BaseLib2/Level1/Object.h /opt/MARTe/BaseLib2/Level0/System.h \
/opt/MARTe/BaseLib2/Level1/ObjectRegistryItem.h \
/opt/MARTe/BaseLib2/Level1/ErrorSystemInstructions.h \
/opt/MARTe/BaseLib2/Level0/GenDefs.h \
/opt/MARTe/BaseLib2/Level0/LinkedListHolder.h \
/opt/MARTe/BaseLib2/Level0/LinkedListable.h \
/opt/MARTe/BaseLib2/Level0/FastPollingMutexSem.h \
/opt/MARTe/BaseLib2/Level0/Atomic.h /opt/MARTe/BaseLib2/Level0/Threads.h \
/opt/MARTe/BaseLib2/Level0/ErrorManagement.h \
/opt/MARTe/BaseLib2/Level0/ExceptionHandlerDefinitions.h \
/opt/MARTe/BaseLib2/Level0/ThreadInitialisationInterface.h \
/opt/MARTe/BaseLib2/Level0/EventSem.h \
/opt/MARTe/BaseLib2/Level0/SemCore.h \
/opt/MARTe/BaseLib2/Level0/ProcessorType.h \
/opt/MARTe/BaseLib2/Level0/ThreadsDatabase.h \
/opt/MARTe/BaseLib2/Level1/ErrorSystemInstructionItem.h \
/opt/MARTe/BaseLib2/Level1/ClassStructure.h \
/opt/MARTe/BaseLib2/Level1/ClassStructureEntry.h \
/opt/MARTe/BaseLib2/Level1/BasicTypes.h \
/opt/MARTe/BaseLib2/Level0/BString.h \
/opt/MARTe/BaseLib2/Level0/ErrorManagement.h \
/opt/MARTe/BaseLib2/Level0/LoadableLibrary.h \
/opt/MARTe/BaseLib2/Level1/ObjectMacros.h \
/opt/MARTe/BaseLib2/Level1/GCNamedObject.h \
/opt/MARTe/BaseLib2/Level0/MutexSem.h \
/opt/MARTe/BaseLib2/Level1/GCRCItem.h \
/opt/MARTe/BaseLib2/Level1/GCNOExtender.h \
/opt/MARTe/BaseLib2/Level2/CDBExtended.h \
/opt/MARTe/BaseLib2/Level1/ConfigurationDataBase.h \
/opt/MARTe/BaseLib2/Level1/CDBVirtual.h \
/opt/MARTe/BaseLib2/Level1/CDBTypes.h \
/opt/MARTe/BaseLib2/Level0/Iterators.h \
/opt/MARTe/BaseLib2/Level1/CDBNull.h \
/opt/MARTe/BaseLib2/Level2/CDBDataTypes.h \
/opt/MARTe/BaseLib2/Level1/CDBTypes.h \
/opt/MARTe/BaseLib2/Level2/Streamable.h \
/opt/MARTe/BaseLib2/Level0/CStream.h \
/opt/MARTe/BaseLib2/Level2/CStreamBuffering.h \
/opt/MARTe/BaseLib2/Level1/Object.h \
/opt/MARTe/BaseLib2/Level1/StreamAttributes.h \
/opt/MARTe/BaseLib2/Level2/FString.h \
/opt/MARTe/BaseLib2/Level2/TCPSocket.h \
/opt/MARTe/BaseLib2/Level0/BasicTCPSocket.h \
/opt/MARTe/BaseLib2/Level0/BasicSocket.h \
/opt/MARTe/BaseLib2/Level0/InternetAddress.h \
/opt/MARTe/BaseLib2/Level0/FastPollingMutexSem.h \
/opt/MARTe/BaseLib2/Level0/BString.h \
/opt/MARTe/BaseLib2/Level0/SocketSelect.h \
/opt/MARTe/BaseLib2/Level0/InternetService.h \
/opt/MARTe/BaseLib2/Level0/Endianity.h \
/opt/MARTe/BaseLib2/Level0/SocketSelect.h \
/opt/MARTe/BaseLib2/Level0/InternetService.h \
/opt/MARTe/BaseLib2/Level0/SocketTimer.h \
/opt/MARTe/BaseLib2/Level5/MessageHandler.h \
/opt/MARTe/BaseLib2/Level5/MessageInterface.h \
/opt/MARTe/BaseLib2/Level5/MessageEnvelope.h \
/opt/MARTe/BaseLib2/Level1/GCReference.h \
/opt/MARTe/BaseLib2/Level5/Message.h \
/opt/MARTe/BaseLib2/Level1/GCNamedObject.h \
/opt/MARTe/BaseLib2/Level5/MessageCode.h \
/opt/MARTe/BaseLib2/Level5/MDRFlags.h \
/opt/MARTe/BaseLib2/Level0/MuxLock.h \
/opt/MARTe/BaseLib2/Level0/MutexSem.h \
/opt/MARTe/BaseLib2/Level5/MessageQueue.h \
/opt/MARTe/BaseLib2/Level0/EventSem.h \
/opt/MARTe/BaseLib2/Level5/MessageDispatcher.h \
/opt/MARTe/BaseLib2/Level5/MessageDeliveryRequest.h \
/opt/MARTe/BaseLib2/Level5/MessageHandler.h \
/opt/MARTe/BaseLib2/Level2/FString.h

View File

@@ -0,0 +1,95 @@
TCPMessageHandler.o: TCPMessageHandler.cpp TCPMessageHandler.h \
/opt/MARTe/BaseLib2/Level1/GCReferenceContainer.h \
/opt/MARTe/BaseLib2/Level0/LinkedListable.h \
/opt/MARTe/BaseLib2/Level0/System.h \
/opt/MARTe/BaseLib2/Level0/SystemMSC.h \
/opt/MARTe/BaseLib2/Level0/SystemLinux.h \
/opt/MARTe/BaseLib2/Level0/GenDefs.h \
/opt/MARTe/BaseLib2/Level0/SystemVX5100.h \
/opt/MARTe/BaseLib2/Level0/SystemVX5500.h \
/opt/MARTe/BaseLib2/Level0/SystemV6X5100.h \
/opt/MARTe/BaseLib2/Level0/SystemV6X5500.h \
/opt/MARTe/BaseLib2/Level0/SystemVX68k.h \
/opt/MARTe/BaseLib2/Level0/SystemRTAI.h \
/opt/MARTe/BaseLib2/Level0/SystemSolaris.h \
/opt/MARTe/BaseLib2/Level0/SystemMacOSX.h \
/opt/MARTe/BaseLib2/Level0/Memory.h \
/opt/MARTe/BaseLib2/Level0/Iterators.h \
/opt/MARTe/BaseLib2/Level1/GCRTemplate.h \
/opt/MARTe/BaseLib2/Level1/GCReference.h \
/opt/MARTe/BaseLib2/Level0/Atomic.h /opt/MARTe/BaseLib2/Level0/Sleep.h \
/opt/MARTe/BaseLib2/Level0/FastMath.h /opt/MARTe/BaseLib2/Level0/HRT.h \
/opt/MARTe/BaseLib2/Level0/Processor.h \
/opt/MARTe/BaseLib2/Level1/ObjectRegistryDataBase.h \
/opt/MARTe/BaseLib2/Level0/StreamInterface.h \
/opt/MARTe/BaseLib2/Level0/TimeoutType.h \
/opt/MARTe/BaseLib2/Level1/GarbageCollectable.h \
/opt/MARTe/BaseLib2/Level1/Object.h /opt/MARTe/BaseLib2/Level0/System.h \
/opt/MARTe/BaseLib2/Level1/ObjectRegistryItem.h \
/opt/MARTe/BaseLib2/Level1/ErrorSystemInstructions.h \
/opt/MARTe/BaseLib2/Level0/GenDefs.h \
/opt/MARTe/BaseLib2/Level0/LinkedListHolder.h \
/opt/MARTe/BaseLib2/Level0/LinkedListable.h \
/opt/MARTe/BaseLib2/Level0/FastPollingMutexSem.h \
/opt/MARTe/BaseLib2/Level0/Atomic.h /opt/MARTe/BaseLib2/Level0/Threads.h \
/opt/MARTe/BaseLib2/Level0/ErrorManagement.h \
/opt/MARTe/BaseLib2/Level0/ExceptionHandlerDefinitions.h \
/opt/MARTe/BaseLib2/Level0/ThreadInitialisationInterface.h \
/opt/MARTe/BaseLib2/Level0/EventSem.h \
/opt/MARTe/BaseLib2/Level0/SemCore.h \
/opt/MARTe/BaseLib2/Level0/ProcessorType.h \
/opt/MARTe/BaseLib2/Level0/ThreadsDatabase.h \
/opt/MARTe/BaseLib2/Level1/ErrorSystemInstructionItem.h \
/opt/MARTe/BaseLib2/Level1/ClassStructure.h \
/opt/MARTe/BaseLib2/Level1/ClassStructureEntry.h \
/opt/MARTe/BaseLib2/Level1/BasicTypes.h \
/opt/MARTe/BaseLib2/Level0/BString.h \
/opt/MARTe/BaseLib2/Level0/ErrorManagement.h \
/opt/MARTe/BaseLib2/Level0/LoadableLibrary.h \
/opt/MARTe/BaseLib2/Level1/ObjectMacros.h \
/opt/MARTe/BaseLib2/Level1/GCNamedObject.h \
/opt/MARTe/BaseLib2/Level0/MutexSem.h \
/opt/MARTe/BaseLib2/Level1/GCRCItem.h \
/opt/MARTe/BaseLib2/Level1/GCNOExtender.h \
/opt/MARTe/BaseLib2/Level2/CDBExtended.h \
/opt/MARTe/BaseLib2/Level1/ConfigurationDataBase.h \
/opt/MARTe/BaseLib2/Level1/CDBVirtual.h \
/opt/MARTe/BaseLib2/Level1/CDBTypes.h \
/opt/MARTe/BaseLib2/Level0/Iterators.h \
/opt/MARTe/BaseLib2/Level1/CDBNull.h \
/opt/MARTe/BaseLib2/Level2/CDBDataTypes.h \
/opt/MARTe/BaseLib2/Level1/CDBTypes.h \
/opt/MARTe/BaseLib2/Level2/Streamable.h \
/opt/MARTe/BaseLib2/Level0/CStream.h \
/opt/MARTe/BaseLib2/Level2/CStreamBuffering.h \
/opt/MARTe/BaseLib2/Level1/Object.h \
/opt/MARTe/BaseLib2/Level1/StreamAttributes.h \
/opt/MARTe/BaseLib2/Level2/FString.h \
/opt/MARTe/BaseLib2/Level2/TCPSocket.h \
/opt/MARTe/BaseLib2/Level0/BasicTCPSocket.h \
/opt/MARTe/BaseLib2/Level0/BasicSocket.h \
/opt/MARTe/BaseLib2/Level0/InternetAddress.h \
/opt/MARTe/BaseLib2/Level0/FastPollingMutexSem.h \
/opt/MARTe/BaseLib2/Level0/BString.h \
/opt/MARTe/BaseLib2/Level0/SocketSelect.h \
/opt/MARTe/BaseLib2/Level0/InternetService.h \
/opt/MARTe/BaseLib2/Level0/Endianity.h \
/opt/MARTe/BaseLib2/Level0/SocketSelect.h \
/opt/MARTe/BaseLib2/Level0/InternetService.h \
/opt/MARTe/BaseLib2/Level0/SocketTimer.h \
/opt/MARTe/BaseLib2/Level5/MessageHandler.h \
/opt/MARTe/BaseLib2/Level5/MessageInterface.h \
/opt/MARTe/BaseLib2/Level5/MessageEnvelope.h \
/opt/MARTe/BaseLib2/Level1/GCReference.h \
/opt/MARTe/BaseLib2/Level5/Message.h \
/opt/MARTe/BaseLib2/Level1/GCNamedObject.h \
/opt/MARTe/BaseLib2/Level5/MessageCode.h \
/opt/MARTe/BaseLib2/Level5/MDRFlags.h \
/opt/MARTe/BaseLib2/Level0/MuxLock.h \
/opt/MARTe/BaseLib2/Level0/MutexSem.h \
/opt/MARTe/BaseLib2/Level5/MessageQueue.h \
/opt/MARTe/BaseLib2/Level0/EventSem.h \
/opt/MARTe/BaseLib2/Level5/MessageDispatcher.h \
/opt/MARTe/BaseLib2/Level5/MessageDeliveryRequest.h \
/opt/MARTe/BaseLib2/Level5/MessageHandler.h \
/opt/MARTe/BaseLib2/Level2/FString.h