File

src/port/refs/bulkio.ref.ts

Description

BulkioRef is akin to the internal "ref" member found in the Python Shell.

Extends

PortRef

Index

Properties
Methods
Accessors

Constructor

constructor(url: string, rp: RestPythonService)

Constructor

Parameters :
Name Type Optional Description
url string
rp RestPythonService

Methods

connectPort
connectPort(target: PortReceiver, connection_id?: string)

Connect to the packet stream of the bulkio service listener

Parameters :
Name Type Optional Description
target PortReceiver
  • The callback for when new packets are received.
connection_id string true
  • The connection_id (stream_id), if applicable.
Returns : Subscription
disconnectPort
disconnectPort(connection?: Subscription)

Disconnect this connection. NOTE: This is equivalent call unsubscribe() on the Subscription and also disconnects the service from the server.

Parameters :
Name Type Optional Description
connection Subscription true
  • The connection (subscription) returned from the connectPort call.
Returns : void
release
release()

Release the port's underlying socket service.

Returns : void

Properties

Private bulkioService
bulkioService: BulkioListenerService
Type : BulkioListenerService

The socket service for this port ref.

Private connectionId
connectionId: string
Type : string

The connection (or allocation) ID for the stream

Public url
url: string
Type : string

The REST URL for the port

Accessors

xMax
setxMax(value: number)

Set the max number of samples for the X axis (causes inter-sample averaging). The REST Python server will try to adjust to near this limit based on the data size. Setting the width to less than or equal to 0 will disable this feature.

Parameters :
Name Type Optional Description
value number
Returns : void
xBegin
setxBegin(value: number)

Set the beginning index of the zoom region for the X axis. The index is inclusive and based on data available at the UI (the server will adjust the index for the actual packet size). The zoom will not be enabled until the zoom level is set.

Parameters :
Name Type Optional Description
value number
Returns : void
xEnd
setxEnd(value: number)

Set the ending index of the zoom region for the X axis. The index is inclusive and based on data available at the UI (the server will adjust the index for the actual packet size). The zoom will not be enabled until the zoom level is set.

Parameters :
Name Type Optional Description
value number
Returns : void
xZoomIn
setxZoomIn(value: number)

Command a zoom in on the X axis. Command will be executed regardless of the value set.

Parameters :
Name Type Optional Description
value number
Returns : void
xZoomReset
setxZoomReset(value: number)

Command a zoom reset on the X axis. Command will be executed regardless of the value set.

Parameters :
Name Type Optional Description
value number
Returns : void
yMax
setyMax(value: number)

Set the max number of samples for the Y axis (causes inter-sample averaging). The REST Python server will try to adjust to near this limit based on the data size. Setting the width to less than or equal to 0 will disable this feature.

Parameters :
Name Type Optional Description
value number
Returns : void
yBegin
setyBegin(value: number)

Set the beginning index of the zoom region for the Y axis. The index is inclusive and based on data available at the UI (the server will adjust the index for the actual packet size). The zoom will not be enabled until the zoom level is set.

Parameters :
Name Type Optional Description
value number
Returns : void
yEnd
setyEnd(value: number)

Set the ending index of the zoom region for the Y axis. The index is inclusive and based on data available at the UI (the server will adjust the index for the actual packet size). The zoom will not be enabled until the zoom level is set.

Parameters :
Name Type Optional Description
value number
Returns : void
yZoomIn
setyZoomIn(value: number)

Command a zoom in on the Y axis. Command will be executed regardless of the value set.

Parameters :
Name Type Optional Description
value number
Returns : void
yZoomReset
setyZoomReset(value: number)

Command a zoom reset on the Y axis. Command will be executed regardless of the value set.

Parameters :
Name Type Optional Description
value number
Returns : void
packetsPerSecond
setpacketsPerSecond(pps: number)

Set the data update rate of the connection. This is a maximum update rate and may be approximated. Setting the value to less than or equal to zero disables this feature (i.e., lets the service push as quickly as the socket and server will allow).

Parameters :
Name Type Optional Description
pps number
  • The maximum number of packets per second to receive.
Returns : void
deserializeTime
getdeserializeTime()

Statistic indicating how long it took to deserialize the packet.

Returns : number
packetLength
getpacketLength()

The number of data words in the most recent packet.

Returns : number
packetSubsize
getpacketSubsize()

The frame size of the most recent packet. 0 - One dimensional data (no frames)

 >0 - Two dimensional data
Returns : number
packetMode
getpacketMode()

The complex flag for the most recent packet. 0 - Scalar data 1 - Complex data

Returns : number
import { Subscription } from 'rxjs/Subscription';
import 'rxjs/add/operator/map';

import { BulkioPacket } from '../../models/index';

import { PortRef } from './port.ref';

import { BulkioListenerService } from '../../sockets/sockets.module';

import {
    RestPythonService
} from '../../rest-python/rest-python.module';

/**
 * The PortReceiver interface receives BulkioPacket pushes from
 * the bulkio port service.
 */
export interface PortReceiver {
    /** Callback for when a packet is received on the socket */
    (packet: BulkioPacket): void;
}

/**
 * BulkioRef is akin to the internal "ref" member found in the Python Shell.
 */
export class BulkioRef extends PortRef {
    /** The connection (or allocation) ID for the stream */
    private connectionId: string;
    /** The socket service for this port ref. */
    private bulkioService: BulkioListenerService;

    /**
     * Connect to the packet stream of the bulkio service listener
     * @param {PortReceiver} target - The callback for when new packets are received.
     * @param {string} connection_id - The connection_id (stream_id), if applicable.
     * @return {Subscription} The RxJS Subscription for this connection.
     */
    connectPort(target: PortReceiver, connection_id?: string): Subscription {
        if (connection_id !== this.connectionId) {
            this.disconnectPort();
        }
        if (!this.bulkioService.connected) {
            this.bulkioService.connect(connection_id);
            this.connectionId = connection_id;
        }
        return this.bulkioService.packet$.subscribe(target);
    }

    /**
     * Disconnect this connection.
     * NOTE: This is equivalent call unsubscribe() on the Subscription and
     *       also disconnects the service from the server.
     * @param {Subscription} connection - The connection (subscription) returned
     *     from the connectPort call.
     */
    disconnectPort(connection?: Subscription) {
        if (connection) {
            connection.unsubscribe();
        }
        this.bulkioService.disconnect();
    }

    /**
     * Set the max number of samples for the X axis (causes inter-sample
     * averaging).  The REST Python server will try to adjust to near this limit
     * based on the data size. Setting the width to less than or equal to 0 will
     * disable this feature.
     * @param {number} value
     */
    set xMax(value: number) { this.bulkioService.xMax = value; }

    /**
     * Set the beginning index of the zoom region for the X axis. The index is
     * inclusive and based on data available at the UI (the server will adjust
     * the index for the actual packet size). The zoom will not be enabled until
     * the zoom level is set.
     * @param {number} value
     */
    set xBegin(value: number) { this.bulkioService.xBegin = value; }

    /**
     * Set the ending index of the zoom region for the X axis. The index is
     * inclusive and based on data available at the UI (the server will adjust
     * the index for the actual packet size). The zoom will not be enabled until
     * the zoom level is set.
     * @param {number} value
     */
    set xEnd(value: number) { this.bulkioService.xEnd = value; }

    /**
     * Command a zoom in on the X axis. Command will be executed
     * regardless of the value set.
     * @param {number} value
     */
    set xZoomIn(value: number) { this.bulkioService.xZoomIn = value; }

    /**
     * Command a zoom reset on the X axis. Command will be executed
     * regardless of the value set.
     * @param {number} value
     */
    set xZoomReset(value: number) { this.bulkioService.xZoomReset = value; }

    /**
     * Set the max number of samples for the Y axis (causes inter-sample
     * averaging).  The REST Python server will try to adjust to near this limit
     * based on the data size. Setting the width to less than or equal to 0 will
     * disable this feature.
     * @param {number} value
     */
    set yMax(value: number) { this.bulkioService.yMax = value; }

    /**
     * Set the beginning index of the zoom region for the Y axis. The index is
     * inclusive and based on data available at the UI (the server will adjust
     * the index for the actual packet size). The zoom will not be enabled until
     * the zoom level is set.
     * @param {number} value
     */
    set yBegin(value: number) { this.bulkioService.yBegin = value; }

    /**
     * Set the ending index of the zoom region for the Y axis. The index is
     * inclusive and based on data available at the UI (the server will adjust
     * the index for the actual packet size). The zoom will not be enabled until
     * the zoom level is set.
     * @param {number} value
     */
    set yEnd(value: number) { this.bulkioService.yEnd = value; }

    /**
     * Command a zoom in on the Y axis. Command will be executed
     * regardless of the value set.
     * @param {number} value
     */
    set yZoomIn(value: number) { this.bulkioService.yZoomIn = value; }

    /**
     * Command a zoom reset on the Y axis. Command will be executed
     * regardless of the value set.
     * @param {number} value
     */
    set yZoomReset(value: number) { this.bulkioService.yZoomReset = value; }

    /**
     * Set the data update rate of the connection.  This is a maximum update
     * rate and may be approximated.  Setting the value to less than or equal
     * to zero disables this feature (i.e., lets the service push as quickly
     * as the socket and server will allow).
     * @param {number} pps - The maximum number of packets per second to receive.
     */
    set packetsPerSecond(pps: number) {
        this.bulkioService.packetsPerSecond = pps;
    }

    /**
     * Statistic indicating how long it took to deserialize the packet.
     * @return {number} The time required to deserialize the BulkioPacket
     */
    get deserializeTime(): number {
        return this.bulkioService.deserializeTime;
    }

    /**
     * The number of data words in the most recent packet.
     * @return {number}
     */
    get packetLength(): number {
        return this.bulkioService.packetLength;
    }

    /**
     * The frame size of the most recent packet.
     *      0 - One dimensional data (no frames)
     *     >0 - Two dimensional data
     * @return {number}
     */
    get packetSubsize(): number {
        return this.bulkioService.packetSubsize;
    }

    /**
     * The complex flag for the most recent packet.
     *     0 - Scalar data
     *     1 - Complex data
     * @return {number}
     */
    get packetMode(): number {
        return this.bulkioService.packetMode;
    }

    /**
     * Release the port's underlying socket service.
     */
    release(): void {
        this.bulkioService.disconnect();
        super.release();
    }

    /**
     * Constructor
     * @param url The REST URL for the port
     * @param rp the REST Python service
     */
    constructor(public url: string, rp: RestPythonService) {
        super(url);
        this.bulkioService = new BulkioListenerService(rp.bulkioSocketUrl(url));
    }
}

results matching ""

    No results matching ""