Revision 32

View differences:

logic/trunk/src/logics/conditions.h
1
#ifndef CONDITIONS_H_INCLUDED
2
#define CONDITIONS_H_INCLUDED
3

  
4
#include "../logics/operators.h"
5
#include "../init/devicelist.h"
6

  
7
typedef struct condition_list_leaf
8
{
9
    int                         OPERATOR_TYPE;
10
    int                         val;
11
    struct  condition_list_leaf *nxt;
12
    struct  device_d            *dev;
13
}cond_lst_leaf;
14

  
15
typedef struct condition_list
16
{
17
    int                         OPERATOR_TYPE;
18
    struct condition_list       *sub_lst;
19
    struct condition_list_leaf  *sub_leaf;
20
}cond_lst;
21

  
22
#endif // CONDITIONS_H_INCLUDED
logic/trunk/src/logics/operators.c
1
#include "operators.h"
2

  
3
int operator_AND(int a, int b)
4
{
5
    if(a && b)
6
        return 1;
7
    return 0;
8
}
9

  
10
int operator_NOT_AND(int a, int b)
11
{
12
//    if((!a  b) || )
13
        return 1;
14
    return 0;
15
}
16

  
17
int operator_OR(int a, int b)
18
{
19
    if(a || b)
20
        return 1;
21
    return 0;
22
}
23

  
24
int operator_XOR(int a, int b)
25
{
26
    if((a && !b) || (!a && b))
27
        return 1;
28
    return 0;
29
}
30

  
31
int operator_GREATER(int a, int b)
32
{
33
    if(a > b)
34
        return 1;
35
    return 0;
36
}
37

  
38
int operator_GREATER_OR_EQUAL (int a, int b)
39
{
40
    if(a >= b)
41
        return 1;
42
    return 0;
43
}
44

  
45
int operator_LESS(int a, int b)
46
{
47
    if(a < b)
48
        return 1;
49
    return 0;
50
}
51

  
52
int operator_LESS_OR_EQUAL(int a, int b)
53
{
54
    if(a <= b)
55
        return 1;
56
    return 0;
57
}
logic/trunk/src/logics/operators.h
1
#ifndef OPERATORS_H_INCLUDED
2
#define OPERATORS_H_INCLUDED
3

  
4
#define AND                 0
5
#define NOT_AND             1
6
#define OR                  2
7
#define XOR                 3
8
#define GREATER             4
9
#define GREATER_OR_EQUAL    5
10
#define LESS                6
11
#define LESS_OR_EQUAL       7
12

  
13
int operator_AND                (int a, int b);
14
int operator_NOT_AND            (int a, int b);
15
int operator_OR                 (int a, int b);
16
int operator_XOR                (int a, int b);
17
int operator_GREATER            (int a, int b);
18
int operator_GREATER_OR_EQUAL   (int a, int b);
19
int operator_LESS               (int a, int b);
20
int operator_LESS_OR_EQUAL      (int a, int b);
21

  
22
#endif // OPERATORS_H_INCLUDED

Also available in: Unified diff