Exemplo n.º 1
0
bool FilterWheel::LoadFromRegistry(std::string strSerialNumber, std::string strWheelName, int iNumFiltersExpected )
{
	QSI_Registry reg;

	std::string strValue;
	std::string strKeyPath = KEY_QSI + strSerialNumber;
	strKeyPath = strKeyPath + "/FilterWheels/";
	strKeyPath = strKeyPath + strWheelName;

	Name = strWheelName;
	Filters.clear();
	m_iNumFilters = 0;

	// open registry key

	m_iNumFilters = reg.GetNumber(strKeyPath, SUBKEY_NumFilters, 0);

	if (m_iNumFilters == 0)
		return false;

	for (int i = 0; i < m_iNumFilters; i++)
	{
		Filter filter;

		std::string  strFilterNum;
		//strFilterNum.Format("%d", i+1);
		strFilterNum = StringOf(i+1);

		std::string  strFilterNameValue = SUBKEY_FilterName + strFilterNum;
		std::string  strName = reg.GetString( strKeyPath, strFilterNameValue, "Unnamed" );
		if (strName == "") strName = "Position " + StringOf(i+1); //strName.Format("Position %d", i+1);
			
		filter.Name = std::string( strName );

		std::string  strFilterOffsetValue = SUBKEY_FilterFocus + strFilterNum;
		filter.Offset = reg.GetNumber( strKeyPath, strFilterOffsetValue, 0 );

		std::string  strFilterTrimValue = SUBKEY_FilterTrim + strFilterNum;
		filter.Trim = reg.GetNumber( strKeyPath, strFilterTrimValue, 0 );

		this->Filters.push_back(filter);
	}

	// Now check to see if we need to expand the wheel size to match the camera's current wheel.
	if (iNumFiltersExpected > m_iNumFilters)
	{
		Filter filter;
		for (int i = m_iNumFilters; i < iNumFiltersExpected; i++)
		{
			AddFilter( filter );
		}
	}
	
	return true;
}
Exemplo n.º 2
0
    void AudioAsset::Load(const std::string &filename, bool streamFromDisk)
	{
        this->filename = filename;
        
        this->streamFromDisk = streamFromDisk;
        
        FILE *f;
        f = fopen(this->filename.c_str(),"rb");
        
        if (!f){
            Debug::Log("Asset " + filename + " was not found and cannot be loaded."); // ERROR
            return;
        }
        
        fseek(f,0,SEEK_END);
        size = ftell(f);
        fseek(f,0,SEEK_SET);
        
        if (!streamFromDisk){
            // Load to memory!
            dataBuffer = malloc(size);
            fread(dataBuffer,size,1,f);
            
            Debug::Log("Commited " + StringOf(size) + " bytes to memory for " + GetName());
        }
        
        fclose(f);
	}
Exemplo n.º 3
0
void FilterWheel::SaveToRegistry(std::string  strSerialNumber)
{
	QSI_Registry reg;
	std::string strValue;
	std::string strWheelName = this->Name;
	std::string strWheelNames = KEY_QSI  + strSerialNumber + "/FilterWheel/Names";
	reg.SetString(strWheelNames, Name.c_str(), "");

	std::string strKeyPath = KEY_QSI  + strSerialNumber + "/FilterWheels/" + this->Name.c_str();

	// Save filter count, no all position maybe named (below)
	reg.SetNumber(strKeyPath, SUBKEY_NumFilters, m_iNumFilters);

	for (int i = 0; i < m_iNumFilters; i++)
	{
		std::string strFilterNum;
		//strFilterNum.Format("%d", i+1);
		strFilterNum = StringOf(i+1);

		std::string strFilterNameValue = SUBKEY_FilterName + strFilterNum;
		strValue = this->Filters[i].Name.c_str();
		reg.SetString( strKeyPath, strFilterNameValue, strValue );

		std::string strFilterOffsetValue = SUBKEY_FilterFocus + strFilterNum;
		reg.SetNumber( strKeyPath, strFilterOffsetValue, this->Filters[i].Offset);

		std::string  strFilterTrimValue = SUBKEY_FilterTrim + strFilterNum;
		reg.SetNumber( strKeyPath, strFilterTrimValue, this->Filters[i].Trim);
	}
	return;
}
Exemplo n.º 4
0
 void ChannelStream::Check( std::string erat )
 {
     int error = alGetError();
     
     VERBOSE("Checking " + erat);
         
     if(error != AL_NO_ERROR)
         Debug::Log("OpenAL Error on " + erat + ": " + StringOf(error) + " (" + GetALErrorString(error) + ")");
         //printf("OpenAL Error: %d\n",error);
 }
Exemplo n.º 5
0
    void ChannelStream::Empty()
    {
        int queued = 0;
        
        VERBOSE("Empty");
        
        alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
        Check("emptystart");
        
        while(queued--)
        {
            ALuint buffer;
            
            alSourceUnqueueBuffers(source, 1, &buffer);

            Check("empty " + StringOf(queued+1));
        }
    }
Exemplo n.º 6
0
#define NEED_NCURSES_CH_T
#include <curses.priv.h>

#include <tic.h>
#include <ctype.h>

MODULE_ID("$Id: visbuf.c,v 1.36 2010/05/01 20:44:34 tom Exp $")

#define NUM_VISBUFS 4

#define NormalLen(len) (size_t) (((size_t)(len) + 1) * 4)
#define WideLen(len)   (size_t) (((size_t)(len) + 1) * 4 * MB_CUR_MAX)

#ifdef TRACE
static const char d_quote[] = StringOf(D_QUOTE);
static const char l_brace[] = StringOf(L_BRACE);
static const char r_brace[] = StringOf(R_BRACE);
#endif

static char *
_nc_vischar(char *tp, unsigned c)
{
    if (c == '"' || c == '\\') {
	*tp++ = '\\';
	*tp++ = (char) c;
    } else if (is7bits(c) && (isgraph(c) || c == ' ')) {
	*tp++ = (char) c;
    } else if (c == '\n') {
	*tp++ = '\\';
	*tp++ = 'n';
Exemplo n.º 7
0
 *	lib_traceatr.c - Tracing/Debugging routines (attributes)
 */

#include <curses.priv.h>

#ifndef CUR
#define CUR SP_TERMTYPE
#endif

MODULE_ID("$Id: lib_traceatr.c,v 1.68 2009/12/12 21:37:37 tom Exp $")

#define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))

#ifdef TRACE

static const char l_brace[] = StringOf(L_BRACE);
static const char r_brace[] = StringOf(R_BRACE);

#ifndef USE_TERMLIB

#define my_buffer _nc_globals.traceatr_color_buf
#define my_select _nc_globals.traceatr_color_sel
#define my_cached _nc_globals.traceatr_color_last

static char *
color_of(int c)
{
    if (c != my_cached) {
	my_cached = c;
	my_select = !my_select;
	if (c == COLOR_DEFAULT)
Exemplo n.º 8
0
int S_SQLAccessFactory::handleQuery()
{
  // get what command is requested
  MDInterpreter interpreter;
  MDInterpreter::CommandToken cmdToken = interpreter.parseCommand (query);

  // check whether the command is supported
  int ret = checkInvalidCommand(soap ,cmdToken, _ACCESS_FACTORY);
  if ( ret != SOAP_OK ) return ret;

  ret = checkDBConnection(soap, helper);
  if (ret != SOAP_OK ) return ret;

  ret = checkTooManyIndirectServiceForUser();
  if ( ret != SOAP_OK ) return ret;
  
  Statement statement(*(helper->dbConn->dbServer->dbConn), debug);

  // initialze prop
  EntryProps prop;
  prop.directoryTable = "SQLRespone";
  prop.indexTable = "masterindex";
  prop.flags = 0;

  std::string table;

  int error = 0 ;
  do {
    if( statement.beginTransaction()) { error = 1; break; }

    // parse requested query
    std::string translatedQuery;
    helper->dbConn->dbServer->sqlParse(query, cmdToken, translatedQuery);

    int isPlain = helper->dbConn->dbServer->asp->isPlain ;

    DBResult dbResult;
    std::vector<std::string> results;
    helper->dbConn->getResult(dbResult,results);
    if (dbResult.errorCode != 0) {   // error
      return returnErrorDBResult(soap, dbResult);
    }

    std::stringstream query_s ;

    // add an directory entry into masterindex
    prop.id = helper->dbConn->dbServer->addDirectoryToIndex("SQLResponse"
                , prop, statement);
    if ( prop.id < 0 ) { error = 1; break; }

    switch(cmdToken) {
      case MDInterpreter::cSELECT:
      {
        table = "responses" + StringOf(prop.id) + "_"
                 + StringOf(helper->dbConn->dbServer->asp->numColumn) ;
        query_s << "CREATE VIEW " << table << " AS " << translatedQuery << ";";
        break;
      }
      case MDInterpreter::cUPDATE:
      case MDInterpreter::cDELETE:
      case MDInterpreter::cINSERT:
      {
        query_s <<  translatedQuery << ";";
        table = "responseu" + StringOf(prop.id) + "_"  ;
        break;
      }
      default:
        ERRLOG("Unsupported command token: " << cmdToken);  
    }
    DMESG("Translated query : " <<  query_s.str() << std::endl);

    if( statement.exec(query_s.str())) { error = 1; break; }

    switch(cmdToken) {
      case MDInterpreter::cUPDATE:
      case MDInterpreter::cDELETE:
      case MDInterpreter::cINSERT:
      {
        table += StringOf(statement.numRows() ) ;
        break;
      }
      default:
        ERRLOG("Unsupported command token: " << cmdToken);      
    }

    dran = "/SQLResponse/" + table ;
    prop.flags = EPT_DIR ;
    if( isPlain ) prop.flags += EP_PLAIN;
    prop.id = commitDirectoryToIndex2(prop, "masterindex", table, statement);
  } while ( false ) ;


  if (error)  {
    return generateSoapError(soap, "Invalid Expression Fault" , NULL
            , SOAP_TYPE_wsdai__InvalidExpressionFaultType );
  }

  if ( helper->dbConn->dbServer->finalizeDirectoryToIndex(prop.id, statement) < 0) {
    return generateSoapError(soap, "Invalid Expression Fault" , NULL
                , SOAP_TYPE_wsdai__InvalidExpressionFaultType );
  }

  statement.commitTransaction();

  return SOAP_OK;
}