-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmock-edm.service.ts
87 lines (71 loc) · 3.2 KB
/
mock-edm.service.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { Injectable } from '@angular/core';
import {Observable, of} from 'rxjs';
import {ExperimentDescription} from './data-types/ExperimentDescription';
import {Load} from './data-types/Load';
import {ControllableGenerator} from './data-types/ControllableGenerator';
import {NonControllableGenerator} from './data-types/NonControllableGenerator';
import {StorageUnit} from './data-types/StorageUnit';
import {DataProvisionService} from './data-provision.service';
import {ExperimentInstance} from './data-types/ExperimentInstance';
@Injectable({
providedIn: 'root'
})
/**
* A service to act as a placeholder for the EDM platform.
* It mocks the required functionality, and acts as placeholder for the respective requests put into the platform.
* Since it will be deleted once the EDM platform is established, it will not be further covered in the documentation.
*/
export class MockEDMService {
constructor(
private data: DataProvisionService
) { }
static getConfiguredLoads(): Observable<Load[]> {
const loadsToReturn: Load[] = DataProvisionService.getLoads();
return of(loadsToReturn);
}
static getConfiguredStorages(): Observable<StorageUnit[]> {
const storagesToReturn: StorageUnit[] = DataProvisionService.getStorages();
return of(storagesToReturn);
}
static getConfiguredCGs(): Observable<ControllableGenerator[]> {
const cgsToReturn: ControllableGenerator[] = DataProvisionService.getControllableGenerators();
return of(cgsToReturn);
}
static getConfiguredNCGs(): Observable<NonControllableGenerator[]> {
const ncgsToReturn: NonControllableGenerator[] = DataProvisionService.getNonControllableGenerators();
return of(ncgsToReturn);
}
// TODO do something meaningful
addExperimentDescription(descriptionToStore: ExperimentDescription): void {
console.log('Attempting to store ' + descriptionToStore);
}
addNewLoad(load: Load): void {
console.log('Load ' + load.model + ' added as mock functionality');
console.log('Newly added load has a load time series of ' + load.loadProfile);
}
addNewControllableGenerator(cg: ControllableGenerator): void {
console.log('Controllable Generator ' + cg.model + ' added as mock functionality');
}
addNewNonControllableGenerator(ncg: NonControllableGenerator): void {
console.log('NonControllableGenerator ' + ncg.model + ' added as mock functionality');
}
addNewStorage(storage: StorageUnit): void {
console.log('Storage ' + storage.model + ' added as mock functionality');
}
getExperimentInstanceIDSet(): Observable<Set<number>> {
const numberSet = new Set<number>();
console.log('trying to get the experiment instance IDs, with instances ' + this.data.getMockExperimentInstances());
this.data.getMockExperimentInstances().forEach(currentElement => {
numberSet.add(currentElement.experimentID);
});
return of (numberSet);
}
getExperimentDescriptions(): ExperimentDescription[] {
const mockData: ExperimentDescription[] = new Array<ExperimentDescription>();
mockData[0] = DataProvisionService.getExperimentDescription(0);
return mockData;
}
addExperimentInstance(instanceToAdd: ExperimentInstance) {
console.log('Attempting to store ' + instanceToAdd);
}
}