Skip to content

Commit

Permalink
Adds routes and build directory
Browse files Browse the repository at this point in the history
  • Loading branch information
baudev committed Mar 21, 2020
1 parent fbaf89a commit 90399f6
Show file tree
Hide file tree
Showing 14 changed files with 661 additions and 46 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,4 @@ dist
.tern-port

# IntelliJ
.idea/

# Output
build/
.idea/
77 changes: 77 additions & 0 deletions build/Camera.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { WebControl } from "./WebControl";
import { MotionDetectionStatus } from "./Enums/MotionDetectionStatus";
import { MotionConnectionStatus } from "./Enums/MotionConnectionStatus";
export declare class Camera {
/**
* Id of the camera
*/
private _id;
/**
* Webcontrol instance
*/
private _webControl;
constructor(id: number, webControl: WebControl);
/**
* Lists all the configuration values for the camera.
*/
getConfigList(): Promise<string>;
/**
* Set the value for the requested parameter.
* @param parm
* @param value1
*/
setConfig(parm: string, value1: string): Promise<void>;
/**
* Return the value currently set for the parameter.
* @param parm
*/
getConfig(parm: string): Promise<string>;
/**
* Write the current parameters to the file.
*/
writeConfig(): Promise<string>;
/**
* Return the current status of the camera.
*/
getDetectionStatus(): Promise<MotionDetectionStatus>;
/**
* Return the connection status of the camera.
*/
getConnectionStatus(): Promise<MotionConnectionStatus>;
/**
* Start or resume motion detection.
*/
startDetection(): Promise<string>;
/**
* Pause the motion detection.
*/
pauseDetection(): Promise<string>;
/**
* Trigger a new event.
*/
startEvent(): Promise<string>;
/**
* Trigger the end of a event.
*/
endEvent(): Promise<string>;
/**
* Create a snapshot.
*/
createSnapshot(): Promise<string>;
/**
* Shutdown and restart Motion.
*/
restart(): Promise<string>;
/**
* Close all connections to the camera.
*/
quit(): Promise<string>;
/**
* Entirely shutdown the Motion application.
*/
end(): Promise<string>;
get id(): number;
set id(value: number);
get webControl(): WebControl;
set webControl(value: WebControl);
}
142 changes: 142 additions & 0 deletions build/Camera.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const MotionDetectionStatus_1 = require("./Enums/MotionDetectionStatus");
const MotionConnectionStatus_1 = require("./Enums/MotionConnectionStatus");
class Camera {
constructor(id, webControl) {
this._id = id;
this._webControl = webControl;
}
/**
* Lists all the configuration values for the camera.
*/
getConfigList() {
return this.webControl.getConfigList(this.id);
}
/**
* Set the value for the requested parameter.
* @param parm
* @param value1
*/
setConfig(parm, value1) {
return new Promise(((resolve, reject) => {
this.webControl.setConfig(this.id, parm, value1)
.then((res) => {
return new RegExp(/Done/).test(res) ? resolve() : reject();
})
.catch((err) => reject(err));
}));
}
/**
* Return the value currently set for the parameter.
* @param parm
*/
getConfig(parm) {
return new Promise(((resolve, reject) => {
return this.webControl.getConfig(this.id, parm)
.then((response) => {
let regex = /= (.+) /;
let match = regex.exec(response);
return match && match[1] ? resolve(match[1]) : reject();
})
.catch((err) => reject(err));
}));
}
/**
* Write the current parameters to the file.
*/
writeConfig() {
return this.webControl.writeConfig(this.id);
}
/**
* Return the current status of the camera.
*/
getDetectionStatus() {
return this.webControl.getDetectionStatus(this.id)
.then((message) => {
return new RegExp(/Detection status ACTIVE/).test(message) ? MotionDetectionStatus_1.MotionDetectionStatus.ENABLE : MotionDetectionStatus_1.MotionDetectionStatus.DISABLE;
});
}
/**
* Return the connection status of the camera.
*/
getConnectionStatus() {
return this.webControl.getDetectionConnection(this.id)
.then((message) => {
return new RegExp(/Camera Connection OK/).test(message) ? MotionConnectionStatus_1.MotionConnectionStatus.OK : MotionConnectionStatus_1.MotionConnectionStatus.DISCONNECTED;
});
}
/**
* Start or resume motion detection.
*/
startDetection() {
return this.webControl.setDetectionStart(this.id);
}
/**
* Pause the motion detection.
*/
pauseDetection() {
return this.webControl.setDetectionPause(this.id);
}
/**
* Trigger a new event.
*/
startEvent() {
return this.webControl.startEvent(this.id);
}
/**
* Trigger the end of a event.
*/
endEvent() {
return this.webControl.endEvent(this.id);
}
/**
* Create a snapshot.
*/
createSnapshot() {
return this.webControl.getSnapshot(this.id)
.then(() => __awaiter(this, void 0, void 0, function* () {
return (yield this.getConfig("target_dir")) + "/lastsnap.jpg";
}));
}
/**
* Shutdown and restart Motion.
*/
restart() {
return this.webControl.restart(this.id);
}
/**
* Close all connections to the camera.
*/
quit() {
return this.webControl.quit(this.id);
}
/**
* Entirely shutdown the Motion application.
*/
end() {
return this.webControl.end(this.id);
}
get id() {
return this._id;
}
set id(value) {
this._id = value;
}
get webControl() {
return this._webControl;
}
set webControl(value) {
this._webControl = value;
}
}
exports.Camera = Camera;
4 changes: 4 additions & 0 deletions build/Enums/MotionConnectionStatus.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export declare enum MotionConnectionStatus {
DISCONNECTED = 0,
OK = 1
}
7 changes: 7 additions & 0 deletions build/Enums/MotionConnectionStatus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var MotionConnectionStatus;
(function (MotionConnectionStatus) {
MotionConnectionStatus[MotionConnectionStatus["DISCONNECTED"] = 0] = "DISCONNECTED";
MotionConnectionStatus[MotionConnectionStatus["OK"] = 1] = "OK";
})(MotionConnectionStatus = exports.MotionConnectionStatus || (exports.MotionConnectionStatus = {}));
4 changes: 4 additions & 0 deletions build/Enums/MotionDetectionStatus.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export declare enum MotionDetectionStatus {
DISABLE = 0,
ENABLE = 1
}
7 changes: 7 additions & 0 deletions build/Enums/MotionDetectionStatus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var MotionDetectionStatus;
(function (MotionDetectionStatus) {
MotionDetectionStatus[MotionDetectionStatus["DISABLE"] = 0] = "DISABLE";
MotionDetectionStatus[MotionDetectionStatus["ENABLE"] = 1] = "ENABLE";
})(MotionDetectionStatus = exports.MotionDetectionStatus || (exports.MotionDetectionStatus = {}));
23 changes: 23 additions & 0 deletions build/MotionApi.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { WebControl } from "./WebControl";
import { Camera } from "./Camera";
export declare class MotionApi {
private _cameras;
/**
* Webcontrol instance
*/
private _webControl;
/**
* Creates MotionApi object
* @param apiUrl The base url of the HTTP motion server
*/
constructor(apiUrl: string);
/**
* Returns an unique instance of the camera
* @param idCamera
*/
getCamera(idCamera: number): Camera;
get cameras(): Array<Camera>;
set cameras(value: Array<Camera>);
get webControl(): WebControl;
set webControl(value: WebControl);
}
45 changes: 45 additions & 0 deletions build/MotionApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const WebControl_1 = require("./WebControl");
const Camera_1 = require("./Camera");
const _ = require('lodash');
class MotionApi {
/**
* Creates MotionApi object
* @param apiUrl The base url of the HTTP motion server
*/
constructor(apiUrl) {
this._cameras = [];
this._webControl = new WebControl_1.WebControl(apiUrl);
}
/**
* Returns an unique instance of the camera
* @param idCamera
*/
getCamera(idCamera) {
let camera = _.find(this.cameras, function (camera) {
return camera.id === idCamera;
});
if (camera !== undefined) {
return camera;
}
else {
let newCamera = new Camera_1.Camera(idCamera, this.webControl);
this.cameras.push(newCamera);
return newCamera;
}
}
get cameras() {
return this._cameras;
}
set cameras(value) {
this._cameras = value;
}
get webControl() {
return this._webControl;
}
set webControl(value) {
this._webControl = value;
}
}
exports.MotionApi = MotionApi;
Loading

0 comments on commit 90399f6

Please sign in to comment.