/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ociweb.grove;

import com.ociweb.gl.api.Behavior;
import com.ociweb.iot.grove.six_axis_accelerometer.*;
import com.ociweb.iot.maker.FogCommandChannel;
import com.ociweb.iot.maker.FogRuntime;

/**
 *
 * @author huydo
 */
public class AccelBehavior implements Behavior {
    private final FogCommandChannel ch;
    
    private final SixAxisAccelerometer_Transducer accSensor;
    private final AccerometerValues values;

    AccelBehavior(FogRuntime runtime){
        this.ch = runtime.newCommandChannel();
        this.values = new AccerometerValues() {
            @Override
            public void onChange(Changed changed) {
                if (changed == Changed.mag) {
                    System.out.println("heading: " + values.getHeading());
                }
                else if (changed == Changed.accel) {
                    System.out.println("accel x: " + values.getAccelX() + " y: " + values.getAccelY() + " z: "+ values.getAccelZ());
                }
            }
        };
        accSensor = new SixAxisAccelerometer_Transducer(ch, values, values, null);
    }
}

@@ -493,22 +493,22 @@
 annel ch
-;%0A    
+annel;
 %0A    pri
@@ -660,16 +660,21 @@
  this.ch
+annel
  = runti
@@ -839,85 +839,235 @@
     
-if (changed == Changed.mag) %7B%0A                    System.out.println(%22heading
+System.out.println(%22heading: %22 + values.getHeading());%0A                System.out.println(%22pitch: %22 + values.getPitch());%0A                System.out.println(%22roll: %22 + values.getRoll());%0A                System.out.println(%22tilt
 : %22 
@@ -1070,32 +1070,36 @@
 : %22 + values.get
+Tilt
 Heading());%0A    
@@ -1114,71 +1114,181 @@
     
-%7D%0A                else if (changed == Changed.accel) %7B%0A        
+System.out.println(%22mx: %22 + values.getMagX());%0A                System.out.println(%22my: %22 + values.getMagY());%0A                System.out.println(%22mz: %22 + values.getMagZ());%0A
     
@@ -1287,32 +1287,36 @@
 ));%0A            
+    
 System.out.print
@@ -1324,13 +1324,8 @@
 n(%22a
-ccel 
 x: %22
@@ -1349,47 +1349,118 @@
 lX()
- + %22 y: %22 + values.getAccelY() + %22 
+);%0A                System.out.println(%22ay: %22 + values.getAccelY());%0A                System.out.println(%22a
 z: %22
+ 
 + va
@@ -1486,33 +1486,55 @@
                 
-%7D
+System.out.println(%22%22);
 %0A            %7D%0A 
@@ -1601,16 +1601,21 @@
 ducer(ch
+annel
 , values

add more logging to example