1553.c 6.19 KB
Newer Older
1
#if (defined (__PO_HI_NEED_DRIVER_1553_RASTA))\n
2
3
4
/*
Code automatically generated by asn1scc tool
*/
yoogx's avatar
yoogx committed
5
#include <limits.h>
6
7
8
9
#include <string.h>
#include <math.h>
#include "1553.h"

10
11
12
13
14
15
16
17
18



flag __po_hi_c_Node_Addr_T_Equal(const __po_hi_c_Node_Addr_T* pVal1, const __po_hi_c_Node_Addr_T* pVal2)
{
	return (*(pVal1)) == (*(pVal2));

}

19
20
void __po_hi_c_Node_Addr_T_Initialize(__po_hi_c_Node_Addr_T* pVal)
{
21
22

	(*(pVal)) = 0;
23
24
}

yoogx's avatar
yoogx committed
25
flag __po_hi_c_Node_Addr_T_IsConstraintValid(const __po_hi_c_Node_Addr_T* pVal, int* pErrCode)
26
{
yoogx's avatar
yoogx committed
27
    flag ret = TRUE;
28
29
30
	
    ret = ((*(pVal)) <= 31UL);
    *pErrCode = ret ? 0 :  ERR_NODE_ADDR_T;
31

32
33
	return ret;
}
34
35


36
37
38
39
40

flag __po_hi_c_Standard_T_Equal(const __po_hi_c_Standard_T* pVal1, const __po_hi_c_Standard_T* pVal2)
{
	return (*(pVal1)) == (*(pVal2));

yoogx's avatar
yoogx committed
41
}
42

43
44
void __po_hi_c_Standard_T_Initialize(__po_hi_c_Standard_T* pVal)
{
45
46

	(*(pVal)) = __po_hi_c_mil1553a;
47
48
}

yoogx's avatar
yoogx committed
49
flag __po_hi_c_Standard_T_IsConstraintValid(const __po_hi_c_Standard_T* pVal, int* pErrCode)
50
{
yoogx's avatar
yoogx committed
51
    flag ret = TRUE;
52
53
54
	
    ret = ((((*(pVal)) == __po_hi_c_mil1553a)) || (((*(pVal)) == __po_hi_c_mil1553b)));
    *pErrCode = ret ? 0 :  ERR_STANDARD_T;
55

56
57
	return ret;
}
58
59


60
61
62
63
64

flag __po_hi_c_Mode_T_Equal(const __po_hi_c_Mode_T* pVal1, const __po_hi_c_Mode_T* pVal2)
{
	return (*(pVal1)) == (*(pVal2));

yoogx's avatar
yoogx committed
65
}
66

67
68
void __po_hi_c_Mode_T_Initialize(__po_hi_c_Mode_T* pVal)
{
69
70

	(*(pVal)) = __po_hi_c_controller;
71
72
}

yoogx's avatar
yoogx committed
73
flag __po_hi_c_Mode_T_IsConstraintValid(const __po_hi_c_Mode_T* pVal, int* pErrCode)
74
{
yoogx's avatar
yoogx committed
75
    flag ret = TRUE;
76
77
78
	
    ret = ((((((*(pVal)) == __po_hi_c_controller)) || (((*(pVal)) == __po_hi_c_terminal)))) || (((*(pVal)) == __po_hi_c_monitor)));
    *pErrCode = ret ? 0 :  ERR_MODE_T;
79

80
81
	return ret;
}
82
83


84
85
86
87
88

flag __po_hi_c_Bus_T_Equal(const __po_hi_c_Bus_T* pVal1, const __po_hi_c_Bus_T* pVal2)
{
	return (*(pVal1)) == (*(pVal2));

yoogx's avatar
yoogx committed
89
}
90

91
92
void __po_hi_c_Bus_T_Initialize(__po_hi_c_Bus_T* pVal)
{
93
94

	(*(pVal)) = __po_hi_c_none;
95
}
yoogx's avatar
yoogx committed
96
97
98
99

flag __po_hi_c_Bus_T_IsConstraintValid(const __po_hi_c_Bus_T* pVal, int* pErrCode)
{
    flag ret = TRUE;
100
101
102
	
    ret = ((((((((*(pVal)) == __po_hi_c_none)) || (((*(pVal)) == __po_hi_c_bus_a)))) || (((*(pVal)) == __po_hi_c_bus_b)))) || (((*(pVal)) == __po_hi_c_both)));
    *pErrCode = ret ? 0 :  ERR_BUS_T;
yoogx's avatar
yoogx committed
103
104
105

	return ret;
}
106
107
108
109



flag __po_hi_c_mil_1553_conf_t_devname_Equal(const __po_hi_c_mil_1553_conf_t_devname val1, const __po_hi_c_mil_1553_conf_t_devname val2)
110
{
111
112
	return strcmp(val1, val2) == 0;

113
114
}

115
flag __po_hi_c_mil_1553_conf_t_Equal(const __po_hi_c_mil_1553_conf_t* pVal1, const __po_hi_c_mil_1553_conf_t* pVal2)
yoogx's avatar
yoogx committed
116
{
117
118
119
120
121
122
123
124
125
	flag ret=TRUE;

    ret = __po_hi_c_mil_1553_conf_t_devname_Equal(pVal1->devname, pVal2->devname);

    if (ret) {
        ret = (pVal1->standard == pVal2->standard);

        if (ret) {
            ret = (pVal1->mode == pVal2->mode);
126

127
128
            if (ret) {
                ret = (pVal1->bus == pVal2->bus);
129

130
131
                if (ret) {
                    ret = (pVal1->termaddr == pVal2->termaddr);
132

133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
                    if (ret) {
                        ret = (pVal1->broadcast == pVal2->broadcast);

                        if (ret) {
                            ret = (pVal1->exist.rxblock == pVal2->exist.rxblock);
                            if (ret && pVal1->exist.rxblock) {
                            	ret = (pVal1->rxblock == pVal2->rxblock);
                            }

                            if (ret) {
                                ret = (pVal1->exist.txblock == pVal2->exist.txblock);
                                if (ret && pVal1->exist.txblock) {
                                	ret = (pVal1->txblock == pVal2->txblock);
                                }

                            }
                        }
                    }
                }
            }
        }
    }
yoogx's avatar
yoogx committed
155
	return ret;
156
157
158
159
160
161
162
163

}

void __po_hi_c_mil_1553_conf_t_devname_Initialize(__po_hi_c_mil_1553_conf_t_devname val)
{

	memset(val, 0x0, 21);

yoogx's avatar
yoogx committed
164
}
165
166
void __po_hi_c_mil_1553_conf_t_Initialize(__po_hi_c_mil_1553_conf_t* pVal)
{
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186


	/*set devname */
	__po_hi_c_mil_1553_conf_t_devname_Initialize(pVal->devname);
	/*set standard */
	__po_hi_c_Standard_T_Initialize((&(pVal->standard)));
	/*set mode */
	__po_hi_c_Mode_T_Initialize((&(pVal->mode)));
	/*set bus */
	__po_hi_c_Bus_T_Initialize((&(pVal->bus)));
	/*set termaddr */
	__po_hi_c_Node_Addr_T_Initialize((&(pVal->termaddr)));
	/*set broadcast */
	pVal->broadcast = FALSE;
	/*set rxblock */
	pVal->exist.rxblock = 1;
	pVal->rxblock = FALSE;
	/*set txblock */
	pVal->exist.txblock = 1;
	pVal->txblock = FALSE;
187
188
}

189
flag __po_hi_c_mil_1553_conf_t_IsConstraintValid(const __po_hi_c_mil_1553_conf_t *pVal, int* pErrCode)
190
{
yoogx's avatar
yoogx committed
191
    flag ret = TRUE;
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
	
    ret = ((1 <= strlen(pVal->devname)) && (strlen(pVal->devname) <= 20));
    *pErrCode = ret ? 0 :  ERR_MIL_1553_CONF_T_DEVNAME;
    if (ret) {
        ret = (((pVal->standard == __po_hi_c_mil1553a)) || ((pVal->standard == __po_hi_c_mil1553b)));
        *pErrCode = ret ? 0 :  ERR_MIL_1553_CONF_T_STANDARD;
        if (ret) {
            ret = (((((pVal->mode == __po_hi_c_controller)) || ((pVal->mode == __po_hi_c_terminal)))) || ((pVal->mode == __po_hi_c_monitor)));
            *pErrCode = ret ? 0 :  ERR_MIL_1553_CONF_T_MODE;
            if (ret) {
                ret = (((((((pVal->bus == __po_hi_c_none)) || ((pVal->bus == __po_hi_c_bus_a)))) || ((pVal->bus == __po_hi_c_bus_b)))) || ((pVal->bus == __po_hi_c_both)));
                *pErrCode = ret ? 0 :  ERR_MIL_1553_CONF_T_BUS;
                if (ret) {
                    ret = (pVal->termaddr <= 31UL);
                    *pErrCode = ret ? 0 :  ERR_MIL_1553_CONF_T_TERMADDR;
                    if (ret) {
                        ret = TRUE;
                        *pErrCode = ret ? 0 :  ERR_MIL_1553_CONF_T_BROADCAST;
                        if (ret) {
                            if (pVal->exist.rxblock) {
                            	ret = TRUE;
                            	*pErrCode = ret ? 0 :  ERR_MIL_1553_CONF_T_RXBLOCK;
                            }
                            if (ret) {
                                if (pVal->exist.txblock) {
                                	ret = TRUE;
                                	*pErrCode = ret ? 0 :  ERR_MIL_1553_CONF_T_TXBLOCK;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
227

yoogx's avatar
yoogx committed
228
	return ret;
229
230
}

231
\n#endif