4 * Class Publisher provides methods for creating and working
5 * with the ORTE publisher.
7 * @author Lukas Pokorny (lukas_pokorny@centrum.cz)
8 * @author CTU FEE Prague - Department of Control Engineering (dce.felk.cvut.cz)
9 * @author Project ORTE - OCERA Real Time Ethernet (www.ocera.org)
10 * @author dedication to Kj
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
25 import org.ocera.orte.*;
26 import org.ocera.orte.types.*;
29 public class Publisher {
31 // load native library 'libjorte.so'
34 System.loadLibrary("jorte");
37 public static void main(String[] args)
40 System.out.println(":j: * ********************************************* *");
41 System.out.println(":j: * JORTE Publisher is starting.. *");
42 System.out.println(":j: * ********************************************* *");
44 // set publisher's parameters
45 NtpTime persistence = new NtpTime(3);
48 MyEvents events = new MyEvents();
51 * Create a new Application Domain for a Publisher.
52 * (Constructor without arguments creates the default Application Domain.)
54 // creates default app domain
55 //DomainApp appDomain = new DomainApp();
56 // creates user defined app domain
58 DomainApp appDomain = new DomainApp(ORTEConstant.ORTE_DEFAULT_DOMAIN,
59 DomainProp.defaultPropsCreate(),
62 if (appDomain == null)
64 System.out.println(":!j: cannot create default domain!");
68 // create a HelloMessage instance
69 HelloMsg hellomsg = new HelloMsg(appDomain,"Example HelloMsg");
71 // set basic subscription properties
72 PublProp publProp = new PublProp(hellomsg.getTopic(),
77 System.out.println(":j: set publication properties..");
79 /* set verbosity mode - just uncomment the line bellow */
80 // JOrte.verbositySetOptions("ALL:10");
82 // create a publication
83 Publication pub = appDomain.createPublication(publProp,
87 System.out.println(":j!: publisher not created!");
90 System.out.println(":j: publisher created!");
91 System.out.println(":j: * ********************************************* *");
92 System.out.println(":j: start sending data:");
93 System.out.println(":j: * ********************************************* *");
95 for(int i = 0; i < 40; i++)
98 System.out.println("<< data to send: " + hellomsg);
100 System.out.println(" ");