/ scripts / gladevcp_demo
gladevcp_demo
 1  #!/bin/bash
 2  
 3  # This file is used for scripts that demonstrate gladevcp
 4  # The scripts typically use an extension of .demo
 5  # 1) start realtime
 6  # 2) run glacevcp with supplied parameters
 7  # 3) stop realtime
 8  
 9  # Copyright: 2014
10  # Author:    Dewey Garrett <dgarrett@panix.com>
11  #
12  # This program is free software; you can redistribute it and/or modify
13  # it under the terms of the GNU General Public License as published by
14  # the Free Software Foundation; either version 2 of the License, or
15  # (at your option) any later version.
16  #
17  # This program is distributed in the hope that it will be useful,
18  # but WITHOUT ANY WARRANTY; without even the implied warranty of
19  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  # GNU General Public License for more details.
21  #
22  # You should have received a copy of the GNU General Public License
23  # along with this program; if not, write to the Free Software
24  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  
26  prog=$(basename $0)
27  
28  function usage () {
29    cat <<EOF
30  Usage:
31        $prog [gladevcp options]
32  
33  
34  gladevcp_demo: start realtime and invoke gladevcp
35  
36  The help for gladvcp shows its options:
37  gladevcp --help
38  $(gladevcp -h)
39  EOF
40    exit 1
41  } ;# usage
42  
43  function popup () {
44    msg="$*"
45    wish <<EOF &
46    wm withdraw .
47    tk_messageBox \
48      -title "$prog" \
49      -message "$msg" \
50      -icon error \
51      -type ok
52    destroy .
53  EOF
54  } ;# popup
55  
56  # begin----------------------------------------------------
57  REALTIME=$(linuxcnc_var REALTIME)
58  $REALTIME status >/dev/null
59  status=$?
60  if [ $status = 0 ] ; then
61    msg="$prog: Realtime is already active"
62    echo "$msg"
63    popup "$msg"
64    exit 1
65  else
66    $REALTIME start
67  fi
68  
69  case $# in
70    0) usage;;
71    *) ARGS="$@";;
72  esac
73  
74  if [ ! -z "$debug" ] ; then
75    echo debug=$debug
76    echo REALTIME=$REALTIME
77    echo ARGS="$ARGS"
78  pwd
79  fi
80  
81  eval gladevcp "$ARGS"
82  halrun -U