Skip to content

Commit

Permalink
Add PTZ GetStatus
Browse files Browse the repository at this point in the history
Only returns the UTC timestamp. Does not populate the optional
position and status fields
  • Loading branch information
RogerHardiman committed Jul 27, 2020
1 parent 966107a commit e7dc1ac
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions services/ptz_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ class PTZService extends SoapService {
this.extendService();
}



leftPad(number, targetLength) {
var output = number + '';
while (output.length < targetLength) {
output = '0' + output;
}
return output;
}

extendService() {
var port = this.ptz_service.PTZService.PTZ;
Expand Down Expand Up @@ -217,6 +222,21 @@ class PTZService extends SoapService {
return GetNodesResponse;
};

port.GetStatus = (arg) => {
// ToDo. Check token and return a valid response or an error reponse

var now = new Date();
var utc = now.getUTCFullYear() + '-' + this.leftPad((now.getUTCMonth()+1),2) + '-' + this.leftPad(now.getUTCDate(),2) + 'T'
+ this.leftPad(now.getUTCHours(),2) + ':' + this.leftPad(now.getUTCMinutes(),2) + ':' + this.leftPad(now.getUTCSeconds(),2) + 'Z';

var GetStatusResponse = {
PTZStatus: {
UtcTime: utc
}
};
return GetStatusResponse;
};

port.SetHomePosition = (args) => {
if (this.callback) this.callback('sethome', {});
var SetHomePositionResponse = { };
Expand Down

0 comments on commit e7dc1ac

Please # to comment.