Search in sources :

Example 36 with RtThread

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

the class Periodic method main.

public static void main(String[] args) {
    RtThread rt = new RtThread(10, 100000) {

        public void run() {
            int ts, ts_old;
            waitForNextPeriod();
            ts_old = Native.rd(Const.IO_US_CNT);
            for (; ; ) {
                waitForNextPeriod();
                ts = Native.rd(Const.IO_US_CNT);
                Result.printPeriod(ts_old, ts);
                ts_old = ts;
            }
        }
    };
    //
    // do busy work
    //
    RtThread rts = new RtThread(9, 1000000) {

        public void run() {
            for (; ; ) {
                System.out.print('*');
                waitForNextPeriod();
                int ts = Native.rd(Const.IO_US_CNT) + 990000;
                while (ts - Native.rd(Const.IO_US_CNT) > 0) ;
            }
        }
    };
    RtThread.startMission();
    // sleep
    for (; ; ) {
        System.out.print('m');
        // RtThread.debug();
        Timer.wd();
        RtThread.sleepMs(1200);
    }
}
Also used : RtThread(joprt.RtThread)

Example 37 with RtThread

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

the class PeriodicWCET method main.

public static void main(String[] args) {
    RtThread rt = new RtThread(10, 100000) {

        public void run() {
            // f1();	does NOT work!!!
            f4();
        }

        void f1() {
            f2();
        }

        void f2() {
            f3();
        }

        void f3() {
            f4();
        }

        void f4() {
            f5();
        }

        void f5() {
            f6();
        }

        void f6() {
            f7();
        }

        void f7() {
            f8();
        }

        void f8() {
            f9();
        }

        void f9() {
            f10();
        }

        void f10() {
            loop();
        }

        void loop() {
            // for maximum code length
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            Timer.cnt();
            waitForNextPeriod();
            int ts_old = Native.rd(Const.IO_US_CNT);
            for (; ; ) {
                waitForNextPeriod();
                int ts = Native.rd(Const.IO_US_CNT);
                Result.printPeriod(ts_old, ts);
                ts_old = ts;
            }
        }
    };
    for (int i = 0; i < 6; ++i) {
        RtThread rts = new RtThread(9, 1000000) {

            public void run() {
                f1();
            }

            void f1() {
                f2();
            }

            void f2() {
                f3();
            }

            void f3() {
                f4();
            }

            void f4() {
                f5();
            }

            void f5() {
                f6();
            }

            void f6() {
                f7();
            }

            void f7() {
                f8();
            }

            void f8() {
                f9();
            }

            void f9() {
                f10();
            }

            void f10() {
                f11();
            }

            void f11() {
                loop();
            }

            void loop() {
                for (; ; ) {
                    System.out.print('*');
                    waitForNextPeriod();
                    int ts = Native.rd(Const.IO_US_CNT) + 890000;
                    while (ts - Native.rd(Const.IO_US_CNT) > 0) ;
                }
            }
        };
    }
    RtThread.startMission();
    // sleep
    for (; ; ) {
        Timer.wd();
        try {
            RtThread.sleepMs(1200);
        } catch (Exception e) {
        }
    }
}
Also used : 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