Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1702 | - | 1 | #include "eoseventparser.h" |
2 | #include "dataitem.h" |
||
3 | #include "camcontroller.h" |
||
4 | |||
5 | extern DIT_MODE diMode; |
||
6 | extern DIT_APERTURE diAperture; |
||
7 | extern DIT_WB diWb; |
||
8 | extern DIT_SHUTTER_SPEED diShutterSpeed; |
||
9 | extern DIT_PSTYLE diPStyle; |
||
10 | extern DIT_ISO diIso; |
||
11 | extern DIT_EXPCOMP diExpComp; |
||
12 | |||
13 | extern EEPROMByteList vlAperture; |
||
14 | extern EEPROMByteList vlShutterSpeed; |
||
15 | extern EEPROMByteList vlWhiteBalance; |
||
16 | extern EEPROMByteList vlPictureStyle; |
||
17 | extern EEPROMByteList vlExpCompensation; |
||
18 | extern EEPROMByteList vlIso; |
||
19 | |||
20 | bool EOSEventParser::EventRecordParse(uint8_t **pp, uint16_t *pcntdn) |
||
21 | { |
||
22 | switch (nRecStage) |
||
23 | { |
||
24 | case 0: |
||
25 | // Retrieves the size of the event record |
||
26 | if (!valueParser.Parse(pp, pcntdn)) |
||
27 | return false; |
||
28 | |||
29 | nRecSize = (uint16_t)varBuffer; |
||
30 | |||
31 | // calculates the number of event parameters ( size / 4 - 1 ) |
||
32 | paramCountdown = (nRecSize >> 2) - 1; |
||
33 | |||
34 | paramCount = 1; |
||
35 | nRecSize -= 4; |
||
36 | nRecStage ++; |
||
37 | case 1: |
||
38 | for (; paramCountdown; paramCountdown--, paramCount++, nRecSize -= 4) |
||
39 | { |
||
40 | if (!valueParser.Parse(pp, pcntdn)) |
||
41 | return false; |
||
42 | |||
43 | switch (paramCount) |
||
44 | { |
||
45 | // Event Code |
||
46 | case 1: |
||
47 | eosEvent.eventCode = (uint16_t)varBuffer; |
||
48 | break; |
||
49 | // Property Code |
||
50 | case 2: |
||
51 | // if (eosEvent.eventCode == EOS_EC_ObjectCreated) |
||
52 | // { |
||
53 | // } |
||
54 | eosEvent.propCode = (uint16_t)varBuffer; |
||
55 | break; |
||
56 | // C189 - Property Value, C18A - Enumerator Type |
||
57 | case 3: |
||
58 | eosEvent.propValue = varBuffer; |
||
59 | |||
60 | if (eosEvent.eventCode == EOS_EC_DevPropChanged) |
||
61 | { |
||
62 | |||
63 | switch (eosEvent.propCode) |
||
64 | { |
||
65 | case EOS_DPC_Aperture: |
||
66 | diAperture.Set(varBuffer); |
||
67 | break; |
||
68 | case EOS_DPC_ShutterSpeed: |
||
69 | diShutterSpeed.Set(varBuffer); |
||
70 | break; |
||
71 | case EOS_DPC_ShootingMode: |
||
72 | diMode.Set(varBuffer); |
||
73 | break; |
||
74 | case EOS_DPC_WhiteBalance: |
||
75 | diWb.Set(varBuffer); |
||
76 | break; |
||
77 | case EOS_DPC_PictureStyle: |
||
78 | diPStyle.Set(varBuffer); |
||
79 | break; |
||
80 | case EOS_DPC_Iso: |
||
81 | diIso.Set(varBuffer); |
||
82 | break; |
||
83 | case EOS_DPC_ExposureCompensation: |
||
84 | diExpComp.Set(varBuffer); |
||
85 | break; |
||
86 | }; |
||
87 | } |
||
88 | break; |
||
89 | // C18A/enumType == 3 - Size of enumerator array |
||
90 | case 4: |
||
91 | if (eosEvent.eventCode == EOS_EC_DevPropValuesAccepted) |
||
92 | { |
||
93 | switch (eosEvent.propCode) |
||
94 | { |
||
95 | case EOS_DPC_Aperture: |
||
96 | vlAperture.SetSize((uint8_t)varBuffer); |
||
97 | break; |
||
98 | case EOS_DPC_ShutterSpeed: |
||
99 | vlShutterSpeed.SetSize((uint8_t)varBuffer); |
||
100 | break; |
||
101 | case EOS_DPC_WhiteBalance: |
||
102 | vlWhiteBalance.SetSize((uint8_t)varBuffer); |
||
103 | break; |
||
104 | case EOS_DPC_PictureStyle: |
||
105 | vlPictureStyle.SetSize((uint8_t)varBuffer); |
||
106 | break; |
||
107 | case EOS_DPC_Iso: |
||
108 | vlIso.SetSize((uint8_t)varBuffer); |
||
109 | break; |
||
110 | case EOS_DPC_ExposureCompensation: |
||
111 | vlExpCompensation.SetSize((uint8_t)varBuffer); |
||
112 | break; |
||
113 | }; |
||
114 | } |
||
115 | break; |
||
116 | // C18A/enumType == 3 - Enumerator Values |
||
117 | default: |
||
118 | if (eosEvent.eventCode == EOS_EC_DevPropValuesAccepted) |
||
119 | { |
||
120 | switch (eosEvent.propCode) |
||
121 | { |
||
122 | case EOS_DPC_Aperture: |
||
123 | vlAperture.Set(paramCount-5, (uint8_t)varBuffer); |
||
124 | break; |
||
125 | case EOS_DPC_ShutterSpeed: |
||
126 | vlShutterSpeed.Set(paramCount-5, (uint8_t)varBuffer); |
||
127 | break; |
||
128 | case EOS_DPC_WhiteBalance: |
||
129 | vlWhiteBalance.Set(paramCount-5, (uint8_t)varBuffer); |
||
130 | break; |
||
131 | case EOS_DPC_PictureStyle: |
||
132 | vlPictureStyle.Set(paramCount-5, (uint8_t)varBuffer); |
||
133 | break; |
||
134 | case EOS_DPC_ExposureCompensation: |
||
135 | vlExpCompensation.Set(paramCount-5, (uint8_t)varBuffer); |
||
136 | break; |
||
137 | case EOS_DPC_Iso: |
||
138 | vlIso.Set(paramCount-5, (uint8_t)varBuffer); |
||
139 | break; |
||
140 | } // switch (eosEvent.propCode) |
||
141 | } |
||
142 | } // switch (paramCount) |
||
143 | } // for |
||
144 | nRecStage ++; |
||
145 | case 2: |
||
146 | if (nRecSize) |
||
147 | if (!byteSkipper.Skip(pp, pcntdn, nRecSize)) |
||
148 | return false; |
||
149 | |||
150 | nRecSize = 0; |
||
151 | nRecStage = 0; |
||
152 | } |
||
153 | return true; |
||
154 | } |
||
155 | |||
156 | void EOSEventParser::InitEOSEventStruct() |
||
157 | { |
||
158 | eosEvent.eventCode = constInitialEventCode; |
||
159 | eosEvent.propCode = 0; |
||
160 | eosEvent.propValue = 0; |
||
161 | } |
||
162 | |||
163 | |||
164 | void EOSEventParser::Parse(const uint16_t len, const uint8_t *pbuf, const uint32_t &offset) |
||
165 | { |
||
166 | uint8_t *p = (uint8_t*) pbuf; |
||
167 | uint16_t cntdn = len; |
||
168 | |||
169 | switch (nStage) |
||
170 | { |
||
171 | case 0: |
||
172 | p += 12; |
||
173 | cntdn -= 12; |
||
174 | nStage ++; |
||
175 | case 1: |
||
176 | theBuffer.valueSize = 4; |
||
177 | valueParser.Initialize(&theBuffer); |
||
178 | InitEOSEventStruct(); |
||
179 | nStage ++; |
||
180 | case 2: |
||
181 | while (1) |
||
182 | { |
||
183 | if (!EventRecordParse(&p, &cntdn)) |
||
184 | return; |
||
185 | if (IsLastEventRecord()) |
||
186 | break; |
||
187 | InitEOSEventStruct(); |
||
188 | } |
||
189 | nStage = 0; |
||
190 | } |
||
191 | } |