Exemplo n.º 1
0
/* To stop everything in case of emergency */
static void handler_alert(int n) {
	LOCK(Box);
	LOCK(Palette);
	LOCK(Print);
	LOCK(Valve);
	INIT_LOGGER();
	/* Send a log so that the client knows that we received an emergency stop (important call, not to be deleted or changed) */
	LOG(EMERGENCY_STOP_MSG);
}
Exemplo n.º 2
0
int main(int argc, char* argv[])
{
	boost::asio::io_service io;
	avws::web_socket s(io);

	INIT_LOGGER(".", "avws.log");

	s.open("ws://echo.websocket.org");

	UNINIT_LOGGER();
	return 0;
}
int main(int argc, char **argv)
{
    rclcpp::init(argc,argv);
    node = std::make_shared<rclcpp::Node>("simpleLoggerEcho");

    INIT_LOGGER(node);
    simpleLoggerSubscriber subscriber(node);
    rclcpp::WallRate loop_rate(20);
    while(rclcpp::ok())
    {
        rclcpp::spin_some(node);
        loop_rate.sleep();
    }

}
Exemplo n.º 4
0
int main()
{
    INIT_LOGGER("../conf/log4cplus.conf");

    ConfReader conf;
    if(conf.Init(CONF_NAME) != 0)
    {
    	string ErrMsg = conf.GetErrMsg();
    	printf("Init conf=%s failed.ErrMsg=%s\n", CONF_NAME,  ErrMsg.c_str());
    	return -1;
    }

    WeCacheServer server(&conf);
    if(server.Init() != 0)
        return -1;

    //Set yourself Packet class by server.SetInternalPacket() method if needed:
    //server.SetInternalPacket(other_packet);

    server.RunForever();
    return 0;
}
Exemplo n.º 5
0
gcm::Geo2MeshLoader::Geo2MeshLoader() {
    INIT_LOGGER("gcm.Geo2MeshLoader");
    GmshInitialize();
}
Exemplo n.º 6
0
int main(int argc, char* argv[])
{
	if (argc != 2)
	{
		std::cerr << "usage: " << argv[0] << " <url>\n";
		return -1;
	}

#if WIN32
	std::locale::global(std::locale(""));
#endif

	INIT_LOGGER(".", "multi_download.log");

	try {
		boost::asio::io_service io;
		avhttp::multi_download d(io);

		avhttp::settings s;
		s.check_certificate = false;
		// s.m_download_rate_limit = 102400;

		d.start(argv[1], s);

		if (d.file_size() != -1)
			std::cout << "file \'" << d.file_name().c_str() <<
			"\' size is: " << "(" << d.file_size() << " bytes) " << add_suffix((float)d.file_size()).c_str() << std::endl;

		boost::thread t(boost::bind(&boost::asio::io_service::run,& io));

		if (d.file_size() != -1)
		{
			printf("\n");
			int percent = 0;
			boost::int64_t bytes_download = 0;
			while (percent != 100 && !d.stopped())
			{
				boost::int64_t file_size = d.file_size();
				bytes_download = d.bytes_download();
				percent = (int)(((double)bytes_download / (double)file_size) * 100.0f);
				boost::this_thread::sleep(boost::posix_time::millisec(200));
				printf("\r");
				printf("%3d%% [", percent);
				int progress = percent / 2;
				for (int i = 0; i < progress; i++)
					printf("=");
				if (progress != 50)
					printf(">");
				for (int i = 0; i < 49 - progress; i++)
					printf(" ");
				printf("]  %s  %s/s", add_suffix((float)bytes_download).c_str(), add_suffix((float)d.download_rate()).c_str());
			}
			printf("\n");
		}

		t.join();

		std::cout << "\n*** download completed! ***\n";
	}
	catch (std::exception& e)
	{
		std::cerr << e.what() << std::endl;
		return -1;
	}

	UNINIT_LOGGER();

	return 0;
}
Exemplo n.º 7
0
gcm::LineFirstOrderInterpolator::LineFirstOrderInterpolator()
{
    type = "LineFirstOrderInterpolator";
    INIT_LOGGER("gcm.LineFirstOrderInterpolator");
}
 MeshNodeIterator<EulerMesh, 0>::MeshNodeIterator(EulerMesh* mesh): mesh(mesh)
 {
     INIT_LOGGER("gcm.snapshot.MeshNodeIterator.EulerMesh");
     data = new data_t;
     static_cast<data_t*>(data)->dims = mesh->getNodeDimensions();
 }
Exemplo n.º 9
0
gcm::TetrFirstOrderInterpolator::TetrFirstOrderInterpolator()
{
    type = "TetrFirstOrderInterpolator";
    INIT_LOGGER("gcm.TetrFirstOrderInterpolator");
}
Exemplo n.º 10
0
xml::Node::Node(const xmlNodePtr node): node(node)
{
    INIT_LOGGER("xml.Node");
}
Exemplo n.º 11
0
/* Main function
 * Fills the box with accepted parts and then transmits it to the printer
 */
void* doBox(void*a) {
	/* INIT *******************************************************************/
	INCLUDE(Box)
	INCLUDE(Valve)
	INIT_LOGGER();
	INIT_CONTROL();
	INIT_CHECK_FOR_APP_END();
	extern int PARTS_BY_BOX;
	extern int MAX_REFUSED_PARTS_BY_BOX;
	extern int CurrentBatchProdMax;
	extern int CurrentProducedBoxes;
	extern int CurrentBatchRefusedPartsNumber;
	extern int BOXES_BY_PALETTE;
	extern sem_t SemSyncBoxPrint;
	extern sem_t SemPushBoxPrint;
	extern sem_t SemNewPart;
	int refusedPartsCount = 0; /* Number of parts that have been refused for the current box (not to be higher than MAX_REFUSED_PARTS_BY_BOX) */
	int currentBoxPartsNumber = 0;

#ifdef DBG
	printf("%d\n", (int) getpid());
#endif

	/* MAIN LOOP **************************************************************/
	for (;;) {
		CHECK_WAIT_BOOL(Box);
		CHECK_FOR_APP_END_AND_STOP("Box");
		DBGPRINT("doBox", "Main", "Task is unlocked.");

		bool boxIsMissing = TRUE;
#ifdef SIMU_MODE
		boxIsMissing = simu_missing_box();
#endif

		if (boxIsMissing) {
			/* Closing the valve */
			LOCK(Valve);
			DBGPRINT("doBox", "Main", "Closing valve.");
			LOG("doBox: Missing box, ERROR.");
			LOCK(Box); /* Forbidding ourself to do another loop before the green
					   * light has been set by the doControl thread */

			/* Sending error message */
			ERR_MSG(ERR_BOX);
			/* Going back to the beginning of the loop and standing still until
			 * the doControl thread says otherwise */
			continue;
		}

		/* At the end of the loop (and thus at its beginning, the other way
		 * around), we are basically just waiting for a new part
		 * This part will come as a unlocking the sempahore SemSimuNewPart
		 * (supposed to be an IT) */
		sem_wait(&SemNewPart);

		bool refused = TRUE;
#ifdef SIMU_MODE
		refused = simu_refusal();
#endif
		if (!refused) /* Part is accepted */ {
			DBGPRINT("doBox", "Main", "New accepted part.");
			LOG("doBox: New accepted part.");
			/* There's a new part to put in that freaking box: */
			currentBoxPartsNumber = (currentBoxPartsNumber + 1) % PARTS_BY_BOX;
			DBGPRINT("doBox", "Main", "currentBoxPartsNumber=");
#ifdef DBG
			printf("%d\n", currentBoxPartsNumber);
#endif

			if (!currentBoxPartsNumber) /* Is the box full? */ {
				DBGPRINT("doBox", "Main", "The box is full");
				refusedPartsCount = 0; /* Reset refused parts by box counter */
				CurrentProducedBoxes++;
				if ((CurrentProducedBoxes / BOXES_BY_PALETTE) >= CurrentBatchProdMax) {
					/* The current batch is over, so close the valve */
					LOCK(Valve);
					/* And send a log so that the client is able to know that
					 * the production of the current batch is over
					 * (important call, not to be deleted or changed) */
					LOG(PRODUCTION_IS_OVER_MSG);
				}
				/* **** "READY TO GO TO PRINTER" SEMAPHORE CHECK */
				sem_wait(&SemSyncBoxPrint);
				sem_post(&SemPushBoxPrint);
			}
		} else {
			DBGPRINT("doBox", "Main", "New REFUSED part.");
			LOG("doBox: New REFUSED part.");

			refusedPartsCount++;
			CurrentBatchRefusedPartsNumber++;
			if (refusedPartsCount >= MAX_REFUSED_PARTS_BY_BOX) {
				/* Closing the valve */
				refusedPartsCount = 0; /* Resetting the counter, so that when
									    * the error is marked as "solved" we
									    * don't go back into error mode */
				LOCK(Valve);
				DBGPRINT("doBox", "Main", "Closing valve.");
				LOG("doBox: Refused rate is too high, ERROR.");
				LOCK(Box); /* Forbidding ourself to do another loop before the
						   * green light has been set by the doControl thread */

				/* Sending error message */
				ERR_MSG(ERR_BOX_REFUSED_RATE);
			}
		}
	}
}
 AbstractVTKSnapshotWriter()
 {
     INIT_LOGGER("gcm.snapshot.AbstractVTKSnapshotWriter");
 }