HEADS-project / training

Training material to get started with the HEADS technologies
10 stars 16 forks source link

Problems with running kevoree?? #115

Closed kehusa closed 8 years ago

kehusa commented 8 years ago

After generating code with HEADS IDE I got the following error:

I this on your table, Brice?

HomeGWLightController_lightSwitch (LightSwitch): ZWave?nodeReady(3, [object Object])
HomeGWLightController_lightSwitch (LightSwitch): internal event ZWave?nodeReady
Node ready: 3:[object Object]HomeGWLightController_lightSwitch (LightSwitch): ZWave?nodeReady(4, [object Object])
HomeGWLightController_lightSwitch (LightSwitch): internal event ZWave?nodeReady
Node ready: 4:[object Object]HomeGWLightController_lightSwitch (LightSwitch): ZWave?scanComplete()
12:05:39 ALL KevoreeLogger Set logLevel= info
12:05:44 INFO KevoreeCore Platform node name: node0
npm WARN package.json home-gw@1.0.30 No repository field.
npm WARN package.json home-gw@1.0.30 No README data
npm WARN package.json kevoree-comp-mqttpubclient@2.0.1 No repository field.
npm WARN package.json kevoree-comp-mqttsubclient@2.0.3 No repository field.
npm WARN package.json kevoree-comp-wsmsgbroker@2.0.0 No repository field.
npm WARN package.json lightcontrol@1.0.36 No repository field.
lightcontrol@1.0.39 node_modules/lightcontrol
├── colors@1.1.2
├── state.js@5.7.0
└── kevoree-entities@8.1.0 (pseudoclass@1.0.3, kevoree-commons@2.2.1, kevoree-library@5.0.9)
12:06:19 ERROR Bootstrapper TypeError: Cannot read property 'getPostJsononsmarttrackerListeners' of undefined
at PseudoClass.AbstractComponent.extend.construct (/home/pi/test/node_modules/lightcontrol/lib/HomeGWLightController.js:72:49)
at PseudoClass.prototype.construct (/home/pi/test/node_modules/lightcontrol/node_modules/kevoree-entities/node_modules/pseudoclass/source/Class.js:275:17)
at new PseudoClass (/home/pi/test/node_modules/lightcontrol/node_modules/kevoree-entities/node_modules/pseudoclass/source/Class.js:216:19)
at PseudoClass.module.exports.AdaptationPrimitive.extend.execute (/home/pi/test/node_modules/kevoree-node-javascript/lib/adaptations/AddInstance.js:37:36)
at executeCommand (/usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-core/kevoree-core.js:161:41)
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-core/node_modules/async/lib/async.js:187:20
at iterate (/usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-core/node_modules/async/lib/async.js:265:13)
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-core/node_modules/async/lib/async.js:277:29
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-core/node_modules/async/lib/async.js:44:16
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-core/kevoree-core.js:170:41
12:06:19 ERROR KevoreeCore Error: Something went wrong while processing adaptations.
'kevoree-chan-local' bootstrap failed!
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-commons/lib/Bootstrapper.js:68:33
at PseudoClass.<anonymous> (/usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-resolvers/lib/NPMResolver.js:39:21)
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-resolvers/node_modules/exec-npm-install/exec-npm-install.js:50:21
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-resolvers/node_modules/exec-npm-install/node_modules/async/lib/async.js:52:16
at done (/usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-resolvers/node_modules/exec-npm-install/node_modules/async/lib/async.js:248:21)
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-resolvers/node_modules/exec-npm-install/node_modules/async/lib/async.js:44:16
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-resolvers/node_modules/exec-npm-install/exec-npm-install.js:25:21
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-resolvers/node_modules/exec-npm-install/lib/exists.js:29:29
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-resolvers/node_modules/npm-vers/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:76:16
at fs.js:336:14
12:06:20 WARN KevoreeCore Shutting down Kevoree because first deployment failed...
12:06:20 INFO KevoreeCore Model deployed successfully: 0 adaptations (57ms)
12:06:20 INFO KevoreeCore Platform stopped: node0
maxleiko commented 8 years ago

Your HomeGWLightController has been falsy generated I guess

12:06:19 ERROR Bootstrapper TypeError: Cannot read property 'getPostJsononsmarttrackerListeners' of undefined at PseudoClass.AbstractComponent.extend.construct (/home/pi/test/node_modules/lightcontrol/lib/HomeGWLightController.js:72:49)
brice-morin commented 8 years ago

OK, I will try on a simple example if I can reproduce the bug.

brice-morin commented 8 years ago

Works for me on a simple example... Note that in the file call <_your-thingml-configuration_>.js, you should remove this line at the top var colors = require('colors/safe');, as we do not use it anymore (and it is not declared in the package.json). I will update the compiler to remove it automatically. If it is still not working, copy/paste the whole HomeGWLightController.js file here.

brice-morin commented 8 years ago

Or actually send me the whole generate code

kehusa commented 8 years ago
var StateJS = require('state.js');
StateJS.internalTransitionsTriggerCompletion = true;
//Trace function for LightController
function LightController_print_debug(instance, msg) {
  if (instance.debug) {
    console.log(instance.name + msg + "");
  }
}

LightController.prototype.LightController_print_debug = function (instance, msg) {
  LightController_print_debug(instance, msg);
};
/**
 * Definition for type : LightController
 **/
function LightController(name, root, LightController_reading_var, LightController_readValue_var, LightController_topic_var, LightController_deviceId_var, SensorServer_delay_var, debug) {

  this.name = name;
  this.root = root;
  this.debug = debug;
  var _this;
  this.setThis = function (__this) {
    _this = __this;
  };

  this.ready = false;
  //Children
  this.forkID = 0;
  const forks = [];
  this.getForks = function () {
    return forks;
  }

  //Attributes
  this.LightController_reading_var = LightController_reading_var;
  var debug_LightController_reading_var = LightController_reading_var;
  this.LightController_readValue_var = LightController_readValue_var;
  var debug_LightController_readValue_var = LightController_readValue_var;
  this.LightController_topic_var = LightController_topic_var;
  var debug_LightController_topic_var = LightController_topic_var;
  this.LightController_deviceId_var = LightController_deviceId_var;
  var debug_LightController_deviceId_var = LightController_deviceId_var;
  this.SensorServer_delay_var = SensorServer_delay_var;
  var debug_SensorServer_delay_var = SensorServer_delay_var;
  //message queue
  const queue = [];
  this.getQueue = function () {
    return queue;
  };

  //callbacks for attributes
  this.propertyListener = {};

  //callbacks for third-party listeners
  const start_periodic_readingOnsensor_serviceListeners = [];
  this.getStart_periodic_readingonsensor_serviceListeners = function () {
    return start_periodic_readingOnsensor_serviceListeners;
  };
  const reading_cancelOnsensor_serviceListeners = [];
  this.getReading_cancelonsensor_serviceListeners = function () {
    return reading_cancelOnsensor_serviceListeners;
  };
  const readOnsensor_serviceListeners = [];
  this.getReadonsensor_serviceListeners = function () {
    return readOnsensor_serviceListeners;
  };
  const lightOnOnlightswitchListeners = [];
  this.getLightOnonlightswitchListeners = function () {
    return lightOnOnlightswitchListeners;
  };
  const lightOffOnlightswitchListeners = [];
  this.getLightOffonlightswitchListeners = function () {
    return lightOffOnlightswitchListeners;
  };
  const postJsonOnsmarttrackerListeners = [];
  this.getPostJsononsmarttrackerListeners = function () {
    return postJsonOnsmarttrackerListeners;
  };
  //CEP dispatch functions
  this.cepDispatch = function (message) {}
    //ThingML-defined functions
  function numberify(LightController_numberify_readValue_var) {
    LightController_print_debug(_this, " (LightController): Start numberify(" + LightController_numberify_readValue_var + ")...");

    var reading = JSON.parse(LightController_numberify_readValue_var)
    return parseInt(String(reading.value));
    LightController_print_debug(_this, " (LightController): numberify Done.");
  }

  this.numberify = function (LightController_numberify_readValue_var) {
    numberify(LightController_numberify_readValue_var);
  };

  function stringify(LightController_stringify_anyValue_var) {
    LightController_print_debug(_this, " (LightController): Start stringify(" + LightController_stringify_anyValue_var + ")...");
    return String(LightController_stringify_anyValue_var);
    LightController_print_debug(_this, " (LightController): stringify Done.");
  }

  this.stringify = function (LightController_stringify_anyValue_var) {
    stringify(LightController_stringify_anyValue_var);
  };

  function createObservation(LightController_createObservation_lightValue_var) {
    LightController_print_debug(_this, " (LightController): Start createObservation(" + LightController_createObservation_lightValue_var + ")...");
    var obsdata = [];
    if (LightController_createObservation_lightValue_var === 0) {
      obsdata.push({
        "light": "off"
      });

    }
    if (LightController_createObservation_lightValue_var === 100) {
      obsdata.push({
        "light": "on"
      });

    }

    var obs = {
      deviceId: _this.LightController_deviceId_var,
      observations: obsdata
    };

    return JSON.stringify(obs);

    LightController_print_debug(_this, " (LightController): createObservation Done.");
  }

  this.createObservation = function (LightController_createObservation_lightValue_var) {
    createObservation(LightController_createObservation_lightValue_var);
  };

  function extractIntensity(LightController_extractIntensity_m_var) {
    LightController_print_debug(_this, " (LightController): Start extractIntensity(" + LightController_extractIntensity_m_var + ")...");
    console.log('Got here1' + LightController_extractIntensity_m_var)

    var i = LightController_extractIntensity_m_var[0].substring(0, 6)

    if (i == '000101') {
      return 0;
    }
    if (i == '000102') {
      return 100;
    }

    console.log('Got here2')
    return -1;

    LightController_print_debug(_this, " (LightController): extractIntensity Done.");
  }

  this.extractIntensity = function (LightController_extractIntensity_m_var) {
    extractIntensity(LightController_extractIntensity_m_var);
  };

  function extractFall(LightController_extractFall_m_var) {
    LightController_print_debug(_this, " (LightController): Start extractFall(" + LightController_extractFall_m_var + ")...");
    var reading = JSON.parse(LightController_extractFall_m_var)
    console.log('Got here3' + LightController_extractFall_m_var)
    if (reading.topic == 'sensor/fallIndex') {
      var msg = JSON.parse(reading.message)
      console.log('Got here5: ' + msg.fall)
      if (msg.fall == true) {
        console.log('Got here6')
        return true;
      }
    }
    return false;

    LightController_print_debug(_this, " (LightController): extractFall Done.");
  }

  this.extractFall = function (LightController_extractFall_m_var) {
    extractFall(LightController_extractFall_m_var);
  };

  //Internal functions
  function sendStart_periodic_readingOnSensor_service(delay) {
    if (this.root === null || this.root === undefined) {
      LightController_print_debug(_this, " (SensorServer): sensor_service!start_periodic_reading(" + delay + ")");
      //notify listeners
      const arrayLength = this.getStart_periodic_readingonsensor_serviceListeners().length;
      if (arrayLength < 1) {
        LightController_print_debug(_this, "(SensorServer): message lost, because no connector/listener is defined!");
      }
      for (var _i = 0; _i < arrayLength; _i++) {
        this.getStart_periodic_readingonsensor_serviceListeners()[_i](delay);
      }
    } else {
      sendStart_periodic_readingOnSensor_service.call(this.root, delay);
    }
  }

  function sendReading_cancelOnSensor_service() {
    if (this.root === null || this.root === undefined) {
      LightController_print_debug(_this, " (SensorServer): sensor_service!reading_cancel()");
      //notify listeners
      const arrayLength = this.getReading_cancelonsensor_serviceListeners().length;
      if (arrayLength < 1) {
        LightController_print_debug(_this, "(SensorServer): message lost, because no connector/listener is defined!");
      }
      for (var _i = 0; _i < arrayLength; _i++) {
        this.getReading_cancelonsensor_serviceListeners()[_i]();
      }
    } else {
      sendReading_cancelOnSensor_service.call(this.root);
    }
  }

  function sendReadOnSensor_service() {
    if (this.root === null || this.root === undefined) {
      LightController_print_debug(_this, " (SensorServer): sensor_service!read()");
      //notify listeners
      const arrayLength = this.getReadonsensor_serviceListeners().length;
      if (arrayLength < 1) {
        LightController_print_debug(_this, "(SensorServer): message lost, because no connector/listener is defined!");
      }
      for (var _i = 0; _i < arrayLength; _i++) {
        this.getReadonsensor_serviceListeners()[_i]();
      }
    } else {
      sendReadOnSensor_service.call(this.root);
    }
  }

  function sendLightOnOnLightswitch(LocId) {
    if (this.root === null || this.root === undefined) {
      LightController_print_debug(_this, " (SensorServer): lightswitch!lightOn(" + LocId + ")");
      //notify listeners
      const arrayLength = this.getLightOnonlightswitchListeners().length;
      if (arrayLength < 1) {
        LightController_print_debug(_this, "(SensorServer): message lost, because no connector/listener is defined!");
      }
      for (var _i = 0; _i < arrayLength; _i++) {
        this.getLightOnonlightswitchListeners()[_i](LocId);
      }
    } else {
      sendLightOnOnLightswitch.call(this.root, LocId);
    }
  }

  function sendLightOffOnLightswitch(LocId) {
    if (this.root === null || this.root === undefined) {
      LightController_print_debug(_this, " (SensorServer): lightswitch!lightOff(" + LocId + ")");
      //notify listeners
      const arrayLength = this.getLightOffonlightswitchListeners().length;
      if (arrayLength < 1) {
        LightController_print_debug(_this, "(SensorServer): message lost, because no connector/listener is defined!");
      }
      for (var _i = 0; _i < arrayLength; _i++) {
        this.getLightOffonlightswitchListeners()[_i](LocId);
      }
    } else {
      sendLightOffOnLightswitch.call(this.root, LocId);
    }
  }

  function sendPostJsonOnSmarttracker(value) {
    if (this.root === null || this.root === undefined) {
      LightController_print_debug(_this, " (SensorServer): smarttracker!postJson(" + value + ")");
      //notify listeners
      const arrayLength = this.getPostJsononsmarttrackerListeners().length;
      if (arrayLength < 1) {
        LightController_print_debug(_this, "(SensorServer): message lost, because no connector/listener is defined!");
      }
      for (var _i = 0; _i < arrayLength; _i++) {
        this.getPostJsononsmarttrackerListeners()[_i](value);
      }
    } else {
      sendPostJsonOnSmarttracker.call(this.root, value);
    }
  }

  //State machine (states and regions)
  this.build = function (session, root) { //optional session name and root instance to fork a new session
      if (session === null || session == undefined) {
        this.statemachine = new StateJS.StateMachine("Server").entry(function () {
          LightController_print_debug(_this, " (LightController): Enters Server:Server");
        }).exit(function () {
          LightController_print_debug(_this, " (LightController): Exits Server:Server");
        })

        ;
        this._initial_LightController_Server = new StateJS.PseudoState("_initial", this.statemachine, StateJS.PseudoStateKind.Initial);
        var LightController_Server_reading = new StateJS.State("reading", this.statemachine).entry(function () {
          LightController_print_debug(_this, " (LightController): Enters reading:reading");
        }).exit(function () {
          LightController_print_debug(_this, " (LightController): Exits reading:reading");
        })

        ;
        var LightController_Server_reading_light = new StateJS.State("light", LightController_Server_reading).entry(function () {
          LightController_print_debug(_this, " (LightController): Enters reading:light");
          process.stdout.write(String("Light\n"));
        }).exit(function () {
          LightController_print_debug(_this, " (LightController): Exits reading:light");
        })

        ;
        var LightController_Server_reading_dark = new StateJS.State("dark", LightController_Server_reading).entry(function () {
          LightController_print_debug(_this, " (LightController): Enters reading:dark");
          process.stdout.write(String("Dark\n"));
        }).exit(function () {
          LightController_print_debug(_this, " (LightController): Exits reading:dark");
        })

        ;
        var _initial_LightController_Server_reading = new StateJS.PseudoState("_initial", LightController_Server_reading, StateJS.PseudoStateKind.Initial);
        _initial_LightController_Server_reading.to(LightController_Server_reading_dark);
        this._initial_LightController_Server.to(LightController_Server_reading);
        LightController_Server_reading_light.to(LightController_Server_reading_dark).when(function (readingJson) {
          return readingJson[0] === "sensor_mqtt" && readingJson[1] === "readingJson" && extractIntensity(readingJson[2]) === 0;
        }).effect(function (readingJson) {
          LightController_print_debug(_this, " (LightController): transition light -> dark event sensor_mqtt?readingJson");
          process.stdout.write(String("Sensor readingJson <"));
          process.stdout.write(String(readingJson[2]));
          process.stdout.write(String(">"));
          process.stdout.write(String(" readValue <"));
          process.stdout.write(String(extractIntensity(readingJson[2])));
          process.stdout.write(String(">"));
          setImmediate(sendPostJsonOnSmarttracker.bind(_this), createObservation(extractIntensity(readingJson[2])));
          process.stdout.write(String("sent on MQTT"));
        });
        LightController_Server_reading_dark.to(LightController_Server_reading_light).when(function (readingJson) {
          return readingJson[0] === "sensor_mqtt" && readingJson[1] === "readingJson" && extractIntensity(readingJson[2]) > 0;
        }).effect(function (readingJson) {
          LightController_print_debug(_this, " (LightController): transition dark -> light event sensor_mqtt?readingJson");
          process.stdout.write(String("Sensor readingJson <"));
          process.stdout.write(String(readingJson[2]));
          process.stdout.write(String(">"));
          process.stdout.write(String(" readValue <"));
          process.stdout.write(String(extractIntensity(readingJson[2])));
          process.stdout.write(String(">"));
          setImmediate(sendPostJsonOnSmarttracker.bind(_this), createObservation(extractIntensity(readingJson[2])));
          setImmediate(sendLightOnOnLightswitch.bind(_this), "3");
          process.stdout.write(String("sent on MQTT"));
        });
        LightController_Server_reading_dark.to(null).when(function (fall) {
          return fall[0] === "fall" && fall[1] === "fall";
        }).effect(function (fall) {
          LightController_print_debug(_this, " (LightController): internal event fall?fall");
          setImmediate(sendLightOnOnLightswitch.bind(_this), fall[3]);
        });
      }
    }
    //Public API for lifecycle management
  LightController.prototype._stop = function () {
    this.ready = false;
  };

  //Public API for third parties
  LightController.prototype._init = function () {
    this.Server_instance = new StateJS.StateMachineInstance("Server_instance");
    StateJS.initialise(this.statemachine, this.Server_instance);
    var msg = this.getQueue().shift();
    while (msg !== undefined) {
      StateJS.evaluate(this.statemachine, this.Server_instance, msg);
      msg = this.getQueue().shift();
    }
    this.ready = true;
  };

  LightController.prototype._receive = function () {
    this.getQueue().push(arguments);
    this.cepDispatch(arguments);
    if (this.ready) {
      var msg = this.getQueue().shift();
      while (msg !== undefined) {
        StateJS.evaluate(this.statemachine, this.Server_instance, msg);
        const forkLength = this.getForks().length;
        for (var _i = 0; _i < forkLength; _i++) {
          this.getForks()[_i]._receive.apply(this.getForks()[_i], msg);
        }
        msg = this.getQueue().shift();
      }
    }
  };
  LightController.prototype.onPropertyChange = function (property, callback) {
    if (this.propertyListener[property] === undefined) {
      this.propertyListener[property] = [];
    }
    this.propertyListener[property].push(callback);
  };

  LightController.prototype.receivereadingOnsensor_service = function (value) {
    LightController_print_debug(this, " (LightController): sensor_service?reading(" + value + ")");
    this._receive("sensor_service", "reading", value);
  };

  LightController.prototype.receivereadyOnsensor_service = function () {
    LightController_print_debug(this, " (LightController): sensor_service?ready()");
    this._receive("sensor_service", "ready");
  };

  LightController.prototype.receivereadingJsonOnsensor_mqtt = function (value) {
    LightController_print_debug(this, " (LightController): sensor_mqtt?readingJson(" + value + ")");
    this._receive("sensor_mqtt", "readingJson", value);
  };

  LightController.prototype.receivefallOnfall = function (sensorId, fnId) {
    LightController_print_debug(this, " (LightController): fall?fall(" + sensorId + ", " + fnId + ")");
    this._receive("fall", "fall", sensorId, fnId);
  };

  LightController.prototype.receivecommandJsonOnsmarttracker = function (value) {
    LightController_print_debug(this, " (LightController): smarttracker?commandJson(" + value + ")");
    this._receive("smarttracker", "commandJson", value);
  };

  LightController.prototype.getName = function () {
    return "LightController";
  };

  LightController.prototype.toString = function () {
    var result = "instance " + this.getName() + "\n";
    result += "\treading = " + this.LightController_reading_var;
    result += "\treadValue = " + this.LightController_readValue_var;
    result += "\ttopic = " + this.LightController_topic_var;
    result += "\tdeviceId = " + this.LightController_deviceId_var;
    result += "\tdelay = " + this.SensorServer_delay_var;
    result += "";
    return result;
  }
};

module.exports = LightController;
maxleiko commented 8 years ago

This is not a Kevoree JS Component.
Is this the file ?

kehusa commented 8 years ago

it is on npm: lightcontrol, ver 1.0.41

kehusa commented 8 years ago
var AbstractComponent = require('kevoree-entities').AbstractComponent;
var colors = require('colors/safe');
var ZWave = require('./ZWave');
var DeviceSession = require('./DeviceSession');
var LightController = require('./LightController');
/**
 * Kevoree component
 * @type {HomeGWLightController}
 */
var HomeGWLightController = AbstractComponent.extend({
  toString: 'HomeGWLightController',
  //Attributes
  dic_lightControllerServer_LightController_deviceId_var: {
    defaultValue: "magnusuuiddevicen"
  },
  dic_deviceSession_DeviceSession_deviceId_var: {
    defaultValue: "zwave"
  },
  construct: function () {
    this.zwave = new ZWave("zwave", null, null, null, null, false);
    this.zwave.setThis(this.zwave);
    this.zwave.build();
    this.lightControllerServer = new LightController("lightControllerServer", null, null, "0", null, "magnusuuiddevicen", 1000, true);
    this.lightControllerServer.setThis(this.lightControllerServer);
    this.lightControllerServer.build();
    this.deviceSession = new DeviceSession("deviceSession", null, "zwave", true);
    this.deviceSession.setThis(this.deviceSession);
    this.deviceSession.build();
    //Connecting internal ports...
    //Connecting ports...
    this.zwave.getDriverReadyonZWaveIntListeners().push(this.zwave.receivedriverReadyOnZWaveIntRec.bind(this.zwave));
    this.zwave.getDriverFailedonZWaveIntListeners().push(this.zwave.receivedriverFailedOnZWaveIntRec.bind(this.zwave));
    this.zwave.getNodeAddedonZWaveIntListeners().push(this.zwave.receivenodeAddedOnZWaveIntRec.bind(this.zwave));
    this.zwave.getValueAddedonZWaveIntListeners().push(this.zwave.receivevalueAddedOnZWaveIntRec.bind(this.zwave));
    this.zwave.getValueChangedonZWaveIntListeners().push(this.zwave.receivevalueChangedOnZWaveIntRec.bind(this.zwave));
    this.zwave.getValueRemovedonZWaveIntListeners().push(this.zwave.receivevalueRemovedOnZWaveIntRec.bind(this.zwave));
    this.zwave.getNodeReadyonZWaveIntListeners().push(this.zwave.receivenodeReadyOnZWaveIntRec.bind(this.zwave));
    this.zwave.getPollingEnabledonZWaveIntListeners().push(this.zwave.receivepollingEnabledOnZWaveIntRec.bind(this.zwave));
    this.zwave.getPollingDisabledonZWaveIntListeners().push(this.zwave.receivepollingDisabledOnZWaveIntRec.bind(this.zwave));
    this.zwave.getNotificationonZWaveIntListeners().push(this.zwave.receivenotificationOnZWaveIntRec.bind(this.zwave));
    this.zwave.getControllerCommandonZWaveIntListeners().push(this.zwave.receivecontrollerCommandOnZWaveIntRec.bind(this.zwave));
    this.zwave.getScanCompleteonZWaveIntListeners().push(this.zwave.receivescanCompleteOnZWaveIntRec.bind(this.zwave));
    this.zwave.getDriverReadyonZWaveListeners().push(this.deviceSession.receivedriverReadyOnZWave.bind(this.deviceSession));
    this.zwave.getDriverFailedonZWaveListeners().push(this.deviceSession.receivedriverFailedOnZWave.bind(this.deviceSession));
    this.zwave.getNodeAddedonZWaveListeners().push(this.deviceSession.receivenodeAddedOnZWave.bind(this.deviceSession));
    this.zwave.getValueAddedonZWaveListeners().push(this.deviceSession.receivevalueAddedOnZWave.bind(this.deviceSession));
    this.zwave.getValueChangedonZWaveListeners().push(this.deviceSession.receivevalueChangedOnZWave.bind(this.deviceSession));
    this.zwave.getValueRemovedonZWaveListeners().push(this.deviceSession.receivevalueRemovedOnZWave.bind(this.deviceSession));
    this.zwave.getNodeReadyonZWaveListeners().push(this.deviceSession.receivenodeReadyOnZWave.bind(this.deviceSession));
    this.zwave.getPollingEnabledonZWaveListeners().push(this.deviceSession.receivepollingEnabledOnZWave.bind(this.deviceSession));
    this.zwave.getPollingDisabledonZWaveListeners().push(this.deviceSession.receivepollingDisabledOnZWave.bind(this.deviceSession));
    this.zwave.getNotificationonZWaveListeners().push(this.deviceSession.receivenotificationOnZWave.bind(this.deviceSession));
    this.zwave.getControllerCommandonZWaveListeners().push(this.deviceSession.receivecontrollerCommandOnZWave.bind(this.deviceSession));
    this.zwave.getScanCompleteonZWaveListeners().push(this.deviceSession.receivescanCompleteOnZWave.bind(this.deviceSession));
    this.deviceSession.getConnectonZWaveListeners().push(this.zwave.receiveconnectOnZWave.bind(this.zwave));
    this.deviceSession.getDisconnectonZWaveListeners().push(this.zwave.receivedisconnectOnZWave.bind(this.zwave));
    this.deviceSession.getSetValueonZWaveListeners().push(this.zwave.receivesetValueOnZWave.bind(this.zwave));
    this.deviceSession.getSetLevelonZWaveListeners().push(this.zwave.receivesetLevelOnZWave.bind(this.zwave));
    this.deviceSession.getSetNodeOnonZWaveListeners().push(this.zwave.receivesetNodeOnOnZWave.bind(this.zwave));
    this.deviceSession.getSetNodeOffonZWaveListeners().push(this.zwave.receivesetNodeOffOnZWave.bind(this.zwave));
    this.deviceSession.getSetLocationonZWaveListeners().push(this.zwave.receivesetLocationOnZWave.bind(this.zwave));
    this.deviceSession.getSetNameonZWaveListeners().push(this.zwave.receivesetNameOnZWave.bind(this.zwave));
    this.deviceSession.getHardResetonZWaveListeners().push(this.zwave.receivehardResetOnZWave.bind(this.zwave));
    this.deviceSession.getSoftResetonZWaveListeners().push(this.zwave.receivesoftResetOnZWave.bind(this.zwave));
    this.deviceSession.getBeginControllerCommandonZWaveListeners().push(this.zwave.receivebeginControllerCommandOnZWave.bind(this.zwave));
    this.deviceSession.getCancelControllerCommandonZWaveListeners().push(this.zwave.receivecancelControllerCommandOnZWave.bind(this.zwave));
    this.lightControllerServer.getLightOnonlightswitchListeners().push(this.deviceSession.receivelightOnOnlightswitch.bind(this.deviceSession));
    this.lightControllerServer.getLightOffonlightswitchListeners().push(this.deviceSession.receivelightOffOnlightswitch.bind(this.deviceSession));
    this.deviceSession.getPostJsononsmarttrackerListeners().push(this.dev_sma_postJson_proxy.bind(this));
    this.lightControllerServer.getStart_periodic_readingonsensor_serviceListeners().push(this.lig_sen_start_periodic_reading_proxy.bind(this));
    this.lightControllerServer.getReading_cancelonsensor_serviceListeners().push(this.lig_sen_reading_cancel_proxy.bind(this));
    this.lightControllerServer.getReadonsensor_serviceListeners().push(this.lig_sen_read_proxy.bind(this));
    this.lightControllerServer.getPostJsononsmarttrackerListeners().push(this.lig_sma_postJson_proxy.bind(this));
    this.HomeGWLightController_lightControllerServer.getPostJsononsmarttrackerListeners().push(this.lig_sma_postJson_proxy.bind(this));
    this.HomeGWLightController_deviceSession.getPostJsononsmarttrackerListeners().push(this.dev_sma_postJson_proxy.bind(this));
  },

  start: function (done) {
    this.dictionary.on('lightControllerServer_LightController_deviceId_var', function (newValue) {
      console.log("Kevoree attribute lightControllerServer_LightController_deviceId_var updated...");
      if (this.lightControllerServer.LightController_deviceId_var !== newValue) {
        console.log("updating ThingML attribute...");
        this.lightControllerServer.LightController_deviceId_var = newValue;
      }
    });
    this.lightControllerServer.LightController_deviceId_var = this.dictionary.getValue('lightControllerServer_LightController_deviceId_var');
    this.lightControllerServer.onPropertyChange('deviceId', function (newValue) {
      console.log("ThingML attribute lightControllerServer_LightController_deviceId_var updated...");
      if (this.dictionary.getValue('lightControllerServer_LightController_deviceId_var') !== newValue) {
        console.log("updating Kevoree attribute...");
        this.submitScript('set ' + this.getNodeName() + '.' + this.getName() + '.lightControllerServer_LightController_deviceId_var = "' + newValue + '"');
      }
    }.bind(this));
    this.dictionary.on('deviceSession_DeviceSession_deviceId_var', function (newValue) {
      console.log("Kevoree attribute deviceSession_DeviceSession_deviceId_var updated...");
      if (this.deviceSession.DeviceSession_deviceId_var !== newValue) {
        console.log("updating ThingML attribute...");
        this.deviceSession.DeviceSession_deviceId_var = newValue;
      }
    });
    this.deviceSession.DeviceSession_deviceId_var = this.dictionary.getValue('deviceSession_DeviceSession_deviceId_var');
    this.deviceSession.onPropertyChange('deviceId', function (newValue) {
      console.log("ThingML attribute deviceSession_DeviceSession_deviceId_var updated...");
      if (this.dictionary.getValue('deviceSession_DeviceSession_deviceId_var') !== newValue) {
        console.log("updating Kevoree attribute...");
        this.submitScript('set ' + this.getNodeName() + '.' + this.getName() + '.deviceSession_DeviceSession_deviceId_var = "' + newValue + '"');
      }
    }.bind(this));
    this.lightControllerServer._init();
    this.deviceSession._init();
    this.zwave._init();
    done();
  },

  stop: function (done) {
    this.deviceSession._stop();
    this.lightControllerServer._stop();
    this.zwave._stop();
    done();
  },
  in_lig_sen__in: function (msg) { //Dangling ThingML port sensor_service (handling all incoming messages)
    if (msg.split('@:@')[0] === 'reading') {
      this.lightControllerServer.receivereadingOnsensor_service(msg.split('@:@')[1].split(';')[0]);
    } else if (msg.split('@:@')[0] === 'ready') {
      this.lightControllerServer.receivereadyOnsensor_service();
    }
  },
  lig_sen_start_periodic_reading_proxy: function () { //Dangling ThingML port sensor_service (handler for message start_periodic_reading)
    this.out_lig_sen__out('start_periodic_reading@:@' + arguments[0] + ';');
  },
  lig_sen_reading_cancel_proxy: function () { //Dangling ThingML port sensor_service (handler for message reading_cancel)
    this.out_lig_sen__out('reading_cancel@:@');
  },
  lig_sen_read_proxy: function () { //Dangling ThingML port sensor_service (handler for message read)
    this.out_lig_sen__out('read@:@');
  },
  out_lig_sen__out: function (msg) {
    /* Kevoree required port (out) for dangling ThingML port sensor_service
    This will be overwritten @runtime by Kevoree JS */
  },
  in_lig_sen__in: function (msg) { //Dangling ThingML port sensor_mqtt (handling all incoming messages)
    if (msg.split('@:@')[0] === 'readingJson') {
      this.lightControllerServer.receivereadingJsonOnsensor_mqtt(msg.split('@:@')[1].split(';')[0]);
    }
  },
  in_lig_fal__in: function (msg) { //Dangling ThingML port fall (handling all incoming messages)
    if (msg.split('@:@')[0] === 'fall') {
      this.lightControllerServer.receivefallOnfall(msg.split('@:@')[1].split(';')[0], msg.split('@:@')[1].split(';')[1]);
    }
  },
  in_lig_sma__in: function (msg) { //Dangling ThingML port smarttracker (handling all incoming messages)
    if (msg.split('@:@')[0] === 'commandJson') {
      this.lightControllerServer.receivecommandJsonOnsmarttracker(msg.split('@:@')[1].split(';')[0]);
    }
  },
  lig_sma_postJson_proxy: function () { //Dangling ThingML port smarttracker (handler for message postJson)
    this.out_lig_sma__out('postJson@:@' + arguments[0] + ';');
  },
  out_lig_sma__out: function (msg) {
    /* Kevoree required port (out) for dangling ThingML port smarttracker
    This will be overwritten @runtime by Kevoree JS */
  },
  in_dev_sma__in: function (msg) { //Dangling ThingML port smarttracker (handling all incoming messages)
    if (msg.split('@:@')[0] === 'commandJson') {
      this.deviceSession.receivecommandJsonOnsmarttracker(msg.split('@:@')[1].split(';')[0]);
    }
  },
  dev_sma_postJson_proxy: function () { //Dangling ThingML port smarttracker (handler for message postJson)
    this.out_dev_sma__out('postJson@:@' + arguments[0] + ';');
  },
  out_dev_sma__out: function (msg) {
    /* Kevoree required port (out) for dangling ThingML port smarttracker
    This will be overwritten @runtime by Kevoree JS */
  },
  in_lig_sen_readingJson_in: function (msg) { //@protocol "kevoree" for message readingJson on port sensor_mqtt
    this.lightControllerServer.receivereadingJsonOnsensor_mqtt(msg.split(';'));
  },
  in_lig_sma_commandJson_in: function (msg) { //@protocol "kevoree" for message commandJson on port smarttracker
    this.lightControllerServer.receivecommandJsonOnsmarttracker(msg.split(';'));
  },
  lig_sma_postJson_proxy: function () { //@protocol "kevoree" for message postJson on port smarttracker
    this.out_lig_sma_postJson_out(arguments[0]);
  },
  out_lig_sma_postJson_out: function (msg) { /* This will be overwritten @runtime by Kevoree JS */ },
  in_dev_sma_commandJson_in: function (msg) { //@protocol "kevoree" for message commandJson on port smarttracker
    this.deviceSession.receivecommandJsonOnsmarttracker(msg.split(';'));
  },
  dev_sma_postJson_proxy: function () { //@protocol "kevoree" for message postJson on port smarttracker
    this.out_dev_sma_postJson_out(arguments[0]);
  },
  out_dev_sma_postJson_out: function (msg) { /* This will be overwritten @runtime by Kevoree JS */ }
});

module.exports = HomeGWLightController;
brice-morin commented 8 years ago

Just as a quick test, try commenting lines 72 and 73 in the file above. Those lines:

//this.HomeGWLightController_lightControllerServer.getPostJsononsmarttrackerListeners().push(this.lig_sma_postJson_proxy.bind(this));
//this.HomeGWLightController_deviceSession.getPostJsononsmarttrackerListeners().push(this.dev_sma_postJson_proxy.bind(this));
kehusa commented 8 years ago

Then I got one step further. Now I had this error:

Node added: 1ThingML attribute deviceSession_DeviceSession_deviceId_var updated...
updating Kevoree attribute...
/home/pi/test/node_modules/lightcontrol/node_modules/kevoree-entities/lib/KevoreeEntity.js:153
this.getKevoreeCore().submitScript(script, callback);
^
TypeError: undefined is not a function
at PseudoClass.Class.submitScript (/home/pi/test/node_modules/lightcontrol/node_modules/kevoree-entities/lib/KevoreeEntity.js:153:31)
at PseudoClass.<anonymous> (/home/pi/test/node_modules/lightcontrol/lib/HomeGWLightController.js:91:6)
at /home/pi/test/node_modules/lightcontrol/lib/DeviceSession.js:374:39
at invoke (/home/pi/test/node_modules/lightcontrol/node_modules/state.js/lib/state.com.js:840:9)
at traverse (/home/pi/test/node_modules/lightcontrol/node_modules/state.js/lib/state.com.js:949:5)
at evaluateState (/home/pi/test/node_modules/lightcontrol/node_modules/state.js/lib/state.com.js:925:22)
at /home/pi/test/node_modules/lightcontrol/node_modules/state.js/lib/state.com.js:907:17
at Array.every (native)
at evaluateState (/home/pi/test/node_modules/lightcontrol/node_modules/state.js/lib/state.com.js:906:23)
at Object.evaluate (/home/pi/test/node_modules/lightcontrol/node_modules/state.js/lib/state.com.js:898:12)
kehusa commented 8 years ago

But isn't that the same as npm -i lightcontrol.

Knut Eilif

Den ons. 3. aug. 2016, 18:30 skrev Brice Morin notifications@github.com:

Or actually send me the whole generate code

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/HEADS-project/training/issues/115#issuecomment-237230109, or mute the thread https://github.com/notifications/unsubscribe-auth/AIN55wCE0QJ6NT8jzt2eU7TDJAjEeAc6ks5qcJJBgaJpZM4JbmV0 .

brice-morin commented 8 years ago

@maxleiko did you change something around the submitScript method?

maxleiko commented 8 years ago

@brice-morin nope

maxleiko commented 8 years ago

My instinct tells me this is due to a this mixup in the generated code.

brice-morin commented 8 years ago

Well, I can believe that, this is a somewhat relative theory in JS when you come from Java... and had to do some trick to try to make it more absolute...

maxleiko commented 8 years ago

Looks like it's working :+1: (just kidding)

brice-morin commented 8 years ago

OK, I reproduced an example that updates a @kevoree "instance" attribute in ThingML and reflect this update in Kevoree. It seems to work. Note that I changed the ThingML -> Kevoree compiler (which is now a proper network plugin in the ThingML code generation framework). Update your HEADS IDE in some minutes and retry.

kehusa commented 8 years ago

nodejs/kevoreejs option seems to be gone in Heads menu element.

2016-08-05 10:26 GMT+02:00 Brice Morin notifications@github.com:

OK, I reproduced an example that updates a @kevoree "instance" attribute in ThingML and reflect this update in Kevoree. It seems to work. Note that I changed the ThingML -> Kevoree compiler (which is now a proper network plugin in the ThingML code generation framework). Update your HEADS IDE in some minutes and retry.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/HEADS-project/training/issues/115#issuecomment-237787095, or mute the thread https://github.com/notifications/unsubscribe-auth/AIN554eSXvpolep8y1Qh5gcK0_OhC_lqks5qcvOtgaJpZM4JbmV0 .

| Knut Eilif Husa | Tellu AS | Lensmannslia 4, 1386 Asker - NORWAY| Direct: +47 452 49496 | www.tellu.no |

This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system.

brice-morin commented 8 years ago

Indeed :-)

You now just need to compile as plain node.js. Based on the @kevoree annotations, we will automatically generate the Kevoree related code without you needing to explicitly ask for it. Yes, I saved you a click ;-)

kehusa commented 8 years ago

Are there any new annotations I have to add to my code then? Or will it work as it is?

2016-08-05 11:32 GMT+02:00 Brice Morin notifications@github.com:

Indeed :-)

You now just need to compile as plain node.js. Based on the @kevoree annotations, we will automatically generate the Kevoree related code without you needing to explicitly ask for it. Yes, I saved you a click ;-)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/HEADS-project/training/issues/115#issuecomment-237806404, or mute the thread https://github.com/notifications/unsubscribe-auth/AIN550yBBXID4n-ZJmAsoNMIeqzbBIseks5qcwNHgaJpZM4JbmV0 .

| Knut Eilif Husa | Tellu AS | Lensmannslia 4, 1386 Asker - NORWAY| Direct: +47 452 49496 | www.tellu.no |

This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system.

brice-morin commented 8 years ago

Should work as is

kehusa commented 8 years ago

Tried running wit last version bu I still got the error with submitScript: ThingML attribute deviceSession_DeviceSession_deviceId_var updated... updating Kevoree attribute... /home/pi/test/node_modules/lightcontrol/node_modules/kevoree-entities/lib/KevoreeEntity.js:153 this.getKevoreeCore().submitScript(script, callback); ^ TypeError: undefined is not a function at PseudoClass.Class.submitScript (/home/pi/test/node_modules/lightcontrol/node_modules/kevoree-entities/lib/KevoreeEntity.js:153:31) at PseudoClass. (/home/pi/test/node_modules/lightcontrol/lib/HomeGWLightController.js:96:6) at /home/pi/test/node_modules/lightcontrol/lib/DeviceSession.js:419:39 at invoke (/home/pi/test/node_modules/lightcontrol/node_modules/state.js/lib/state.com.js:840:9) at traverse (/home/pi/test/node_modules/lightcontrol/node_modules/state.js/lib/state.com.js:949:5) at evaluateState (/home/pi/test/node_modules/lightcontrol/node_modules/state.js/lib/state.com.js:925:22) at /home/pi/test/node_modules/lightcontrol/node_modules/state.js/lib/state.com.js:907:17 at Array.every (native) at evaluateState (/home/pi/test/node_modules/lightcontrol/node_modules/state.js/lib/state.com.js:906:23) at Object.evaluate (/home/pi/test/node_modules/lightcontrol/node_modules/state.js/lib/state.com.js:898:12)

2016-08-05 12:53 GMT+02:00 Brice Morin notifications@github.com:

Should work as is

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/HEADS-project/training/issues/115#issuecomment-237821864, or mute the thread https://github.com/notifications/unsubscribe-auth/AIN55-oelY7HUDgBu6cyCFRgNmJpCxEYks5qcxY0gaJpZM4JbmV0 .

| Knut Eilif Husa | Tellu AS | Lensmannslia 4, 1386 Asker - NORWAY| Direct: +47 452 49496 | www.tellu.no |

This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system.

brice-morin commented 8 years ago

Ok, I will look for a quick fix early next week. After that, I will start a big refactoring using @maxleiko inputs to improve the generated code and stop struggling with 'this'

brice-morin commented 8 years ago

in HomeGWLightController can you replace bind(this) with bind(HomeGWLightController )?

I have a hard time reproducing the bug here on a small system I can easily run. So I will probably ask you to try different things, while I try to reproduce the bug here.

kehusa commented 8 years ago

Got this with the last version:

lightcontrol@1.0.46 node_modules/lightcontrol
├── state.js@5.7.0
└── kevoree-entities@8.1.0 (pseudoclass@1.0.3, kevoree-commons@2.2.1, kevoree-library@5.0.9)
15:29:53 ERROR Bootstrapper TypeError: undefined is not a function
at PseudoClass.AbstractComponent.extend.construct (/home/pi/test/node_modules/lightcontrol/lib/HomeGWLightController.js:22:20)
at PseudoClass.prototype.construct (/home/pi/test/node_modules/lightcontrol/node_modules/kevoree-entities/node_modules/pseudoclass/source/Class.js:275:17)
at new PseudoClass (/home/pi/test/node_modules/lightcontrol/node_modules/kevoree-entities/node_modules/pseudoclass/source/Class.js:216:19)
at PseudoClass.module.exports.AdaptationPrimitive.extend.execute (/home/pi/test/node_modules/kevoree-node-javascript/lib/adaptations/AddInstance.js:37:36)
at executeCommand (/usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-core/kevoree-core.js:161:41)
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-core/node_modules/async/lib/async.js:187:20
at iterate (/usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-core/node_modules/async/lib/async.js:265:13)
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-core/node_modules/async/lib/async.js:277:29
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-core/node_modules/async/lib/async.js:44:16
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-core/kevoree-core.js:170:41
15:29:53 ERROR KevoreeCore Error: Something went wrong while processing adaptations.
'kevoree-comp-mqttpubclient' bootstrap failed!
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-commons/lib/Bootstrapper.js:68:33
at PseudoClass.<anonymous> (/usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-resolvers/lib/NPMResolver.js:39:21)
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-resolvers/node_modules/exec-npm-install/exec-npm-install.js:50:21
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-resolvers/node_modules/exec-npm-install/node_modules/async/lib/async.js:52:16
at done (/usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-resolvers/node_modules/exec-npm-install/node_modules/async/lib/async.js:248:21)
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-resolvers/node_modules/exec-npm-install/node_modules/async/lib/async.js:44:16
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-resolvers/node_modules/exec-npm-install/exec-npm-install.js:25:21
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-resolvers/node_modules/exec-npm-install/lib/exists.js:29:29
at /usr/local/lib/node_modules/kevoree-nodejs-runtime/node_modules/kevoree-resolvers/node_modules/npm-vers/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:76:16
at fs.js:336:14
15:29:53 WARN KevoreeCore Shutting down Kevoree because first deployment failed...
15:29:53 INFO KevoreeCore Model deployed successfully: 0 adaptations (54ms)
15:29:53 INFO KevoreeCore Platform stopped: node0
brice-morin commented 8 years ago

Hmmmm... I tried to compile this ThingML file and it seems to work (except that it crashes because for some reason, it was some problem with openzwave-shared). Is that the right ThingML configuration you are trying to get running? Or is it another one?

Also I pushed another (small but useful) update to the Eclipse plugins this morning.