summaryrefslogtreecommitdiff
path: root/maximus/functioncall/src/FunctionSciMsg.cpp
blob: d70eaafd459d397eb17687916b587353a9a007af (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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
/************************************************************************
                        FunctionSciMsg.cpp - Copyright buret

Here you can write a license for your code, some comments or any other
information you want to have in your generated code. To to this simply
configure the "headings" directory in uml to point to a directory
where you have your heading files.

or you can just replace the contents of this file with your own.
If you want to do this, this file is located at

/usr/share/apps/umbrello/headings/heading.cpp

-->Code Generators searches for heading files based on the file extension
   i.e. it will look for a file name ending in ".h" to include in C++ header
   files, and for a file name ending in ".java" to include in all generated
   java code.
   If you name the file "heading.<extension>", Code Generator will always
   choose this file even if there are other files with the same extension in the
   directory. If you name the file something else, it must be the only one with that
   extension in the directory to guarantee that Code Generator will choose it.

you can use variables in your heading files which are replaced at generation
time. possible variables are : author, date, time, filename and filepath.
just write %variable_name%

This file was generated on %date% at %time%
The original location of this file is /home/buret/eclipse/maximus/functioncall/src/FunctionSciMsg.cpp
**************************************************************************/

#include "FunctionSciMsg.h"
#include "FunctionCallManager.h"
#include "FunctionCallParameter.h"
#include "Error.h"

// For 'cout'
//
#include <iostream>
using namespace std;

#include <cstring> // for 'strcpy' and 'strcmp'
#include <iomanip> // for 'std::setfill' and 'std::setw'
#include <sstream> // for 'ostringstream' and 'stringstream'


// Constructors/Destructors
//  


FunctionSciMsg::FunctionSciMsg ( ):
mSpecializedSciMsgType(FUNCTION_CALL_TYPE_NONE),
mSpecializedSciMsgParametersNumber(0),
mpSpecializedSciMsgHeader(NULL),
mpFunctionCallManager(NULL)
{
  //clog << "FunctionSciMsg()" << endl;
  
  initAttributes ();
}


FunctionSciMsg::FunctionSciMsg ( FunctionCallManager * p_function_call_manager ):
mSpecializedSciMsgType(FUNCTION_CALL_TYPE_NONE),
mSpecializedSciMsgParametersNumber(0),
mpSpecializedSciMsgHeader(NULL),
mpFunctionCallManager(NULL)
{
  //clog << "FunctionSciMsg(FunctionCallManager*)" << endl;
  
  if (NULL != p_function_call_manager)
  {
    mpFunctionCallManager = p_function_call_manager;
  }
  else
  {
    throw Error("FunctionSciMsg(FunctionCallManager*)", "Received function call manager pointer is NULL");
  }
  
  initAttributes ();
}


void FunctionSciMsg::initAttributes ( )
{
  //clog << "FunctionSciMsg::initAttributes" << endl;
  
  mpSpecializedSciMsgHeader = new Function_Call_Header;
  if (NULL != mpSpecializedSciMsgHeader)
  {
    mpSpecializedSciMsgHeader->version = FUNCTION_CALL_VERSION;
    mpSpecializedSciMsgHeader->type = 0x00;
    mpSpecializedSciMsgHeader->param_nb = 0x00;
    mpSpecializedSciMsgHeader->flags = 0x00;
  }
}


FunctionSciMsg::FunctionSciMsg ( const FunctionSciMsg & function_sci_msg ) : SciMsg ( function_sci_msg )
{
  //clog << "FunctionSciMsg(FunctionSciMsg&)" << endl;
 
  initAttributes ();  

  setSpecializedSciMsgType (function_sci_msg.getSpecializedSciMsgType());
  setSpecializedSciMsgParametersNumber (function_sci_msg.getSpecializedSciMsgParametersNumber());
  
  setSpecializedSciMsgHeader (function_sci_msg.getSpecializedSciMsgHeader());

  setFunctionName (function_sci_msg.getFunctionName());
  setListOfParameters (function_sci_msg.getListOfParameters());
    
  setFunctionCallManager (function_sci_msg.getFunctionCallManager());
}


FunctionSciMsg::~FunctionSciMsg ( )
{
  //clog << "~FunctionSciMsg" << endl;
  
  if (NULL != mpSpecializedSciMsgHeader)
  {
    delete (mpSpecializedSciMsgHeader);
    mpSpecializedSciMsgHeader = NULL;
  }
  
  if (!mListOfParameters.empty())
  {
    mListOfParameters.clear();
  }
  
  if (NULL != mpFunctionCallManager)
  {
    mpFunctionCallManager = NULL;
  }
}


//
// Methods
//  


// Other methods
//  


// public methods
//  


ostream & operator<< ( ostream & os, const FunctionSciMsg & function_sci_msg )
{
  os << "\tfunction SCI msg = [function name = ";
  if (!function_sci_msg.getFunctionName().empty())
  {
    os << function_sci_msg.getFunctionName();
  }
  else
  {
    os << "NULL"; 
  }
  os << "]" << endl;
  return os;
}


SciMsg * FunctionSciMsg::create ( ) const
{
  //clog << "FunctionSciMsg::create" << endl;
  
  return new FunctionSciMsg (mpFunctionCallManager);
}


bool FunctionSciMsg::dispatchMsg ( )
{
  //clog << "FunctionSciMsg::dispatchMsg" << endl;
  bool bDispatch = false;

  if ( NULL != mpFunctionCallManager )
  {
    bDispatch = identifyCallbackName();
    bDispatch &= identifyCallbackParameters(); 
    
    if ( FUNCTION_CALL_TYPE_RSP == getSpecializedSciMsgType() )
    {
      bDispatch &= mpFunctionCallManager->receiveMsg(*this);
    } 
  }
  else
  {
    throw Error("FunctionSciMsg::dispatchMsg", "Function call manager pointer is NULL");
  }
  
  return bDispatch;
}


// When receiving a SCI msg, specialized SCI msg header has to be extracted from received SCI msg data
// 
bool FunctionSciMsg::identifySpecializedSciMsgHeader ( )
{
  //clog << "FunctionSciMsg::identifySpecializedSciMsgHeader" << endl;
  bool bIdentifyHeader = false;

  if (NULL != SciMsg::getSciMsgData())
  {
    // Set specialized SCI msg header size
    //
    SciMsg::setSpecializedSciMsgHeaderSize((unsigned long)sizeof(struct Function_Call_Header));

    // Get specialized SCI message header contents
    //
    if (SciMsg::getSciMsgDataLength() >= SciMsg::getSpecializedSciMsgHeaderSize()) // check that there are enough data to get the specialized SCI message header
    {
      if (NULL != mpSpecializedSciMsgHeader)
      {
        *mpSpecializedSciMsgHeader = *((Function_Call_Header*)SciMsg::getSciMsgData());
        
        // Set specialized SCI msg attributes from specialized SCI msg header
        //
        setSpecializedSciMsgType (static_cast<Function_Call_Type>(getSpecializedSciMsgHeader()->type));
        setSpecializedSciMsgParametersNumber (static_cast<Function_Call_Parameters_Number>(getSpecializedSciMsgHeader()->param_nb));
        
        displaySpecializedSciMsgHeader();
        bIdentifyHeader = true;
      }
    }
    else
    {
      throw Error("FunctionSciMsg::identifySpecializedSciMsgHeader", "Not enough data to get the specialized SCI message header");
    }
  }
  else
  {
    throw Error("FunctionSciMsg::identifySpecializedSciMsgHeader", "SCI msg data pointer is NULL");
  } 
    
  return bIdentifyHeader;
}


// Check specialized SCI msg compatibility (check specialized SCI msg version)
//
bool FunctionSciMsg::checkCompatibility ( ) const
{
  //clog << "FunctionSciMsg::checkCompatibility" << endl;
  bool bCheck = false;
  
  if ( (NULL != getSpecializedSciMsgHeader()) && (FUNCTION_CALL_VERSION == getSpecializedSciMsgHeader()->version) )
  {
    bCheck = SciMsg::checkCompatibility();
  }
  
  return bCheck;
}


// Called by user to configure a message to send
//
bool FunctionSciMsg::addParameter ( const FunctionCallParameter & function_argument_to_add )
{
  clog << "FunctionSciMsg::addParameter" << endl;
  bool bAddParameter = false;

  if ( FUNCTION_CALL_PARAM_MAX_SIZE >= function_argument_to_add.getValueLength())
  {
    mListOfParameters.push_back(function_argument_to_add);
    displayListOfParameters();
    bAddParameter = true;
  }
  else
  {
    throw Error("FunctionSciMsg::addParameter", "Length of parameter value exceeds max size");
  }
 
  return bAddParameter;
}


// Called by user when a message is received to retrieve function parameters
//
bool FunctionSciMsg::bindParameter ( const string name_of_parameter_to_get, unsigned long & data_length, unsigned char * & p_data ) const
{
  clog << "FunctionSciMsg::bindParameter" << endl;
  bool bBindParameter = false;

  displayListOfParameters();
  FunctionCallParameter tempParameter;
    
  for (unsigned int i=0; i<mListOfParameters.size(); ++i)
  {
    tempParameter = mListOfParameters[i];
    if ( !tempParameter.getName().compare(name_of_parameter_to_get) )
    {
      data_length = tempParameter.getValueLength();
      p_data = new unsigned char [data_length]; // to be deleted by user
      if ( (NULL != tempParameter.getValue()) && (NULL != p_data) )
      {
        memcpy(p_data, tempParameter.getValue(), data_length);
        clog << "\tbind parameter = ";
        tempParameter.displayParameter();
        clog << endl;
        i = mListOfParameters.size()-1;
        bBindParameter = true;
      }
    }
  }

  return bBindParameter;
}


// Called when a function SCI msg is received
//
bool FunctionSciMsg::identifyCallbackName ( )
{
  clog << "FunctionSciMsg::identifyCallbackName" << endl;
  bool bIdentifyName = false;
  
  if (NULL != getSpecializedSciMsgData())
  {
    // Find function name length
    //               
    unsigned long functionNameLength = 0;
    while ( (getSpecializedSciMsgDataLength() >= functionNameLength)
            && ('\0' != *(getSpecializedSciMsgData()+functionNameLength)) )
    {
      if (FUNCTION_CALL_ID_MAX_SIZE > functionNameLength) /* max length of a function id */
      {
        functionNameLength++;
      }
      else
      {
        throw Error("FunctionSciMsg::identifyCallbackName", "Length of function call name exceeds max size");
      }
    }
    clog << "\tcallback name length = " << dec << functionNameLength+1 << endl;
          
    // Copy function name from specialized SCI msg data to function name attribute
    //
    mFunctionName.assign((char*)getSpecializedSciMsgData(), functionNameLength);
    clog << "\tcallback name = " << mFunctionName << endl;
      
    // Remove function name from specialized SCI msg data
    //
    unsigned long tempDataLength = getSpecializedSciMsgDataLength();
    unsigned char * pTempData = getSpecializedSciMsgData();
    bIdentifyName = SciMsg::removeData (functionNameLength+1, tempDataLength, &pTempData);
    if (0 != bIdentifyName)
    {
      bIdentifyName &= setSpecializedSciMsgDataLength(tempDataLength);
      bIdentifyName &= setSpecializedSciMsgData(pTempData);
    }
    pTempData = NULL; // free pointer
  }
  else
  {
    if (!getFunctionName().empty()) // function name has already been set
    {
      bIdentifyName = true;
    }
    else
    {
      throw Error("FunctionSciMsg::identifyCallbackName", "Specialized SCI msg data pointer is NULL");
    }
  }
  
  return bIdentifyName;
}


// Called when a function SCI msg is received
//
bool FunctionSciMsg::identifyCallbackParameters ( )
{
  clog << "FunctionSciMsg::identifyCallbackParameters" << endl;
  bool bIdentifyParameters = false;
      
  if ( NULL != getSpecializedSciMsgData() )
  {
    // For each parameter
    //
    for (unsigned int n=0; n<getSpecializedSciMsgParametersNumber(); n++)
    {
      // Find parameter name length
      //                
      unsigned long parameterNameLength = 0;
      while ( (getSpecializedSciMsgDataLength() >= parameterNameLength)
              && ('\0' != *(getSpecializedSciMsgData()+parameterNameLength)) )
      {
        parameterNameLength++;
      }
      clog << dec << "\tparameter " << n+1 << " name length = " << parameterNameLength+1 << endl;
      
      // Copy parameter name from specialized SCI msg data to parameter name attribute
      //
      string tempParameterName;
      tempParameterName.assign((char*)getSpecializedSciMsgData(), parameterNameLength);
      FunctionCallParameter parameterToFill;
      parameterToFill.setName (tempParameterName);
      
      // Remove parameter name from specialized SCI msg data
      //
      unsigned long tempDataLength = getSpecializedSciMsgDataLength();
      unsigned char * pTempData = getSpecializedSciMsgData();
      bIdentifyParameters = SciMsg::removeData (parameterNameLength+1, tempDataLength, &pTempData);
      if (0 != bIdentifyParameters)
      {
        bIdentifyParameters &= setSpecializedSciMsgDataLength(tempDataLength);
        bIdentifyParameters &= setSpecializedSciMsgData(pTempData);
      }  
          
      // Find parameter value length (coded on 2 bytes)
      //
      uint16_t tempLength = (static_cast<uint8_t>(*(getSpecializedSciMsgData()))<<8) + static_cast<uint8_t>(*(getSpecializedSciMsgData()+1));
      if ( FUNCTION_CALL_PARAM_MAX_SIZE >= tempLength )
      {
        parameterToFill.setValueLength (static_cast<unsigned long>(tempLength));
      }
      else
      {
        throw Error("FunctionSciMsg::identifyCallbackParameters", "Length of parameter value exceeds max size");
      }
        
      // Find parameter value
      //
      unsigned char * pTempParameterValue = new unsigned char [parameterToFill.getValueLength()];
      memcpy(pTempParameterValue, getSpecializedSciMsgData()+2, parameterToFill.getValueLength()); // +2 because parameter value length is coded on 2 bytes
      parameterToFill.setValue (pTempParameterValue);
      
      // Display parameter value
      //
      clog << dec << "\tparameter " << n+1 << " value = 0x ";
      for (unsigned int i=0; i<parameterToFill.getValueLength(); i++)
      {
        clog << setfill('0') << setw(2) << uppercase << hex << (unsigned short int)*(parameterToFill.getValue()+i) << " ";
      }
      clog << endl;
                
      // Remove parameter value length and parameter value from specialized SCI msg data
      //
      tempDataLength = getSpecializedSciMsgDataLength();
      pTempData = getSpecializedSciMsgData();
      bIdentifyParameters &= SciMsg::removeData (2+parameterToFill.getValueLength(), tempDataLength, &pTempData); // +2 because parameter value length is coded on 2 bytes
      if (0 != bIdentifyParameters)
      {
        bIdentifyParameters &= setSpecializedSciMsgDataLength(tempDataLength);
        bIdentifyParameters &= setSpecializedSciMsgData(pTempData);
      }
      pTempData = NULL; // free pointer  
      if (NULL != pTempParameterValue)
      {
        delete [] pTempParameterValue;
        pTempParameterValue = NULL;
      }
        
      // Add parameter to the parameters list of the received function SCI msg
      //
      bIdentifyParameters &= addParameter(parameterToFill);
    }
  }
  else
  {
    throw Error("FunctionSciMsg::identifyCallbackParameters", "Specialized SCI msg data pointer is NULL");
  }

  return bIdentifyParameters;
}


// Called when a function SCI msg is sent
// Fill specialized SCI msg attributes
// Fill specialized SCI msg data length and specialized SCI msg data
//
bool FunctionSciMsg::fillSpecializedSciMsgToSend ( )
{
  clog << "FunctionSciMsg::fillSpecializedSciMsgToSend" << endl;
  bool bFill = false;
  
  displayListOfParameters();
  Function_Call_Parameters_Number numberOfParameters = 0;
  unsigned long dataLength = 0;
  unsigned char * pData = NULL;
  
  // Function name is sent into the SCI msg data, before parameters
  //
  if (!getFunctionName().empty())
  {
    pData = (unsigned char *)(malloc(getFunctionName().size()+1)); // memory allocation for function name
    getFunctionName().copy ((char*)(pData), getFunctionName().size()); // copy function name into data
    pData[getFunctionName().size()] = '\0';
    clog << "\tfunction name = " << pData << endl; // display function name
    dataLength += static_cast<unsigned long>(getFunctionName().size()+1); // update data length
       
    // Parameters are defined as 'FunctionCallParameter'
    // They will be sent into the function SCI msg into specialized SCI msg data
    // 'FunctionCallParameter' fields are sent according to the following format:
    // name\0lengthp_value etc. with length coded on 2 bytes
    // Number of parameters is sent into the 'Function_Call_Header.param_nb' field
    //
    for (unsigned int i=0; i<mListOfParameters.size(); ++i)
    {
      // Dynamic memory allocation for parameter
      //         
      pData = (unsigned char *)(realloc(pData, dataLength+((mListOfParameters)[i].getName().length())+1+2+(mListOfParameters)[i].getValueLength()));
      
      // Parameter name
      //
      mListOfParameters[i].getName().copy ((char*)(pData+dataLength), mListOfParameters[i].getName().size()); // copy parameter name into data
      *(pData+dataLength+mListOfParameters[i].getName().size()) = '\0';
      clog << "\tparameter " << dec << i+1 << " name = ";
      for (unsigned int j=dataLength; j<dataLength+mListOfParameters[i].getName().size(); j++)
      {
       clog << *(pData+j); // display parameter name
      }
      clog << endl;
      dataLength += static_cast<unsigned long>(mListOfParameters[i].getName().size()+1); // update data length
      
      // Parameter value length
      //
      uint16_t tempLength = static_cast<uint16_t>(mListOfParameters[i].getValueLength());
      uint8_t tempLengthHigh=0, tempLengthLow=0;
      tempLengthHigh = static_cast<uint8_t>(tempLength >> 8);
      tempLengthLow = static_cast<uint8_t>(tempLength);
      *(pData+dataLength) = static_cast<unsigned char>(tempLengthHigh);
      *(pData+dataLength+1) = static_cast<unsigned char>(tempLengthLow);
      clog << "\tparameter " << dec << i+1 << " value length = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(tempLengthHigh);
      clog << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(tempLengthLow) << endl; // display parameter value length
      dataLength += 2; // update data length
      
      // Parameter value
      //
      clog << "\tparameter " << dec << i+1 << " value length = " << mListOfParameters[i].getValueLength() << endl;
      clog << "\tparameter " << dec << i+1 << " value = ";
      if (0 != (mListOfParameters[i].getValueLength()))
      {
        for (unsigned int j=0; j<mListOfParameters[i].getValueLength(); j++)
        {
          *(pData+dataLength+j) = *(mListOfParameters[i].getValue()+j);
          clog << *(pData+dataLength+j); // display parameter value
        }
        clog << endl;
      }
      else
      {
        clog << "NULL" << endl;
      }
      dataLength += mListOfParameters[i].getValueLength(); // update data length
         
      // Increment number of parameters that have been copied into data
      //
      numberOfParameters++;
    }
  }
  else
  {
    throw Error("FunctionSciMsg::fillSpecializedSciMsgToSend", "Function name pointer is NULL"); 
  }
    
  // Fill specialized SCI msg type,
  // specialized SCI msg number of parameters,
  // specialized SCI msg data length,
  // and specialized SCI msg data
  //
  if (NULL != pData)
  {
    bFill = setSpecializedSciMsgType(FUNCTION_CALL_TYPE_REQ);
    bFill &= setSpecializedSciMsgParametersNumber(numberOfParameters);
    bFill &= setSpecializedSciMsgDataLength(dataLength);
    bFill &= setSpecializedSciMsgData(pData);
    
    // Free temporary allocated memory
    //
    delete [] pData;
    pData = NULL;
  }
    
  return bFill;
}


void FunctionSciMsg::displaySpecializedSciMsgHeader ( ) const
{
  clog << "\tfunction SCI msg header = " << endl;
  clog << "\t\tversion = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(mpSpecializedSciMsgHeader->version) << endl;
  clog << "\t\ttype = ";
  displaySpecializedSciMsgType();
  clog << endl;
  clog << "\t\tnumber of parameters = " << dec << static_cast<unsigned short int>(mpSpecializedSciMsgHeader->param_nb) << endl;
  clog << "\t\tflags = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(mpSpecializedSciMsgHeader->flags) << endl; 
}


// private methods
//  


void FunctionSciMsg::displaySpecializedSciMsgType ( ) const
{
  switch (getSpecializedSciMsgType())
  {
    case 0:
      clog << "FUNCTION_CALL_TYPE_NONE";
      break;
    case 1:
      clog << "FUNCTION_CALL_TYPE_REQ";
      break;
    case 2:
      clog << "FUNCTION_CALL_TYPE_RSP";
      break;
    default:      
      clog << "unknown";
      break;
  }
}


void FunctionSciMsg::displayParameter ( unsigned int parameter_iterator ) const
{
  clog << "\tparameter " << dec << parameter_iterator+1 << " = ";
  if (parameter_iterator < mListOfParameters.size())
  {
    mListOfParameters[parameter_iterator].displayParameter();
    clog << endl;
  }
  else
  {
    clog << "\tdoes not exist!" << endl;
  }
}


void FunctionSciMsg::displayListOfParameters ( ) const
{
  clog << "\tlist of parameters = " << endl;
  if (!mListOfParameters.empty())
  {
    for (unsigned int i=0; i<mListOfParameters.size(); i++)
    {
      clog << "\t";
      mListOfParameters[i].displayParameter();
      clog << endl;
    }
  }
  else
  {
    clog << "\tlist is empty!" << endl;
  }
}


// protected methods
//  


// Accessor methods
//  


// public attribute accessor methods
//  


// private attribute accessor methods
//  


Function_Call_Type FunctionSciMsg::getSpecializedSciMsgType ( ) const
{
  return mSpecializedSciMsgType;
}


bool FunctionSciMsg::setSpecializedSciMsgType ( const Function_Call_Type type )
{
  //clog << "FunctionSciMsg::setSpecializedSciMsgType" << endl;
    
  mSpecializedSciMsgType = type;
  //clog << "\ttype = ";
  //displaySpecializedSciMsgType();
  //clog << endl;
  
  return true; 
}


Function_Call_Parameters_Number FunctionSciMsg::getSpecializedSciMsgParametersNumber ( ) const
{
  return mSpecializedSciMsgParametersNumber;
}


bool FunctionSciMsg::setSpecializedSciMsgParametersNumber  ( const Function_Call_Parameters_Number number_of_parameters )
{
  //clog << "FunctionSciMsg::setSpecializedSciMsgParametersNumber" << endl;
  
  if ( FUNCTION_CALL_PARAM_MAX_NB >= number_of_parameters ) /* max number of parameter in a function call */
  {
    mSpecializedSciMsgParametersNumber = number_of_parameters;
    //clog << "\tnumber of parameters = " << dec << getSpecializedSciMsgParametersNumber() << endl;
  }
  else
  {
    throw Error("FunctionSciMsg::setSpecializedSciMsgParametersNumber", "Number of parameters exceeds max number");
  }
  
  return true;
}


void * FunctionSciMsg::returnSpecializedSciMsgHeader ( ) const
{
  return (void*)mpSpecializedSciMsgHeader;
}


Function_Call_Header * FunctionSciMsg::getSpecializedSciMsgHeader ( ) const
{
  return mpSpecializedSciMsgHeader;
}


bool FunctionSciMsg::setSpecializedSciMsgHeader ( const Function_Call_Header * p_specialized_sci_msg_header )
{
  //clog << "FunctionSciMsg::setSpecializedSciMsgHeader" << endl;
  bool bSetHeader = false;
  
  if ( (NULL != p_specialized_sci_msg_header) && (NULL != mpSpecializedSciMsgHeader) )
  {
    *mpSpecializedSciMsgHeader = *p_specialized_sci_msg_header;
    
    // Set specialized SCI msg attributes from specialized SCI msg header
    //
    bSetHeader = setSpecializedSciMsgType (static_cast<Function_Call_Type>(getSpecializedSciMsgHeader()->type));
    bSetHeader &= setSpecializedSciMsgParametersNumber (static_cast<Function_Call_Parameters_Number>(getSpecializedSciMsgHeader()->param_nb));
        
    displaySpecializedSciMsgHeader();
  }
  else
  {
    throw Error("FunctionSciMsg::setSpecializedSciMsgHeader", "Received and/or initialized function call header pointer is NULL");
  }
   
  return bSetHeader;
}


string FunctionSciMsg::getFunctionName ( ) const
{
  return mFunctionName;  
}


// Called by user to configure a SCI message to send
//  
bool FunctionSciMsg::setFunctionName ( const string name )
{
  //clog << "FunctionSciMsg::setFunctionCallName" << endl;
  bool bSetName = false;

  if ( FUNCTION_CALL_ID_MAX_SIZE > name.size() ) /* max length of a function id */
  {
    mFunctionName = name;
    clog << "\tfunction call name = " << mFunctionName << endl;
    bSetName = true;
  }
  
  return bSetName;
}


const ParametersList & FunctionSciMsg::getListOfParameters ( ) const
{
  return mListOfParameters;
}
 

bool FunctionSciMsg::setListOfParameters ( const ParametersList & list_of_parameters )
{
  //clog << "FunctionSciMsg::setListOfParameters" << endl;

  mListOfParameters = list_of_parameters;
  displayListOfParameters();
  
  return true;
}


FunctionCallManager * FunctionSciMsg::getFunctionCallManager ( ) const
{
  return mpFunctionCallManager;
}
 

bool FunctionSciMsg::setFunctionCallManager ( FunctionCallManager * p_function_call_manager )
{
  //clog << "FunctionSciMsg::setFunctionCallManager" << endl;
  bool bSet = false;
  
  if (NULL != p_function_call_manager)
  {
    mpFunctionCallManager = p_function_call_manager;
    bSet = true;
  }
  else
  {
    throw Error("FunctionSciMsg::setFunctionCallManager", "Received function call manager pointer is NULL");
  }
  
  return bSet;
}


// protected attribute accessor methods
//