<commit_before>"use strict";

// if local development, communicate with DEFAULT_HOSTNAME, otherwise - with web-UI host
const DEFAULT_HOSTNAME = "demo.semiot.ru";
const hostname = location.hostname === "localhost" ? DEFAULT_HOSTNAME : location.hostname;

const TSDB_BASE_URL = `http://${hostname}:4242/api/query`;

export default {
    COOKIE_NAME: "ru.semiot",
    VERSION: `@VERSION`,
    URLS: {
        messageBus: "ws://" + hostname + ":8080/ws",
        tripleStore: "http://" + hostname + ":3030/ds/query",
        tsdb: {
            archiveQuantity: `${TSDB_BASE_URL}?start={0}&end={1}&m=sum:{2}`,
            archiveEnum: `${TSDB_BASE_URL}?start={0}&end={1}&m=sum:{2}{enum_value=*}`,
            last: `${TSDB_BASE_URL}/last/{0}`
        }
    },
    TOPICS: {
        "device_registered": 'ru.semiot.devices.newandobserving',
        "device_turned_off": 'ru.semiot.devices.turnoff',
        "device_remove": 'ru.semiot.devices.remove'
    },
    SPARQL: {
        prefixes: {
            rdfs: 'http://www.w3.org/2000/01/rdf-schema#',
            ssn: 'http://purl.oclc.org/NET/ssnx/ssn#',
            rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
            ssncom: 'http://purl.org/NET/ssnext/communication#',
            saref: 'http://ontology.tno.nl/saref#',
            mcht: 'http://purl.org/NET/ssnext/machinetools#',
            qudt: 'http://www.qudt.org/qudt/owl/1.0.0/qudt/#',
            "qudt-quantity": 'http://qudt.org/vocab/quantity#',
            "qudt-unit": "http://qudt.org/vocab/unit#",
            om: 'http://purl.org/ifgi/om#'
        },
        types: {
            heatSystem: "http://purl.org/NET/ssnext/heatmeters#HeatMeter",
            electricSystem: "http://purl.org/NET/ssnext/electricmeters#ElectricMeter",
            temperature: "http://purl.org/NET/ssnext/heatmeters#Temperature",
            heat: "http://purl.org/NET/ssnext/heatmeters#Heat",
            observationResult: "http://purl.org/NET/ssnext/meters/core#hasQuantityValue"
        },
        queries: {
            getAllSystems: [
                "SELECT DISTINCT ?label ?uri ?state",
                "WHERE {",
                "   ?uri a ssn:System ;",
                "       saref:hasState ?state ;",
                "       rdfs:label ?label .",
                "}"
            ].join('\n'),
            getSystemEndpoint: `
                SELECT ?endpoint ?type ?observationType ?propLabel ?valueUnitLabel {
                  <{0}> ssn:hasSubSystem ?subsystem .
                  ?subsystem ssn:observes ?type .
                  ?subsystem ssn:hasMeasurementCapability ?mc .
                  ?mc ssn:forProperty ?prop .
                  ?prop rdfs:label ?propLabel .
                  ?mc ssn:hasMeasurementProperty ?mp .
                  ?mp ssn:hasValue ?v .
                  ?v a ?observationType .
                  ?v ssn:hasValue ?valueUnit .
                  ?valueUnit rdfs:label ?valueUnitLabel .
                  ?subsystem ssncom:hasCommunicationEndpoint ?endpoint .
                  ?endpoint ssncom:protocol 'WAMP' .
                }
            `,
            getSystemName: [
                "SELECT ?label {",
                "   <{0}> rdfs:label ?label .",
                "}"
            ].join('\n'),
            getMachineToolStates: `
                SELECT ?stateURI ?stateLabel ?stateDescription
                WHERE {
                    ?stateURI rdf:type mcht:MachineToolWorkingStateValue ;
                        rdfs:label ?stateLabel ;
                        rdfs:comment ?stateDescription .
                }
            `
        }
    },
    TIMEZONE_OFFSET: -1 * new Date().getTimezoneOffset() * 60 * 1000 // in ms
};
<commit_msg>#86 Close<commit_after>"use strict";

// change it to target hostname when develop
const DEFAULT_HOSTNAME = "localhost";
const hostname = location.hostname === "localhost" ? DEFAULT_HOSTNAME : location.hostname;

const TSDB_BASE_URL = `http://${hostname}:4242/api/query`;

export default {
    COOKIE_NAME: "ru.semiot",
    VERSION: `@VERSION`,
    URLS: {
        messageBus: "ws://" + hostname + ":8080/ws",
        tripleStore: "http://" + hostname + ":3030/ds/query",
        tsdb: {
            archiveQuantity: `${TSDB_BASE_URL}?start={0}&end={1}&m=sum:{2}`,
            archiveEnum: `${TSDB_BASE_URL}?start={0}&end={1}&m=sum:{2}{enum_value=*}`,
            last: `${TSDB_BASE_URL}/last/{0}`
        }
    },
    TOPICS: {
        "device_registered": 'ru.semiot.devices.newandobserving',
        "device_turned_off": 'ru.semiot.devices.turnoff',
        "device_remove": 'ru.semiot.devices.remove'
    },
    SPARQL: {
        prefixes: {
            rdfs: 'http://www.w3.org/2000/01/rdf-schema#',
            ssn: 'http://purl.oclc.org/NET/ssnx/ssn#',
            rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
            ssncom: 'http://purl.org/NET/ssnext/communication#',
            saref: 'http://ontology.tno.nl/saref#',
            mcht: 'http://purl.org/NET/ssnext/machinetools#',
            qudt: 'http://www.qudt.org/qudt/owl/1.0.0/qudt/#',
            "qudt-quantity": 'http://qudt.org/vocab/quantity#',
            "qudt-unit": "http://qudt.org/vocab/unit#",
            om: 'http://purl.org/ifgi/om#'
        },
        types: {
            heatSystem: "http://purl.org/NET/ssnext/heatmeters#HeatMeter",
            electricSystem: "http://purl.org/NET/ssnext/electricmeters#ElectricMeter",
            temperature: "http://purl.org/NET/ssnext/heatmeters#Temperature",
            heat: "http://purl.org/NET/ssnext/heatmeters#Heat",
            observationResult: "http://purl.org/NET/ssnext/meters/core#hasQuantityValue"
        },
        queries: {
            getAllSystems: [
                "SELECT DISTINCT ?label ?uri ?state",
                "WHERE {",
                "   ?uri a ssn:System ;",
                "       saref:hasState ?state ;",
                "       rdfs:label ?label .",
                "}"
            ].join('\n'),
            getSystemEndpoint: `
                SELECT ?endpoint ?type ?observationType ?propLabel ?valueUnitLabel {
                  <{0}> ssn:hasSubSystem ?subsystem .
                  ?subsystem ssn:observes ?type .
                  ?subsystem ssn:hasMeasurementCapability ?mc .
                  ?mc ssn:forProperty ?prop .
                  ?prop rdfs:label ?propLabel .
                  ?mc ssn:hasMeasurementProperty ?mp .
                  ?mp ssn:hasValue ?v .
                  ?v a ?observationType .
                  ?v ssn:hasValue ?valueUnit .
                  ?valueUnit rdfs:label ?valueUnitLabel .
                  ?subsystem ssncom:hasCommunicationEndpoint ?endpoint .
                  ?endpoint ssncom:protocol 'WAMP' .
                }
            `,
            getSystemName: [
                "SELECT ?label {",
                "   <{0}> rdfs:label ?label .",
                "}"
            ].join('\n'),
            getMachineToolStates: `
                SELECT ?stateURI ?stateLabel ?stateDescription
                WHERE {
                    ?stateURI rdf:type mcht:MachineToolWorkingStateValue ;
                        rdfs:label ?stateLabel ;
                        rdfs:comment ?stateDescription .
                }
            `
        }
    },
    TIMEZONE_OFFSET: -1 * new Date().getTimezoneOffset() * 60 * 1000 // in ms
};
<|endoftext|>


<commit_before>export { Base }; // Stage.BlockParamsCreator.Base

import * as Pool from "../../util/Pool.js";
import * as Recyclable from "../../util/Recyclable.js";
import * as ValueDesc from "../../../Unpacker/ValueDesc.js";
import * as Block from "../../Block.js";
import { Params } from "../Stage_Params.js";

/**
 * Base class for all Stage.BlockParamsCreator.Xxx classes.
 *
 *
 * @member {number} outChannels0
 *   The output0's channel count in current configuration.
 *
 * @member {number} outChannels1
 *   The output1's channel count in current configuration.
 *
 */
class Base {

  /**
   * @param {Params} stageParams
   *   The Stage.Params object which provides basic parameters.
   */
  constructor( stageParams ) {
    this.stageParams = stageParams;

//       this.input0_height, this.input0_width, this.input0_channelCount,
//       this.nConvBlockTypeId,
//       this.pointwise1ChannelCount,
//       this.depthwise_AvgMax_Or_ChannelMultiplier, this.depthwiseFilterHeight, this.depthwiseFilterWidth, this.depthwiseStridesPad,
//       this.depthwiseActivationId,
//       this.pointwise20ChannelCount, this.pointwise20ActivationId,
//       this.nSqueezeExcitationChannelCountDivisor, this.bSqueezeExcitationPrefix,
//       this.nActivationId,
//       this.bKeepInputTensor

    this.inputHeight0 = this.inputWidth0 =
    this.channelCount0_pointwise1Before = this.channelCount1_pointwise1Before =
    this.pointwise1ChannelCount = this.bPointwise1Bias = this.pointwise1ActivationId =
    this.depthwise_AvgMax_Or_ChannelMultiplier = this.depthwiseFilterHeight = this.depthwiseFilterWidth =
    this.depthwiseStridesPad = this.bDepthwiseBias = this.depthwiseActivationId =
    this.pointwise20ChannelCount = this.bPointwise20Bias = this.pointwise20ActivationId =
    this.bOutput1Requested = this.bKeepInputTensor = undefined;

    this.blockCount = // How many block should be in the stage.
    this.depthwiseFilterHeight_Default = this.depthwiseFilterWidth_Default = // The default depthwise filter size.
    this.depthwiseFilterHeight_Last = this.depthwiseFilterWidth_Last =       // The last block's depthwise filter size.
    this.outChannels0 = this.outChannels1 = -1;

    this.channelShuffler = undefined;
  }

  /** Called to determine blockCount, depthwiseFilterHeight_Default, depthwiseFilterWidth_Default, depthwiseFilterHeight_Last,
    * depthwiseFilterWidth_Last.
    *
    * Sub-class could override this method to adjust data members.
    */
  determine_blockCount_depthwiseFilterHeightWidth_Default_Last() {
    let stageParams = this.stageParams;
    this.blockCount = stageParams.blockCountRequested; // By default, the block count is just the original block count.

    // By default, all blocks uses the original depthwise filter size.
    this.depthwiseFilterHeight_Default = this.depthwiseFilterHeight_Last = stageParams.depthwiseFilterHeight;
    this.depthwiseFilterWidth_Default = this.depthwiseFilterWidth_Last = stageParams.depthwiseFilterWidth;
  }

  /**
   * Called before block0 is about to be created. Sub-class should override this method to adjust data members.
   *
   * Block 0.
   *
   * The special points of a stage's block 0 are:
   *   - halve the height x width. (Both ShuffleNetV2 and MobileNetV2) (by depthwise convolution with strides = 2)
   *   - Double channels. (Please see explanation of class Stage.Base)
   */
  configTo_beforeBlock0() {
    let stageParams = this.stageParams;

    this.inputHeight0 = stageParams.sourceHeight; // block0 inputs the source image size.
    this.inputWidth0 = stageParams.sourceWidth;

    this.bias_activation_setup_forBlock0(); // bias, activation of pointwise1, depthwise1, pointwise2

    this.depthwiseFilterHeight = this.depthwiseFilterHeight_Default;
    this.depthwiseFilterWidth = this.depthwiseFilterWidth_Default;

    // block0 uses depthwise ( strides = 2, pad = "same" ) to halve ( height, width ).
    this.depthwiseStridesPad = ValueDesc.StridesPad.Singleton.Ids.STRIDES_2_PAD_SAME;

    this.bKeepInputTensor = stageParams.bKeepInputTensor; // block0 may or may not keep input tensor according to caller's necessary.

//!!! ...unfinished... (2022/06/08)
// If (
//        ( ( inputHeight == 1 ) && ( inputWidth == 1 ) )
//     && ( depthwise_AvgMax_Or_ChannelMultiplier <= 1 ) // i.e. avg or max or none or ( channelMultiplier == 1 ).
//     && ( depthwiseActivationId == ValueDesc.ActivationFunction.Singleton.Ids.NONE ) // i.e. depthwise is linear.
//     && (   ( nSqueezeExcitationChannelCountDivisor == ValueDesc.SqueezeExcitationChannelCountDivisor.Singleton.Ids.NONE ) // (-2), no squeeze-and-excitation (i.e. depthwise is linear)
//         || ( bSqueezeExcitationPrefix == false ) ) // or, has squeeze-and-excitation, but after pointwise2. (i.e. depthwise is still linear)
//        )
//    )
//
// Then, the depthwise should be discarded to improve performance.
// Perhaps, this automatical optimization could be done in Block.Base (i.e. not in Stage).
//

  }

  /**
   * Called after block0 is created (i.e. before block1, 2, 3, ...). Sub-class should override this method to adjust data members.
   */
  configTo_afterBlock0() {
    this.inputHeight0 = this.stageParams.outputHeight; // all blocks (except block0) inputs half the source image size.
    this.inputWidth0 = this.stageParams.outputWidth;

    // All blocks (except block0 in NoPointwise1) will not double the channel count by depthwise, because block0 has already double
    // output channel count.
    //
    this.depthwise_AvgMax_Or_ChannelMultiplier = 1;

    // All blocks (except block0) uses depthwise ( strides = 1, pad = "same" ) to keep ( height, width ).
    this.depthwiseStridesPad = ValueDesc.StridesPad.Singleton.Ids.STRIDES_1_PAD_SAME;

    this.bKeepInputTensor = false; // No matter bKeepInputTensor, all blocks (except block0) should not keep input tensor.
  }

  /**
   * Called before blockLast is about to be created. Sub-class could override this method to adjust data members.
   */
  configTo_beforeBlockLast() {

    // Besides, the blockLast may use a different depthwise filter size. This is especially true for NotShuffleNet_NotMobileNet.
    this.depthwiseFilterHeight = this.depthwiseFilterHeight_Last;
    this.depthwiseFilterWidth = this.depthwiseFilterWidth_Last;

    this.bias_activation_setup_forBlockLast(); // bias, activation of pointwise1, depthwise1, pointwise2
  }

  /**
   * Config the bias and activation of pointwise1, depthwise1, pointwise2 for block0.
   */
  bias_activation_setup_forBlock0() {
    let stageParams = this.stageParams;

    // pointwise1
    {
      this.bPointwise1Bias = true;
      this.pointwise1ActivationId = stageParams.nActivationId;
    }

    // depthwise
    {
      // MobileNetV2_Xxx's depthwise have bias and activation (to remedy its pointwise2's no activation).
      //
      if ( ValueDesc.ConvStageType.isMobileNetV2( stageParams.nConvStageType ) ) {
        this.bDepthwiseBias = true;
        this.depthwiseActivationId = stageParams.nActivationId;

      // non-MobileNetV2_Xxx's depthwise have no bias and no activation. (since they will be done at (squeeze-and-excitation
      // and) pointwise2.)
      //
      } else {
        this.bDepthwiseBias = false;
        this.depthwiseActivationId = ValueDesc.ActivationFunction.Singleton.Ids.NONE;

//!!! ...unfinished... (2022/06/17)
// If there is squeeze-and-excitation prefix pointwise2, the depthwise should be viewed as non-linear (even if depthwise activation
// does not exist). In this case, depthwise's bias should be existed too.

      }
    }

    // pointwise2
    {
      this.bPointwise20Bias = true; // All blocks' outputs needs bias (even if MobileNetV2_Xxx).

      // MobileNetV2_Xxx's pointwise2 always does not have activation function.
      //
      // The reason is that MobileNetV2_Xxx's pointwise2 has add-input-to-output so its block's output is not affine transformation
      // (even if no activation function). It and the next block's pointwise1 is not continuous multiple affine transformation
      // and will not become just one affine transformation.
      //
      if ( ValueDesc.ConvStageType.isMobileNetV2( stageParams.nConvStageType ) ) {
        this.pointwise20ActivationId = ValueDesc.ActivationFunction.Singleton.Ids.NONE;

      // For all other ConvStageType, all non-blockLast's pointwise2 must have activation function (to become non-affine transformation).
      // The reason is to avoid the previous block's pointwise2 and the next block's pointwis1 become just one affine transformation.
      } else {
        this.pointwise20ActivationId = stageParams.nActivationId;
      }
    }
  }

  /**
   * Config the bias and activation of pointwise1, depthwise1, pointwise2 for blockLast.
   */
  bias_activation_setup_forBlockLast() {
    let stageParams = this.stageParams;

    // pointwise2
    {
      // MobileNetV2_Xxx's pointwise2 always does not have activation function.
      //
      // The reason is that MobileNetV2_Xxx's pointwise2 has add-input-to-output so its block's output is not affine transformation
      // (even if no activation function). It and the next block's pointwise1 is not continuous multiple affine transformation
      // and will not become just one affine transformation.
      //
      if ( ValueDesc.ConvStageType.isMobileNetV2( stageParams.nConvStageType ) ) {
        this.pointwise20ActivationId = ValueDesc.ActivationFunction.Singleton.Ids.NONE;

      // For all other ConvStageType, whether blockLast's pointwise2 has activation function is according to the specified flag.
      } else {
        if ( stageParams.bPointwise2ActivatedAtStageEnd == false ) {
          this.pointwise20ActivationId = ValueDesc.ActivationFunction.Singleton.Ids.NONE;
        } else {
          this.pointwise20ActivationId = stageParams.nActivationId;
        }
      }
    }
  }

  /**
   *
   * @return {Block.Params}
   *   Create and return a Block.Params according to this object's current state.
   */
  create_BlockParams() {
    let params = Block.Params.Pool.get_or_create_by(
      this.input0_height, this.input0_width, this.input0_channelCount,
      this.nConvBlockTypeId,
      this.pointwise1ChannelCount,
      this.depthwise_AvgMax_Or_ChannelMultiplier, this.depthwiseFilterHeight, this.depthwiseFilterWidth, this.depthwiseStridesPad,
      this.depthwiseActivationId,
      this.pointwise20ChannelCount, this.pointwise20ActivationId,
      this.nSqueezeExcitationChannelCountDivisor, this.bSqueezeExcitationPrefix,
      this.nActivationId,
      this.bKeepInputTensor
    );
    return params;
  }

}
<commit_msg>Update Base.js<commit_after>export { Base }; // Stage.BlockParamsCreator.Base

import * as Pool from "../../util/Pool.js";
import * as Recyclable from "../../util/Recyclable.js";
import * as ValueDesc from "../../../Unpacker/ValueDesc.js";
import * as Block from "../../Block.js";
import { Params } from "../Stage_Params.js";

/**
 * Base class for all Stage.BlockParamsCreator.Xxx classes.
 *
 *
 * @member {number} outChannels0
 *   The output0's channel count in current configuration.
 *
 * @member {number} outChannels1
 *   The output1's channel count in current configuration.
 *
 */
class Base extends Recyclable.Root {

  /**
   * Used as default Stage.BlockParamsCreator.Base provider for conforming to Recyclable interface.
   */
  static Pool = new Pool.Root( "Stage.BlockParamsCreator.Base.Pool", Base, Base.setAsConstructor );

  /**
   * @param {Params} stageParams
   *   The Stage.Params object which provides basic parameters.
   */
  constructor( stageParams ) {
    super();
    Base.setAsConstructor_self.call( this, stageParams );
  }

  /** @override */
  static setAsConstructor() {
    super.setAsConstructor();
    Base.setAsConstructor_self.call( this, stageParams );
    return this;
  }

  /** @override */
  static setAsConstructor_self( stageParams ) {
    this.stageParams = stageParams;
  }

  /** @override */
  disposeResources() {
    this.channelShuffler = undefined;

    this.blockCount = undefined; // How many block should be in the stage.
    this.depthwiseFilterHeight_Default = undefined;
    this.depthwiseFilterWidth_Default = undefined; // The default depthwise filter size.
    this.depthwiseFilterHeight_Last = undefined;
    this.depthwiseFilterWidth_Last = undefined;       // The last block's depthwise filter size.
    this.outChannels0 = undefined;
    this.outChannels1 = undefined;

    this.bKeepInputTensor = undefined;
    this.nActivationId = undefined;
    this.bSqueezeExcitationPrefix = undefined;
    this.nSqueezeExcitationChannelCountDivisor = undefined;
    this.pointwise20ActivationId = undefined;
    this.pointwise20ChannelCount = undefined;
    this.depthwiseActivationId = undefined;
    this.depthwiseStridesPad = undefined;
    this.depthwiseFilterWidth = undefined;
    this.depthwiseFilterHeight = undefined;
    this.depthwise_AvgMax_Or_ChannelMultiplier = undefined;
    this.pointwise1ChannelCount = undefined;
    this.nConvBlockTypeId = undefined;
    this.input0_channelCount = undefined;
    this.input0_width = undefined;
    this.input0_height = undefined;

    this.stageParams = undefined;

    super.disposeResources();
  }

  /** Called to determine blockCount, depthwiseFilterHeight_Default, depthwiseFilterWidth_Default, depthwiseFilterHeight_Last,
    * depthwiseFilterWidth_Last.
    *
    * Sub-class could override this method to adjust data members.
    */
  determine_blockCount_depthwiseFilterHeightWidth_Default_Last() {
    let stageParams = this.stageParams;
    this.blockCount = stageParams.blockCountRequested; // By default, the block count is just the original block count.

    // By default, all blocks uses the original depthwise filter size.
    this.depthwiseFilterHeight_Default = this.depthwiseFilterHeight_Last = stageParams.depthwiseFilterHeight;
    this.depthwiseFilterWidth_Default = this.depthwiseFilterWidth_Last = stageParams.depthwiseFilterWidth;
  }

  /**
   * Called before block0 is about to be created. Sub-class should override this method to adjust data members.
   *
   * Block 0.
   *
   * The special points of a stage's block 0 are:
   *   - halve the height x width. (Both ShuffleNetV2 and MobileNetV2) (by depthwise convolution with strides = 2)
   *   - Double channels. (Please see explanation of class Stage.Base)
   */
  configTo_beforeBlock0() {
    let stageParams = this.stageParams;

    this.inputHeight0 = stageParams.sourceHeight; // block0 inputs the source image size.
    this.inputWidth0 = stageParams.sourceWidth;

    this.bias_activation_setup_forBlock0(); // bias, activation of pointwise1, depthwise1, pointwise2

    this.depthwiseFilterHeight = this.depthwiseFilterHeight_Default;
    this.depthwiseFilterWidth = this.depthwiseFilterWidth_Default;

    // block0 uses depthwise ( strides = 2, pad = "same" ) to halve ( height, width ).
    this.depthwiseStridesPad = ValueDesc.StridesPad.Singleton.Ids.STRIDES_2_PAD_SAME;

    this.bKeepInputTensor = stageParams.bKeepInputTensor; // block0 may or may not keep input tensor according to caller's necessary.

//!!! ...unfinished... (2022/06/08)
// If (
//        ( ( inputHeight == 1 ) && ( inputWidth == 1 ) )
//     && ( depthwise_AvgMax_Or_ChannelMultiplier <= 1 ) // i.e. avg or max or none or ( channelMultiplier == 1 ).
//     && ( depthwiseActivationId == ValueDesc.ActivationFunction.Singleton.Ids.NONE ) // i.e. depthwise is linear.
//     && (   ( nSqueezeExcitationChannelCountDivisor == ValueDesc.SqueezeExcitationChannelCountDivisor.Singleton.Ids.NONE ) // (-2), no squeeze-and-excitation (i.e. depthwise is linear)
//         || ( bSqueezeExcitationPrefix == false ) ) // or, has squeeze-and-excitation, but after pointwise2. (i.e. depthwise is still linear)
//        )
//    )
//
// Then, the depthwise should be discarded to improve performance.
// Perhaps, this automatical optimization could be done in Block.Base (i.e. not in Stage).
//

  }

  /**
   * Called after block0 is created (i.e. before block1, 2, 3, ...). Sub-class should override this method to adjust data members.
   */
  configTo_afterBlock0() {
    this.inputHeight0 = this.stageParams.outputHeight; // all blocks (except block0) inputs half the source image size.
    this.inputWidth0 = this.stageParams.outputWidth;

    // All blocks (except block0 in NoPointwise1) will not double the channel count by depthwise, because block0 has already double
    // output channel count.
    //
    this.depthwise_AvgMax_Or_ChannelMultiplier = 1;

    // All blocks (except block0) uses depthwise ( strides = 1, pad = "same" ) to keep ( height, width ).
    this.depthwiseStridesPad = ValueDesc.StridesPad.Singleton.Ids.STRIDES_1_PAD_SAME;

    this.bKeepInputTensor = false; // No matter bKeepInputTensor, all blocks (except block0) should not keep input tensor.
  }

  /**
   * Called before blockLast is about to be created. Sub-class could override this method to adjust data members.
   */
  configTo_beforeBlockLast() {

    // Besides, the blockLast may use a different depthwise filter size. This is especially true for NotShuffleNet_NotMobileNet.
    this.depthwiseFilterHeight = this.depthwiseFilterHeight_Last;
    this.depthwiseFilterWidth = this.depthwiseFilterWidth_Last;

    this.bias_activation_setup_forBlockLast(); // bias, activation of pointwise1, depthwise1, pointwise2
  }

  /**
   * Config the bias and activation of pointwise1, depthwise1, pointwise2 for block0.
   */
  bias_activation_setup_forBlock0() {
    let stageParams = this.stageParams;

    // pointwise1
    {
      this.bPointwise1Bias = true;
      this.pointwise1ActivationId = stageParams.nActivationId;
    }

    // depthwise
    {
      // MobileNetV2_Xxx's depthwise have bias and activation (to remedy its pointwise2's no activation).
      //
      if ( ValueDesc.ConvStageType.isMobileNetV2( stageParams.nConvStageType ) ) {
        this.bDepthwiseBias = true;
        this.depthwiseActivationId = stageParams.nActivationId;

      // non-MobileNetV2_Xxx's depthwise have no bias and no activation. (since they will be done at (squeeze-and-excitation
      // and) pointwise2.)
      //
      } else {
        this.bDepthwiseBias = false;
        this.depthwiseActivationId = ValueDesc.ActivationFunction.Singleton.Ids.NONE;

//!!! ...unfinished... (2022/06/17)
// If there is squeeze-and-excitation prefix pointwise2, the depthwise should be viewed as non-linear (even if depthwise activation
// does not exist). In this case, depthwise's bias should be existed too.

      }
    }

    // pointwise2
    {
      this.bPointwise20Bias = true; // All blocks' outputs needs bias (even if MobileNetV2_Xxx).

      // MobileNetV2_Xxx's pointwise2 always does not have activation function.
      //
      // The reason is that MobileNetV2_Xxx's pointwise2 has add-input-to-output so its block's output is not affine transformation
      // (even if no activation function). It and the next block's pointwise1 is not continuous multiple affine transformation
      // and will not become just one affine transformation.
      //
      if ( ValueDesc.ConvStageType.isMobileNetV2( stageParams.nConvStageType ) ) {
        this.pointwise20ActivationId = ValueDesc.ActivationFunction.Singleton.Ids.NONE;

      // For all other ConvStageType, all non-blockLast's pointwise2 must have activation function (to become non-affine transformation).
      // The reason is to avoid the previous block's pointwise2 and the next block's pointwis1 become just one affine transformation.
      } else {
        this.pointwise20ActivationId = stageParams.nActivationId;
      }
    }
  }

  /**
   * Config the bias and activation of pointwise1, depthwise1, pointwise2 for blockLast.
   */
  bias_activation_setup_forBlockLast() {
    let stageParams = this.stageParams;

    // pointwise2
    {
      // MobileNetV2_Xxx's pointwise2 always does not have activation function.
      //
      // The reason is that MobileNetV2_Xxx's pointwise2 has add-input-to-output so its block's output is not affine transformation
      // (even if no activation function). It and the next block's pointwise1 is not continuous multiple affine transformation
      // and will not become just one affine transformation.
      //
      if ( ValueDesc.ConvStageType.isMobileNetV2( stageParams.nConvStageType ) ) {
        this.pointwise20ActivationId = ValueDesc.ActivationFunction.Singleton.Ids.NONE;

      // For all other ConvStageType, whether blockLast's pointwise2 has activation function is according to the specified flag.
      } else {
        if ( stageParams.bPointwise2ActivatedAtStageEnd == false ) {
          this.pointwise20ActivationId = ValueDesc.ActivationFunction.Singleton.Ids.NONE;
        } else {
          this.pointwise20ActivationId = stageParams.nActivationId;
        }
      }
    }
  }

  /**
   *
   * @return {Block.Params}
   *   Create and return a Block.Params according to this object's current state.
   */
  create_BlockParams() {
    let params = Block.Params.Pool.get_or_create_by(
      this.input0_height, this.input0_width, this.input0_channelCount,
      this.nConvBlockTypeId,
      this.pointwise1ChannelCount,
      this.depthwise_AvgMax_Or_ChannelMultiplier, this.depthwiseFilterHeight, this.depthwiseFilterWidth, this.depthwiseStridesPad,
      this.depthwiseActivationId,
      this.pointwise20ChannelCount, this.pointwise20ActivationId,
      this.nSqueezeExcitationChannelCountDivisor, this.bSqueezeExcitationPrefix,
      this.nActivationId,
      this.bKeepInputTensor
    );
    return params;
  }

}
<|endoftext|>


<commit_before>var tessel = require('tessel');
var Attiny = require('attiny-common');

var attiny = new Attiny(tessel.port['A']);

var firmwareOptions = {
  firmwareFile : __dirname + '../firmware/src/infrared-attx4.hex',
  firmwareVersion : 3,
  moduleID : 0x0B,
  signature : 0x930C,
  crc : 13777,
}

// Force an update
attiny.updateFirmware(firmwareOptions, function(err) {
  if (err) {
    throw err
  }
  else {
    console.log('done updating...');
  }
});<commit_msg>fixes update script firmware path<commit_after>var tessel = require('tessel');
var Attiny = require('attiny-common');

var attiny = new Attiny(tessel.port['A']);

var firmwareOptions = {
  firmwareFile : __dirname + '/../firmware/src/infrared-attx4.hex',
  firmwareVersion : 3,
  moduleID : 0x0B,
  signature : 0x930C,
  crc : 13777,
}

// Force an update
attiny.updateFirmware(firmwareOptions, function(err) {
  if (err) {
    throw err
  }
  else {
    console.log('done updating...');
  }
});<|endoftext|>


<commit_before>var EVENT_TYPE = require("../../renderer/scene/constants.js").EVENT_TYPE;
var Targets = require("../base/rendertarget");

var LightPass = require("../render-passes/light-pass");
var PointLightPass = require("../render-passes/pointlight-pass");

/**
 * @param {GLContext} context
 * @param {GLScene} scene
 * @constructor
 */
var ShadowMapService = function (context, scene) {
    this.context = context;
    scene.on(EVENT_TYPE.LIGHT_STRUCTURE_CHANGED, this.onLightStructureChanged.bind(this));
    scene.on(EVENT_TYPE.LIGHT_VALUE_CHANGED, this.onLightValueChanged.bind(this));
    scene.on(EVENT_TYPE.SCENE_SHAPE_CHANGED, this.onSceneShapeChanged.bind(this));

    this.shadowMapInfos = [];
    this.dirty = true;
};

XML3D.extend(ShadowMapService.prototype, {
    onLightStructureChanged: function (light, removed) {
        var shadowMapInfos = this.shadowMapInfos;
        if (removed) {
            removeLight(shadowMapInfos, light);
        } else {
            if (lightNeedsShadowMap(light)) {
                addLight(shadowMapInfos, light);
                this.requestRendering("light added");
            }
        }
    },

    onLightValueChanged: function () {
        this.requestRendering("light value changed");
    },

    onSceneShapeChanged: function () {
        this.requestRendering("scene shape changed");
    },

    requestRendering: function(/*reason*/) {
        this.dirty = true;
    },

    updateForRendering: function() {
        if(this.dirty) {
            var shadowMaps = this.shadowMapInfos;
            for (var i = 0; i < shadowMaps.length; i++) {
                shadowMaps[i].pass.renderScene();
            }
            this.dirty = false;
        }
    },

    fillGlobalParameters: function(globals) {
        var shadowUnits = mergeShadowParameters(this.shadowMapInfos);
        XML3D.extend(globals, shadowUnits);
    }

});

function lightNeedsShadowMap(light) {
    return !!light.model.getParameter("castShadow")[0];
}

function addLight(shadowMapInfos, light) {
    var context = light.scene.context;
    var passInfo = createPassInfo(light, context);
    shadowMapInfos.push(passInfo);
}

function removeLight(shadowMapInfos, light) {
    for (var i = 0; i < shadowMapInfos.length; i++) {
        if (shadowMapInfos[i].light === light) {
            shadowMapInfos.splice(index, 1);
            // TODO: Free pass and other resources, free texture slot
            return;
        }
    }
}

function createPassInfo(light, context) {
    var size = Math.max(context.canvasTarget.width, context.canvasTarget.height) * 2;
    var params = {
        width: size,
        height: size,
        colorFormat: context.gl.RGBA,
        depthFormat: context.gl.DEPTH_COMPONENT16,
        stencilFormat: null,
        depthAsRenderbuffer: true
    };

    var pass = light.model.id == "point" ? createPointLightPass(light, context, params) : createLightPass(light, context, params);
    pass.init(context);

    // Bind target in order to create texture map
    pass.output.bind();

    // TODO: Better way to fix the texture unit?
    var unitEntry = context.textureManager.getEntry(pass.output.colorTarget.handle.id);
    unitEntry.fixed = true;

    pass.output.unbind();

    return {
        light: light, pass: pass, slot: unitEntry.slot
    };
}

function createLightPass(light, context, params) {
    var lightFramebuffer = new Targets.GLRenderTarget(context, params);
    return new LightPass({context: context}, lightFramebuffer, light);
}

function createPointLightPass(light, context, params) {
    var lightFramebuffer = new Targets.GLCubeMapRenderTarget(context, params);
    return new PointLightPass({context: context}, lightFramebuffer, light);
}

function mergeShadowParameters(shadowMapInfos) {
    var result = {};
    ["spot", "point", "directional"].forEach(function(model) {
        var sameModel = shadowMapInfos.filter(function(info) { return info.light.model.id == model; });
        result[model + "LightShadowMap"] = sameModel.map(function (info) {
            return info.slot;
        });
    });
    return result;
}

module.exports = ShadowMapService;
<commit_msg>The dummy RenderInterface objects used in light pass construction also need empty functions for setting/resetting GL states<commit_after>var EVENT_TYPE = require("../../renderer/scene/constants.js").EVENT_TYPE;
var Targets = require("../base/rendertarget");

var LightPass = require("../render-passes/light-pass");
var PointLightPass = require("../render-passes/pointlight-pass");

/**
 * @param {GLContext} context
 * @param {GLScene} scene
 * @constructor
 */
var ShadowMapService = function (context, scene) {
    this.context = context;
    scene.on(EVENT_TYPE.LIGHT_STRUCTURE_CHANGED, this.onLightStructureChanged.bind(this));
    scene.on(EVENT_TYPE.LIGHT_VALUE_CHANGED, this.onLightValueChanged.bind(this));
    scene.on(EVENT_TYPE.SCENE_SHAPE_CHANGED, this.onSceneShapeChanged.bind(this));

    this.shadowMapInfos = [];
    this.dirty = true;
};

XML3D.extend(ShadowMapService.prototype, {
    onLightStructureChanged: function (light, removed) {
        var shadowMapInfos = this.shadowMapInfos;
        if (removed) {
            removeLight(shadowMapInfos, light);
        } else {
            if (lightNeedsShadowMap(light)) {
                addLight(shadowMapInfos, light);
                this.requestRendering("light added");
            }
        }
    },

    onLightValueChanged: function () {
        this.requestRendering("light value changed");
    },

    onSceneShapeChanged: function () {
        this.requestRendering("scene shape changed");
    },

    requestRendering: function(/*reason*/) {
        this.dirty = true;
    },

    updateForRendering: function() {
        if(this.dirty) {
            var shadowMaps = this.shadowMapInfos;
            for (var i = 0; i < shadowMaps.length; i++) {
                shadowMaps[i].pass.renderScene();
            }
            this.dirty = false;
        }
    },

    fillGlobalParameters: function(globals) {
        var shadowUnits = mergeShadowParameters(this.shadowMapInfos);
        XML3D.extend(globals, shadowUnits);
    }

});

function lightNeedsShadowMap(light) {
    return !!light.model.getParameter("castShadow")[0];
}

function addLight(shadowMapInfos, light) {
    var context = light.scene.context;
    var passInfo = createPassInfo(light, context);
    shadowMapInfos.push(passInfo);
}

function removeLight(shadowMapInfos, light) {
    for (var i = 0; i < shadowMapInfos.length; i++) {
        if (shadowMapInfos[i].light === light) {
            shadowMapInfos.splice(index, 1);
            // TODO: Free pass and other resources, free texture slot
            return;
        }
    }
}

function createPassInfo(light, context) {
    var size = Math.max(context.canvasTarget.width, context.canvasTarget.height) * 2;
    var params = {
        width: size,
        height: size,
        colorFormat: context.gl.RGBA,
        depthFormat: context.gl.DEPTH_COMPONENT16,
        stencilFormat: null,
        depthAsRenderbuffer: true
    };

    var pass = light.model.id == "point" ? createPointLightPass(light, context, params) : createLightPass(light, context, params);
    pass.init(context);

    // Bind target in order to create texture map
    pass.output.bind();

    // TODO: Better way to fix the texture unit?
    var unitEntry = context.textureManager.getEntry(pass.output.colorTarget.handle.id);
    unitEntry.fixed = true;

    pass.output.unbind();

    return {
        light: light, pass: pass, slot: unitEntry.slot
    };
}

function createLightPass(light, context, params) {
    var lightFramebuffer = new Targets.GLRenderTarget(context, params);
    return new LightPass({context: context, setGLState: function() {}, resetGLState: function() {}}, lightFramebuffer, light);
}

function createPointLightPass(light, context, params) {
    var lightFramebuffer = new Targets.GLCubeMapRenderTarget(context, params);
    return new PointLightPass({context: context, setGLState: function() {}, resetGLState: function() {}}, lightFramebuffer, light);
}

function mergeShadowParameters(shadowMapInfos) {
    var result = {};
    ["spot", "point", "directional"].forEach(function(model) {
        var sameModel = shadowMapInfos.filter(function(info) { return info.light.model.id == model; });
        result[model + "LightShadowMap"] = sameModel.map(function (info) {
            return info.slot;
        });
    });
    return result;
}

module.exports = ShadowMapService;
<|endoftext|>


<commit_before>var utils  = require('../utils');

/**
 * session
 *
 * Takes a list of files and creates a set of file names that occur in subject
 * directories. Then generates a warning if a given subject is missing any
 * files from the set.
 */
var session = function missingSessionFiles(fileList) {
    var subjects = [];
    var issues = [];
    for (var key in fileList) {
        var file = fileList[key];
        var filename;

        if (!file || (typeof window != 'undefined' && !file.webkitRelativePath)) {
            continue;
        }

        var path = utils.files.relativePath(file);
        if (!utils.type.isBIDS(path)) {
            continue;
        }
        var subject;
        //match the subject identifier up to the '/' in the full path to a file.
        var match = path.match(/sub-(.*?)(?=\/)/);
        if (match === null) {
            continue;
        } else {
            subject = match[0];
        }
        // initialize an empty array if we haven't seen this subject before
        if (typeof(subjects[subject]) === 'undefined') {
            subjects[subject] = [];
        }
        // files are prepended with subject name, the following two commands
        // remove the subject from the file name to allow filenames to be more
        // easily compared
        filename = path.substring(path.match(subject).index + subject.length);
        filename = filename.replace(subject, '<sub>');
        subjects[subject].push(filename);
    }

    var subject_files = [];
    for (var subject in subjects) {
        subject_files = subject_files.concat(subjects[subject])
    }
    // Converting to a Set removes all duplicates
    all_files = new Set(subject_files);

    // Converting it back to an array for easy iteration
    all_files = Array.from(all_files);
    for (var subject in subjects) {
        for (var set_file in all_files) {
            if (subjects[subject].indexOf(all_files[set_file]) === -1) {
                filename = all_files[set_file].replace('<sub>', subject);
                file.relativePath = '/' + subject + filename;
                issues.push(new utils.Issue({
                    file: file,
                    evidence: "Subject: " + subject + "; Missing file: " + filename,
                    code: 38
                }));
            }
        }
    }
    return issues;
};

module.exports = session;
<commit_msg>removed use of 'set' and 'Array.from' due to limited support in browsers and older node versions<commit_after>var utils  = require('../utils');

/**
 * session
 *
 * Takes a list of files and creates a set of file names that occur in subject
 * directories. Then generates a warning if a given subject is missing any
 * files from the set.
 */
var session = function missingSessionFiles(fileList) {
    var subjects = [];
    var issues = [];
    for (var key in fileList) {
        var file = fileList[key];
        var filename;

        if (!file || (typeof window != 'undefined' && !file.webkitRelativePath)) {
            continue;
        }

        var path = utils.files.relativePath(file);
        if (!utils.type.isBIDS(path)) {
            continue;
        }
        var subject;
        //match the subject identifier up to the '/' in the full path to a file.
        var match = path.match(/sub-(.*?)(?=\/)/);
        if (match === null) {
            continue;
        } else {
            subject = match[0];
        }
        // initialize an empty array if we haven't seen this subject before
        if (typeof(subjects[subject]) === 'undefined') {
            subjects[subject] = [];
        }
        // files are prepended with subject name, the following two commands
        // remove the subject from the file name to allow filenames to be more
        // easily compared
        filename = path.substring(path.match(subject).index + subject.length);
        filename = filename.replace(subject, '<sub>');
        subjects[subject].push(filename);
    }

    var subject_files = [];
    for (var key in subjects) {
        var subject = subjects[key];
        for (var file of subject) {
            if (subject_files.indexOf(file) < 0) {
                subject_files.push(file);
            }
        }
    }

    for (var subject in subjects) {
        for (var set_file in subject_files) {
            if (subjects[subject].indexOf(subject_files[set_file]) === -1) {
                filename = subject_files[set_file].replace('<sub>', subject);
                file.relativePath = '/' + subject + filename;
                issues.push(new utils.Issue({
                    file: file,
                    evidence: "Subject: " + subject + "; Missing file: " + filename,
                    code: 38
                }));
            }
        }
    }
    return issues;
};

module.exports = session;
<|endoftext|>


<commit_before>// var regnos=[],names=[],h3s=[],h4s=[]
// var h3s=document.getElementsByTagName('h3')
// var h4s=document.getElementsByTagName('h4')
// for(var i=0;i<h3s.length;i++){regnos.push(h3s[i].innerHTML);}
// for(var i=1;i<h4s.length;i++){names.push(h4s[i].innerHTML.split('
')[1].split('
')[0]);}

var regnos=["E/11/010", "E/11/014", "E/11/019", "E/11/020", "E/11/024", "E/11/028", "E/11/029", "E/11/032", "E/11/037", "E/11/040", "E/11/044", "E/11/054", "E/11/059", "E/11/060", "E/11/064", "E/11/067", "E/11/080", "E/11/105", "E/11/106", "E/11/113", "E/11/132", "E/11/133", "E/11/137", "E/11/139", "E/11/143", "E/11/145", "E/11/148", "E/11/163", "E/11/171", "E/11/174", "E/11/183", "E/11/193", "E/11/201", "E/11/188", "E/11/204", "E/11/209", "E/11/217", "E/11/237", "E/11/258", "E/11/268", "E/11/269", "E/11/297", "E/11/305", "E/11/308", "E/11/311", "E/11/313", "E/11/315", "E/11/337", "E/11/343", "E/11/353", "E/11/368", "E/11/379", "E/11/381", "E/11/384", "E/11/395", "E/11/405", "E/11/419", "E/11/429", "E/11/431", "E/11/436", "E/11/438", "E/11/444", "E/11/452", "E/11/484", "E/11/485", "E/11/486", "E/11/487", "E/11/488"]

var names=["T.M.S.U.B.Abeysinghe", "A.S.M.C.BAgalawatte", "W.G.N.M.Amarasinghe", "D.M.A.M.K.L.Andradi", "A.S.P.Athukorala", "B.A.N.Y.Balaarachchi", "K.Balakayan", "B.M.N.M.Balasooriya", "H.M.A.P.KBandara", "K.M.P.Bandara", "R.M.L.SBandara", "B.S.Bulathsinhala", "B.V.O.Chathuranga", "G.D.Chathuranga", "G.D.RDabarera", "W.T.Darshana", "J.P.T.Dhanushka", "U.W.T.DEhelepola", "C.N.Ekanayake", "M.S.D.Eranga", "P.AGregory", "D.L.Gunaratne", "K.A.R.L.A.Gunawardana", "S.D.T.Guruge", "M.G.Harischandra", "S.K.E.Harshani", "D.H.M.S.N.Herath", "T.D.Hirimuthugoda", "J.D.C.Jayalath", "D.N.Jayanath", "O.M.D.N.I.Jayathilaka", "K.E.G.A.P.Kadurugasyaya", "D.S.L.Karunasekara", "J.L.M.M.Jayawardena", "K.P.D.H.M.Karunatissa", "P.Keerthanan", "B.U.Kulathilaka", "Y.M.P.NLankathilaka", "M.M.D.B.Marasinghe", "N.B.U.SNanayakkara", "D.N.U.Naranpanawa", "K.N.M.Perera", "W.D.Y.NPiyasinghe", "W.M.S.Prasadima", "E.K.V.MPremaratne", "M.P.Prematilake", "R.M.P.Rajapaksha", "R.M.D.MRathnayake", "A.R.S.PRodrigo", "J.CSamarasinghe", "S.Selvaluxmiy", "A.S.D.Senevirathna", "V.Seralathan", "E.L.W.Shantha", "K.V.C.C.Somathilaka", "D.N.Tennakoon", "R.Velmakivan", "W.M.D.B.Weerakoon", "I.L.Weeraratne", "N.B.Weerasinghe", "W.M.T.G.I.S.Weerasooriya", "W.R.M.B.C.Wickramasinghe", "Y.A.D.S.S.Wijerathna", "K.W.H.N.T.Hettiarachchi", "W.T.S.Wehalla", "S.S.Manamendra", "M.B.K.Jayawardhana", "K.G.DE.A.Rajapakse"]

// get list
// regnos.forEach(function (v, i) {
//     console.log(v,names[i]);
// })

console.log(regnos.length);<commit_msg>Full javascript<commit_after>var regnos=[],names=[],h3s=[],h4s=[]
var h3s=document.getElementsByTagName('h3')
var h4s=document.getElementsByTagName('h4')
for(var i=0;i<h3s.length;i++){regnos.push(h3s[i].innerHTML);}
for(var i=1;i<h4s.length;i++){names.push(h4s[i].innerHTML.split('
')[1].split('
')[0]);}

var regnos=["E/11/010", "E/11/014", "E/11/019", "E/11/020", "E/11/024", "E/11/028", "E/11/029", "E/11/032", "E/11/037", "E/11/040", "E/11/044", "E/11/054", "E/11/059", "E/11/060", "E/11/064", "E/11/067", "E/11/080", "E/11/105", "E/11/106", "E/11/113", "E/11/132", "E/11/133", "E/11/137", "E/11/139", "E/11/143", "E/11/145", "E/11/148", "E/11/163", "E/11/171", "E/11/174", "E/11/183", "E/11/193", "E/11/201", "E/11/188", "E/11/204", "E/11/209", "E/11/217", "E/11/237", "E/11/258", "E/11/268", "E/11/269", "E/11/297", "E/11/305", "E/11/308", "E/11/311", "E/11/313", "E/11/315", "E/11/337", "E/11/343", "E/11/353", "E/11/368", "E/11/379", "E/11/381", "E/11/384", "E/11/395", "E/11/405", "E/11/419", "E/11/429", "E/11/431", "E/11/436", "E/11/438", "E/11/444", "E/11/452", "E/11/484", "E/11/485", "E/11/486", "E/11/487", "E/11/488"]

var names=["T.M.S.U.B.Abeysinghe", "A.S.M.C.BAgalawatte", "W.G.N.M.Amarasinghe", "D.M.A.M.K.L.Andradi", "A.S.P.Athukorala", "B.A.N.Y.Balaarachchi", "K.Balakayan", "B.M.N.M.Balasooriya", "H.M.A.P.KBandara", "K.M.P.Bandara", "R.M.L.SBandara", "B.S.Bulathsinhala", "B.V.O.Chathuranga", "G.D.Chathuranga", "G.D.RDabarera", "W.T.Darshana", "J.P.T.Dhanushka", "U.W.T.DEhelepola", "C.N.Ekanayake", "M.S.D.Eranga", "P.AGregory", "D.L.Gunaratne", "K.A.R.L.A.Gunawardana", "S.D.T.Guruge", "M.G.Harischandra", "S.K.E.Harshani", "D.H.M.S.N.Herath", "T.D.Hirimuthugoda", "J.D.C.Jayalath", "D.N.Jayanath", "O.M.D.N.I.Jayathilaka", "K.E.G.A.P.Kadurugasyaya", "D.S.L.Karunasekara", "J.L.M.M.Jayawardena", "K.P.D.H.M.Karunatissa", "P.Keerthanan", "B.U.Kulathilaka", "Y.M.P.NLankathilaka", "M.M.D.B.Marasinghe", "N.B.U.SNanayakkara", "D.N.U.Naranpanawa", "K.N.M.Perera", "W.D.Y.NPiyasinghe", "W.M.S.Prasadima", "E.K.V.MPremaratne", "M.P.Prematilake", "R.M.P.Rajapaksha", "R.M.D.MRathnayake", "A.R.S.PRodrigo", "J.CSamarasinghe", "S.Selvaluxmiy", "A.S.D.Senevirathna", "V.Seralathan", "E.L.W.Shantha", "K.V.C.C.Somathilaka", "D.N.Tennakoon", "R.Velmakivan", "W.M.D.B.Weerakoon", "I.L.Weeraratne", "N.B.Weerasinghe", "W.M.T.G.I.S.Weerasooriya", "W.R.M.B.C.Wickramasinghe", "Y.A.D.S.S.Wijerathna", "K.W.H.N.T.Hettiarachchi", "W.T.S.Wehalla", "S.S.Manamendra", "M.B.K.Jayawardhana", "K.G.DE.A.Rajapakse"]

get list
regnos.forEach(function (v, i) {
    console.log(v,names[i]);
})

console.log(regnos.length);<|endoftext|>


<commit_before>import Vue from 'vue'

import QAvatar from '../components/avatar/QAvatar.js'
import QIcon from '../components/icon/QIcon.js'
import QBtn from '../components/btn/QBtn.js'

import { noop } from '../utils/event.js'
import { isSSR } from './Platform.js'

let uid = 0
let defaults = {}

const positionList = [
  'top-left', 'top-right',
  'bottom-left', 'bottom-right',
  'top', 'bottom', 'left', 'right', 'center'
]

const notifTypes = {
  positive: {
    icon () { return this.$q.iconSet.type.positive },
    color: 'positive'
  },

  negative: {
    icon () { return this.$q.iconSet.type.negative },
    color: 'negative'
  },

  warning: {
    icon () { return this.$q.iconSet.type.warning },
    color: 'warning',
    textColor: 'dark'
  },

  info: {
    icon () { return this.$q.iconSet.type.info },
    color: 'info'
  }
}

const groups = {}
const positionClass = {}

const Notifications = {
  name: 'QNotifications',

  created () {
    this.notifs = {}

    positionList.forEach(pos => {
      this.notifs[pos] = []

      const
        vert = ['left', 'center', 'right'].includes(pos) ? 'center' : (pos.indexOf('top') > -1 ? 'top' : 'bottom'),
        align = pos.indexOf('left') > -1 ? 'start' : (pos.indexOf('right') > -1 ? 'end' : 'center'),
        classes = ['left', 'right'].includes(pos) ? `items-${pos === 'left' ? 'start' : 'end'} justify-center` : (pos === 'center' ? 'flex-center' : `items-${align}`)

      positionClass[pos] = `q-notifications__list q-notifications__list--${vert} fixed column no-wrap ${classes}`
    })
  },

  methods: {
    add (config) {
      if (!config) {
        console.error('Notify: parameter required')
        return false
      }

      let notif = { textColor: 'white' }

      if (typeof config === 'string' || config.ignoreDefaults !== true) {
        Object.assign(notif, defaults)
      }

      if (Object(config) === config) {
        Object.assign(notif, notifTypes[config.type], config)

        if (typeof notif.icon === 'function') {
          notif.icon = notif.icon.call(this)
        }
      }
      else {
        Object.assign(notif, { message: config })
      }

      notif.meta = {
        hasMedia: Boolean(notif.icon || notif.avatar)
      }

      if (notif.position) {
        if (!positionList.includes(notif.position)) {
          console.error(`Notify: wrong position: ${notif.position}`)
          return false
        }
      }
      else {
        notif.position = 'bottom'
      }

      if (notif.timeout === void 0) {
        notif.timeout = 5000
      }
      else {
        const t = parseInt(notif.timeout, 10)
        if (isNaN(t) || t < 0) {
          console.error(`Notify: wrong timeout: ${notif.timeout}`)
          return false
        }
        notif.timeout = t
      }

      if (notif.timeout === 0) {
        notif.progress = false
      }
      else if (notif.progress === true) {
        notif.meta.progressStyle = {
          animationDuration: `${notif.timeout + 1000}ms`
        }
      }

      const actions = (Array.isArray(config.actions) === true ? config.actions : [])
        .concat(config.ignoreDefaults !== true && Array.isArray(defaults.actions) === true ? defaults.actions : [])

      notif.closeBtn && actions.push({
        label: typeof notif.closeBtn === 'string'
          ? notif.closeBtn
          : this.$q.lang.label.close
      })

      notif.actions = actions.map(({ handler, noDismiss, ...item }) => ({
        props: { flat: true, ...item },
        on: {
          click: typeof handler === 'function'
            ? () => {
              noDismiss !== true && notif.meta.close()
              handler()
            }
            : () => {
              notif.meta.close()
            }
        }
      }))

      if (notif.multiLine === void 0) {
        notif.multiLine = notif.actions.length > 1
      }

      Object.assign(notif.meta, {
        staticClass: `q-notification row items-stretch` +
          ` q-notification--${notif.multiLine === true ? 'multi-line' : 'standard'}` +
          (notif.color !== void 0 ? ` bg-${notif.color}` : '') +
          (notif.textColor !== void 0 ? ` text-${notif.textColor}` : '') +
          (notif.classes !== void 0 ? ` ${notif.classes}` : ''),

        wrapperClass: 'q-notification__wrapper col relative-position border-radius-inherit ' +
          (notif.multiLine === true ? 'column no-wrap justify-center' : 'row items-center'),

        contentClass: 'q-notification__content row items-center' +
          (notif.multiLine === true ? '' : ' col')
      })

      if (notif.group === false) {
        notif.group = void 0
      }
      else {
        if (notif.group === void 0 || notif.group === true) {
          // do not replace notifications with different buttons
          notif.group = [
            notif.message,
            notif.caption,
            notif.multiline
          ].concat(
            notif.actions.map(a => `${a.props.label}*${a.props.icon}`)
          ).join('|')
        }

        notif.group += '|' + notif.position
      }

      if (notif.actions.length === 0) {
        notif.actions = void 0
      }
      else {
        notif.meta.actionsClass = 'q-notification__actions row items-center ' +
          (notif.multiLine === true ? 'justify-end' : 'col-auto') +
          (notif.meta.hasMedia === true ? ' q-notification__actions--with-media' : '')
      }

      const groupNotif = groups[notif.group]

      // wohoo, new notification
      if (groupNotif === void 0) {
        notif.meta.uid = uid++
        notif.meta.badge = 1

        if (['left', 'right', 'center'].indexOf(notif.position) !== -1) {
          this.notifs[notif.position].splice(
            Math.floor(this.notifs[notif.position].length / 2),
            0,
            notif
          )
        }
        else {
          const action = notif.position.indexOf('top') > -1 ? 'unshift' : 'push'
          this.notifs[notif.position][action](notif)
        }

        if (notif.group !== void 0) {
          groups[notif.group] = notif
        }
      }
      // ok, so it's NOT a new one
      else {
        // reset timeout if any
        if (groupNotif.meta.timer !== void 0) {
          clearTimeout(groupNotif.meta.timer)
        }

        const original = groups[notif.group]

        notif.meta.uid = original.meta.uid
        notif.meta.badge = original.meta.badge + 1
        notif.meta.badgeStaticClass = 'q-notification__badge' +
          (notif.badgeColor !== void 0 ? ` bg-${notif.badgeColor}` : '') +
          (notif.badgeTextColor !== void 0 ? ` text-${notif.badgeTextColor}` : '')

        notif = Object.assign(original, notif)
      }

      notif.meta.close = () => {
        this.remove(notif)
      }

      this.$forceUpdate()

      if (notif.timeout > 0) {
        notif.meta.timer = setTimeout(() => {
          notif.meta.close()
        }, notif.timeout + /* show duration */ 1000)
      }

      return notif.meta.close
    },

    remove (notif) {
      if (notif.meta.timer) { clearTimeout(notif.meta.timer) }

      const index = this.notifs[notif.position].indexOf(notif)
      if (index !== -1) {
        if (notif.group !== void 0) {
          delete groups[notif.group]
        }

        const el = this.$refs[`notif_${notif.meta.uid}`]

        if (el) {
          const { width, height } = getComputedStyle(el)

          el.style.left = `${el.offsetLeft}px`
          el.style.width = width
          el.style.height = height
        }

        this.notifs[notif.position].splice(index, 1)

        this.$forceUpdate()

        if (typeof notif.onDismiss === 'function') {
          notif.onDismiss()
        }
      }
    }
  },

  render (h) {
    return h('div', { staticClass: 'q-notifications' }, positionList.map(pos => {
      return h('transition-group', {
        key: pos,
        staticClass: positionClass[pos],
        tag: 'div',
        props: {
          name: `q-notification--${pos}`,
          mode: 'out-in'
        }
      }, this.notifs[pos].map(notif => {
        let msgChild

        const meta = notif.meta
        const msgData = { staticClass: 'q-notification__message col' }

        if (notif.html === true) {
          msgData.domProps = {
            innerHTML: notif.caption
              ? `<div>${notif.message}</div><div class="q-notification__caption">${notif.caption}</div>`
              : notif.message
          }
        }
        else {
          const msgNode = [ notif.message ]
          msgChild = notif.caption
            ? [
              h('div', msgNode),
              h('div', { staticClass: 'q-notification__caption' }, [ notif.caption ])
            ]
            : msgNode
        }

        const mainChild = []

        if (meta.hasMedia === true) {
          if (notif.icon) {
            mainChild.push(
              h(QIcon, {
                staticClass: 'q-notification__icon col-auto',
                props: { name: notif.icon }
              })
            )
          }
          else if (notif.avatar) {
            mainChild.push(
              h(QAvatar, { staticClass: 'q-notification__avatar col-auto' }, [
                h('img', { attrs: { src: notif.avatar } })
              ])
            )
          }
        }

        mainChild.push(
          h('div', msgData, msgChild)
        )

        const child = [
          h('div', { staticClass: meta.contentClass }, mainChild)
        ]

        notif.progress === true && child.push(
          h('div', {
            key: `${meta.uid}|p|${meta.badge}`,
            staticClass: 'q-notification__progress',
            style: meta.progressStyle,
            class: notif.progressClass
          })
        )

        notif.actions !== void 0 && child.push(
          h('div', {
            staticClass: meta.actionsClass
          }, notif.actions.map(a => h(QBtn, { props: a.props, on: a.on })))
        )

        meta.badge > 1 && child.push(
          h('div', {
            key: `${meta.uid}|${meta.badge}`,
            staticClass: meta.badgeStaticClass,
            style: notif.badgeStyle,
            class: notif.badgeClass
          }, [ meta.badge ])
        )

        return h('div', {
          ref: `notif_${meta.uid}`,
          key: meta.uid,
          staticClass: meta.staticClass
        }, [
          h('div', { staticClass: meta.wrapperClass }, child)
        ])
      }))
    }))
  }
}

export default {
  create (opts) {
    if (isSSR === true) { return noop }
    return this.__vm.add(opts)
  },
  setDefaults (opts) {
    opts === Object(opts) && Object.assign(defaults, opts)
  },
  registerType (typeName, typeOpts) {
    if (isSSR !== true && typeOpts === Object(typeOpts)) {
      notifTypes[typeName] = typeOpts
    }
  },

  install ({ cfg, $q }) {
    if (isSSR === true) {
      $q.notify = noop
      $q.notify.setDefaults = noop
      return
    }

    this.setDefaults(cfg.notify)

    $q.notify = this.create.bind(this)
    $q.notify.setDefaults = this.setDefaults
    $q.notify.registerType = this.registerType

    const node = document.createElement('div')
    document.body.appendChild(node)

    this.__vm = new Vue(Notifications)
    this.__vm.$mount(node)
  }
}
<commit_msg>fix: action handlers in Notify are again triggered before onDismiss (fix #6380)<commit_after>import Vue from 'vue'

import QAvatar from '../components/avatar/QAvatar.js'
import QIcon from '../components/icon/QIcon.js'
import QBtn from '../components/btn/QBtn.js'

import { noop } from '../utils/event.js'
import { isSSR } from './Platform.js'

let uid = 0
let defaults = {}

const positionList = [
  'top-left', 'top-right',
  'bottom-left', 'bottom-right',
  'top', 'bottom', 'left', 'right', 'center'
]

const notifTypes = {
  positive: {
    icon () { return this.$q.iconSet.type.positive },
    color: 'positive'
  },

  negative: {
    icon () { return this.$q.iconSet.type.negative },
    color: 'negative'
  },

  warning: {
    icon () { return this.$q.iconSet.type.warning },
    color: 'warning',
    textColor: 'dark'
  },

  info: {
    icon () { return this.$q.iconSet.type.info },
    color: 'info'
  }
}

const groups = {}
const positionClass = {}

const Notifications = {
  name: 'QNotifications',

  created () {
    this.notifs = {}

    positionList.forEach(pos => {
      this.notifs[pos] = []

      const
        vert = ['left', 'center', 'right'].includes(pos) ? 'center' : (pos.indexOf('top') > -1 ? 'top' : 'bottom'),
        align = pos.indexOf('left') > -1 ? 'start' : (pos.indexOf('right') > -1 ? 'end' : 'center'),
        classes = ['left', 'right'].includes(pos) ? `items-${pos === 'left' ? 'start' : 'end'} justify-center` : (pos === 'center' ? 'flex-center' : `items-${align}`)

      positionClass[pos] = `q-notifications__list q-notifications__list--${vert} fixed column no-wrap ${classes}`
    })
  },

  methods: {
    add (config) {
      if (!config) {
        console.error('Notify: parameter required')
        return false
      }

      let notif = { textColor: 'white' }

      if (typeof config === 'string' || config.ignoreDefaults !== true) {
        Object.assign(notif, defaults)
      }

      if (Object(config) === config) {
        Object.assign(notif, notifTypes[config.type], config)

        if (typeof notif.icon === 'function') {
          notif.icon = notif.icon.call(this)
        }
      }
      else {
        Object.assign(notif, { message: config })
      }

      notif.meta = {
        hasMedia: Boolean(notif.icon || notif.avatar)
      }

      if (notif.position) {
        if (!positionList.includes(notif.position)) {
          console.error(`Notify: wrong position: ${notif.position}`)
          return false
        }
      }
      else {
        notif.position = 'bottom'
      }

      if (notif.timeout === void 0) {
        notif.timeout = 5000
      }
      else {
        const t = parseInt(notif.timeout, 10)
        if (isNaN(t) || t < 0) {
          console.error(`Notify: wrong timeout: ${notif.timeout}`)
          return false
        }
        notif.timeout = t
      }

      if (notif.timeout === 0) {
        notif.progress = false
      }
      else if (notif.progress === true) {
        notif.meta.progressStyle = {
          animationDuration: `${notif.timeout + 1000}ms`
        }
      }

      const actions = (Array.isArray(config.actions) === true ? config.actions : [])
        .concat(config.ignoreDefaults !== true && Array.isArray(defaults.actions) === true ? defaults.actions : [])

      notif.closeBtn && actions.push({
        label: typeof notif.closeBtn === 'string'
          ? notif.closeBtn
          : this.$q.lang.label.close
      })

      notif.actions = actions.map(({ handler, noDismiss, ...item }) => ({
        props: { flat: true, ...item },
        on: {
          click: typeof handler === 'function'
            ? () => {
              handler()
              noDismiss !== true && notif.meta.close()
            }
            : () => {
              notif.meta.close()
            }
        }
      }))

      if (notif.multiLine === void 0) {
        notif.multiLine = notif.actions.length > 1
      }

      Object.assign(notif.meta, {
        staticClass: `q-notification row items-stretch` +
          ` q-notification--${notif.multiLine === true ? 'multi-line' : 'standard'}` +
          (notif.color !== void 0 ? ` bg-${notif.color}` : '') +
          (notif.textColor !== void 0 ? ` text-${notif.textColor}` : '') +
          (notif.classes !== void 0 ? ` ${notif.classes}` : ''),

        wrapperClass: 'q-notification__wrapper col relative-position border-radius-inherit ' +
          (notif.multiLine === true ? 'column no-wrap justify-center' : 'row items-center'),

        contentClass: 'q-notification__content row items-center' +
          (notif.multiLine === true ? '' : ' col')
      })

      if (notif.group === false) {
        notif.group = void 0
      }
      else {
        if (notif.group === void 0 || notif.group === true) {
          // do not replace notifications with different buttons
          notif.group = [
            notif.message,
            notif.caption,
            notif.multiline
          ].concat(
            notif.actions.map(a => `${a.props.label}*${a.props.icon}`)
          ).join('|')
        }

        notif.group += '|' + notif.position
      }

      if (notif.actions.length === 0) {
        notif.actions = void 0
      }
      else {
        notif.meta.actionsClass = 'q-notification__actions row items-center ' +
          (notif.multiLine === true ? 'justify-end' : 'col-auto') +
          (notif.meta.hasMedia === true ? ' q-notification__actions--with-media' : '')
      }

      const groupNotif = groups[notif.group]

      // wohoo, new notification
      if (groupNotif === void 0) {
        notif.meta.uid = uid++
        notif.meta.badge = 1

        if (['left', 'right', 'center'].indexOf(notif.position) !== -1) {
          this.notifs[notif.position].splice(
            Math.floor(this.notifs[notif.position].length / 2),
            0,
            notif
          )
        }
        else {
          const action = notif.position.indexOf('top') > -1 ? 'unshift' : 'push'
          this.notifs[notif.position][action](notif)
        }

        if (notif.group !== void 0) {
          groups[notif.group] = notif
        }
      }
      // ok, so it's NOT a new one
      else {
        // reset timeout if any
        if (groupNotif.meta.timer !== void 0) {
          clearTimeout(groupNotif.meta.timer)
        }

        const original = groups[notif.group]

        notif.meta.uid = original.meta.uid
        notif.meta.badge = original.meta.badge + 1
        notif.meta.badgeStaticClass = 'q-notification__badge' +
          (notif.badgeColor !== void 0 ? ` bg-${notif.badgeColor}` : '') +
          (notif.badgeTextColor !== void 0 ? ` text-${notif.badgeTextColor}` : '')

        notif = Object.assign(original, notif)
      }

      notif.meta.close = () => {
        this.remove(notif)
      }

      this.$forceUpdate()

      if (notif.timeout > 0) {
        notif.meta.timer = setTimeout(() => {
          notif.meta.close()
        }, notif.timeout + /* show duration */ 1000)
      }

      return notif.meta.close
    },

    remove (notif) {
      if (notif.meta.timer) { clearTimeout(notif.meta.timer) }

      const index = this.notifs[notif.position].indexOf(notif)
      if (index !== -1) {
        if (notif.group !== void 0) {
          delete groups[notif.group]
        }

        const el = this.$refs[`notif_${notif.meta.uid}`]

        if (el) {
          const { width, height } = getComputedStyle(el)

          el.style.left = `${el.offsetLeft}px`
          el.style.width = width
          el.style.height = height
        }

        this.notifs[notif.position].splice(index, 1)

        this.$forceUpdate()

        if (typeof notif.onDismiss === 'function') {
          notif.onDismiss()
        }
      }
    }
  },

  render (h) {
    return h('div', { staticClass: 'q-notifications' }, positionList.map(pos => {
      return h('transition-group', {
        key: pos,
        staticClass: positionClass[pos],
        tag: 'div',
        props: {
          name: `q-notification--${pos}`,
          mode: 'out-in'
        }
      }, this.notifs[pos].map(notif => {
        let msgChild

        const meta = notif.meta
        const msgData = { staticClass: 'q-notification__message col' }

        if (notif.html === true) {
          msgData.domProps = {
            innerHTML: notif.caption
              ? `<div>${notif.message}</div><div class="q-notification__caption">${notif.caption}</div>`
              : notif.message
          }
        }
        else {
          const msgNode = [ notif.message ]
          msgChild = notif.caption
            ? [
              h('div', msgNode),
              h('div', { staticClass: 'q-notification__caption' }, [ notif.caption ])
            ]
            : msgNode
        }

        const mainChild = []

        if (meta.hasMedia === true) {
          if (notif.icon) {
            mainChild.push(
              h(QIcon, {
                staticClass: 'q-notification__icon col-auto',
                props: { name: notif.icon }
              })
            )
          }
          else if (notif.avatar) {
            mainChild.push(
              h(QAvatar, { staticClass: 'q-notification__avatar col-auto' }, [
                h('img', { attrs: { src: notif.avatar } })
              ])
            )
          }
        }

        mainChild.push(
          h('div', msgData, msgChild)
        )

        const child = [
          h('div', { staticClass: meta.contentClass }, mainChild)
        ]

        notif.progress === true && child.push(
          h('div', {
            key: `${meta.uid}|p|${meta.badge}`,
            staticClass: 'q-notification__progress',
            style: meta.progressStyle,
            class: notif.progressClass
          })
        )

        notif.actions !== void 0 && child.push(
          h('div', {
            staticClass: meta.actionsClass
          }, notif.actions.map(a => h(QBtn, { props: a.props, on: a.on })))
        )

        meta.badge > 1 && child.push(
          h('div', {
            key: `${meta.uid}|${meta.badge}`,
            staticClass: meta.badgeStaticClass,
            style: notif.badgeStyle,
            class: notif.badgeClass
          }, [ meta.badge ])
        )

        return h('div', {
          ref: `notif_${meta.uid}`,
          key: meta.uid,
          staticClass: meta.staticClass
        }, [
          h('div', { staticClass: meta.wrapperClass }, child)
        ])
      }))
    }))
  }
}

export default {
  create (opts) {
    if (isSSR === true) { return noop }
    return this.__vm.add(opts)
  },
  setDefaults (opts) {
    opts === Object(opts) && Object.assign(defaults, opts)
  },
  registerType (typeName, typeOpts) {
    if (isSSR !== true && typeOpts === Object(typeOpts)) {
      notifTypes[typeName] = typeOpts
    }
  },

  install ({ cfg, $q }) {
    if (isSSR === true) {
      $q.notify = noop
      $q.notify.setDefaults = noop
      return
    }

    this.setDefaults(cfg.notify)

    $q.notify = this.create.bind(this)
    $q.notify.setDefaults = this.setDefaults
    $q.notify.registerType = this.registerType

    const node = document.createElement('div')
    document.body.appendChild(node)

    this.__vm = new Vue(Notifications)
    this.__vm.$mount(node)
  }
}
<|endoftext|>


<commit_before>describe('Usage Graph component', () => {
  let parentScope, element;

  beforeEach(module('app.services','app.shared'));

  beforeEach(inject(($compile, $rootScope, $state, CollectionsApi) => {
    parentScope = $rootScope.$new();
    parentScope.charts = {
        cpuChart: {
            config: {
                units: 'mhz',
            },
            data: {
                'used': '1000',
                'total': '2000',
            },
            label: 'used',
        },
        memoryChart: {
            config: {
                units: 'GB',
            },
            data: {
                'used': '2',
                'total': '8',
            },
            label: 'used',
        },
        storageChart: {
            config: {
                units: 'GB',
            },
            data: {
                'used': '2',
                'total': '40',
            },
            label: 'used',
            chartId: 'storageChart'
        }
    };

    element = angular.element(`
      <usage-graphs cpu-chart="charts.cpuChart" memory-chart="charts.memoryChart" storage-chart="charts.storageChart"></usage-graphs>
    `);
    $compile(element)(parentScope);
    parentScope.$digest();
  }));

  it('displays 3 Graphs', () => {
    const graphs = element[0].querySelectorAll('div[pf-c3-chart]');
    expect(graphs.length).to.eq(3);
  });
  it('Chart availble values match', () => {
     const graphs = element[0].querySelectorAll('.metric-number');
        expect(graphs[0].innerHTML).to.eq("1000");
        expect(graphs[1].innerHTML).to.eq("6");
        expect(graphs[2].innerHTML).to.eq("38");
  })
});
<commit_msg>Refactor usage-graphs spec to select correct element<commit_after>describe('Usage Graph component', () => {
  let parentScope, element;

  beforeEach(module('app.services','app.shared'));

  beforeEach(inject(($compile, $rootScope, $state, CollectionsApi) => {
    parentScope = $rootScope.$new();
    parentScope.charts = {
        cpuChart: {
            config: {
                units: 'mhz',
            },
            data: {
                'used': '1000',
                'total': '2000',
            },
            label: 'used',
        },
        memoryChart: {
            config: {
                units: 'GB',
            },
            data: {
                'used': '2',
                'total': '8',
            },
            label: 'used',
        },
        storageChart: {
            config: {
                units: 'GB',
            },
            data: {
                'used': '2',
                'total': '40',
            },
            label: 'used',
            chartId: 'storageChart'
        }
    };

    element = angular.element(`
      <usage-graphs cpu-chart="charts.cpuChart" memory-chart="charts.memoryChart" storage-chart="charts.storageChart"></usage-graphs>
    `);
    $compile(element)(parentScope);
    parentScope.$digest();
  }));

  it('displays 3 Graphs', () => {
    const graphs = element[0].querySelectorAll('pf-donut-pct-chart');
    expect(graphs.length).to.eq(3);
  });
  it('Chart availble values match', () => {
     const graphs = element[0].querySelectorAll('.metric-number');
        expect(graphs[0].innerHTML).to.eq("1000");
        expect(graphs[1].innerHTML).to.eq("6");
        expect(graphs[2].innerHTML).to.eq("38");
  })
});
<|endoftext|>


<commit_before>define([
  "app/app",
  "app/router",

  "adapters/ApplicationAdapter",
  "adapters/FormDataAdapter",
  "adapters/AttachmentAdapter",
  "adapters/SubscriberAdapter",
  "adapters/SubscriptionAdapter",
  "adapters/TimelineAdapter",

  "components/Pagination",

  "helpers/Handlebars",

  "initializers/AjaxPrefilter",
  "initializers/PubSub",
  "initializers/Session",
  "initializers/DS",

  "models/Attachment",
  "models/Comment",
  "models/Group",
  "models/Post",
  "models/User",
  "models/Subscription",
  "models/Subscriber",
  "models/Timeline",

  "controllers/ForgotPasswordController",
  "controllers/GroupsHomeController",
  "controllers/GroupsNewController",
  "controllers/PostAttachmentController",
  "controllers/PostGenericController",
  "controllers/PostController",
  "controllers/PostCommentController",
  "controllers/ResetPasswordController",
  "controllers/SessionNewController",
  "controllers/SessionDestroyController",
  "controllers/SettingsGenericController",
  "controllers/SettingsIndexController",
  "controllers/SettingsFeedController",
  "controllers/TimelineGenericController",
  "controllers/TimelineCommentsController",
  "controllers/TimelineIndexController",
  "controllers/TimelineDiscussionsController",
  "controllers/TimelineHomeController",
  "controllers/TimelineLikesController",
  "controllers/TimelinePostController",
  "controllers/TimelineSubscribersController",
  "controllers/TimelineSubscriptionsController",
  "controllers/UsersNewController",

  "fields/CreatePostView",
  "fields/CreateAttachmentView",
  "fields/EditPostView",
  "fields/CreateCommentView",
  "fields/EditCommentView",
  "fields/UpdateProfilePictureView",

  "routes/ForgotPasswordRoute",
  "routes/GroupsHomeRoute",
  "routes/GroupsNewRoute",
  "routes/HomeRoute",
  "routes/PostRoute",
  "routes/ResetPasswordRoute",
  "routes/SessionNewRoute",
  "routes/SessionDestroyRoute",
  "routes/SettingsIndexRoute",
  "routes/SettingsFeedRoute",
  "routes/TimelineCommentsRoute",
  "routes/TimelineIndexRoute",
  "routes/TimelineDiscussionsRoute",
  "routes/TimelineHomeRoute",
  "routes/TimelineLikesRoute",
  "routes/TimelineSubscribersRoute",
  "routes/TimelineSubscriptionsRoute",
  "routes/UsersNewRoute",

  "serializers/PostSerializer",

  "transforms/FileTransform",

  "views/AuthorizedView",
  "views/UnauthorizedView",

  // page views
  "views/ForgotPasswordView",
  "views/GroupsHomeView",
  "views/GroupsNewView",
  "views/HomeView",
  "views/NotFoundView",
  "views/PostView",
  "views/ResetPasswordView",
  "views/SessionNewView",
  "views/SettingsIndexView",
  "views/SettingsFeedView",
  "views/TimelineCommentsView",
  "views/TimelineIndexView",
  "views/TimelineDiscussionsView",
  "views/TimelineHomeView",
  "views/TimelineLikesView",
  "views/TimelineSubscribersView",
  "views/TimelineSubscriptionsView",
  "views/UsersNewView",

  // partial views
  "views/BreadcrumbsView",
  "views/FooterView",
  "views/HiddenPostsView",
  "views/MyGroupsView",
  "views/PaginationView",
  "views/PostsView",
  "views/PostAttachmentView",
  "views/PostCommentView",
  "views/PostLikesView",
  "views/PostTitleView",
  "views/ProfileLinksView",
  "views/SendToView",
  "views/SubmitPostView",
  "views/TimelinePostView"
], function(App) {
  "use strict";

  return App
})
<commit_msg>Includes missing NotFound route to main dependencies. Fixes #402.<commit_after>define([
  "app/app",
  "app/router",

  "adapters/ApplicationAdapter",
  "adapters/FormDataAdapter",
  "adapters/AttachmentAdapter",
  "adapters/SubscriberAdapter",
  "adapters/SubscriptionAdapter",
  "adapters/TimelineAdapter",

  "components/Pagination",

  "helpers/Handlebars",

  "initializers/AjaxPrefilter",
  "initializers/PubSub",
  "initializers/Session",
  "initializers/DS",

  "models/Attachment",
  "models/Comment",
  "models/Group",
  "models/Post",
  "models/User",
  "models/Subscription",
  "models/Subscriber",
  "models/Timeline",

  "controllers/ForgotPasswordController",
  "controllers/GroupsHomeController",
  "controllers/GroupsNewController",
  "controllers/PostAttachmentController",
  "controllers/PostGenericController",
  "controllers/PostController",
  "controllers/PostCommentController",
  "controllers/ResetPasswordController",
  "controllers/SessionNewController",
  "controllers/SessionDestroyController",
  "controllers/SettingsGenericController",
  "controllers/SettingsIndexController",
  "controllers/SettingsFeedController",
  "controllers/TimelineGenericController",
  "controllers/TimelineCommentsController",
  "controllers/TimelineIndexController",
  "controllers/TimelineDiscussionsController",
  "controllers/TimelineHomeController",
  "controllers/TimelineLikesController",
  "controllers/TimelinePostController",
  "controllers/TimelineSubscribersController",
  "controllers/TimelineSubscriptionsController",
  "controllers/UsersNewController",

  "fields/CreatePostView",
  "fields/CreateAttachmentView",
  "fields/EditPostView",
  "fields/CreateCommentView",
  "fields/EditCommentView",
  "fields/UpdateProfilePictureView",

  "routes/ForgotPasswordRoute",
  "routes/GroupsHomeRoute",
  "routes/GroupsNewRoute",
  "routes/HomeRoute",
  "routes/NotFoundRoute",
  "routes/PostRoute",
  "routes/ResetPasswordRoute",
  "routes/SessionNewRoute",
  "routes/SessionDestroyRoute",
  "routes/SettingsIndexRoute",
  "routes/SettingsFeedRoute",
  "routes/TimelineCommentsRoute",
  "routes/TimelineIndexRoute",
  "routes/TimelineDiscussionsRoute",
  "routes/TimelineHomeRoute",
  "routes/TimelineLikesRoute",
  "routes/TimelineSubscribersRoute",
  "routes/TimelineSubscriptionsRoute",
  "routes/UsersNewRoute",

  "serializers/PostSerializer",

  "transforms/FileTransform",

  "views/AuthorizedView",
  "views/UnauthorizedView",

  // page views
  "views/ForgotPasswordView",
  "views/GroupsHomeView",
  "views/GroupsNewView",
  "views/HomeView",
  "views/NotFoundView",
  "views/PostView",
  "views/ResetPasswordView",
  "views/SessionNewView",
  "views/SettingsIndexView",
  "views/SettingsFeedView",
  "views/TimelineCommentsView",
  "views/TimelineIndexView",
  "views/TimelineDiscussionsView",
  "views/TimelineHomeView",
  "views/TimelineLikesView",
  "views/TimelineSubscribersView",
  "views/TimelineSubscriptionsView",
  "views/UsersNewView",

  // partial views
  "views/BreadcrumbsView",
  "views/FooterView",
  "views/HiddenPostsView",
  "views/MyGroupsView",
  "views/PaginationView",
  "views/PostsView",
  "views/PostAttachmentView",
  "views/PostCommentView",
  "views/PostLikesView",
  "views/PostTitleView",
  "views/ProfileLinksView",
  "views/SendToView",
  "views/SubmitPostView",
  "views/TimelinePostView"
], function(App) {
  "use strict";

  return App
})
<|endoftext|>


<commit_before>// ==========================================================================
// Project:  SproutCore Runtime
// Copyright: ©2011 Strobe Inc. and contributors.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================
/*global testBoth */

// used by unit tests to test both accessor mode and non-accessor mode
testBoth = function testBoth(testname, callback) {

  function scget(x,y) { return SC.get(x,y); }
  function scset(x,y,z) { return SC.set(x,y,z); }
  function aget(x,y) { return x[y]; }
  function aset(x,y,z) { return (x[y] = z); }

  test(testname+' using SC.get()/SC.set()', function() {
    callback(scget, scset);
  });

  test(testname+' using accessors', function() {
    if (SC.USES_ACCESSORS) callback(aget, aset);
    else ok('SKIPPING ACCESSORS');
  });
};<commit_msg>IE doesn't like assigning a function to a variable of the same name.<commit_after>// ==========================================================================
// Project:  SproutCore Runtime
// Copyright: ©2011 Strobe Inc. and contributors.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================
/*global testBoth */

// used by unit tests to test both accessor mode and non-accessor mode
testBoth = function(testname, callback) {

  function scget(x,y) { return SC.get(x,y); }
  function scset(x,y,z) { return SC.set(x,y,z); }
  function aget(x,y) { return x[y]; }
  function aset(x,y,z) { return (x[y] = z); }

  test(testname+' using SC.get()/SC.set()', function() {
    callback(scget, scset);
  });

  test(testname+' using accessors', function() {
    if (SC.USES_ACCESSORS) callback(aget, aset);
    else ok('SKIPPING ACCESSORS');
  });
};<|endoftext|>