Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

  • core 3.4.5 + mangoApi 3.4.6
    Hello I'm experimenting with the mdp-time-picker where I store the light on/off times in arduino based controller as a Unix EPOCH. Works fine so far via the watch list. I have CV (current value) and SP (setpoint). I slapped together some very temporary code and everything works except when I click "test restore" all values restore accept for the HH::MM value in in the time-picker. When one drills down on it, the underlying info is updated and if I hit Ok then it gets refreshed. see attached screen shot

    not so nice HTML stuff

    <div layout="row" flex="" layout-wrap="" layout-align="space-between">
        <ma-get-point-value point-xid="DP_c373b0f5-9962-42da-8f4e-732e4928549d" point="DY_103_OFT_CV"></ma-get-point-value>
        <ma-get-point-value point-xid="DP_c5b8682a-5404-4cff-8440-71b178164cc9" point="DY_103_ONT_CV"></ma-get-point-value>
        <ma-get-point-value point-xid="DP_4de82242-f4df-4144-8d81-4657084a714a" point="DY_103_OFT_SP"></ma-get-point-value>
        <ma-get-point-value point-xid="DP_01f2db2e-2aa4-466d-a9c5-f06e4420a3cb" point="DY_103_ONT_SP"></ma-get-point-value>
        <md-card-content>
            Growing Chamber
            <div layout="column" ng-controller="lightController" ng-init="init(1535557320,1535557920)">
                <p>{{DY_103_OFT_CV.value}} PO:{{pendingOffTime}}
                </p>
                <p>{{persistOffTime()}}</p>
                <md-button ng-click="init2(DY_103_OFT_CV.value)" class="md-raised"> Test Restore</md-button>
                <mdp-time-picker mdp-placeholder="Off Time" mdp-format="hh:mm" mdp-open-on-click mdp-auto-switch="true" ng-model="pendingOffTime"></mdp-time-picker>
                <md-button ng-click="DY_103_OFT_SP.setValue(persistOffTime())" class="md-raised">Set to {{persistOffTime()}}</md-button>
                <p>END GC</p>
            </div>
    

    userModule.js - not so nice code.

    define(['angular', 'require'], function(angular, require) {
    'use strict';
    
    var userModule = angular.module('userModule', ['maUiApp']);
    
    userModule.component('myComponent', {
        bindings: {
            name: '@?'
        },
        template: '<span>Hello {{$ctrl.name}}</span>'
    });
    
    // d
    userModule.controller('lightController', ['$scope', function($scope) {
      $scope.init = function(aOffTime, aOnTime)
      {
    
     	$scope.currentOffTime = new Date ( aOffTime * 1000);
       $scope.pendingOffTime = new Date ( aOffTime * 1000);
      };
    
    //$scope.currentOffTime = new Date(0);
    //$scope.pendingOffTime = new Date(0);
      $scope.persistOffTime = function() {  return ( $scope.pendingOffTime.valueOf() / 1000 ) }
    
    $scope.init2 = function( aOffTime)
    {
    	$scope.pendingOffTime.setTime(aOffTime * 1000 );
    	//return( $scope.pendingOffTime.toLocaleTimeString() );
    
    //return( "co:" + aOffTime * 1000 );	
    }
    }]);
    
    return userModule;
    
    }); // define
    

  • My only thought is for you is as ngModel is used for inputs, set the value by doing

    $scope.pendingOffTime=(aOffTime * 1000);
    

    instead.
    Although you may need to make (aOffTime * 1000); into a moment object first...


  • Thanks for the reply.
    I removed the need for a controller albeit at the expense of not exactly what I wanted. I was access to the mdp-time-picker as setup under under mango so I can get events. I also did no see how to include moment in my module. Tried different ways but did not work.

    I ended up with this for now.

    <div layout="row" flex="" layout-wrap="" layout-align="space-between">
        <ma-get-point-value point-xid="DP_c373b0f5-9962-42da-8f4e-732e4928549d" point="DY_103_OFT_CV"></ma-get-point-value>
        <ma-get-point-value point-xid="DP_c5b8682a-5404-4cff-8440-71b178164cc9" point="DY_103_ONT_CV"></ma-get-point-value>
        <ma-get-point-value point-xid="DP_4de82242-f4df-4144-8d81-4657084a714a" point="DY_103_OFT_SP"></ma-get-point-value>
        <ma-get-point-value point-xid="DP_01f2db2e-2aa4-466d-a9c5-f06e4420a3cb" point="DY_103_ONT_SP"></ma-get-point-value>
        <md-card-content>
            Growing Chamber
            <div layout="column">
                <div layout="row">
                    <mdp-time-picker mdp-placeholder="Off Time" mdp-format="hh:mm A" mdp-auto-switch="true" ng-model="offTime">
                        <p>Current Off Time: {{DY_103_OFT_CV.value * 1000 | maMoment:'format':'hh:mm A'}}</p>
                        <md-button ng-show="offTime != null" ng-click="DY_103_OFT_SP.setValue(offTime.valueOf() / 1000)" class="md-raised">Update</md-button>
                    </mdp-time-picker>
                    <mdp-time-picker mdp-placeholder="On Time" mdp-format="hh:mm A" mdp-auto-switch="true" ng-model="onTime">
                        <p>Current Off Time: {{DY_103_ONT_CV.value * 1000 | maMoment:'format':'hh:mm A'}}</p>
                        <md-button ng-show="onTime != null" ng-click="DY_103_ONT_SP.setValue(onTime.valueOf() / 1000)" class="md-raised">Update</md-button>
                    </mdp-time-picker>
                </div>
            </div>
    

  • To get moment in your controller:
    Change

    define(['angular', 'require'], function(angular, require) {
    

    To

    define(['angular', 'require','moment-timezone'], function(angular, require, moment) {
    

    in userModule.js

    Fox


  • Thanks. I