/******************************************************************************* * ALMA - Atacama Large Millimiter Array * Copyright (c) European Southern Observatory, 2012 * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * "@(#) $Id: CERNASIMessage.cpp,v 1.1 2012/04/05 13:21:00 acaproni Exp $" * * who when what * -------- -------- ---------------------------------------------- * acaproni 2012-04-02 created */ #include "CERNASIMessage.h" #include #include #include #include "utilConstants.h" using laserSource::CERNASIMessage; CERNASIMessage::CERNASIMessage(acsalarm::ASIMessage& message): m_message(message) { } std::string CERNASIMessage::toXML() { std::stringstream ret; // create the XML header // e.g. ret << XML_HEADER << std::endl; // create the opening tag for the ASI-Message element // e.g. ret <ALARM_SYSTEM_SOURCES ret << SPACE << SPACE<NEWBIE.AOC.NRAO.EDU ret << SPACE << SPACE< ret << timestampToXML( &m_message.getSourceTimestamp(), SOURCE_TIMESTAMP_ELEMENT_NAME, 3); // create the opening tag for the fault-states element // e.g. ret << SPACE << SPACE< // ACTIVE // // // // // // // std::vector& faultStates = m_message.getFaultStates(); for(unsigned int i = 0; i < faultStates.size(); i++) { ret << faultStateToXML(&faultStates[i],6); } // create the closing tag for the fault-states element // e.g. ret << SPACE << SPACE< ret << LESS_THAN_SIGN<toISOFormat(); ret< for(int x = 0; x < amountToIndent; x++) { ret << SPACE; } ret << LESS_THAN_SIGN<getFamily()<getMember()<getCode()<TERMINATE ret<< LESS_THAN_SIGN<getDescriptor(); ret<< LESS_THAN_SIGN< // // // // acsalarm::Properties userProperties = state->getUserProperties(); if(userProperties.getSize()>0) { ret<< propertiesToXML(userProperties,amountToIndent+3); } // generate the user timestamp element // e.g. ret<getUserTimestamp(), std::string(USER_TIMESTAMP_ELEMENT_NAME), amountToIndent+3); // generate the fault-state closing element // e.g. for(int x = 0; x < amountToIndent; x++) { ret< > propNames=props.propertyNames(); int propNamesSize = propNames->size(); if(propNamesSize>0) { // Generate the user properties opening element tag // e.g. for(int x = 0; x < amountToIndent; x++) { ret< for (int t=0; tat(t); std::string propValue=props.getProperty(propName); for(int x = 0; x < amountToIndent + 3; x++) { ret< for(int x = 0; x < amountToIndent; x++) { ret<