examples/DS401_Slave_Gui/CallBack.cpp
author etisserant
Fri, 01 Feb 2008 18:06:55 +0100
changeset 378 d2abf6c8c27b
parent 302 7ba4302a9999
child 382 860e858685d3
permissions -rw-r--r--
As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.

Concerned callbacks :

initialisation
preOperational
operational
stopped
heartbeatError
post_sync
post_TPDO
post_SlaveBootup
storeODSubIndex
post_emcy
246
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
     1
/*
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
     2
This file is part of CanFestival, a library implementing CanOpen Stack. 
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
     3
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
     4
Copyright (C): Edouard TISSERANT and Francis DUPIN
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
     5
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
     6
See COPYING file for copyrights details.
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
     7
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
     8
This library is free software; you can redistribute it and/or
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
     9
modify it under the terms of the GNU Lesser General Public
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    10
License as published by the Free Software Foundation; either
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    11
version 2.1 of the License, or (at your option) any later version.
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    12
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    13
This library is distributed in the hope that it will be useful,
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    14
but WITHOUT ANY WARRANTY; without even the implied warranty of
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    16
Lesser General Public License for more details.
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    17
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    18
You should have received a copy of the GNU Lesser General Public
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    19
License along with this library; if not, write to the Free Software
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    21
*/
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    22
#include <wx/wxprec.h>
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    23
#include <wx/wx.h>
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    24
#include <wx/textctrl.h>
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    25
#include <iostream>
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    26
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    27
#include "CallBack.h"
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    28
#include "main.h"
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    29
extern "C" 
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    30
  {
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    31
	#include "ObjDict.h"
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    32
  }
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    33
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    34
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    35
extern wxTextCtrl 	*textLog;
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    36
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    37
/*****************************************************************************/
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 302
diff changeset
    38
void Call_heartbeatError(CO_Data* d, UNS8 heartbeatID)
246
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    39
{
302
7ba4302a9999 Many fixes in OD of DS401_Slave_GUI. Still very unstable. Work in progress
etisserant
parents: 295
diff changeset
    40
	//*textLog << wxT("HeartbeatError\n");
246
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    41
}
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    42
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 302
diff changeset
    43
void Call_initialisation(CO_Data* d)
246
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    44
{
302
7ba4302a9999 Many fixes in OD of DS401_Slave_GUI. Still very unstable. Work in progress
etisserant
parents: 295
diff changeset
    45
	//*textLog << wxT("Initialisation\n");
246
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    46
}
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    47
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 302
diff changeset
    48
void Call_preOperational(CO_Data* d)
246
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    49
{
302
7ba4302a9999 Many fixes in OD of DS401_Slave_GUI. Still very unstable. Work in progress
etisserant
parents: 295
diff changeset
    50
	//*textLog << wxT("PreOperational\n");
246
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    51
}
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    52
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 302
diff changeset
    53
void Call_operational(CO_Data* d)
246
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    54
{
302
7ba4302a9999 Many fixes in OD of DS401_Slave_GUI. Still very unstable. Work in progress
etisserant
parents: 295
diff changeset
    55
	//*textLog << wxT("Operational\n");
246
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    56
}
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    57
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 302
diff changeset
    58
void Call_stopped(CO_Data* d)
246
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    59
{
302
7ba4302a9999 Many fixes in OD of DS401_Slave_GUI. Still very unstable. Work in progress
etisserant
parents: 295
diff changeset
    60
	//*textLog << wxT("Stopped\n");
246
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    61
}
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    62
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 302
diff changeset
    63
void Call_post_sync(CO_Data* d)
246
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    64
{
295
25ff2fadff89 DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents: 246
diff changeset
    65
    //*textLog << wxT("Post_sync\n");
246
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    66
	printf("POST SYNC:\n");
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    67
	printf("     Write_Outputs: %x \n     Analogue_Output1: %d \n     Analogue_Output2: %d \n", Write_Outputs_8_Bit[0], Write_Analogue_Output_16_Bit[0], Write_Analogue_Output_16_Bit[1]);
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    68
	printf("     Read_Input: %x \n     Analogue_Input1: %d \n     Analogue_Input2: %d \n", Read_Inputs_8_Bit[0], Read_Analogue_Input_16_Bit[0], Read_Analogue_Input_16_Bit[1]);
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    69
}
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    70
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 302
diff changeset
    71
void Call_post_TPDO(CO_Data* d)
246
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    72
{
302
7ba4302a9999 Many fixes in OD of DS401_Slave_GUI. Still very unstable. Work in progress
etisserant
parents: 295
diff changeset
    73
	//*textLog << wxT("Post_TPDO\n");
246
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    74
}
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    75
378
d2abf6c8c27b As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents: 302
diff changeset
    76
void Call_storeODSubIndex(CO_Data* d, UNS16 wIndex, UNS8 bSubindex)
246
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    77
{
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    78
	printf("StoreODSubIndex : %4.4x %2.2x\n", wIndex,  bSubindex);
302
7ba4302a9999 Many fixes in OD of DS401_Slave_GUI. Still very unstable. Work in progress
etisserant
parents: 295
diff changeset
    79
	//*textLog << wxT("StoreODSubIndex :\n");
246
d635cfc520ee Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff changeset
    80
}