コード例 #1
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::endDTD()
{
	poco_assert (_inDTD);
	if (_inInternalDTD)
	{
		writeNewLine();
		writeMarkup("]");
		_inInternalDTD = false;
	}
	writeMarkup(">");
	writeNewLine();
	_inDTD = false;
}
コード例 #2
0
ファイル: parser.c プロジェクト: WCP52/gpha
/**
 * Process command
 * @param context
 */
static void processCommand(scpi_t * context) {
    const scpi_command_t * cmd = context->paramlist.cmd;

    context->cmd_error = FALSE;
    context->output_count = 0;
    context->input_count = 0;

    SCPI_DEBUG_COMMAND(context);
    /* if callback exists - call command callback */
    if (cmd->callback != NULL) {
        if ((cmd->callback(context) != SCPI_RES_OK) && !context->cmd_error) {
            SCPI_ErrorPush(context, SCPI_ERROR_EXECUTION_ERROR);
        }
    }

    /* conditionaly write new line */
    writeNewLine(context);

    /* skip all whitespaces */
    paramSkipWhitespace(context);

    /* set error if command callback did not read all parameters */
    if (context->paramlist.length != 0 && !context->cmd_error) {
        SCPI_ErrorPush(context, SCPI_ERROR_PARAMETER_NOT_ALLOWED);
    }
}
コード例 #3
0
ファイル: AlDatabase.cpp プロジェクト: panicsteve/dynee5
void AlDatabase::write(const char *key, bool value)
{
  writeIndent();
  writeKey(key);
  if (value) fputc('1', pFile); else fputc('0', pFile);
  writeNewLine();
}
コード例 #4
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId)
{
	if (!_inDTD) throw XMLException("Notation declaration not within DTD");
	if (!_inInternalDTD)
	{
		writeMarkup(" [");
		_inInternalDTD = true;
	}
	if (_options & PRETTY_PRINT)
	{
		writeNewLine();
		writeMarkup(_indent);
	}
	writeMarkup("<!NOTATION ");
	writeXML(name);
	if (systemId && !systemId->empty())
	{
		writeMarkup(" SYSTEM \"");
		writeXML(*systemId);
		writeMarkup("\"");
	}
	if (publicId && !publicId->empty())
	{
		writeMarkup(" PUBLIC \"");
		writeXML(*publicId);
		writeMarkup("\"");
	}
	writeMarkup(">");
}
コード例 #5
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName)
{
	if (!_inDTD) throw XMLException("Entity declaration not within DTD");
	if (!_inInternalDTD)
	{
		writeMarkup(" [");
		_inInternalDTD = true;
	}
	if (_options & PRETTY_PRINT)
	{
		writeNewLine();
		writeMarkup(_indent);
	}
	writeMarkup("<!ENTITY ");
	writeXML(name);
	if (!systemId.empty())
	{
		writeMarkup(" SYSTEM \"");
		writeXML(systemId);
		writeMarkup("\"");
	}
	if (publicId && !publicId->empty())
	{
		writeMarkup(" PUBLIC \"");
		writeXML(*publicId);
		writeMarkup("\"");
	}
	if (!notationName.empty())
	{
		writeMarkup(" NDATA ");
		writeXML(notationName);
	}
	writeMarkup(">");
}
コード例 #6
0
ファイル: AlDatabase.cpp プロジェクト: panicsteve/dynee5
void AlDatabase::write(const char *key, int value)
{
  writeIndent();
  writeKey(key);
  fprintf(pFile, "%d", value);
  writeNewLine();
}
コード例 #7
0
ファイル: AlDatabase.cpp プロジェクト: panicsteve/dynee5
void AlDatabase::writeHex(const char *key, unsigned int value)
{
  writeIndent();
  writeKey(key);
  fprintf(pFile, "0x%08X", value);
  writeNewLine();
}
コード例 #8
0
ファイル: AlDatabase.cpp プロジェクト: panicsteve/dynee5
void AlDatabase::write(const char *key, const char *value)
{
  writeIndent();
  writeKey(key);
  write(value);
  writeNewLine();
}
コード例 #9
0
ファイル: AlDatabase.cpp プロジェクト: panicsteve/dynee5
void AlDatabase::writeBlockEnd()
{
  pIndent--;
  writeIndent();
  write("end");
  writeNewLine();
}
コード例 #10
0
ファイル: sonar.c プロジェクト: duralakun/minorGems
int fireSonarUnit( char inUnit ) {
	putchar( 'R' );
	putchar( 'T' );
	putchar( ' ' );
	putchar( '0' );
	putchar( '0' );
	putchar( '0' );
	
	// read the echo
	//skipBytes( 6 );

	// write the ASCII hex equivalent of inUnit
	putchar( convertIntToASCIIHex( inUnit ) );

	// read the echo
	//skipBytes( 1 );

	// add a delay here to allow the echos to come back for the
	// above... we're not sure how many to wait for, but
	// we can wait as long as we want here without violating the protocol

	// 20 ms should be long enough
	delay_ms( 20 );
	
	writeNewLine();

	// skip the echoed newline
	skipBytes( 2 );
	
	// thus to fire unit 10, we will be sending:
	// "RT 000A" followed by a new line

	// read the response value
	return readSerialASCIIHex();
	}
コード例 #11
0
ファイル: sonar.c プロジェクト: duralakun/minorGems
void waitForPrompt() {
	//writeNewLine();
	//writeNewLine();
	//writeNewLine();
	delay_ms( 20 );
	writeNewLine();
	waitForByte( '*' );
	}
コード例 #12
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::prettyPrint() const
{
	if ((_options & PRETTY_PRINT) && !_contentWritten)
	{
		writeNewLine();
		writeIndent();
	}
}
コード例 #13
0
ファイル: AlDatabase.cpp プロジェクト: panicsteve/dynee5
void AlDatabase::writeBlockBegin(const char *name)
{
  writeIndent();
  writeKey("begin");
  write(name);
  pIndent++;
  writeNewLine();
}
コード例 #14
0
ファイル: parser.c プロジェクト: RedPitaya/scpi-parser
/**
 * Parse one command line
 * @param context
 * @param data - complete command line
 * @param len - command line length
 * @return 1 if the last evaluated command was found
 */
int SCPI_Parse(scpi_t * context, char * data, int len) {
    int result = 0;
    scpi_parser_state_t * state;
    int r;
    scpi_token_t cmd_prev = {SCPI_TOKEN_UNKNOWN, NULL, 0};

    if (context == NULL) {
        return -1;
    }

    state = &context->parser_state;
    context->output_count = 0;

    while (1) {
        result = 0;

        r = scpiParser_detectProgramMessageUnit(state, data, len);

        if (state->programHeader.type == SCPI_TOKEN_INVALID) {
            SCPI_ErrorPush(context, SCPI_ERROR_INVALID_CHARACTER);
        } else if (state->programHeader.len > 0) {

            composeCompoundCommand(&cmd_prev, &state->programHeader);

            if (findCommandHeader(context, state->programHeader.ptr, state->programHeader.len)) {

                context->param_list.lex_state.buffer = state->programData.ptr;
                context->param_list.lex_state.pos = context->param_list.lex_state.buffer;
                context->param_list.lex_state.len = state->programData.len;
                context->param_list.cmd_raw.data = state->programHeader.ptr;
                context->param_list.cmd_raw.position = 0;
                context->param_list.cmd_raw.length = state->programHeader.len;

                processCommand(context);

                result = 1;
                cmd_prev = state->programHeader;
            } else {
                SCPI_ErrorPush(context, SCPI_ERROR_UNDEFINED_HEADER);
            }
        }

        if (r < len) {
            data += r;
            len -= r;
        } else {
            break;
        }

    }

    /* conditionaly write new line */
    writeNewLine(context);

    return result;
}
コード例 #15
0
ファイル: sonar.c プロジェクト: duralakun/minorGems
void setInitialBlanking() {
	// set a blanking time that was found to work by experiment
	putchar( 'I' );
	putchar( 'B' );
	putchar( ' ' );
	putchar( '0' );
	putchar( '0' );
	putchar( 'C' );
	putchar( '8' );
	
	writeNewLine();
	}
コード例 #16
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::writeXMLDeclaration()
{
	writeMarkup("<?xml version=\"1.0\"");
	if (!_encoding.empty())
	{
		writeMarkup(" encoding=\"");
		writeMarkup(_encoding);
		writeMarkup("\"");
	}
	writeMarkup("?>");
	writeNewLine();
}
コード例 #17
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::processingInstruction(const XMLString& target, const XMLString& data)
{
	if (_unclosedStartTag) closeStartTag();
	prettyPrint();
	writeMarkup("<?");
	writeXML(target);
	if (!data.empty())
	{
		writeMarkup(MARKUP_SPACE);
		writeXML(data);
	}
	writeMarkup("?>");
	if (_depth == 0)
		writeNewLine();
}
コード例 #18
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::endElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname)
{
	if (_depth < 1)
		throw XMLException("No unclosed tag");

	if (!_elementStack.back().equalsWeakly(qname, namespaceURI, localName))
		throw XMLException("End tag does not match start tag", nameToString(localName, qname));

	_elementStack.pop_back();
	--_depth;
	if (!_unclosedStartTag) prettyPrint();
	writeEndElement(namespaceURI, localName, qname);
	_contentWritten = false;
	if (_depth == 0)
		writeNewLine();
}
コード例 #19
0
ファイル: sonar.c プロジェクト: duralakun/minorGems
void setPower( char inPowerOn ) {
	// output the same command header in either case
	putchar( 'C' );
	putchar( 'P' );
	putchar( ' ' );
	putchar( '0' );

	if( inPowerOn ) {
		// turn power on to chain pair A
		putchar( 'F' );
		}
	else {
		// turn power off to chain pair A
		putchar( '0' );
		}

	// read the echo
	//skipBytes( 5 );
	
	writeNewLine();
	}
コード例 #20
0
ファイル: XMLWriter.cpp プロジェクト: BrianHoldsworth/Poco
void XMLWriter::writeAttributes(const AttributeMap& attributeMap)
{
	for (AttributeMap::const_iterator it = attributeMap.begin(); it != attributeMap.end(); ++it)
	{
		if ((_options & PRETTY_PRINT) && (_options & PRETTY_PRINT_ATTRIBUTES))
		{
			writeNewLine();
			writeIndent(_depth + 1);
		}
		else
		{
			writeMarkup(MARKUP_SPACE);
		}
		writeXML(it->first);
		writeMarkup(MARKUP_EQQUOT);
		for (XMLString::const_iterator itc = it->second.begin(); itc != it->second.end(); ++itc)
		{
			XMLChar c = *itc;
			switch (c)
			{
			case '"':  writeMarkup(MARKUP_QUOTENC); break;
			case '\'': writeMarkup(MARKUP_APOSENC); break;
			case '&':  writeMarkup(MARKUP_AMPENC); break;
			case '<':  writeMarkup(MARKUP_LTENC); break;
			case '>':  writeMarkup(MARKUP_GTENC); break;
			case '\t': writeMarkup(MARKUP_TABENC); break;
			case '\r': writeMarkup(MARKUP_CRENC); break;
			case '\n': writeMarkup(MARKUP_LFENC); break;
			default:
				if (c >= 0 && c < 32)
					throw XMLException("Invalid character token.");
				else 
					writeXML(c);
			}
		}
		writeMarkup(MARKUP_QUOT);
	}
}
コード例 #21
0
	bool Generator::processText (const Byte *string, bool willReachEndOfParagraph)
	{
		//
		// Look out for characters in the string and emit signals as appropriate:
		//
		//	1	pageNumber
		//	10	newLine
		//	13	carriageReturn
		//	12	pageBreak
		//	31	optionalHyphen
		//	?	text
		//

		const int outBufferMaxLen = 1024;
		Byte outBuffer [outBufferMaxLen];
		DWord outBufferLen = 0;

		for (; *string; string++)
		{
			// buffer full?
			if (outBufferLen >= outBufferMaxLen - 1)
			{
				// flush
				outBuffer [outBufferMaxLen - 1] = '\0';
				if (!writeText (outBuffer)) return false;
				outBufferLen = 0;
			}
		
			switch (*string)
			{
			// write text, generate signals for special characters, write more text...
			case 1:		// pageNumber anchor
			case 12:		// pageBreak (some silly document might have this in the middle of a paragraph!)
			case 13:
			case 10:		// newLine (some silly document _does_ have a newline in the middle of a paragraph!)
			case 31:    // optionalHyphen (aka "soft hyphen" an invisible hyphen, unless at end of line)
				// output text before this character
				if (outBufferLen)
				{
					outBuffer [outBufferLen] = 0;	// null terminate
					if (!writeText (outBuffer)) return false;
					outBufferLen = 0;
				}

				// generate signal
				switch (*string)
				{
				case 1:	if (!writePageNumber ()) return false;	break;
				case 12:	if (!writePageBreak ()) return false;	break;
				case 10:	if (!writeNewLine (willReachEndOfParagraph && string [1] == 0)) return false;	break;
				case 13:	if (!writeCarriageReturn ()) return false;	break;
				case 31: if (!writeOptionalHyphen ()) return false; break;
				}

				break;

			// normal text character
			default:
				outBuffer [outBufferLen++] = *string;
				break;
			}	// switch (*string)	{
		}	// for (; *string; string++)	{

		// flush
		if (outBufferLen)
		{
			outBuffer [outBufferLen] = 0;
			if (!writeText (outBuffer)) return false;
		}

		return true;
	}
コード例 #22
0
ファイル: sonar.c プロジェクト: duralakun/minorGems
/**
 * Main function.
 */
void main( void ) {

	// set B0, B1, and B2 to output
	set_bit( STATUS, RP0 );

	clear_bit( TRISB, 0 );
	clear_bit( TRISB, 1 );
	clear_bit( TRISB, 2 );
	
	clear_bit( STATUS, RP0 );

	
	serialSetup();
	
	// testing serial
	/*while( 1 ) {
		setBufferSize( 23 );
		writeBuffer( "Testing Testing Testing" );
		writeNewLine();
		}
	*/
	
	//writeNewLine();
	//waitForPrompt();
	delay_ms( 100 );

	writeNewLine();
	delay_ms( 20 );
	writeNewLine();
	delay_ms( 20 );
	writeNewLine();
	delay_ms( 20 );

	// turn the power on
	setPower( 1 );

	// wait for one secont for the power to come up
	delay_s( 1 );

	setInitialBlanking();
	delay_ms( 20 );
	
	while( 1 ) {
		tooClose = 0;
		tooCloseLeft = 0;
		tooCloseRight = 0;

		// for each group of units
		for( groupIndex = 0; groupIndex < numGroups; groupIndex++ ) {

			// for each unit in this group
			for( inGroupIndex = 0;
				 inGroupIndex < numInGroup; inGroupIndex++ ) {

				unitIndex = groupIndex * numInGroup + inGroupIndex;

				echoTime = fireSonarUnit( unitIndex + 1 );

				if( ( echoTime != 0 ) && ( echoTime < minEchoTime ) ) {
					if( groupIndex == 0 ) {
						tooCloseLeft = 1;
						}
					else {
						tooCloseRight = 1;
						}
					}
				}
			}

		tooClose = tooCloseLeft || tooCloseRight;
	
		if( tooClose ) {
			set_bit( PORTB, 0 );
			}
		else {
			clear_bit( PORTB, 0 );
			}
		
		if( tooCloseLeft ) {
			set_bit( PORTB, 1 );
			}
		else {
			clear_bit( PORTB, 1 );
			}

		if( tooCloseRight ) {
			set_bit( PORTB, 2 );
			}
		else {
			clear_bit( PORTB, 2 );
			}
		
		}
	
	}