Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Таймеры предназначены для планирования событий системы во времени.

Запросы для управления таймерами:

addtimer - добавить таймер. Дополнительные параметры:

  • k - идентификатор сессии пользователя;
  • id - идентификатор элемента, в случае если идентификатор отсутствует создается новый элемент типа 'timer', иначе модифицируется существующий;

  • name - имя таймера, не более 63 символов;
  • begin - время начала работы таймера (формат Unix Time Stamp), в режиме schedule не используется;
  • end - время окончания работы таймера (формат Unix Time Stamp), в режиме schedule не используется;
  • mode - режим работы таймера: "once" - однократный; "week" - каждую неделю; "monthly" - каждый месяц; "schedule" - почасовое расписание на каждый день недели;
  • days - в зависимости от режима:
    •  дни недели срабатывания таймера, битовое поле, в котором каждый бит отвечает за срабатывание в соответствующий день недели;
      0 (младший) - понедельник;
      1 - вторник;
      2 - среда;
      3 - четверг;
      4 - пятница;
      5 - суббота;
      6 - воскресенье;
      т.е., например, для срабатывания таймера в понедельник, среду и пятницу необходимо задать:
      days=(1<<0) | (1<<2) | (1<<4) = 0b00010101 = 0x15
    • дни месяца срабатывания таймера, битовое поле, в котором каждый бит отвечает за срабатывание в соответствующий день месяца;
      т.е., например, для срабатывания таймера 1, 3 и 5 числа каждого месяца необходимо задать:
      days=(1<<1) | (1<<3) | (1<<5) = 0b00101010 = 0x2a
    • в режиме schedule не используется;
  • daypattern - используется только в режиме schedule. Представляет из себя строку битовых полей в десятичном виде, с разделением через запятую. Каждое поле соответствует одному дню недели, от понедельника до воскресенья. Каждый бит кодирует соответствующий час в сутках (0-23): 0 - таймер неактивен, 1 - таймер активен.

deltimer - удалить таймер. Дополнительные параметры:

  • k - идентификатор сессии пользователя;
  • timer - идентификатор элемента.

getelement - чтение элемента. Обязательные параметры:

  • k - идентификатор сессии пользователя;
  • id - идентификатор элемента.

Ответ содержит информацию об элементе:

...

<element id="501001" module="2010" num="1" clas="devirt" type="timer" name="my_timer" 
state="alarm"
value="1453731709" begin="32400" end="61200" days="31" mode="weekly" daypattern="0,159632,456993,158,0,3365,77" />

Timers are designed to schedule system events in time.


Queries for managing timers:

addtimer - add a timer. Extra options are:

  • k

...

  • - user session ID;
  • id - the identifier of the element

...

  • ; if the identifier

...

  • is absent, a new element of the type 'timer' is created, otherwise the existing one is modified;
  • name - the name of the timer, not more than 63 characters;
  • begin - the timer start time (the Unix Time Stamp format), in schedule mode it is not used;
  • end - the timer expiration time (the Unix Time Stamp format), in schedule mode it is not used;
  • mode - timer mode: "once" - once; "week" - every week; "monthly" - every month; "schedule" - hourly schedule for each day of the week;
  • days - depending on the mode:
    •  the days of the week of the timer operation, a bit field in which each bit is responsible for triggering on the corresponding day of the week;
      0 (junior) - Monday;
      1 - Tuesday;
      2 - Wensday;
      3 - Thursday;
      4 - Friday;
      5 - Saturday;
      6 - Sunday;
      ie, for example, to tigger the timer on Monday, Wednesday and Friday you must specify:
      days=(1<<0) | (1<<2) | (1<<4) = 0b00010101 = 0x15
    • days of the month of the timer operation, a bit field in which each bit is responsible for triggering on the corresponding day of the month;
      ie, for example, to activate the timer 1, 3 and 5 of each month, you must specify:
      days=(1<<1) | (1<<3) | (1<<5) = 0b00101010 = 0x2a
    • in schedule mode it is not used;
  • daypattern - used only in schedule mode. It is a string of bit fields in decimal form, separated by commas. Each field corresponds to one day of the week, from Monday to Sunday. Each bit encodes the corresponding hour in days (0-23): 0 - the timer is inactive, 1 - the timer is active.


deltimer - delete the timer. Extra options are:

  • k

...

  • -user session ID;
  • timer - the identifier of the element.


getelement - read the element. Required parameters are:

  • k

...

  • - user session ID;
  • id

...

  • - element ID.

The

...

response contains information about the element:

<element id="501001" module="2010" num="1" clas="devirt" type="timer" name="my_timer" 
state="alarm"
value="1453731709" begin="32400" end="61200" days="31" mode="weekly" daypattern="0,159632,456993,158,0,3365,77" />