CORDET Framework - C2 Implementation
CrDemoSlave1/CrDaTempMonitor.c
Go to the documentation of this file.
1 
19 #include <stdio.h>
20 #include "CrDaServerSocket.h"
21 #include "CrDaConstants.h"
23 /* Include FW Profile files */
24 #include "FwSmConstants.h"
25 #include "FwSmConfig.h"
26 #include "FwSmCore.h"
27 #include "FwPrConfig.h"
28 #include "FwPrCore.h"
29 #include "FwPrConstants.h"
30 /* Include configuration files */
31 #include "CrFwOutStreamUserPar.h"
32 #include "CrFwCmpData.h"
33 /* Include framework files */
37 #include "BaseCmp/CrFwBaseCmp.h"
38 #include "Pckt/CrFwPckt.h"
39 #include "CrFwTime.h"
40 #include "CrFwRepErr.h"
42 /* Include file for socket implementation */
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <unistd.h>
46 #include <string.h>
47 #include <sys/types.h>
48 #include <sys/socket.h>
49 #include <netinet/in.h>
50 #include <netdb.h>
51 #include <fcntl.h>
52 #include <errno.h>
53 #include <pthread.h>
54 
56 static int tempLimit = 0;
57 
60 
61 /* ---------------------------------------------------------------------- */
62 void CrDaTempMonitoringEnable(FwSmDesc_t smDesc) {
64 }
65 
66 /* ---------------------------------------------------------------------- */
67 void CrDaTempMonitoringDisable(FwSmDesc_t smDesc) {
69 }
70 
71 /* ---------------------------------------------------------------------- */
72 void CrDaTempMonitoringSetTempLimit(FwSmDesc_t smDesc) {
73  char* pcktPar = CrFwInCmdGetParStart(smDesc);
74  tempLimit = pcktPar[0];
75 }
76 
77 /* ---------------------------------------------------------------------- */
78 void CrDaTempMonitoringExec(char temp, CrFwDestSrc_t appId) {
79  FwSmDesc_t rep;
80  if (isTempMonitoringEnabled == 1) {
81  if (temp > tempLimit) {
82  if (appId == CR_DA_SLAVE_1)
83  printf("S1: Temperature violation detected -- Sending report to Master Application\n");
84  else
85  printf("S2: Temperature violation detected -- Sending report to Master Application\n");
86  /* Create outReport reporting temperature violation */
90  /* Request outReport to be sent out */
91  CrFwOutLoaderLoad(rep);
92  }
93  }
94  return;
95 }
#define CR_DA_MASTER
The identifier of the Master Application of the CORDET Demo.
Interface through which framework components access the current time.
OutComponent encapsulating a report generated by a Slave Application when a temperature violation has...
#define CR_DA_SERV_SUBTYPE_REP
The identifier of the service sub-type to report a temperature violation.
void CrDaOutCmpTempViolationSetTemp(char temp)
Set the value of the limit violating temperature (an integer in the range 0 to 255).
static int tempLimit
The temperature limit.
Definition of the OutStream component.
Definition of the OutFactory component.
unsigned char CrFwDestSrc_t
Type used for the command or report destination and source.
#define CR_DA_SERV_TYPE
The identifier of the service type supported by the demo application.
Interface for creating and accessing a report or command packet.
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
Definition: CrFwConstants.h:32
void CrDaTempMonitoringDisable(FwSmDesc_t smDesc)
Disable temperature monitoring.
Interface for reporting an error detected by a framework component.
void CrDaTempMonitoringExec(char temp, CrFwDestSrc_t appId)
Execute a temperature monitoring action on the argument temperature.
static CrFwBool_t isTempMonitoringEnabled
The enable status of temperature monitoring.
void CrDaTempMonitoringEnable(FwSmDesc_t smDesc)
Enable temperature monitoring.
Definition of the utility functions for the CORDET Framework.
#define CR_DA_SLAVE_1
The identifier of the first Slave Application of the CORDET Demo.
Definition of Base Component.
Interface for the server socket used in the CORDET Demo.
Header file to define constants and types for the CORDET Demo.
void CrFwOutCmpSetDest(FwSmDesc_t smDesc, CrFwDestSrc_t dest)
Set the destination of the OutComponent.
Definition: CrFwOutCmp.c:192
CrFwBool_t CrFwOutLoaderLoad(FwSmDesc_t outCmp)
Load an OutComponent into its OutManager.
void CrDaTempMonitoringSetTempLimit(FwSmDesc_t smDesc)
Set the limit against the temperature is monitored.
Definition of the OutLoader component.
FwSmDesc_t CrFwOutFactoryMakeOutCmp(CrFwServType_t type, CrFwServSubType_t subType, CrFwDiscriminant_t discriminant, CrFwPcktLength_t length)
Make function for an OutComponent.
CrFwPckt_t CrFwInCmdGetParStart(FwSmDesc_t smDesc)
Return the start address of the parameter area of the InCommand.
Definition: CrFwInCmd.c:395
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved