Search in sources :

Example 11 with RtThread

use of joprt.RtThread in project jop by jop-devel.

the class CmpMain method main.

public static void main(String[] args) {
    SysDevice sys = IOFactory.getFactory().getSysDevice();
    SpeedManager manager = new SpeedManager();
    RtThread smThread = new RtThread(manager, 5, 10 * 1000);
    smThread.setProcessor(3 % sys.nrCpu);
    System.out.println("created SpeedManager");
    Controller control = new Controller(manager);
    RtThread ctrlThread = new RtThread(control, 4, 10 * 1000);
    ctrlThread.setProcessor(0);
    System.out.println("created Controller");
    Filter frontLeftFilter = new Filter("FLF", manager.frontLeftSpeed);
    RtThread flThread = new RtThread(frontLeftFilter, 6, 5 * 1000);
    flThread.setProcessor(1 % sys.nrCpu);
    Filter frontRightFilter = new Filter("FRF", manager.frontRightSpeed);
    RtThread frThread = new RtThread(frontRightFilter, 6, 5 * 1000);
    frThread.setProcessor(2 % sys.nrCpu);
    Filter rearLeftFilter = new Filter("RLF", manager.rearLeftSpeed);
    RtThread rlThread = new RtThread(rearLeftFilter, 6, 5 * 1000);
    rlThread.setProcessor(2 % sys.nrCpu);
    Filter rearRightFilter = new Filter("RRF", manager.rearRightSpeed);
    RtThread rrThread = new RtThread(rearRightFilter, 6, 5 * 1000);
    rrThread.setProcessor(1 % sys.nrCpu);
    System.out.println("created Filters");
    Dispatcher dispatch = new Dispatcher(manager, frontLeftFilter, frontRightFilter, rearLeftFilter, rearRightFilter);
    RtThread dThread = new RtThread(dispatch, 7, 1000);
    dThread.setProcessor(0);
    System.out.println("created Dispatcher");
    RtThread.startMission();
    System.out.println("started Mission");
    for (; ; ) {
    // wait forever
    }
}
Also used : RtThread(joprt.RtThread)

Example 12 with RtThread

use of joprt.RtThread in project jop by jop-devel.

the class RtTron method createPlayers.

private static void createPlayers() {
    int threads = PLAYERS;
    int no = 0;
    int sector = 0;
    int x = 0, y = 0;
    int d = (PLAYERS / 4) % SIZE;
    if (PLAYERS % 4 != 0) {
        d += 1;
    }
    int step = SIZE / d;
    int grenze = PLAYERS / 4 + PLAYERS % 4;
    System.out.println("d: " + d + " - step: " + step);
    for (int i = 0; i < 4; ++i) {
        for (int k = 0; k < grenze; ++k) {
            System.out.println("no: " + no);
            if (threads > 0) {
                p[no] = new TronPlayerThread(no, x, y);
                p[no].setProcessor(no % sys.nrCpu);
                System.out.println("Tron Player " + no + " at Core" + (no % sys.nrCpu) + " starting at (" + x + "/" + y + ")");
                threads--;
            }
            // position update
            if (sector == 0) {
                // sector0
                x += step;
                if (x >= SIZE - 1) {
                    System.out.println("sector = 1");
                    sector = 1;
                }
            } else if (sector == 1) {
                // sector1
                y += step;
                if (y >= SIZE - 1) {
                    System.out.println("sector = 2");
                    sector = 2;
                }
            } else if (sector == 2) {
                x -= step;
                if (x <= 0) {
                    System.out.println("sector = 3");
                    sector = 3;
                }
            } else if (sector == 3) {
                y -= step;
                if (y <= 0) {
                    System.out.println("sector = 0");
                    sector = 0;
                }
            }
            // cpu count
            no++;
        }
    }
    for (int i = PLAYERS; i < sys.nrCpu; ++i) {
        RtThread th = new RtThread(1, 1000 * 1000);
        th.setProcessor(i);
        System.out.println("Dummy for Core" + i);
    }
}
Also used : RtThread(joprt.RtThread)

Example 13 with RtThread

use of joprt.RtThread in project jop by jop-devel.

the class SerialTest method main.

public static void main(String[] args) {
    new RtThread(9, 10000) {

        private Serial ser = new Serial(10, 400, Const.IO_UART1_BASE);

        private int err = 0;

        private int loop = 0;

        public void run() {
            while (true) {
                waitForNextPeriod();
                int rxCnt = ser.rxCnt();
                for (int i = 0; i < rxCnt; i++) {
                    if (ser.txFreeCnt() <= 0) {
                        err++;
                    } else
                        ser.wr(ser.rd());
                }
            }
        }
    };
    RtThread.startMission();
    while (true) {
    }
}
Also used : Serial(ejip123.util.Serial) RtThread(joprt.RtThread)

Example 14 with RtThread

use of joprt.RtThread in project jop by jop-devel.

the class Ppp method init.

/**
*	allocate buffer, start serial buffer and slip Thread.
*/
public static LinkLayer init(int prio, int us, Serial serPort) {
    // already called init()
    if (single != null)
        return single;
    rbuf = new int[MAX_BUF];
    sbuf = new int[MAX_BUF];
    cnt = 0;
    ready = false;
    flag = false;
    scnt = 0;
    sent = 0;
    connCount = 0;
    lcpId = 0x11;
    ipRemote = 0;
    reconnectRequest = false;
    disconnectRequest = false;
    initStr();
    ser = serPort;
    // new Serial(serAddr, 10, 3000);
    single = new Ppp();
    single.setIp(0);
    rth = new RtThread(prio, us) {

        public void run() {
            for (; ; ) {
                waitForNextPeriod();
                single.loop();
            }
        }
    };
    return single;
}
Also used : RtThread(joprt.RtThread)

Example 15 with RtThread

use of joprt.RtThread in project jop by jop-devel.

the class MainPppLoop method main.

/**
*	Start network and enter forever loop.
*/
public static void main(String[] args) {
    Dbg.initSerWait();
    //
    //	initialize TCP/IP
    //
    //net = Ip.init();
    ser = new Serial(IPSER_PRIO, IPSER_PERIOD, Const.IO_UART_BG_MODEM_BASE);
    //
    //	Create serial and PPP
    //
    ipLink = Ppp.init(IPLINK_PRIO, IPLINK_PERIOD, ser);
    new RtThread(20, 100000) {

        public void run() {
            int i = 0;
            for (; ; ) {
                waitForNextPeriod();
                //					Ip.loop();
                ++i;
                if (i == 10) {
                    Timer.wd();
                    System.out.print('*');
                    i = 0;
                }
                Timer.loop();
            }
        }
    };
    /*FIXME 		ipLink.startConnection(new StringBuffer("*99***1#"),
				new StringBuffer("A1.net"),
				new StringBuffer("ppp@A1plus.at"),
				new StringBuffer("ppp"));
*/
    RtThread.startMission();
    //		forever();
    for (; ; ) {
        int t = Timer.getTimeoutMs(800);
        while (!Timer.timeout(t)) {
            RtThread.sleepMs(10);
        }
        System.out.print("M");
    }
}
Also used : Serial(ejip123.util.Serial) RtThread(joprt.RtThread)

Aggregations

RtThread (joprt.RtThread)37 Serial (util.Serial)7 CS8900 (ejip.CS8900)3 Ejip (ejip.Ejip)3 Net (ejip.Net)3 Serial (ejip123.util.Serial)3 SysDevice (com.jopdesign.io.SysDevice)2 HtmlBaseio (ejip.HtmlBaseio)2 SwEvent (joprt.SwEvent)2 Motor (lego.lib.Motor)2 Tftp (ejip.Tftp)1 LTMemory (javax.realtime.LTMemory)1 ScopedMemory (javax.realtime.ScopedMemory)1 UdpJop (wcet.dsvmfp.util.UdpJop)1