TTEthernet Model for INET Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
TTEthernetModel::TTEAPIApplicationBase Class Reference

Base class for a TTEthernet-Application based on the TTEthernet-API. More...

#include <TTEAPIApplicationBase.h>

Inheritance diagram for TTEthernetModel::TTEAPIApplicationBase:
TTEthernetModel::TTEApplicationBase TTEthernetModel::TTEAPITestApplication

Public Member Functions

virtual void registerTask (unsigned int actionTime, void(*functionPointer)(void *), void *setFunctionArg)
 registers a task that is periodically scheduled. More...
 
virtual int32_t tte_get_ct_output_buf (const uint8_t ctrl_id, const uint16_t ct_id, tte_buffer_t *const buf)
 implementation of the TTEthernet-API method. More...
 
virtual int32_t tte_get_bg_output_buf (const uint8_t ctrl_id, const uint8_t channel, tte_buffer_t *const buf)
 implementation of the TTEthernet-API method. More...
 
virtual int32_t tte_get_bg_input_buf (const uint8_t ctrl_id, const uint8_t channel, tte_buffer_t *const buf)
 implementation of the TTEthernet-API method. More...
 
virtual int32_t tte_get_ct_input_buf (const uint8_t ctrl_id, const uint16_t ct_id, tte_buffer_t *const buf)
 implementation of the TTEthernet-API method. More...
 
virtual int32_t tte_get_var (const uint8_t ctrl_id, const tte_var_id_t var_id, const uint32_t var_size, void *const value)
 implementation of the TTEthernet-API method. More...
 
virtual int32_t tte_open_output_buf (tte_buffer_t *const buf, tte_frame_t *const frame)
 implementation of the TTEthernet-API method. More...
 
virtual int32_t tte_open_input_buf (tte_buffer_t *const buf, tte_frame_t *const frame, tte_buf_status_t *const status)
 implementation of the TTEthernet-API method. More...
 
virtual int32_t tte_close_output_buf (tte_buffer_t *const buf)
 implementation of the TTEthernet-API method. More...
 
virtual int32_t tte_close_input_buf (tte_buffer_t *const buf)
 implementation of the TTEthernet-API method. More...
 
virtual int32_t tte_set_buf_var (tte_buffer_t *const buf, const tte_buf_var_id_t var_id, const uint32_t var_size, const void *const value)
 implementation of the TTEthernet-API method. More...
 
virtual int32_t tte_get_buf_var (const tte_buffer_t *const buf, const tte_buf_var_id_t var_id, const uint32_t var_size, void *const value)
 implementation of the TTEthernet-API method. More...
 
- Public Member Functions inherited from TTEthernetModel::TTEApplicationBase
virtual void executeCallback (Callback *cb)
 executes the given Callback in the context of the Application More...
 
virtual void handleParameterChange (const char *parname)
 Indicates a parameter has changed. More...
 

Protected Member Functions

virtual void startApplication ()
 Does nothing in this application. More...
 

Private Member Functions

virtual void initialize ()
 initializes the module. More...
 
virtual void handleMessage (cMessage *msg)
 Handles incoming START_APPLICATION or Scheduler messages. More...
 

Private Attributes

bool synchronized
 

Additional Inherited Members

- Protected Attributes inherited from TTEthernetModel::TTEApplicationBase
std::map< uint16_t, std::list
< Buffer * > > 
buffers
 Map of critical traffic identifies with their corresponding Buffers. More...
 

Detailed Description

Base class for a TTEthernet-Application based on the TTEthernet-API.

The class contains the wrappers for the C to C++ Mapping.

Warning
Please note that the TTEthernet-API functionality is not yet completely implemented
See Also
TTEAPITestApplication, TTEApplicationBase

Definition at line 71 of file TTEAPIApplicationBase.h.

Member Function Documentation

void TTEthernetModel::TTEAPIApplicationBase::handleMessage ( cMessage *  msg)
privatevirtual

Handles incoming START_APPLICATION or Scheduler messages.

The module receives START_APPLICATION messages that trigger startApplication() or messages via schedulerIn that contain Tasks to be executed.

Parameters
msgthe incoming message

Definition at line 42 of file TTEAPIApplicationBase.cc.

43 {
44  if(msg->isSelfMessage() && msg->getKind() == START_APPLICATION){
46  delete msg;
47  }
48  if(msg->arrivedOn("schedulerIn")){
49  Task *task = (Task*)msg->par("task").pointerValue();
50  task->executeTask();
51  //Reregister scheduler
52  TTEScheduler *tteScheduler = (TTEScheduler*) getParentModule()->getSubmodule("tteScheduler");
53  tteScheduler->registerEvent((SchedulerEvent *) msg);
54  }
55  if(msg->arrivedOn("syncIn")){
56  SyncNotification *notification = (SyncNotification*)msg;
57  if(notification->getKind()==SYNC){
58  synchronized=true;
59  }
60  else{
61  synchronized=false;
62  }
63  }
64 }
void TTEthernetModel::TTEAPIApplicationBase::initialize ( )
privatevirtual

initializes the module.

Registeres a START_APPLICATION self-message that triggers the application start

Definition at line 37 of file TTEAPIApplicationBase.cc.

38 {
39  scheduleAt(simTime(), new cMessage("Start Application", START_APPLICATION));
40 }
void TTEthernetModel::TTEAPIApplicationBase::registerTask ( unsigned int  actionTime,
void(*)(void *)  functionPointer,
void *  setFunctionArg 
)
virtual

registers a task that is periodically scheduled.

Parameters
actionTimethe time in ticks in each cycle the tasks is executed
functionPointerthe function to execute

Definition at line 71 of file TTEAPIApplicationBase.cc.

71  {
72  Task *task = new Task();
73  task->setFunctionPointer(functionPointer);
74  task->setFunctionArg(setFunctionArg);
75 
76  //Register Event
77  TTEScheduler *tteScheduler = (TTEScheduler*) getParentModule()->getSubmodule("tteScheduler");
78  SchedulerActionTimeEvent *event = new SchedulerActionTimeEvent("API Scheduler Task Event", ACTION_TIME_EVENT);
79 
80  event->addPar("task").setPointerValue(task);
81 
82  event->setAction_time(actionTime);
83  event->setDestinationGate(gate("schedulerIn"));
84  tteScheduler->registerEvent(event);
85 }
void TTEthernetModel::TTEAPIApplicationBase::startApplication ( )
protectedvirtual

Does nothing in this application.

Must be overwritten with actual application behavior.

Reimplemented in TTEthernetModel::TTEAPITestApplication.

Definition at line 66 of file TTEAPIApplicationBase.cc.

Referenced by handleMessage().

66  {
67  ev << "TTEAPIApplicationBase::startApplication() not implemented" << endl;
68  throw;
69 }
int32_t TTEthernetModel::TTEAPIApplicationBase::tte_close_input_buf ( tte_buffer_t *const  buf)
virtual

implementation of the TTEthernet-API method.

see TTEthernet-API documentation for further information

Definition at line 408 of file TTEAPIApplicationBase.cc.

Referenced by TTEthernetModel::tte_close_input_buf().

408  {
409  Enter_Method_Silent();
410  TTEAPIPriv *priv = (TTEAPIPriv *)buf->priv;
411  //Free memory
412  if(priv->data){
413  //free(priv->data);
414  priv->data = NULL;
415  }
416  if(priv){
417  delete priv;
418  buf->priv=NULL;
419  }
420  return ETT_SUCCESS;
421 }
int32_t TTEthernetModel::TTEAPIApplicationBase::tte_close_output_buf ( tte_buffer_t *const  buf)
virtual

implementation of the TTEthernet-API method.

see TTEthernet-API documentation for further information

Definition at line 380 of file TTEAPIApplicationBase.cc.

Referenced by TTEthernetModel::tte_close_output_buf().

380  {
381  Enter_Method_Silent();
382  TTEAPIPriv *priv = (TTEAPIPriv *)buf->priv;
383  //Copy frame data and free memory
384  APIPayload *payload = (APIPayload*)priv->frame->getEncapsulatedPacket();
385  for(unsigned int i=0;i<payload->getDataArraySize();i++){
386  payload->setData(i, ((unsigned char *)priv->data)[i]);
387  }
388  //Send to CTC
389  if(priv->buffer)
390  if(priv->buffer->gate("in"))
391  if(priv->buffer->gate("in")->getPathStartGate())
392  if((cModule *)priv->buffer->gate("in")->getPathStartGate()->getOwner())
393  if(((cModule *)priv->buffer->gate("in")->getPathStartGate()->getOwner())->gate("in")){
394  sendDirect(priv->frame, ((cModule *)priv->buffer->gate("in")->getPathStartGate()->getOwner())->gate("in"));
395  }
396 
397  if(priv->data){
398  free(priv->data);
399  priv->data = NULL;
400  }
401  if(priv){
402  delete priv;
403  buf->priv=NULL;
404  }
405  return ETT_SUCCESS;
406 }
int32_t TTEthernetModel::TTEAPIApplicationBase::tte_get_bg_input_buf ( const uint8_t  ctrl_id,
const uint8_t  channel,
tte_buffer_t *const  buf 
)
virtual

implementation of the TTEthernet-API method.

see TTEthernet-API documentation for further information

Definition at line 144 of file TTEAPIApplicationBase.cc.

Referenced by TTEthernetModel::tte_get_bg_input_buf().

145  {
146  Enter_Method_Silent();
147  Buffer *buffer = dynamic_cast<Buffer*>(getParentModule()->getSubmodule("bgIn"));
148 
149  buf->ctrl_id=0;
150  buf->direction= TTE_DIR_INPUT;
151  buf->traffic_type= TTE_BG_TRAFFIC;
152 
153  buf->channel=0;
154  buf->shared=1;
155 
156  TTEAPIPriv *priv = new TTEAPIPriv();
157  priv->buffer = buffer;
158 
159  buf->priv=priv;
160  return ETT_SUCCESS;
161 }
int32_t TTEthernetModel::TTEAPIApplicationBase::tte_get_bg_output_buf ( const uint8_t  ctrl_id,
const uint8_t  channel,
tte_buffer_t *const  buf 
)
virtual

implementation of the TTEthernet-API method.

see TTEthernet-API documentation for further information

Definition at line 125 of file TTEAPIApplicationBase.cc.

Referenced by TTEthernetModel::tte_get_bg_output_buf().

126  {
127  Enter_Method_Silent();
128  Buffer *buffer = dynamic_cast<Buffer*>(getParentModule()->getSubmodule("bgOut"));
129 
130  buf->ctrl_id=0;
131  buf->direction= TTE_DIR_OUTPUT;
132  buf->traffic_type= TTE_BG_TRAFFIC;
133 
134  buf->channel=0;
135  buf->shared=1;
136 
137  TTEAPIPriv *priv = new TTEAPIPriv();
138  priv->buffer = buffer;
139 
140  buf->priv=priv;
141  return ETT_SUCCESS;
142 }
int32_t TTEthernetModel::TTEAPIApplicationBase::tte_get_buf_var ( const tte_buffer_t *const  buf,
const tte_buf_var_id_t  var_id,
const uint32_t  var_size,
void *const  value 
)
virtual

implementation of the TTEthernet-API method.

see TTEthernet-API documentation for further information

Definition at line 468 of file TTEAPIApplicationBase.cc.

Referenced by TTEthernetModel::tte_get_buf_var().

471  {
472  Enter_Method_Silent();
473  TTEAPIPriv *priv = (TTEAPIPriv*)buf->priv;
474  switch(var_id){
475  case TTE_BUFVAR_RECEIVE_CB:{
476  APICallback *cb = dynamic_cast<APICallback*>(priv->buffer->getReceiveCallback(this));
477  if(cb == NULL){
478  return ETT_NULLPTR;
479  }
480  void (*func)(void *) = cb->getFunctionPointer();
481  memcpy(value, &func, sizeof(void (*)(void *)));
482  break;
483  }
484  case TTE_BUFVAR_TRANSMIT_CB:{
485  APICallback *cb = dynamic_cast<APICallback*>(priv->buffer->getTransmitCallback(this));
486  if(cb == NULL){
487  return ETT_NULLPTR;
488  }
489  void (*func)(void *) = cb->getFunctionPointer();
490  memcpy(value, &func, sizeof(void (*)(void *)));
491  break;
492  }
493  case TTE_BUFVAR_CB_ARG:{
494  APICallback *cb = dynamic_cast<APICallback*>(priv->buffer->getReceiveCallback(this));
495  if(cb == NULL){
496  APICallback *cb = dynamic_cast<APICallback*>(priv->buffer->getTransmitCallback(this));
497  if(cb == NULL){
498  return ETT_NULLPTR;
499  }
500  void * arg=cb->getFunctionArg();
501  memcpy(value, &arg, sizeof(void *));
502  }
503  else{
504  void * arg=cb->getFunctionArg();
505  memcpy(value, &arg, sizeof(void *));
506  }
507  break;
508  }
509  default:
510  return ETT_NOTSUPPORTED;
511  }
512  return ETT_SUCCESS;
513 }
int32_t TTEthernetModel::TTEAPIApplicationBase::tte_get_ct_input_buf ( const uint8_t  ctrl_id,
const uint16_t  ct_id,
tte_buffer_t *const  buf 
)
virtual

implementation of the TTEthernet-API method.

see TTEthernet-API documentation for further information

Definition at line 163 of file TTEAPIApplicationBase.cc.

Referenced by TTEthernetModel::tte_get_ct_input_buf().

165  {
166  Enter_Method_Silent();
167  std::map<uint16, std::list<Buffer *> >::iterator bufferList = buffers.find(ct_id);
168  if (bufferList != buffers.end())
169  {
170  //Currently we use only the first entry!
171  std::list<Buffer*>::iterator buffer = bufferList->second.begin();
172 
173  buf->ctrl_id=0;
174  buf->direction= TTE_DIR_INPUT;
175  if(dynamic_cast<TTBuffer*>(*buffer) != NULL){
176  buf->traffic_type= TTE_TT_TRAFFIC;
177  }
178  else if(dynamic_cast<RCBuffer*>(*buffer) != NULL){
179  buf->traffic_type= TTE_CT_TRAFFIC;
180  }
181  else{
182  buf->traffic_type= TTE_BG_TRAFFIC;
183  }
184  buf->channel=0;
185  buf->ct_id=ct_id;
186  buf->shared=0;
187 
188  TTEAPIPriv *priv = new TTEAPIPriv();
189  priv->buffer = (*buffer);
190 
191  buf->priv=priv;
192  return ETT_SUCCESS;
193 
194  }
195  else
196  {
197  return ETT_INVMSGID;
198  }
199 }
int32_t TTEthernetModel::TTEAPIApplicationBase::tte_get_ct_output_buf ( const uint8_t  ctrl_id,
const uint16_t  ct_id,
tte_buffer_t *const  buf 
)
virtual

implementation of the TTEthernet-API method.

see TTEthernet-API documentation for further information

Definition at line 87 of file TTEAPIApplicationBase.cc.

Referenced by TTEthernetModel::tte_get_ct_output_buf().

89  {
90  Enter_Method_Silent();
91  std::map<uint16, std::list<Buffer *> >::iterator bufferList = buffers.find(ct_id);
92  if (bufferList != buffers.end())
93  {
94  //Currently we use only the first entry!
95  std::list<Buffer*>::iterator buffer = bufferList->second.begin();
96 
97  buf->ctrl_id=0;
98  buf->direction= TTE_DIR_OUTPUT;
99  if(dynamic_cast<TTBuffer*>(*buffer) != NULL){
100  buf->traffic_type= TTE_TT_TRAFFIC;
101  }
102  else if(dynamic_cast<RCBuffer*>(*buffer) != NULL){
103  buf->traffic_type= TTE_CT_TRAFFIC;
104  }
105  else{
106  buf->traffic_type= TTE_BG_TRAFFIC;
107  }
108  buf->channel=0;
109  buf->ct_id=ct_id;
110  buf->shared=0;
111 
112  TTEAPIPriv *priv = new TTEAPIPriv();
113  priv->buffer = (*buffer);
114 
115  buf->priv=priv;
116  return ETT_SUCCESS;
117 
118  }
119  else
120  {
121  return ETT_INVMSGID;
122  }
123 }
int32_t TTEthernetModel::TTEAPIApplicationBase::tte_get_var ( const uint8_t  ctrl_id,
const tte_var_id_t  var_id,
const uint32_t  var_size,
void *const  value 
)
virtual

implementation of the TTEthernet-API method.

see TTEthernet-API documentation for further information

Definition at line 201 of file TTEAPIApplicationBase.cc.

Referenced by TTEthernetModel::tte_get_var().

204  {
205  Enter_Method_Silent();
206  switch(var_id){
207  case TTE_VAR_LINK_STATUS:{
208  cModule *phy = getParentModule()->getSubmodule("phy", 0);
209  if(phy){
210  for(int i=0;i<phy->getVectorSize();i++){
211  EtherMACFullDuplex *mac = (EtherMACFullDuplex*)getParentModule()->getSubmodule("phy", i)->getSubmodule("mac");
212  if(mac->gate("phys")->isConnected())
213  *((uint8_t*)value) = *((uint8_t*)value)<<1 | 1;
214  else
215  *((uint8_t*)value) = *((uint8_t*)value)<<1;
216  }
217  }
218  else{
219  *((uint8_t*)value) = 0;
220  return ETT_NULLPTR;
221  }
222  break;
223  }
224  case TTE_VAR_CTRL_STATUS:{
225  *((uint32_t*)value) = TTE_STAT_CONFIGURED | TTE_STAT_RUNNING;
226  if(synchronized){
227  *((uint32_t*)value) |= TTE_STAT_SYNCHRONIZED;
228  }
229  break;
230  }
231  case TTE_VAR_CTRL_COUNT:{
232  *((uint8_t*)value) = 1;
233  break;
234  }
235  case TTE_VAR_CHANNEL_COUNT:{
236  cModule *phy = getParentModule()->getSubmodule("phy", 0);
237  if(phy){
238  *((uint8_t*)value) = phy->getVectorSize();
239  }
240  else{
241  *((uint8_t*)value) = 0;
242  return ETT_NULLPTR;
243  }
244  break;
245  }
246  case TTE_VAR_TIME_RESOLUTION:{
247  cModule *scheduler = getParentModule()->getSubmodule("tteScheduler", -1);
248  if(scheduler){
249  *((tte_time_t*)value) = scheduler->par("tick").doubleValue();
250  }
251  else{
252  *((tte_time_t*)value) = 0;
253  return ETT_NULLPTR;
254  }
255  break;
256  }
257  case TTE_VAR_API_VERSION:{
258  *((uint32_t*)value) = TTE_API_VER;
259  break;
260  }
261  case TTE_VAR_THREAD_SAFE:{
262  //TODO: CHECK WHETHER IT IS POSSIBLE TO SET TO TRUE (1)
263  *((uint8_t*)value) = 0;
264  break;
265  }
266  case TTE_VAR_MAC_ADDRESS:{
267  uint8_t *valueArr= (uint8_t *)value;
268  cModule *phy = getParentModule()->getSubmodule("phy", 0);
269  if(phy){
270  EtherMACFullDuplex *mac = (EtherMACFullDuplex*)phy->getSubmodule("mac");
271  MACAddress macAddress = mac->getMACAddress();
272  //Change order
273  valueArr[5] = macAddress.getAddressByte(0);
274  valueArr[4] = macAddress.getAddressByte(1);
275  valueArr[3] = macAddress.getAddressByte(2);
276  valueArr[2] = macAddress.getAddressByte(3);
277  valueArr[1] = macAddress.getAddressByte(4);
278  valueArr[0] = macAddress.getAddressByte(5);
279  }
280  else{
281  valueArr[0] = valueArr[1] = valueArr[2] = valueArr[3] = valueArr[4] = valueArr[5] = 0;
282  return ETT_NULLPTR;
283  }
284  break;
285  }
286  default:
287  return ETT_NOTSUPPORTED;
288  }
289  return ETT_SUCCESS;
290 }
int32_t TTEthernetModel::TTEAPIApplicationBase::tte_open_input_buf ( tte_buffer_t *const  buf,
tte_frame_t *const  frame,
tte_buf_status_t *const  status 
)
virtual

implementation of the TTEthernet-API method.

see TTEthernet-API documentation for further information

Definition at line 340 of file TTEAPIApplicationBase.cc.

Referenced by TTEthernetModel::tte_open_input_buf().

342  {
343  Enter_Method_Silent();
344  TTEAPIPriv *priv = (TTEAPIPriv*)buf->priv;
345 
346 
347  EtherFrame *msg = priv->buffer->getFrame();
348  APIPayload *payload = dynamic_cast<APIPayload*>(msg->decapsulate());
349  if(buf->traffic_type==TTE_CT_TRAFFIC){
350  frame->ct_id = dynamic_cast<CTFrame*>(msg)->getCtID();
351  }
352  frame->length = payload->getByteLength();
353  frame->data = (uint8_t*)malloc(payload->getByteLength());
354  priv->data = frame->data;
355  MACAddress dest= msg->getDest();
356  frame->eth_hdr.dst_mac[0] = dest.getAddressByte(5);
357  frame->eth_hdr.dst_mac[1] = dest.getAddressByte(4);
358  frame->eth_hdr.dst_mac[2] = dest.getAddressByte(3);
359  frame->eth_hdr.dst_mac[3] = dest.getAddressByte(2);
360  frame->eth_hdr.dst_mac[4] = dest.getAddressByte(1);
361  frame->eth_hdr.dst_mac[5] = dest.getAddressByte(0);
362  MACAddress src= msg->getSrc();
363  frame->eth_hdr.src_mac[0] = src.getAddressByte(5);
364  frame->eth_hdr.src_mac[1] = src.getAddressByte(4);
365  frame->eth_hdr.src_mac[2] = src.getAddressByte(3);
366  frame->eth_hdr.src_mac[3] = src.getAddressByte(2);
367  frame->eth_hdr.src_mac[4] = src.getAddressByte(1);
368  frame->eth_hdr.src_mac[5] = src.getAddressByte(0);
369 
370  for(unsigned int i=0;i<payload->getDataArraySize();i++){
371  frame->data[i] = payload->getData(i);
372  }
373 
374  delete payload;
375  delete msg;
376 
377  return ETT_SUCCESS;
378 }
int32_t TTEthernetModel::TTEAPIApplicationBase::tte_open_output_buf ( tte_buffer_t *const  buf,
tte_frame_t *const  frame 
)
virtual

implementation of the TTEthernet-API method.

see TTEthernet-API documentation for further information

Definition at line 292 of file TTEAPIApplicationBase.cc.

Referenced by TTEthernetModel::tte_open_output_buf().

293  {
294  Enter_Method_Silent();
295  TTEAPIPriv *priv = (TTEAPIPriv*)buf->priv;
296 
297  //Now we create a frame that can be accessed later
298  //TODO Divide TT and RC frames in separate types?
299  if(buf->traffic_type==TTE_BG_TRAFFIC){
300  priv->frame = new EtherFrame("BG-Traffic Ethernet Frame", IEEE802CTRL_DATA);
301  }
302  else{
303  std::stringstream frameNameStream;
304  frameNameStream << "CT-ID: " << buf->ct_id;
305  std::string frameName = frameNameStream.str();
306  priv->frame = new CTFrame(frameName.c_str(), IEEE802CTRL_DATA);
307  }
308  priv->frame->setByteLength(ETHER_MAC_FRAME_BYTES);
309 
310  MACAddress dest;
311  dest.setAddressByte(5, frame->eth_hdr.dst_mac[0]);
312  dest.setAddressByte(4, frame->eth_hdr.dst_mac[1]);
313  dest.setAddressByte(3, frame->eth_hdr.dst_mac[2]);
314  dest.setAddressByte(2, frame->eth_hdr.dst_mac[3]);
315  dest.setAddressByte(1, frame->eth_hdr.dst_mac[4]);
316  dest.setAddressByte(0, frame->eth_hdr.dst_mac[5]);
317  priv->frame->setDest(dest);
318  MACAddress src;
319  src.setAddressByte(5, frame->eth_hdr.src_mac[0]);
320  src.setAddressByte(4, frame->eth_hdr.src_mac[1]);
321  src.setAddressByte(3, frame->eth_hdr.src_mac[2]);
322  src.setAddressByte(2, frame->eth_hdr.src_mac[3]);
323  src.setAddressByte(1, frame->eth_hdr.src_mac[4]);
324  src.setAddressByte(0, frame->eth_hdr.src_mac[5]);
325  priv->frame->setSrc(src);
326 
327  APIPayload *payload = new APIPayload("TTEthernet API Payload");
328  payload->setByteLength(frame->length);
329  payload->setDataArraySize(frame->length);
330  priv->frame->encapsulate(payload);
331 
332  frame->data = (uint8_t*)malloc(frame->length);
333  if(!frame->data)
334  return ETT_NOMEM;
335  priv->data = frame->data;
336  return ETT_SUCCESS;
337 }
int32_t TTEthernetModel::TTEAPIApplicationBase::tte_set_buf_var ( tte_buffer_t *const  buf,
const tte_buf_var_id_t  var_id,
const uint32_t  var_size,
const void *const  value 
)
virtual

implementation of the TTEthernet-API method.

see TTEthernet-API documentation for further information

Definition at line 423 of file TTEAPIApplicationBase.cc.

Referenced by TTEthernetModel::tte_set_buf_var().

426  {
427  Enter_Method_Silent();
428  TTEAPIPriv *priv = (TTEAPIPriv*)buf->priv;
429  switch(var_id){
430  case TTE_BUFVAR_RECEIVE_CB:{
431  APICallback *cb = dynamic_cast<APICallback*>(priv->buffer->getReceiveCallback(this));
432  if(cb == NULL){
433  cb = new APICallback(priv->buffer);
434  priv->buffer->addReceiveCallback(cb, this);
435  }
436  cb->setFunctionPointer((void(*)(void *))value);
437  break;
438  }
439  case TTE_BUFVAR_TRANSMIT_CB:{
440  APICallback *cb = dynamic_cast<APICallback*>(priv->buffer->getTransmitCallback(this));
441  if(cb == NULL){
442  cb = new APICallback(priv->buffer);
443  priv->buffer->addTransmitCallback(cb, this);
444  }
445  cb->setFunctionPointer((void(*)(void *))value);
446  break;
447  }
448  case TTE_BUFVAR_CB_ARG:{
449  APICallback *cb = dynamic_cast<APICallback*>(priv->buffer->getReceiveCallback(this));
450  if(cb == NULL){
451  cb = dynamic_cast<APICallback*>(priv->buffer->getTransmitCallback(this));
452  if(cb == NULL){
453  return ETT_NULLPTR;
454  }
455  cb->setFunctionArg((void*)value);
456  }
457  else{
458  cb->setFunctionArg((void*)value);
459  }
460  break;
461  }
462  default:
463  return ETT_NOTSUPPORTED;
464  }
465  return ETT_SUCCESS;
466 }

Member Data Documentation

bool TTEthernetModel::TTEAPIApplicationBase::synchronized
private

Definition at line 74 of file TTEAPIApplicationBase.h.


The documentation for this class was generated from the following files: