⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logic.h

📁 SECS I, SECS II协议通讯源码
💻 H
字号:
/*
 * logic types
 */
#ifndef LOGIC_H
#define LOGIC_H

// Basic types
#include "utype.h"

/* Number of processes supported & stack size*/
#define MaxPauses 40
#ifdef ISBC
#define STACKSIZE 8192
#else
#define STACKSIZE 8192
#endif

/* Bell constants */
#define BELL_FREQ 5000
#define BELL_ONTIME 200
#define BELL_OFFTIME 100

/* Number of timers supported */
#define MaxTimers 100

/* Number of days in a leap year */
#define DAYSPERYEAR 366

/* Number of autostart cycles supported */
#define MaxAutoCycles 10
/* Number of items that can be in an autostart cycle */
#define MaxItemsPerAutoCycle 100

/* Max preset files allowed */
#define MaxSavedPresetFiles 40

/* Save buffer */
#define SAVE_BUFFER_SIZE 256

// Pause after these many lines are read/written from the save name file
#define SAVE_PAUSE 5

// Flags for autostart cycling, year array
#define AU_MAXCYCLES 0xe0
#define AU_CONTCYCLE  AU_MAXCYCLES
#define AU_STOPCYCLE (AU_CONTCYCLE + 1)
// Waiting for a new day
#define AU_NOCYCLE -1

/* Alarm buzzer states */
#define BS_EXIST_ENABLE 1
#define BS_UNACK_ENABLE 2
#define BS_EXIST_PULSE 4
#define BS_UNACK_PULSE 8
#define BS_EXIST_CYCLE 16
#define BS_UNACK_CYCLE 32
#define BS_CHANGE_TIMES 64
#define BS_EXIST_TIMING (BS_EXIST_PULSE | BS_EXIST_CYCLE)
#define BS_UNACK_TIMING (BS_UNACK_PULSE | BS_UNACK_CYCLE)
#define BUZZER_DEFAULT 0
#define BUZZER_TIME 5000

/* Alarm buzzer commands */
#define BC_NEWUNACK 1
#define BC_EXIST 2
#define BC_OFF 3
#define BC_ACKNOWLEDGE 4

/* Reset codes */
#define RT_NONE 0
#define RT_REBOOT 64
#define RT_FACTORY_PRESETS 66
#define RT_FACTORY_PASSWORD 68
#define RT_KILL_SAVED_PRESETS 70
#define RT_SAVE_DEFAULT_PRESET 72
#define RT_RESTORE_DEFAULT_PRESET 74
#define RT_KILL_PASSLVL 76
#define RT_MAINMENU 78
#define RT_ALARMACK 80
#define RT_REPAINT 82
#define RT_MINREPAINT 1

// Timer flags
#define TS_INUSE      0x4000
#define TS_ENABLED     0x2000
#define TS_ON         0x1000
#define TS_ROLLEDOVER 0x0800
#define TM_MASK   0x00ff
#define TM_PULSE 0
#define TM_CYCLE 1
#define TIMER_DEFAULT 10000
#define TIMER_ONESCAN MaxTimers

// Autostart cycle defs
// These bit defs are assumed to be allocated appropriately by the compiler
// For purposes of SECS-2 transmission
typedef struct {
      uint todo : 12 ;  /* What to happen */
      uint min : 6 ;    /* Minute to happen at */
      uint hr : 5 ;     /* Hour to happen at */
      uint day : 9 ;    /* Relative day to happen at */
} ACYCLE ;

// Save preset defs
typedef struct {
    void *value;     // Pointer to value
    int type;         // Value's type
} ASAVE ;

// When type of above is UN_ARRAY it points to this structure
typedef struct {
    void *value;    // Pointer to value
    int count;      // Length of array
} ASAVE_ARRAY;

// Customization structure
typedef struct {
  PTEXT text;
  FUNC routine;
} CUSTOM;

// IO point customization
typedef struct {
  void *draw;     // Draw data from here
  void *put;      // Put data here
  FUNC routine;   // Translation routine
} IOCUSTOM;

// TIMER array
typedef struct {
    uint state;      // Current states
    uint endtime;    // End of interval, ticks
    uint onPeriod;   // On period, ticks
    uint offPeriod;  // Off period, ticks
    uint cycles;     // cycles to run
    FUNC onChange;  // Call this when turning on
    FUNC offChange; // Call this when turning off
    FUNCDATA changedata; // Data passed to the routine on change
} TIMER;

#endif /* LOGIC_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -