bool INDIDeviceControllerInstance::ExecuteGlobal() { Console console; Exception::DisableGUIOutput(); INDIClient* indi = INDIClient::TheClient(); try { if ( p_serverConnect ) { if ( indi == nullptr ) { indi = INDIClient::NewClient( p_serverHostName.ToUTF8(), p_serverPort ); if ( p_verbosity > 0 ) { console.NoteLn( "<end><cbr>INDI Control Client --- (C) Klaus Kretzschmar, 2014-2016" ); console.Flush(); } } indi->SetVerbosity( p_verbosity ); if ( !indi->IsServerConnected() ) { indi->connectServer(); if ( !indi->IsServerConnected() ) throw Error( "INDIDeviceControllerInstance: Failure to connect to INDI server " + p_serverHostName + ", port=" + String( p_serverPort ) ); if ( p_verbosity > 0 ) { console.NoteLn( "* Successfully connected to INDI server " + p_serverHostName + ", port=" + String( p_serverPort ) ); console.Flush(); } } if ( !p_serverCommand.IsEmpty() ) { console.EnableAbort(); if ( p_serverCommand == "GET" ) { o_getCommandResult.Clear(); String device( PropertyUtils::Device( p_getCommandParameters ) ); String property( PropertyUtils::Property( p_getCommandParameters ) ); String element( PropertyUtils::Element( p_getCommandParameters ) ); INDIPropertyListItem item; if ( !indi->GetPropertyItem( device, property, element, item ) ) throw Error( "INDIDeviceControllerInstance: Could not get value of property '" + String( p_getCommandParameters ) + "'" ); o_getCommandResult = item.PropertyValue; if ( p_verbosity > 1 ) console.WriteLn( "<end><cbr>Device=" + device + ", Property=" + property + ", Element=" + element + ", Value=" + o_getCommandResult ); } else if ( p_serverCommand == "SET" ) { for ( auto newProperty : p_newProperties ) { GetNewPropertyListItemParametersFromKey( newProperty ); if ( !indi->SendNewPropertyItem( newProperty, false/*async*/ ) ) throw Error( "INDIDeviceControllerInstance: Failure to send new property values." ); } p_newProperties.Clear(); } else if ( p_serverCommand == "SET_ASYNC" ) { for ( auto newProperty : p_newProperties ) { GetNewPropertyListItemParametersFromKey( newProperty ); if ( !indi->SendNewPropertyItem( newProperty, true/*async*/ ) ) throw Error( "INDIDeviceControllerInstance: Failure to send new property values (asynchronous)." ); } p_newProperties.Clear(); } else throw Error( "INDIDeviceControllerInstance: Unknown command '" + p_serverCommand + "'" ); console.Flush(); } AcquireINDIClientProperties(); } else { if ( indi != nullptr ) { if ( indi->IsServerConnected() ) { AcquireINDIClientProperties(); indi->SetVerbosity( p_verbosity ); indi->disconnectServer(); if ( p_verbosity > 0 ) console.NoteLn( "* Disconnected from INDI server " + p_serverHostName + ", port=" + String( p_serverPort ) ); } INDIClient::DestroyClient(); } } return true; } catch ( const Exception& x ) { if ( p_verbosity > 0 ) x.Show(); return false; } catch ( ... ) { throw; } }