File: PT.cc

package info (click to toggle)
eclipse-titan 8.2.0-1
  • links: PTS
  • area: main
  • in suites: bookworm, sid
  • size: 103,544 kB
  • sloc: cpp: 271,008; ansic: 33,683; yacc: 23,419; makefile: 15,483; lex: 9,204; java: 4,848; perl: 4,555; sh: 2,242; xml: 1,378; javascript: 85; awk: 48; php: 32; python: 13
file content (136 lines) | stat: -rw-r--r-- 2,911 bytes parent folder | download
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// This Test Port skeleton source file was generated by the
// TTCN-3 Compiler of the TTCN-3 Test Executor version CRL 113 200/6 R5B
// for ebotbar (ebotbar@ebotbarVB) on Mon Apr 29 13:25:58 2019

// Copyright (c) 2000-2021 Ericsson Telecom AB

// You may modify this file. Complete the body of empty functions and
// add your member functions here.

#include "PT.hh"

namespace map__param__common {

PT::PT(const char *par_port_name)
	: PT_BASE(par_port_name)
{

}

PT::~PT()
{

}

void PT::set_parameter(const char * /*parameter_name*/,
	const char * /*parameter_value*/)
{

}

/*void PT::Handle_Fd_Event(int fd, boolean is_readable,
	boolean is_writable, boolean is_error) {}*/

void PT::Handle_Fd_Event_Error(int /*fd*/)
{

}

void PT::Handle_Fd_Event_Writable(int /*fd*/)
{

}

void PT::Handle_Fd_Event_Readable(int /*fd*/)
{

}

/*void PT::Handle_Timeout(double time_since_last_call) {}*/

void PT::user_map(const char * /*system_port*/, Map_Params& params)
{
  if (params.get_nof_params() != 0) {
    CHARSTRING p1_str = params.get_param(0);
    if (p1_str.lengthof() > 0) {
      // OK
      OCTETSTRING p1;
      string_to_ttcn(params.get_param(0), p1);
      // check the value
      if (p1 != P1__INITIAL) {
        char* reason = mprintf("Initial value of parameter p1 is incorrect: %s", (const char*) p1_str);
        TTCN_Runtime::setverdict(FAIL, reason);
        Free(reason);
      }
    }
    else {
      // not OK
      TTCN_Runtime::setverdict(FAIL, "Parameter p1 is unset");
    }
    
    CHARSTRING p2_str = params.get_param(1);
    if (p2_str.lengthof() == 0) {
      // OK
      // now set the output value
      params.set_param(1, ttcn_to_string(P2__FINAL));
    }
    else {
      // not OK
      char* reason = mprintf("Parameter p2 is set: %s", (const char*) p2_str);
      TTCN_Runtime::setverdict(FAIL, reason);
      Free(reason);
    }
    CT_component_map__param = TRUE;
  }
  else {
    CT_component_map__empty = TRUE;
  }
}

void PT::user_unmap(const char * /*system_port*/, Map_Params& params)
{
  if (params.get_nof_params() != 0) {
    CHARSTRING p_str = params.get_param(0);
    if (p_str.lengthof() > 0) {
      // OK
      INTEGER p;
      string_to_ttcn(params.get_param(0), p);
      // check the input value
      if (p != P__INITIAL) {
        char* reason = mprintf("Initial value of parameter p is incorrect: %s", (const char*) p_str);
        TTCN_Runtime::setverdict(FAIL, reason);
        Free(reason);
      }
      else {
        // set the output value
        params.set_param(0, ttcn_to_string(P__FINAL));
      }
    }
    else {
      // not OK
      TTCN_Runtime::setverdict(FAIL, "Parameter p is unset");
    }
    CT_component_unmap__param = TRUE;
  }
  else {
    CT_component_unmap__empty = TRUE;
  }
}

void PT::user_start()
{

}

void PT::user_stop()
{

}

void PT::outgoing_send(const CHARSTRING& /*send_par*/)
{

}

} /* end of namespace */