Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

ptp allows you to retrieve information about the network PTP state of the player.

ptp IDL

Code Block
languagejs
interface PtpEvent {
    attribute String type;
};

callback PtpEventCallback = void (PtpEvent event);

interface Ptp {
    Promise<PtpStatus> getStatus();
    void addEventListener(String type, PtpEventCallback callback);
    void removeEventListener(String type, PtpEventCallback callback);
};

interface PtpStatus {
    attribute long timestamp;
    attribute String state;
};                                                                                                           
Panel
borderColor#3D3D3D
bgColor#F4F4F4
titleColor#3D3D3D
borderWidth0
titleBGColor#3D3D3D
borderStylesolid

ON THIS PAGE

Table of Contents
indent20px


Object Creation

To create a ptp object, load the @brightsign/ptp module using the require() method. 

Code Block
languagejs
var ptpclass = require('@brightsign/ptp');
var ptp = new ptpclass();                                                                                 

Ptp

getStatus()
Code Block
languagejs
Promise<PtpStatus> getStatus()                                                                                             

Gets the status of a PTP network for a player.

PtpEvent

This event object is generated by the roPtp object whenever the PTP status of the player changes.

  • [type string] type:   The name of the event ( which will always be PtpEvent).

PtpStatus

  • [timestamp long] timestamp:  The number of seconds since the PTP state was last changed. This value can be compared against the total uptime of the player, which is retrieved by calling UpTime(0).

  • [state string] state:   Indicates the current PTP state of the player.  Values can be Master, Slave, or Uncalibrated.

Example

Code Block
languagejs
// code placeholder
var ptpclass = require('@brightsign/ptp');  
var ptp = new ptpclass();
function main() {    
    console.log("Starting PTP javascript API...");    
    // ptp status test    
    // Two examples of result from getStatus() for Master & Slave player    
    // {"state":"MASTER","timestamp":20}     
    // {"state":"SLAVE","timestamp":24}     
    var status = ptp.getStatus();    
    status.then( function(result) {              
       console.log(JSON.stringify(result)); })    
     .catch( function(err){     
       console.log(JSON.stringify(err)); 
    });

    // add event test 
    if(ptp.addEventListener){ 
       console.log("adding test event"); 
       ptp.addEventListener("ptpevent", EventHandler);     
    }
    // remove event test    
    // set 5 sec timeout for the purpose of testing removeEventListener     
    setTimeout(function (){      
       console.log("removing test event");        
       ptp.removeEventListener("ptpevent", EventHandler) }, 5000);
}
function EventHandler(event){   
    console.log(JSON.stringify(event));  
}                                                                                      

As of BrightSignOS 8.3.20, to get the current data set: 

Code Block
languagejs
var ptpclass = require('@brightsign/ptp');
 var ptp = new ptpclass();
var ds = ptp.getCurrentDataSet();
ds
 .then( function(result) {
   console.log(JSON.stringify(result));
 })
 .catch( function(err){
   console.log(JSON.stringify(err)); }
 );

This will return a promise that, when successful, resolves to type: 

Code Block
languagejs
type CurrentDataSet
{
 stepsRemoved: number;
 offsetFromMaster: number;
 meanPathDelay: number;
}