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 callingUpTime(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; }