void time_to_gmt(utc_time_t *p_loc_time, utc_time_t *p_gmt_time)
{
  time_info_t *p_info = (time_info_t *)class_get_handle_by_id(TIME_CLASS_ID);
  s32 offset = 0;
  s32 sec_of_zone = MINUTE_PER_HOUR * SECOND_PER_MINUTE / 2;
  
  //p_gmt_time->value = p_loc_time->value;
  memcpy(p_gmt_time, p_loc_time, sizeof(utc_time_t));

  //calculate summer time
  if(p_info->is_summer_time)
  {
    offset -= MINUTE_PER_HOUR * SECOND_PER_MINUTE;
  }

  //calculate time zone
  offset -= sec_of_zone * p_info->time_zone;
  
  while(offset < 0)
  {
    day_reduce(p_gmt_time);
    offset += HOUR_PER_DAY * MINUTE_PER_HOUR * SECOND_PER_MINUTE;
  }

  time_up(p_gmt_time, offset);
}
Exemple #2
0
    MissionSpec::MissionSpec()
    {
        initialiser::initXSD();

        // construct a default mission
        About about("");
        FlatWorldGenerator flat_world_gen;
        flat_world_gen.generatorString( "3;7,220*1,5*3,2;3;,biome_1" );
        ServerHandlers server_handlers;
        server_handlers.FlatWorldGenerator( flat_world_gen );
        ServerQuitFromTimeUp time_up( 10000 );
        server_handlers.ServerQuitFromTimeUp().push_back( time_up );
        ServerQuitWhenAnyAgentFinishes any_quits;
        server_handlers.ServerQuitWhenAnyAgentFinishes().push_back( any_quits );
        ServerSection server_section( server_handlers );
        this->mission = boost::make_shared<Mission>( about, server_section );
        // add a single default agent
        AgentHandlers ah;
        ObservationFromFullStats obs;
        ah.ObservationFromFullStats( obs );
        ContinuousMovementCommands cmc;
        ah.ContinuousMovementCommands( cmc );
        AgentStart agent_start;
        AgentSection as( "Cristina", agent_start, ah );
        this->mission->AgentSection().push_back(as);
    }
/*!
   compare times,
  \param[in/out] src
  \param[in] add
 */
void time_add(utc_time_t *p_time_src, utc_time_t *p_time_add)
{
  u32 s = 0;
  s = (((p_time_add->day * HOUR_PER_DAY)
        + p_time_add->hour) * MINUTE_PER_HOUR 
        + p_time_add->minute)* SECOND_PER_MINUTE 
        + p_time_add->second;
  time_up(p_time_src, s);
}
Exemple #4
0
RET_CODE svstb_convert_time(u32 u32Time,utc_time_t *pUTCTime)
{
    utc_time_t start_utc_time = {1970,1,1,0};

    time_to_local(&start_utc_time, pUTCTime);
    time_up(pUTCTime, u32Time);

    return SUCCESS;
}
static void epg_weekday_upgrade(control_t *p_mbox_weekday, BOOL is_force)
{
  //u32 old_context = 0;
  //s8 new_focus = 0;
  //u32 item_num = 0;
  u8 i;
  //u16 unistr[64];

  u8  weekday;
  u16 dst_unistr[128];
  #if 0
  u16 tmp_unistr[128];
  u8  ansstr[256];
  #endif
  u16 weekstr[] = 
    {
      IDS_MON,
      IDS_TUS,
      IDS_WED,
      IDS_THU,
      IDS_FRI,
      IDS_SAT,
      IDS_SUN,
    };
  utc_time_t cur_time = {0};
  utc_time_t tmp_time = {0};
  
  time_get(&cur_time, TRUE);

  for(i = 0; i<SEVEN; i++)
  {
    memcpy(&tmp_time, &cur_time, sizeof(utc_time_t));
    time_up(&tmp_time, ONE_DAY_SECONDS*i);
    weekday = date_to_weekday(&tmp_time);
    gui_get_string(weekstr[weekday], dst_unistr, 64);
    mbox_set_content_by_unistr(p_mbox_weekday, i, dst_unistr);
  }

  if(is_force)
  {
    ctrl_paint_ctrl(p_mbox_weekday, is_force);
  }
}
/*!
   Get current time
  \param[out] the current time
  \param[in] get GMT time ornot
  \return TRUE for get succeed, FALSE  failed
 */
BOOL time_get(utc_time_t *p_time, BOOL b_gmt_time)
{
  utc_time_t gmt_time = {0};
  time_info_t *p_info = (time_info_t *)class_get_handle_by_id(TIME_CLASS_ID);
  //LOCK(p_info);
  gmt_time = p_info->gmt_time;
  time_up(&gmt_time, 
    (mtos_ticks_get() - p_info->sync_ticks) / TICK_PER_SECOND);
  if(b_gmt_time)
  {
    *p_time = gmt_time;
  }
  else
  {
    time_to_local(&gmt_time, p_time);
  }
  //UNLOCK(p_info);

  return TRUE;
}
//lint -e438 -e550 -e830
static void epg_item_update(control_t *p_cont, u8 focus_state, BOOL is_paint )
{
  dvbs_prog_node_t pg;
  utc_time_t s_time = {0}; 
  utc_time_t e_time = {0};  
  //utc_time_t tmp_time = {0};
  //utc_time_t tot_time = {0};//total time, 2 hours, for caculate x & w.
  control_t *p_list, *p_event_list, *p_mbox_week;
  control_t *p_list_cont, *p_prog_cont;
  
  event_node_t *p_evt_head = NULL;
  u16 total_evt  = 0;
  u16 list_curn, pg_id;
  u16 unistr[64];
  u16 old_focus = 0;
  u16 new_focus = 0;
  u8 day_pos;
  memset(&pg, 0, sizeof(dvbs_prog_node_t));

  epg_event_list_get_time_area(&s_time, &e_time);
    
  p_prog_cont = ctrl_get_child_by_id(p_cont, IDC_EPG_PROG_CONT);
  p_list = ctrl_get_child_by_id(p_prog_cont, IDC_EPG_LIST_PG);

  p_list_cont = ctrl_get_child_by_id(p_cont, IDC_EPG_LIST_CONT);
  p_event_list = ctrl_get_child_by_id(p_list_cont, IDC_EPG_LIST_EVT);

  p_mbox_week = ctrl_get_child_by_id(p_list_cont, IDC_EPG_WEEKDAY);

  if(first_time.day != s_time.day)
  {
    epg_weekday_upgrade(p_mbox_week, TRUE);
    time_get(&first_time, FALSE);
  }

  if(p_mbox_week!=NULL)
  {
    day_pos = (u8)mbox_get_focus(p_mbox_week);

    if(day_pos != 0)
    {
      time_up(&s_time, day_pos*24*60*60);
      s_time.hour = 0;
      s_time.minute = 0;
      s_time.second = 0;

      memcpy(&e_time, &s_time, sizeof(utc_time_t));
      e_time.hour = 23;
      e_time.minute = 59;
      e_time.second = 59;
    }
   //ui_set_epg_day_offset(day_pos);
  }
  
  list_curn = list_get_focus_pos(p_list);
  
  pg_id =db_dvbs_get_id_by_view_pos(ui_dbase_get_pg_view_id(), list_curn);
  db_dvbs_get_pg_by_id(pg_id, &pg);

  g_prog_info.network_id = (u16)pg.orig_net_id;
  g_prog_info.ts_id      = (u16)pg.ts_id;
  g_prog_info.svc_id     = (u16)pg.s_id;
  time_to_gmt(&s_time, &(g_prog_info.start_time));
  time_to_gmt(&e_time, &(g_prog_info.end_time));
  mul_epg_set_db_info(&g_prog_info);
  p_evt_head = mul_epg_get_sch_event(&g_prog_info, &total_evt);

  if(p_evt_head != NULL)
  {
    MT_ASSERT(total_evt > 0);
    old_focus = list_get_focus_pos(p_event_list);
    list_set_count(p_event_list, (u16)total_evt, EPG_EVT_LIST_PAGE);
    switch(focus_state)
    {
      case FOCUS_FIRST:
        new_focus = 0;
        break;
      case FOCUS_PREV:
        new_focus = (old_focus < total_evt) ? old_focus : 0;
        break;
      default:  
        new_focus = 0;
        break;
    }
    if (new_focus != old_focus)
    {
      list_set_focus_pos(p_event_list, new_focus);
      list_select_item(p_event_list, new_focus);
    }
    epg_event_list_update(p_event_list, list_get_valid_pos(p_event_list), EPG_EVT_LIST_PAGE, 0);
  }
  else
  {
    list_set_count(p_event_list, 1, EPG_EVT_LIST_PAGE);
    list_set_focus_pos(p_event_list, 0);
    list_select_item(p_event_list, 0);

    list_set_field_content_by_icon(p_event_list, 0, 0, 0);

    if(CUSTOMER_ID == CUSTOMER_AISAT || CUSTOMER_ID == CUSTOMER_AISAT_DEMO)
    {
      gui_get_string(IDS_MSG_NO_INFORMATION, unistr, 64);
    }
    else
    {
      gui_get_string(IDS_RECEIVING_DATA, unistr, 64);
    }
    list_set_field_content_by_unistr(p_event_list, 0, 2, unistr);
    list_set_field_content_by_icon(p_event_list, 0, 3, 0);
  }

  if(is_paint)
  {
    ctrl_paint_ctrl(p_event_list, is_paint);
  }
}