Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 34 Next »

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

ptp IDL
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;
};                                                                                                           

ON THIS PAGE


Object Creation

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

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


Ptp

getStatus()
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.

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


PtpStatus

  • [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).
  • [string] state: Indicates the current PTP state of the player.  Values can be Master, Slave, or Uncalibrated.


Example

// 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: 

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: 

type CurrentDataSet
{
 stepsRemoved: number;
 offsetFromMaster: number;
 meanPathDelay: number;
}



  • No labels