Terminal.c 1.68 KB
/* Terminal struct source file. */

 

#include "Terminal.h"

#include "Msg.h"

#include <stdlib.h>

 

/*

Terminal_SendMessage is not visible to outside the Terminal.c file.

This is equivalent to a private method in C++.

*/

 

static void Terminal_SendMessage(Terminal *pTerm, Msg *pMsg)

{

    /*...*/

}

 

void Terminal_Construct(Terminal *pTerm)

{  

    pTerm->terminalId = UNKNOWN;

    pTerm->terminalType = UNKNOWN;

    pTerm->terminalStatus = UNKNOWN;

}

 

void Terminal_Destroy(Terminal *pTerm)

{

    /*...*/

}

 

int Terminal_HandleRunDiagnostics(Terminal *pTerm, const RunDiagnosticsMsg *pMsg)

{

    int status = 1;

    /*...*/

   return status;

}

 

int Terminal_HandleOutOfService(Terminal *pTerm)

{

    int status = 1;

    pTerm->terminalStatus = OUT_OF_SERVICE;

    /*...*/

    return status;

}

 

int Terminal_HandleInService(Terminal *pTerm)

{

   int status = 1;

   pTerm->terminalStatus = INSERVICE;

   /*...*/

   return status;

}

 

void Terminal_Activate(Terminal *pTerm, const TerminalCreateMsg *pMsg)

{

    TerminalCreateAck *pAck;

    pTerm->terminalId = pMsg->header.terminalId;

    pTerm->terminalType = pMsg->header.terminalType;

    pTerm->terminalStatus = pMsg->header.terminalStatus;

    /*...*/

 

    pAck = (TerminalCreateAck *)malloc(sizeof(TerminalCreateAck));

    pAck->header.terminalId = pTerm->terminalId;

    pAck->header.terminalStatus = pTerm->terminalStatus;

 

    Terminal_SendMessage(pTerm, (Msg *)pAck);

}

 

void Terminal_Deactivate(Terminal *pTerm, const TerminalDeleteMsg *pMsg)

{

    /*...*/

    pTerm->terminalId = UNKNOWN;

    pTerm->terminalType = UNKNOWN;

    pTerm->terminalStatus = UNKNOWN;

    /*...*/

}