@@ -247,99 +247,6 @@ bool DateReader::detect(const ImageViewRGB32& screen){
247247}
248248
249249
250- void DateReader::set_hours (
251- const ProgramInfo& info, VideoStream& stream, ProControllerContext& context,
252- uint8_t hour
253- ){
254- context.wait_for_all_requests ();
255- {
256- auto snapshot = stream.video ().snapshot ();
257- if (!detect (snapshot)){
258- throw_and_log<FatalProgramException>(
259- stream.logger (), ErrorReport::SEND_ERROR_REPORT,
260- " Expected date change menu." ,
261- stream
262- );
263- }
264- }
265-
266- for (size_t attempts = 0 ; attempts < 10 ; attempts++){
267- // Move cursor out of the way.
268- for (size_t c = 0 ; c < 7 ; c++){
269- ssf_issue_scroll_ptv (context, DPAD_LEFT);
270- }
271- context.wait_for_all_requests ();
272- context.wait_for (std::chrono::milliseconds (250 ));
273-
274- // Read the hour.
275- VideoSnapshot snapshot = stream.video ().snapshot ();
276- // int8_t current_hour = read_hours(stream, snapshot);
277- int8_t current_hour = read_date (stream.logger (), snapshot).second .hour ;
278-
279- if (current_hour < 0 ){
280- throw_and_log<FatalProgramException>(
281- stream.logger (), ErrorReport::SEND_ERROR_REPORT,
282- " Unable to read the hour." ,
283- stream
284- );
285- }
286-
287- // We're done.
288- if (current_hour == hour){
289- for (size_t c = 0 ; c < 7 ; c++){
290- ssf_issue_scroll_ptv (context, DPAD_RIGHT);
291- }
292- return ;
293- }
294-
295- // Move the cursor to the hour.
296- ssf_issue_scroll_ptv (context, DPAD_RIGHT);
297- ssf_issue_scroll_ptv (context, DPAD_RIGHT);
298- ssf_issue_scroll_ptv (context, DPAD_RIGHT);
299-
300- ImageViewRGB32 us_hours = extract_box_reference (snapshot, m_us_hour);
301- ImageStats stats_us_hours = image_stats (us_hours);
302- double stddev = stats_us_hours.stddev .sum ();
303- bool format_us = stddev > 30 ;
304- if (format_us){
305- uint8_t diff = (24 + (uint8_t )hour - (uint8_t )current_hour) % 12 ;
306- if (diff < 6 ){
307- for (size_t c = 0 ; c < diff; c++){
308- ssf_issue_scroll_ptv (context, DPAD_UP);
309- }
310- }else {
311- for (size_t c = diff; c < 12 ; c++){
312- ssf_issue_scroll_ptv (context, DPAD_DOWN);
313- }
314- }
315- if ((hour < 12 ) != (current_hour < 12 )){
316- ssf_issue_scroll_ptv (context, DPAD_RIGHT);
317- ssf_issue_scroll_ptv (context, DPAD_RIGHT);
318- ssf_issue_scroll_ptv (context, DPAD_DOWN);
319- }
320- }else {
321- uint8_t diff = (24 + (uint8_t )hour - (uint8_t )current_hour) % 24 ;
322- if (diff < 12 ){
323- for (size_t c = 0 ; c < diff; c++){
324- ssf_issue_scroll_ptv (context, DPAD_UP);
325- }
326- }else {
327- for (size_t c = diff; c < 24 ; c++){
328- ssf_issue_scroll_ptv (context, DPAD_DOWN);
329- }
330- }
331- }
332- }
333-
334- // auto snapshot = console.video().snapshot();
335- throw_and_log<FatalProgramException>(
336- stream.logger (), ErrorReport::SEND_ERROR_REPORT,
337- " Failed to set the hour after 10 attempts." ,
338- stream
339- );
340- }
341-
342-
343250std::pair<DateFormat, DateTime> DateReader::read_date (Logger& logger, std::shared_ptr<const ImageRGB32> screen){
344251 if (!detect (*screen)){
345252 throw_and_log<OperationFailedException>(
0 commit comments