Goed, het volgende is het geval.
Ik heb een collectieklasse, deze bevat meerdere klassen (DUH) en de klasse bevat ook nog een andere klasse.....
Schema:
dataPointCollection
dataPoint
measurement
Nu gaat er iets mis bij het laden van de code. het Measurement object wordt constant overgeschreven, zodat ik aan het eind bij elke dataPoint hetzelfde measurement object heb. [ nog duidelijk
?]
Datapoint.cls
Measurement
DataPointCollection
Inlezen van de data uit de database en invoeren in de datastructuur
Nog een keer het probleem.
Het measurement object geeft na een get bij elke datapoint uit de datapointcollectie dezelfde waarde.
Iemand een oplossing of een idee?
Ik heb een collectieklasse, deze bevat meerdere klassen (DUH) en de klasse bevat ook nog een andere klasse.....
Schema:
dataPointCollection
dataPoint
measurement
Nu gaat er iets mis bij het laden van de code. het Measurement object wordt constant overgeschreven, zodat ik aan het eind bij elke dataPoint hetzelfde measurement object heb. [ nog duidelijk
Datapoint.cls
Visual Basic:
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
| Option Explicit Private meas As New Measurement Private dblPower As Double Private dblRPM As Double Private strComment As String Public Property Set Measure(m As Measurement) Set meas = m End Property Public Property Get Measure() As Measurement Set Measure = meas End Property Public Property Let powerInst(dblP As Double) dblPower = dblP End Property Public Property Get powerInst() As Double powerInst = dblPower End Property Public Property Get rpmInst() As Double rpmInst = dblRPM End Property Public Property Let rpmInst(ByVal vNewValue As Double) dblRPM = vNewValue End Property Public Property Get comment() As String comment = strComment End Property Public Property Let comment(ByVal vNewValue As String) strComment = vNewValue End Property |
Measurement
Visual Basic:
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
| Option Explicit Private mdblrpm As Double Private mdblTorque As Double Private mIntTemp As Integer Private mIntTempPCB As Integer Public Property Get rpm() As Double rpm = mdblrpm End Property Public Property Let rpm(ByVal vNewValue As Double) mdblrpm = vNewValue End Property Public Property Get torque() As Double torque = mdblTorque End Property Public Property Let torque(ByVal vNewValue As Double) mdblTorque = vNewValue End Property Public Property Get temperature() As Integer temperature = mIntTemp End Property Public Property Let temperature(ByVal vNewValue As Integer) mIntTemp = vNewValue End Property Public Property Get temperaturePCB() As Integer temperaturePCB = mIntTempPCB End Property Public Property Let temperaturePCB(ByVal vNewValue As Integer) mIntTempPCB = vNewValue End Property Public Property Get power() As Double power = mdblTorque * 2 * PI * (mdblrpm / 60) End Property Public Property Let power(ByVal vNewValue As Double) mdblTorque = vNewValue / (2 * PI * (mdblrpm / 60)) End Property |
DataPointCollection
Visual Basic:
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
| Option Explicit Private mColDataPoint As New Collection Public Function add(ByVal rpm_In As Double, _ ByVal power_In As Double, ByVal comment As String, _ ByVal m As Measurement) As DataPoint Static intCt As Integer intCt = intCt + 1 Dim NewDataPoint As New DataPoint With NewDataPoint .rpmInst = rpm_In .powerInst = power_In .comment = comment Set .Measure = m mColDataPoint.add NewDataPoint, CStr(intCt) End With Set add = NewDataPoint End Function Public Function Count() As Long Count = mColDataPoint.Count End Function Public Sub Delete(ByVal Index As Variant) mColDataPoint.Remove (Index) End Sub Public Function Item(ByVal Index As Variant) As DataPoint Set Item = mColDataPoint.Item(Index) End Function Public Function NewEnum() As IUnknown Set NewEnum = mColDataPoint.[_NewEnum] End Function Public Sub loadData(strPath As String) Dim fso As New FileSystemObject, fil As File, ts As TextStream Dim txtArr, ergArr, pwrArr As Variant, txt As String, txtTemp As String Dim i%, j% Dim rpm_instel, power_instel As Double Dim meas As New Measurement Set fil = fso.GetFile(strPath) Set ts = fil.OpenAsTextStream(ForReading) txt = ts.ReadAll txtArr = Split(txt, vbCrLf) For i% = LBound(txtArr) To UBound(txtArr) ergArr = Split(txtArr(i%), "|") pwrArr = Split(ergArr(1), ",") rpm_instel = Val(ergArr(0)) For j% = LBound(pwrArr) To UBound(pwrArr) add rpm_instel, Val(pwrArr(j%)), " ", meas Next Next End Sub |
Inlezen van de data uit de database en invoeren in de datastructuur
Visual Basic:
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
| Public Function getCalibrations() As CalibrationCollection Dim strSQL As String Dim rsCalib As ADODB.Recordset Dim nwCalCol As New CalibrationCollection Dim nwCalib As Calibration strSQL = "SELECT * FROM Calibration" Set rsCalib = cnnLode.Execute(strSQL) Do While Not rsCalib.EOF Set nwCalib = nwCalCol.add(Ergometers.Item(rsCalib.Fields(2)), _ getEngineer(rsCalib.Fields(1)), _ getCustomer(rsCalib.Fields(3)), _ rsCalib.Fields(4), _ getCalibMatrix(rsCalib.Fields(0)), _ rsCalib.Fields(0)) rsCalib.MoveNext Loop Set getCalibrations = nwCalCol End Function Public Function getCalibMatrix(key As Integer) As DataPointCollection Dim strSQL As String Dim rsCalibMatrix As ADODB.Recordset Dim nwDataP As New DataPoint Dim nwMeas As New Measurement Dim nwCalibMatrix As New DataPointCollection strSQL = "SELECT * FROM Metingen WHERE Metingen.CalibID=" & key Set rsCalibMatrix = cnnLode.Execute(strSQL) Do While Not rsCalibMatrix.EOF nwMeas.rpm = Val(rsCalibMatrix.Fields(3)) nwMeas.power = Val(rsCalibMatrix.Fields(4)) Set nwDataP = nwCalibMatrix.add(rsCalibMatrix.Fields(1), _ rsCalibMatrix.Fields(2), "", nwMeas) rsCalibMatrix.MoveNext Loop Set getCalibMatrix = nwCalibMatrix End Function |
Nog een keer het probleem.
Het measurement object geeft na een get bij elke datapoint uit de datapointcollectie dezelfde waarde.
Iemand een oplossing of een idee?
Wat niet kan is nog nooit gebeurd