Search in sources :

Example 1 with SwEvent

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

the class Event method main.

public static void main(String[] args) {
    // use serial line for debug output
    Dbg.initSerWait();
    result = new int[CNT];
    sev = new SwEvent(11, 10000) {

        public void handle() {
            f_tim = Native.rd(Const.IO_CNT);
        }
    };
    RtThread rt = new RtThread(10, 10000) {

        public void run() {
            int i, ts;
            for (i = 0; i < CNT; ++i) {
                waitForNextPeriod();
                ts = Native.rd(Const.IO_CNT);
                sev.fire();
                result[i] = f_tim - ts;
            }
            result();
        }

        void result() {
            int max = 0;
            int min = 999999999;
            int i;
            for (i = 0; i < CNT; ++i) {
                int diff = result[i];
                if (diff < min)
                    min = diff;
                if (diff > max)
                    max = diff;
                Dbg.intVal(diff);
                Dbg.wr('\n');
            }
            Dbg.intVal(min);
            Dbg.intVal(max);
            Dbg.wr('\n');
            for (; ; ) waitForNextPeriod();
        }
    };
    RtThread.startMission();
    for (; ; ) {
        // busy do nothing
        ;
    }
}
Also used : RtThread(joprt.RtThread) SwEvent(joprt.SwEvent)

Example 2 with SwEvent

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

the class Event method main.

public static void main(String[] args) {
    sev = new SwEvent(2, 10000) {

        public void handle() {
            System.out.println("fire!");
        }
    };
    RtThread rt = new RtThread(1, 100000) {

        public void run() {
            int i;
            for (i = 0; i < CNT; ++i) {
                waitForNextPeriod();
                System.out.println("befor");
                sev.fire();
                System.out.println("after");
            }
            for (; ; ) waitForNextPeriod();
        }
    };
    RtThread.startMission();
    for (; ; ) {
        // busy do nothing
        ;
    }
}
Also used : RtThread(joprt.RtThread) SwEvent(joprt.SwEvent)

Aggregations

RtThread (joprt.RtThread)2 SwEvent (joprt.SwEvent)2