This repository was archived by the owner on Jun 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathValveData.m
More file actions
105 lines (86 loc) · 3.18 KB
/
ValveData.m
File metadata and controls
105 lines (86 loc) · 3.18 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
%ValveData - Data object to hold the all processing information for valve data
%ValveData inherits from AncillaryData
%
% Syntax: valvedata = ValveData(nameIn, dataValuesIn, timestampsIn, unitsIn)
% Inputs:
% nameIn - Description
% dataValuesIn - Description
% timestampsIn - Description
% unitsIn -
%
%
% Example:
% vd = ValveData('Valve1', ValveState, fullDate, obj.ValveUnits);
%
% Other m-files required: AncillaryData
% Subfunctions: none
% MAT-files required: none
%
% See also: AncillaryData, FlowFileLoader
% Author: Wendy Neary
% MISCLab, University of Maine
% email address: wendy.neary@maine.edu
% Website: http://misclab.umeoce.maine.edu/index.php
% May 2015; Last revision: 13-08-15
%------------- BEGIN CODE --------------
classdef ValveData < AncillaryInlineData
properties
Name
Type = 'valve';
Units
% a timeseries object
DataObject
% preprocessing variables
SmoothData
TransStartData;
TransStartTime;
TransEndData;
TransEndTime;
levelsMap;
end
methods
function obj = ValveData(nameIn, dataValuesIn, timestampsIn, unitsIn)
%%% Pre-initialization %%%
% Any code not using output argument (obj)
%%% Object Initialization %%%
% Call superclass constructor before accessing object
% This statment cannot be conditionalized
obj = obj@AncillaryInlineData(nameIn, dataValuesIn, timestampsIn, unitsIn);
%%% Post-initialization %%%
% Any code, including access to the object
end
function findTransitions(obj)
valveIndex = logical(obj.DataObject.Data);
diffArray = valveIndex(2:end) - valveIndex(1:end-1);
diffArray(end+1) = NaN;
startsIndex = find(diffArray < 0);
endsIndex = find(diffArray > 0);
obj.TransStartTime = obj.DataObject.Time(startsIndex);
obj.TransEndTime = obj.DataObject.Time(endsIndex);
obj.TransStartData = obj.DataObject.Data(startsIndex);
obj.TransEndData = obj.DataObject.Data(endsIndex);
end
%%
% ----------------------------------------------------------------
% plots
% ----------------------------------------------------------------
function plotTransitions(obj)
hold on
grid on
plot(obj.DataObject.Time, obj.DataObject.Data)
plot(obj.TransStartTime, obj.TransStartData, 'g*')
plot(obj.TransEndTime, obj.TransEndData, 'r*')
legend('valve state', 'valve opened/start FSW', 'valve close/end FSW')
dynamicDateTicks
hold off
grid off
end
function plotData(obj)
ts = obj.DataObject;
plot(obj.DataObject.Time, obj.DataObject.Data)
xlabel('Timestamps')
ylabel('Valve State')
dynamicDateTicks();
end % end plotData
end % end methods
end % end classDef