santoslab / aadl-translator

Eclipse Public License 1.0
5 stars 3 forks source link

Support Draeger's ICE as a translation target #21

Open sprocter opened 9 years ago

sprocter commented 9 years ago

Draeger has an ICE implementation called OpenSDC, and it would be interesting / useful to try and target that implementation from our translator.

sprocter commented 9 years ago

So, after some tinkering, it looks like there's quite a bit of boilerplate that we would be able to hide in a similar fashion to the MDCF's use of SuperTypes to hide marshalling and unmarshalling.

Consider the method below, from the OpenSDC device tutorial -- what's important here is the loading of the value into the state variable, which could be hidden via an auto-generated "sendValue()" method similar to what we have now.

private static void runMetricsChanger() {
    Thread t = new Thread(new Runnable() {
        public void run() {
            while (true) {
                // Change value every 5 seconds
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    Log.warn("Interrupted thread.", e);
                }

                // Create random value, round to 1 decimal place
                Random rand = new Random();
                double value = Math.round((rand.nextDouble() + 1) * 1000) / 100;

                // Retrieve queue to offer new value
                BlockingQueue<MDINotification> queue = DeviceApplication
                        .getInstance().getMDINotificationQueue();

                // retrieve state to offer
                NumericMetricDescriptor descr = new NumericMetricDescriptor();
                descr.setHandle("s");
                NumericMetricState state = DeviceApplication.getInstance()
                        .getStateBuilder().getNumericMetricState(descr);

                // Change state's value
                state.setObservedValue(Util.createNumericValue(BigDecimal
                        .valueOf(value)));

                // Notify openSDC of changed value
                queue.offer(new CurrentValueChanged(state));

                Log.info("Numeric metric changed to random value: " + value);
            }
        }
    });
    t.setDaemon(true);
    t.start();
}

That said, it seems like OpenSDC is quite a bit more mature than the MDCF, so there may be some currently unsupported features (consider for example messages -- instead of raw types, OpenSDC supports sets, gets, waveforms, etc.)

yjkim78 commented 9 years ago

Sounds interesting, I will take a look, too!

On Nov 22, 2014, at 12:13 AM, Sam Procter notifications@github.com wrote:

So, after some tinkering, it looks like there's quite a bit of boilerplate that we would be able to hide in a similar fashion to the MDCF's use of SuperTypes to hide marshalling and unmarshalling.

Consider the method below, from the OpenSDC device tutorial

private static void runMetricsChanger() { Thread t = new Thread(new Runnable() { public void run() { while (true) { // Change value every 5 seconds try { Thread.sleep(5000); } catch (InterruptedException e) { Log.warn("Interrupted thread.", e); }

            // Create random value, round to 1 decimal place
            Random rand = new Random();
            double value = Math.round((rand.nextDouble() + 1) * 1000) / 100;

            // Retrieve queue to offer new value
            BlockingQueue<MDINotification> queue = DeviceApplication
                    .getInstance().getMDINotificationQueue();

            // retrieve state to offer
            NumericMetricDescriptor descr = new NumericMetricDescriptor();
            descr.setHandle("s");
            NumericMetricState state = DeviceApplication.getInstance()
                    .getStateBuilder().getNumericMetricState(descr);

            // Change state's value
            state.setObservedValue(Util.createNumericValue(BigDecimal
                    .valueOf(value)));

            // Notify openSDC of changed value
            queue.offer(new CurrentValueChanged(state));

            Log.info("Numeric metric changed to random value: " + value);
        }
    }
});
t.setDaemon(true);
t.start();

} — Reply to this email directly or view it on GitHub.