Beispiel #1
0
      //Handles synchronous commands that need queueing for long running operations. 
      public bool syncCommand( DomeCmds inCmd, double cmdArg )
      {
         bool outputStatus = false;
         if ( inCmd == DomeCmds.ABORT )
         {
             //clear down the existing queue - leave state at aborting. 
             domeState = DomeStates.ABORTING;
             this.cmdQueue.Clear();
             logger.LogMessage( this.GetType().ToString(), " ABORT coomand detected - clearing CMD queue of: " + cmdQueue.Count + " entries");
             //let timer handle the dome and shutter. 
         }
         else
         {
             //NOT IMPLEMENTED: enqueue the new command in case there are existing long-running commands. 
             // this allows the driver to respond rapidly but long commands to take their time in the right order for multiple clients. 
             switch( inCmd )
             {
             case DomeCmds.PARK:
                     outputStatus = rotateDome( parkAzimuth);
                     break;
             case DomeCmds.SLEW_TO_AZIMUTH: 
                     outputStatus = rotateDome( (int) cmdArg );
                     break;
             case DomeCmds.SLEW_TO_ALTITUDE:
                     outputStatus = moveShutter( (int) cmdArg );
                     break;
             case DomeCmds.SYNC_TO_AZIMUTH:
                     azimuth = (int)cmdArg;
                     outputStatus = true;
                     break;
             case DomeCmds.SET_SLAVED:
                     azimuth = (int)cmdArg;
                     outputStatus = true;
                     break;
             case DomeCmds.OPEN_SHUTTER:
                     outputStatus = moveShutter( 110 );
                     break;
             case DomeCmds.CLOSE_SHUTTER:
                     outputStatus = moveShutter( 0 );
                     break;
//                 logger.LogMessage( this.GetType().ToString(), " Setting new CMD tuple: " + inCmd + " with value: " + cmdArg + " to queue");
//                 cmdQueue.Enqueue( new CmdTuple( inCmd, cmdArg ) );
             default: 
                 throw new ASCOM.InvalidOperationException("This cmd is not implemented in syncCommand handler, check for direct function calls.");
                 break;
             }       
         }
         return true;
      }
Beispiel #2
0
      private bool rotateDome( int target )
      {
        bool status = false;
        bool direction = true;
        byte[] outData = new byte[5];
        String dateString; 
        String stateString;
        char[] charString;
        int magnitude = (target - (int) azimuth)/360;

        //Check  current azimuth
        //Estimate shortest direction and distance to travel 
          if( magnitude > 0 && magnitude <180 )
          {
              direction = true;
          }
          else if ( magnitude > 180 && magnitude <360 ) 
          {
              direction = false; 
              magnitude = magnitude -180;
          }
          else if( magnitude < 0 && magnitude > -180 )
          {
              direction = false;               
          }
          else if( magnitude < -180 && magnitude > -360 )
          {
              direction = true;               
              magnitude = 360 + magnitude;
          }              

        //Setup slew
        //LCD                         
        //Move to row 4
        outData[0] = (byte) 0x01 ;//go to row 
        outData[1] = (byte) 0x03 ;//row        
        if ( obboPort.Write( (byte) 0x55, (byte) config.I2CLCDAddr, outData, 2 ) )
            retVal = 0;
        //Move to first col
        outData[0] = (byte) 0x02 ;//go to col 
        outData[1] = (byte) 0x00 ;//col
        if ( obboPort.Write( (byte) 0x55, (byte) config.I2CLCDAddr, outData, outData.Length ) )
            retVal = 0;
        //Write 'slewing' string 
        stateString = "slewing";
        outData = new byte[stateString.Length];
        charString = stateString.ToCharArray();
        for( int i = 0; i< outString.Length; i++)
        {
            outData[i] = (byte) charString[i];
        }
        if ( obboPort.Write( (byte) 0x55, (byte) config.I2CLCDAddr, outData, outData.Length ) )
            retVal = 0;

        //Magnetometer - update azimuth
        outString  = domePort.Read( 0x55, config.I2CMagnetometerAddress, outData, outData.Length );
        
        //motor controller
        //Set motor direction
        outData[0] = (byte) 0x01 ;//set motor direction
        outData[1] = (byte) 0x03 ;//motor direction        
        if ( obboPort.Write( (byte) 0x55, (byte) config.I2CLCDAddr, outData, outData.Length ) )
            retVal = 0;

        //Wait for complete
        while( (target - azimuth) > (int) positioningPrecision )
        {
            if ()
            {
            }
            //Set motor speed
            outData[0] = (byte) 0x01 ;//set motor direction
            outData[1] = (byte) 0x03 ;//motor direction        
            if ( obboPort.Write( (byte) 0x55, (byte) config.I2CLCDAddr, outData, 2 ) )
                retVal = 0;

            //Magnetometer - update azimuth
            outString  = domePort.Read( 0x55, config.I2CMagnetometerAddress, outData, 2 );
            
            //delay here if poss - maybe a 'sleep(500)' 
        }  
          
          //Check we have landed.
        if(( target - azimuth ) < (int) positioningPrecision )
        {
            domeState = DomeStates.STOPPED;   
            status = true;
        }
        else 
        {
            logger.LogMessage(this.GetType().ToString(), "Failed to reach requested dome azimuth: " + target );

        }

        return status;
      }