Index: trunk/MagicSoft/Cosy/Changelog
===================================================================
--- trunk/MagicSoft/Cosy/Changelog	(revision 2322)
+++ trunk/MagicSoft/Cosy/Changelog	(revision 2323)
@@ -1,3 +1,10 @@
                                                                   -*-*- END -*-*-
+ 2003/09/03 - Thomas Bretz
+ 
+   * aposs/Magic.m:
+     - updated to V0.69
+
+
+
  2003/07/16 - Thomas Bretz (La Palma)
 
Index: trunk/MagicSoft/Cosy/aposs/Magic.m
===================================================================
--- trunk/MagicSoft/Cosy/aposs/Magic.m	(revision 2322)
+++ trunk/MagicSoft/Cosy/aposs/Magic.m	(revision 2323)
@@ -10,7 +10,13 @@
 /*                                                                         */
 kVERSION    = 0   /*                                                       */
-kSUBVERSION = 68  /*                                                       */
+kSUBVERSION = 69  /*                                                       */
 /*                                                                         */
 /*  HISTORY:                                                               */
+/*                                                                         */
+/*   * V0.69:                                                              */
+/*       - Implemented Pre-Operational/Operational state                   */
+/*          means: + cannot start RPM mode                                 */
+/*                 + SDO 0x6004 (POSA/POSR) ignored                        */
+/*                 + new SDO 0x1000                                        */
 /*                                                                         */
 /*   * V0.68:                                                              */
@@ -95,4 +101,5 @@
 /*  Object Dictionary:                                                     */
 /*                                                                         */
+/*   0x1000 1 rw Start node (Pre-oprational --> operational)               */
 /*   0x1003 x rw Read delete error list (subidx 0-9)                       */
 /*   0x1004 0 ro Nr of PDOs (transmit)                                     */
@@ -115,5 +122,6 @@
 /*   0x2003 0 wo Acceleration                                              */
 /*          1 wo Deceleration                                              */
-/*   0x3000 x wo Motor 'on', 'off', 'stop'                                 */
+/*   0x3000 x wo Motor 'on', 'off', 'stop' (Warning: Motor off can have    */
+/*                                          strange side effects if RF=1!) */
 /*   0x3001 x wo Home 'home'                                               */
 /*   0x3002 x wo Reopen Communication 'open'                               */
@@ -254,4 +262,6 @@
 firsttimeout   = 0
 
+preop = kTRUE
+
 /*-------------------------------------------------------------------------*/
 /* Can Open Definitions                                                    */
@@ -351,18 +361,18 @@
             gosub reset
             goto mainloop
-         elseif mode==1 then
+         elseif (mode==1) then
             print "Control not in PC mode!"
             gosub reset
             SET PRGPAR 0
             exit
-         elseif fuse==0 then 
+         elseif (fuse==0) then 
             print "Motor-Power Fuse not OK!"
             gosub reset
             goto mainloop
-         elseif vltg==0 then 
+         elseif (vltg==0) then 
             print "Overvoltage control broken!"
             gosub reset
             goto mainloop
-         elseif emcy==0 then 
+         elseif (emcy==0) then 
             print "Please release Emergency Stop!"
             gosub reset
@@ -389,6 +399,8 @@
                brake = 1
                waitt 1000
-            endif          
-            
+            endif
+
+            /* This "motor on" is necessary to make sure the floating analog output 
+               doesn't move the telescope (slowly) */
             motor on
 
@@ -449,8 +461,11 @@
       subidx = canhi&0xff
       sdoval = (canlo&0xff)<<24 | (canlo&0xff00)<<8 | (canlo>>8)&0xff00 | (canlo>>24)&0xff
+      canlo  = 0
 /*
       PRINT "Setting Idx:", idx, "/", subidx, " to ", sdoval
 */
-      if (idx==0x1003 and subidx==0 and sdoval==0) then
+      if (idx==0x1000 and subidx==1 and sdoval==1) then
+         preop = kFALSE
+      elseif (idx==0x1003 and subidx==0 and sdoval==0) then
          i = 9
          while (i) do
@@ -530,21 +545,29 @@
          CANOUT sdotx (canhi&0xffffff | 0x60000000) 0
          EXIT
-      elseif (idx == 0x3006) then
+      elseif (idx == 0x3006) then 
          if (subidx == 0) then
             if (sdoval == ('s'<<24|'t'<<16|'r'<<8|'t')) then 
-               CVEL 0
-               CSTART
-             elseif (sdoval == ('s'<<24|'t'<<16|'o'<<8|'p')) then 
+               if (preop==kFALSE) then
+                  CVEL 0
+                  CSTART
+               else
+                  canlo = 1
+               endif
+            elseif (sdoval == ('s'<<24|'t'<<16|'o'<<8|'p')) then 
                CSTOP
-             endif
+            endif
          elseif (subidx == 1) then
             CVEL sdoval
-         endif
+         endif 
       elseif (idx == 0x3007) then
-         if (subidx==0 and sdoval == ('s'<<24|'y'<<16|'n'<<8|'c')) then 
-            SYNCV
-         elseif (subidx==1 and sdoval == ('s'<<24|'y'<<16|'n'<<8|'c')) then 
-            SYNCP
-         endif   
+         if (preop==kFALSE) then
+            if (subidx==0 and sdoval == ('s'<<24|'y'<<16|'n'<<8|'c')) then 
+               SYNCV
+            elseif (subidx==1 and sdoval == ('s'<<24|'y'<<16|'n'<<8|'c')) then 
+               SYNCP
+            endif
+         else
+            canlo = 1
+         endif      
       elseif (idx == 0x3008) then
          if (sdoval == ('o'<<24|'n'<<16)) then 
@@ -576,8 +599,12 @@
          endif
       elseif (idx == 0x6004) then
-        if (subidx==0) then
-           POSA sdoval
-        elseif (subidx==1) then
-           POSR sdoval
+        if (preop==kFALSE) then
+           if (subidx==0) then
+              POSA sdoval
+           elseif (subidx==1) then
+              POSR sdoval
+           endif             
+        else
+           canlo = 1
         endif
       elseif (idx == 0x6200) then
@@ -601,5 +628,5 @@
       endif
 
-      CANOUT sdotx (canhi&0xffffff | 0x60000000) 0
+      CANOUT sdotx (canhi&0xffffff | 0x60000000) canlo
 /*
       PRINT "Sdo Set ", idx, "/", subidx
@@ -615,6 +642,8 @@
 /*
       PRINT "Requesting Idx:", idx, "/", subidx
-*/
-      if (idx == 0x1003) then
+*/          
+      if (idx == 0x1000 and subidx==1) then
+         sdoval = preop
+      elseif (idx == 0x1003) then
          if (subidx >=0 and subidx<=9) then
             sdoval = errlist[subidx-1]
Index: trunk/MagicSoft/Cosy/aposs/Manual.m
===================================================================
--- trunk/MagicSoft/Cosy/aposs/Manual.m	(revision 2322)
+++ trunk/MagicSoft/Cosy/aposs/Manual.m	(revision 2323)
