summaryrefslogtreecommitdiffstats
path: root/Src/ScriptXml.h
blob: 093c4aea8dfae3e18d16224406caac6b0abcc7a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * Video On Demand Samples
 *
 * Copyright (C) 2015 Microchip Technology Germany II GmbH & Co. KG
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * You may also obtain this software under a propriety license from Microchip.
 * Please contact Microchip for further information.
 *
 */

/*----------------------------------------------------------*/
/*! \file
 *  \brief  This file contains the CSciptXml class.
 */
/*----------------------------------------------------------*/
#ifndef _SCRIPTXML_H_
#define _SCRIPTXML_H_

#include <stdint.h>
#include <stdbool.h>
#include <Types.h>
#include "Xml.h"

#define MAX_SCRIPT_NAME_LENGTH   64
#define MAX_PAYLOAD_LENGTH       64

typedef enum ScriptType_tag
{
    SCRIPT_UNKNOWN,
    SCRIPT_MCM_SEND,
    SCRIPT_PAUSE
} ScriptType_t;

/*----------------------------------------------------------*/
/*!
 * \brief Storage class to store the scripting informations. This class will be returned by
 *        the CSciptXml class.
 */
/*----------------------------------------------------------*/
class CScript
{
public:
    ScriptType_t scriptType;
    char scriptName[MAX_SCRIPT_NAME_LENGTH];
    uint8_t fblockId;
    uint16_t functionId;
    uint8_t opTypeRequest;
    uint8_t opTypeResponse;
    uint8_t payload[MAX_PAYLOAD_LENGTH];
    uint32_t payloadLength;
    uint32_t pauseInMillis;

    CScript() : scriptType( SCRIPT_UNKNOWN ), fblockId( 0xFF ), functionId( 0xFFFF ), opTypeRequest( 0xFF ),
                opTypeResponse( 0xFF ), payloadLength( 0 ), pauseInMillis( 0 )
    {
        scriptName[0] = '\0';
    }
};

/*----------------------------------------------------------*/
/*!
 *  \brief Class to read XML for the NetworkManager scripting use case.
 */
/*----------------------------------------------------------*/
class CSciptXml : public CXml
{
private:
    void StorePayload( xmlChar *xString, CScript *script );
public:
    CSciptXml( const char *szFile );
    CSciptXml( const char *szBuffer, uint32_t nBufferLen );
    bool GetScripts( CSafeVector<CScript *> &allChannels );
};

#endif //_SCRIPTXML_H_