void SharedJelloServer::sendServerUpdate(void)
	{
	/* Lock the client state list: */
	Threads::Mutex::Lock clientStateListLock(clientStateListMutex);
	
	/* Go through all client states: */
	for(ClientStateList::iterator cslIt=clientStates.begin();cslIt!=clientStates.end();++cslIt)
		{
		ClientState* cs=*cslIt;
		if(cs->connected)
			{
			try
				{
				Threads::Mutex::Lock pipeLock(cs->pipeMutex);
				
				if(cs->parameterVersion!=parameterVersion)
					{
					/* Send a parameter update message: */
					writeMessage(SERVER_PARAMUPDATE,*cs->pipe);
					cs->pipe->write<Scalar>(crystal.getAtomMass());
					cs->pipe->write<Scalar>(crystal.getAttenuation());
					cs->pipe->write<Scalar>(crystal.getGravity());
					cs->parameterVersion=parameterVersion;
					}
				
				/* Send a server update message: */
				writeMessage(SERVER_UPDATE,*cs->pipe);
				
				/* Send the crystal's state: */
				crystal.writeAtomStates(*cs->pipe);
				
				cs->pipe->flush();
				}
			catch(...)
				{
				/* Ignore write errors; let the client communication thread handle them */
				}
			}
		}
	}
Exemple #2
0
void CasparDevice::playVideo(int channel, int videolayer, const QString& name, const QString &transition, int duration,
                             const QString& easing, const QString& direction, int seek, int length, bool loop, bool useAuto)
{
    if (useAuto)
        loadVideo(channel, videolayer, name, transition, duration, easing, direction, seek, length, loop, false, useAuto);
    else
        writeMessage(QString("PLAY %1-%2 \"%3\" %4 %5 %6 %7 %8 %9 %10")
                     .arg(channel).arg(videolayer).arg(name).arg(transition).arg(duration).arg(easing)
                     .arg(direction)
                     .arg((seek > 0) ? QString("SEEK %1").arg(seek) : "")
                     .arg((length > 0) ? QString("LENGTH %1").arg(length) : "")
                     .arg((loop == true) ? "LOOP" : ""));
}
Exemple #3
0
    void uiNameChanged(const char* const uiName) override
    {
        CARLA_SAFE_ASSERT_RETURN(uiName != nullptr && uiName[0] != '\0',);

        const CarlaMutexLocker cml(getPipeLock());

        if (! writeMessage("uiTitle\n", 8))
            return;
        if (! writeAndFixMessage(uiName))
            return;

        flushMessages();
    }
void SIPTransaction::sendAckFor2xx(
  const SIPMessage::Ptr& pAck,
  const OSS::IPAddress& dialogTarget)
{
  OSS::mutex_lock lock(_mutex);
  if (!_dialogTarget.isValid())
    _dialogTarget = dialogTarget;

  if (SIPXOR::isEnabled() && _isXOREncrypted)
  {
    pAck->setProperty("xor", "1");
  }

  if (_transport->isReliableTransport())
  {
    writeMessage(pAck);
  }
  else
  {
    writeMessage(pAck, dialogTarget);
  }
}
Exemple #5
0
void ChatWindow::conNameChanged(QString name)
{
  if( m_conName == name ||( name == "" 
                            && m_conName == QString(m_chatConnection->getIp()+":"+QString::number(m_chatConnection->getClientPort())) ) ){
    return;
  }
  if( name == ""  ){
    name = QString(m_chatConnection->getIp()+":"+QString::number(m_chatConnection->getClientPort()));
  }
  writeMessage(StatusMess, QString("%1 changed name to %2").arg(m_conName, name) );
  m_conName = name;
  setWindowTitle(QString("Chat: %1 - KLan").arg(m_conName));
}
Exemple #6
0
void TextOutputWidget::showSuccessMessage(const QString &message)
{
  QColor previousBackgroundColor = m_output->textBackgroundColor();
  QColor previousColor = m_output->textColor();

  m_output->setTextBackgroundColor(m_succesBackgroundColor);
  m_output->setTextColor(m_succesTextColor);

  writeMessage(message);

  m_output->setTextBackgroundColor(previousBackgroundColor);
  m_output->setTextColor(previousColor);
}
Exemple #7
0
void Messages::actionCB()
{
  if (entry.empty()) return;

  history.push_back(entry);  // save in history

  if (entry[0] == '!') performRequest(entry);
  else {
    writeMessage("chat", g.pref.user, entry.c_str());  // display in message zone
    User::userWriting(entry.c_str());		       // send to World Management
  }
  entry = ""; // clear textfield
}
Exemple #8
0
void CasparDevice::loadVideo(int channel, int videolayer, const QString& name, const QString& transition, int duration,
                             const QString& easing, const QString& direction, int seek, int length, bool loop,
                             bool freezeOnLoad, bool useAuto)
{
    writeMessage(QString("%1 %2-%3 \"%4\" %5 %6 %7 %8 %9 %10 %11 %12")
                 .arg((freezeOnLoad == true) ? "LOAD" : "LOADBG")
                 .arg(channel).arg(videolayer).arg(name).arg(transition).arg(duration).arg(easing)
                 .arg(direction)
                 .arg((seek > 0) ? QString("SEEK %1").arg(seek) : "")
                 .arg((length > 0) ? QString("LENGTH %1").arg(length) : "")
                 .arg((loop == true) ? "LOOP" : "")
                 .arg((useAuto == true) ? "AUTO" : ""));
}
/**
 * Returns 1 (true) if the font object type 1 passed as a parameter exists
 * and it is deleted from the manager successfully.
 * @param pFo						Pointer to font object type 1
 */
bool IND_FontManager::remove(IND_Font  *pFo) {
	g_debug->header("Freeing font", DebugApi::LogHeaderBegin);

	if (!_ok) {
		writeMessage();
		return 0;
	}

	// Search object
	bool mIs = 0;
	list <IND_Font *>::iterator mFontListIter;
	for (mFontListIter  = _listFonts->begin();
	        mFontListIter != _listFonts->end();
	        mFontListIter++) {
		if ((*mFontListIter) == pFo) {
			mIs = 1;
			break;
		}
	}

	// Not found
	if (!mIs) {
		writeMessage();
		return 0;
	}

	// ----- Free object -----

	g_debug->header("File name:", DebugApi::LogHeaderInfo);
	g_debug->dataChar(pFo->getFileName(), 1);
    
	// Quit from list
	delFromlist(pFo);

	g_debug->header("Ok", DebugApi::LogHeaderEnd);

	return 1;
}
Exemple #10
0
void Server::sendJob(QTcpSocket* socket)
{
  // mutexes
  if(cur_y >= vres) return;
  qDebug() << "Send Job";

  WhiteNetwork::Job job = { cur_y, cur_y + step };
  cur_y += step;

  QByteArray data;
  QDataStream ds(&data, QIODevice::ReadWrite);
  ds << WhiteNetwork::Message::Job << job;
  writeMessage(socket, data);
}
void withoutDefaultGood(Message mess){

  switch(mess){
    case Message::information:
      writeMessage();
      break;
    case Message:: warning:
      writeWarning();
      break;
    default:
      // nothing can be done
      break;
  }
  
}
Exemple #12
0
void Writer::recordMessage(const protocol::MessagePtr &msg)
{
	if(msg->isRecordable()) {
		const qint64 now = QDateTime::currentMSecsSinceEpoch();

		if(m_minInterval>0) {
			const qint64 interval = now - m_interval;
			if(interval >= m_minInterval) {
				writeMessage(protocol::Interval(0, qMin(qint64(0xffff), interval)));
			}
			m_interval = now;
		}

		if(m_timestampInterval > 0) {
			const qint64 interval = now - m_lastTimestamp;
			if(interval >= m_timestampInterval) {
				writeMessage(protocol::Marker(0, QDateTime::currentDateTime().toString()));
				m_lastTimestamp = now;
			}
		}

		writeMessage(*msg);
	}
}
Exemple #13
0
void _MavlinkInterface::requestDataStream(uint8_t stream_id, int rate)
{
	mavlink_message_t message;
	mavlink_request_data_stream_t ds;
	ds.target_system = system_id;
	ds.target_component = autopilot_id;
	ds.req_stream_id = stream_id;
	ds.req_message_rate = rate;
	ds.start_stop = 1;
	mavlink_msg_request_data_stream_encode(system_id, companion_id, &message,&ds);

	writeMessage(message);

	return;
}
Exemple #14
0
int requestBroadcastMessage(uint8_t address[5], uint8_t broadcast_address[5], uint8_t messageIndex) {
    printk("running init!\n");
    uint8_t type = REQUESTBROADCAST;
    InitBroadcast msg;
    msg.messageId = type;
    msg.messageIndex = messageIndex;
    msg.length = 10;
    msg.uuid = CONFIG_HARDWARE_ID
    memcpy(msg.address, address, 5*sizeof(uint8_t));
    printk("Sending init message\n");
    printk("address %d\n", msg.address[1]);
    int writeReturn = writeMessage(msg, broadcast_address, msg.length);
    printk("sent broadcast\n");
    return writeReturn;
}
void withDefault(Message mess){

  switch(mess){
    case Message::information:
      writeMessage();
      break;
    case Message:: warning:
      writeWarning();
      break;
    default:
      writeUnexpected();
      break;
  }
  
}
Exemple #16
0
void MCentral::repaintGraph(QString name){
	#ifdef MYDEBUG
		qDebug() << "Startuje MCentral::repaintGraph("<<name<<")";
	#endif
	clearMessage(); 
	clearTmpDisp();
	if(name != ""){ //Nie wchodzi do ifa gdy zamykamy ostatni graf
		engine->setCurrentGraph(name); 
		tmpDisp(engine->graphToString());
		writeMessage(engine->dispResults());
	}
	#ifdef MYDEBUG
		qDebug() << "Konczy sie MCentral::repaintGraph("<<name<<")";
	#endif
}
Exemple #17
0
    void threadFunction(void)
    {
        for(uint16_t i = 0u; i < 10u; i++)
        {
            std::stringstream ss;
            int sensorValue = std::rand() % 1000u;
            ss << name() << " data is " << sensorValue << " : " <<
                         writeMessage("/actuator",
                                      reinterpret_cast<uint8_t*>(&sensorValue), sizeof(sensorValue),
                                      100u)
                                                                                       << std::endl;
            CLogger() << ss.str();
            CTiming::sleep_mS(100u);

        }
    }
Exemple #18
0
void RemovalOfNodes::visit(SgNode* node){
  // If the AST node doesn't have the attribute keep, then delete the node.
  if(!node->attribute.exists("keep")){
    SgStatement *stmt = isSgStatement(node);
    if(stmt!=NULL){
      //LowLevelRewrite::remove(stmt);
      MiddleLevelRewrite::remove(stmt); //Still removes #include-statments when removes global variables
#ifdef DEBUG_REMOVAL
      writeMessage(node);
#endif
     }
  }
  // free memory of the ast attribute...
  // else if(node->attribute.exists("keep")){
  //   node->attribute.remove("keep");
  //  }
}
Exemple #19
0
void _Mavlink::command_long_doSetMode(int mode)
{
	mavlink_message_t message;
	mavlink_command_long_t ds;

	ds.target_system = m_systemID;
	ds.target_component = m_targetComponentID;
	ds.command = MAV_CMD_DO_SET_MODE;
	ds.param1 = mode;
	mavlink_msg_command_long_encode(m_systemID, m_componentID, &message, &ds);

	writeMessage(message);

	LOG_I("<- COMMAND_LONG: MAV_CMD_DO_SET_MODE");

	return;
}
			/**
			 * @see Session::handleMessageRead( Message& aMessage)
			 */
			virtual void handleMessageRead( Message& aMessage)
			{
				// This is the place where any request message from a client should
				// be handled
				robot->handleRequest( aMessage);

				// We now just echo the message. In real life we would write our own
				// response to the request.
				writeMessage( aMessage);

				// This is part of the original application. If one wants a stop message
				// just leave this here. Otherwise think something up yourself.
				if (aMessage.getBody() == "stop")
				{
					CommunicationService::getCommunicationService().getIOService().stop();
				}
			}
Exemple #21
0
/**
 * Returns 1 (true) if the image object passed as a parameter
 * exists and is added successfully to the manager creating a new image cloning from a previous one.
 * @param pNewImage					Pointer to a new image object.
 * @param pOldImage					Pointer to the image that is to be cloned.
 */
bool IND_ImageManager::clone(IND_Image *pNewImage, IND_Image *pOldImage) {
	g_debug->header("Cloning Image", DebugApi::LogHeaderBegin);

	if (!_ok || !pNewImage || !pOldImage || !pOldImage->getFreeImageHandle()) {
		writeMessage();

		return 0;
	}

	// ----- Image creation using FreeImage -----

	// Clone the old image

	FIBITMAP* image = FreeImage_Clone(pOldImage->getFreeImageHandle());
	if (!image) {
		g_debug->header("Image could not be cloned", DebugApi::LogHeaderError);
		return 0;
	}
	
	// Attributes

	pNewImage->setWidth(pOldImage->getWidth());
	pNewImage->setHeight(pOldImage->getHeight());
	pNewImage->setBpp(pOldImage->getBpp());
	pNewImage->setBytespp(pOldImage->getBytespp());
	pNewImage->setFormatInt(pOldImage->getFormatInt());
	char ext [128];
	getExtensionFromName(pOldImage->getName(),ext);
	pNewImage->setExtension(ext);
	pNewImage->setPointer(FreeImage_GetBits(image));
	pNewImage->setName("Image cloned");
	pNewImage->setFreeImageHandle(image);

	// ----- Put the object into the manager -----

	addToList(pNewImage);

	// ----- g_debug -----

	g_debug->header("File name:", DebugApi::LogHeaderInfo);
	g_debug->dataChar(pOldImage->getName(), 1);
	g_debug->header("Image cloned", DebugApi::LogHeaderEnd);

	return 1;
}
Exemple #22
0
void GuiChat::processEvent(Event* event)
{
	if(event->hasProperty("CHAT"))
	{
		writeMessage(event);
	}
	if(event->hasProperty("Keyboard"))
	{
		if( (event->getProperty("Fonction").compare("ENTREE")) == 0 )
		{
			if(atoi(event->getProperty("Action").c_str()) == 1)
			{
				sendMessage();
			}
		}
	}

}
Exemple #23
0
void _Mavlink::requestDataStream(uint8_t stream_id, int rate)
{
	mavlink_message_t message;
	mavlink_request_data_stream_t ds;
	ds.target_system = m_systemID;
	ds.target_component = m_targetComponentID;
	ds.req_stream_id = stream_id;
	ds.req_message_rate = rate;
	ds.start_stop = 1;
	mavlink_msg_request_data_stream_encode(m_systemID, m_componentID, &message,
			&ds);

	writeMessage(message);

	LOG_I("<- REQUEST_DATA_STREAM");

	return;
}
void TeamMessageHandler::update(BHumanMessageOutputGenerator& outputGenerator)
{
  outputGenerator.theBHumanArbitraryMessage.queue.clear();

  outputGenerator.sendThisFrame =
#ifndef SITTING_TEST
#ifdef TARGET_ROBOT
    !(theMotionRequest.motion == MotionRequest::specialAction && theMotionRequest.specialActionRequest.specialAction == SpecialActionRequest::playDead) &&
    !(theMotionInfo.motion == MotionRequest::specialAction && theMotionInfo.specialActionRequest.specialAction == SpecialActionRequest::playDead) &&
#endif
#endif // !SITTING_TEST
    theFrameInfo.getTimeSince(timeLastSent) >= sendInterval;

  outputGenerator.generate = [this, &outputGenerator](RoboCup::SPLStandardMessage* const m)
  {
    generateMessage(outputGenerator);
    writeMessage(outputGenerator, m);
  };
}
void GrapheinClient::GrapheinTool::deleteCurvesCallback(Misc::CallbackData* cbData)
{
    if(client==0)
        return;

    /* Delete all local curves: */
    for(CurveMap::Iterator cIt=client->localCurves.begin(); !cIt.isFinished(); ++cIt)
        delete cIt->getDest();
    client->localCurves.clear();

    /* Send a curve deletion message: */
    {
        Threads::Mutex::Lock messageLock(client->messageMutex);
        writeMessage(DELETE_ALL_CURVES,client->message);
    }

    /* Deactivate the tool just in case: */
    active=false;
}
Exemple #26
0
/**
 * Returns 1 (true) if the image object passed as a parameter
 * exists and is added successfully to the manager creating a new procedural image.
 * By default, the new image is not initialized to any color, you should used the Clear()
 * method in order to assing a valid colour.
 * @param pNewImage					Pointer to a new image object.
 * @param pWidth					Width of the new image.
 * @param pHeight					Height of the new image.
 * @param pColorFormat				New image format. See ::IND_ColorFormat.
 */
bool IND_ImageManager::add(IND_Image *pNewImage, int pWidth, int pHeight, IND_ColorFormat pColorFormat) {
	g_debug->header("Creating Image", DebugApi::LogHeaderBegin);

	if (!_ok) {
		writeMessage();
		return 0;
	}

	// ----- Creating image using FreeImage -----

	int bpp = 2; //FIXME: this is very wrong, somehow we need to use the supplied "pColorFormat" instead.

	FIBITMAP* pImage = FreeImage_Allocate(pWidth, pHeight, bpp);
	if (!pImage) {
		g_debug->header("Image could not be created", DebugApi::LogHeaderError);
		return 0;
	}

	// Attributes
	pNewImage->setWidth(FreeImage_GetWidth(pImage));
	pNewImage->setHeight(FreeImage_GetHeight(pImage));
	IND_ColorFormat indFormat = FreeImageHelper::calculateINDFormat(pImage);
	pNewImage->setFormatInt(indFormat);
	pNewImage->setBpp(FreeImage_GetBPP(pImage));
	pNewImage->setBytespp(pNewImage->getBpp()/8);
	pNewImage->setPointer(FreeImage_GetBits(pImage));
	pNewImage->setFreeImageHandle(pImage);

	// Name
	char name[] = "Image Procedural";
	pNewImage->setName(name);

	// ----- Puts the object into the manager -----

	addToList(pNewImage);


	// ----- g_debug -----

	// TODO, add debugging here.......

	return 1;
}
Exemple #27
0
/**
 * Loads an image. Returns a pointer to a FIBITMAP if the path to the file is correct and if Indielib support the image format.
 * Otherwise null is returned.
 * @param pName						Pointer to name of the image file to load.
 */
FIBITMAP* IND_ImageManager::load(const char *pName) {
		g_debug->header("Loading Image", DebugApi::LogHeaderBegin);
	
	if(!pName) {
		g_debug->header("Invalid File name provided (null)",DebugApi::LogHeaderError);
		return NULL;
	}

	g_debug->header("File name:", DebugApi::LogHeaderInfo);
	g_debug->dataChar(pName, 1);

	if (!_ok) {
		writeMessage();
		return NULL;
	}

	// ----- checking file extension -----
	//TODO: Refactor this to use FreeImage getfileType
	char ext [128];
	getExtensionFromName(pName,ext);
	if (!checkExtImage(ext)){
		g_debug->header("Unknown extension", DebugApi::LogHeaderError);
		return NULL;
	}

	g_debug->header("Extension:", DebugApi::LogHeaderInfo);
	g_debug->dataChar(ext, 1);

	// ----- Load image -----
	FREE_IMAGE_FORMAT imgFormat =  FreeImage_GetFileType(pName, 0);
	if (FIF_UNKNOWN == imgFormat) {
		g_debug->header("Image not found", DebugApi::LogHeaderError);
		return NULL;
	}
	FIBITMAP* image = FreeImage_Load(imgFormat, pName, 0);
	if (!image) {
		g_debug->header("Image could not be loaded", DebugApi::LogHeaderError);
		return NULL;
	}

	return image;
}
Exemple #28
0
int _MavlinkInterface::toggleOffboardControl(bool bEnable)
{
	if(m_bControlling == bEnable)return -1;

	// Prepare command for off-board mode
	mavlink_command_long_t com;
	com.target_system = system_id;
	com.target_component = autopilot_id;
	com.command = MAV_CMD_NAV_GUIDED_ENABLE;
	com.confirmation = true;
	com.param1 = (float) bEnable; // flag >0.5 => start, <0.5 => stop

	// Encode
	mavlink_message_t message;
	mavlink_msg_command_long_encode(system_id, companion_id, &message, &com);

	// Send the message
	return writeMessage(message);

}
Exemple #29
0
void _Mavlink::command_long_doSetPositionYawThrust(float steer, float thrust)
{
	mavlink_message_t message;
	mavlink_command_long_t ds;

	ds.target_system = m_systemID;
	ds.target_component = m_targetComponentID;
	ds.command = 213; //MAV_CMD_DO_SET_POSITION_YAW_THRUST;
	ds.confirmation = 0;
	ds.param1 = steer;
	ds.param2 = thrust;
	mavlink_msg_command_long_encode(m_systemID, m_targetComponentID, &message,
			&ds);

	writeMessage(message);

	LOG_I("<- COMMAND_LONG: MAV_CMD_DO_SET_POSITION_YAW_THRUST");

	return;
}
Exemple #30
0
void ClientSocket::sendMessage(const QByteArray &message, int messageCode)
{
    SOCKET_LOG( QString("Sending message to client (exit code: %1).").arg(messageCode) );

    if (!m_socket) {
        SOCKET_LOG("Cannot send message to client. Socket is already deleted.");
    } else if (m_closed) {
        SOCKET_LOG("Client disconnected!");
    } else {
        QByteArray msg;
        QDataStream out(&msg, QIODevice::WriteOnly);
        out.setVersion(QDataStream::Qt_5_0);
        out << static_cast<qint32>(messageCode);
        out.writeRawData( message.constData(), message.length() );
        if ( writeMessage(m_socket, msg) )
            SOCKET_LOG("Message sent to client.");
        else
            SOCKET_LOG("Failed to send message to client!");
    }
}