~iheino+ub/+junk/nut-upsconf-docfix

« back to all changes in this revision

Viewing changes to drivers/nutdrv_qx_zinto.c

  • Committer: Tuomas Heino
  • Author(s): Laurent Bigonville
  • Date: 2014-04-22 20:46:12 UTC
  • Revision ID: iheino+ub@cc.hut.fi-20140422204612-1x2gh3nkezfsdao4
Tags: upstream-2.7.2
ImportĀ upstreamĀ versionĀ 2.7.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* nutdrv_qx_zinto.c - Subdriver for Zinto protocol based UPSes
 
2
 *
 
3
 * Copyright (C)
 
4
 *   2013 Daniele Pezzini <hyouko@gmail.com>
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
19
 *
 
20
 */
 
21
 
 
22
#include "main.h"
 
23
#include "nutdrv_qx.h"
 
24
#include "nutdrv_qx_blazer-common.h"
 
25
 
 
26
#include "nutdrv_qx_zinto.h"
 
27
 
 
28
#define ZINTO_VERSION "Zinto 0.01"
 
29
 
 
30
/* qx2nut lookup table */
 
31
static item_t   zinto_qx2nut[] = {
 
32
 
 
33
        /*
 
34
         * > [Q1\r]
 
35
         * < [(226.0 195.0 226.0 014 49.0 27.5 30.0 00001000\r]
 
36
         *    01234567890123456789012345678901234567890123456
 
37
         *    0         1         2         3         4
 
38
         */
 
39
 
 
40
        { "input.voltage",              0,      NULL,   "Q1\r", "",     47,     '(',    "",     1,      5,      "%.1f", 0,      NULL },
 
41
        { "input.voltage.fault",        0,      NULL,   "Q1\r", "",     47,     '(',    "",     7,      11,     "%.1f", 0,      NULL },
 
42
        { "output.voltage",             0,      NULL,   "Q1\r", "",     47,     '(',    "",     13,     17,     "%.1f", 0,      NULL },
 
43
        { "ups.load",                   0,      NULL,   "Q1\r", "",     47,     '(',    "",     19,     21,     "%.0f", 0,      NULL },
 
44
        { "input.frequency",            0,      NULL,   "Q1\r", "",     47,     '(',    "",     23,     26,     "%.1f", 0,      NULL },
 
45
        { "battery.voltage",            0,      NULL,   "Q1\r", "",     47,     '(',    "",     28,     31,     "%.2f", 0,      NULL },
 
46
        { "ups.temperature",            0,      NULL,   "Q1\r", "",     47,     '(',    "",     33,     36,     "%.1f", 0,      NULL },
 
47
        /* Status bits */
 
48
        { "ups.status",                 0,      NULL,   "Q1\r", "",     47,     '(',    "",     38,     38,     NULL,   QX_FLAG_QUICK_POLL,     blazer_process_status_bits },   /* Utility Fail (Immediate) */
 
49
        { "ups.status",                 0,      NULL,   "Q1\r", "",     47,     '(',    "",     39,     39,     NULL,   QX_FLAG_QUICK_POLL,     blazer_process_status_bits },   /* Battery Low */
 
50
        { "ups.status",                 0,      NULL,   "Q1\r", "",     47,     '(',    "",     40,     40,     NULL,   QX_FLAG_QUICK_POLL,     blazer_process_status_bits },   /* Bypass/Boost or Buck Active */
 
51
        { "ups.alarm",                  0,      NULL,   "Q1\r", "",     47,     '(',    "",     41,     41,     NULL,   0,                      blazer_process_status_bits },   /* UPS Failed */
 
52
        { "ups.type",                   0,      NULL,   "Q1\r", "",     47,     '(',    "",     42,     42,     "%s",   QX_FLAG_STATIC,         blazer_process_status_bits },   /* UPS Type */
 
53
        { "ups.status",                 0,      NULL,   "Q1\r", "",     47,     '(',    "",     43,     43,     NULL,   QX_FLAG_QUICK_POLL,     blazer_process_status_bits },   /* Test in Progress */
 
54
        { "ups.alarm",                  0,      NULL,   "Q1\r", "",     47,     '(',    "",     44,     44,     NULL,   0,                      blazer_process_status_bits },   /* Shutdown Active */
 
55
        { "ups.status",                 0,      NULL,   "Q1\r", "",     47,     '(',    "",     44,     44,     NULL,   QX_FLAG_QUICK_POLL,     blazer_process_status_bits },   /* Shutdown Active */
 
56
        { "ups.beeper.status",          0,      NULL,   "Q1\r", "",     47,     '(',    "",     45,     45,     "%s",   0,                      blazer_process_status_bits },   /* Beeper status */
 
57
 
 
58
        /*
 
59
         * > [F\r]
 
60
         * < [#220.0 000 024.0 50.0\r]
 
61
         *    0123456789012345678901
 
62
         *    0         1         2
 
63
         */
 
64
 
 
65
        { "input.voltage.nominal",      0,      NULL,   "F\r",  "",     22,     '#',    "",     1,      5,      "%.0f", QX_FLAG_STATIC, NULL },
 
66
        { "input.current.nominal",      0,      NULL,   "F\r",  "",     22,     '#',    "",     7,      9,      "%.1f", QX_FLAG_STATIC, NULL },
 
67
        { "battery.voltage.nominal",    0,      NULL,   "F\r",  "",     22,     '#',    "",     11,     15,     "%.1f", QX_FLAG_STATIC, NULL },
 
68
        { "input.frequency.nominal",    0,      NULL,   "F\r",  "",     22,     '#',    "",     17,     20,     "%.0f", QX_FLAG_STATIC, NULL },
 
69
 
 
70
        /*
 
71
         * > [FW?\r]
 
72
         * < [#-------------   ------     VT12046Q  \r]
 
73
         *    012345678901234567890123456789012345678
 
74
         *    0         1         2         3
 
75
         */
 
76
 
 
77
        { "device.mfr",                 0,      NULL,   "FW?\r",        "",     39,     '#',    "",     1,      15,     "%s",   QX_FLAG_STATIC | QX_FLAG_TRIM,  NULL },
 
78
        { "device.model",               0,      NULL,   "FW?\r",        "",     39,     '#',    "",     17,     26,     "%s",   QX_FLAG_STATIC | QX_FLAG_TRIM,  NULL },
 
79
        { "ups.firmware",               0,      NULL,   "FW?\r",        "",     39,     '#',    "",     28,     37,     "%s",   QX_FLAG_STATIC | QX_FLAG_TRIM,  NULL },
 
80
 
 
81
        /* Instant commands */
 
82
        { "beeper.toggle",              0,      NULL,   "Q\r",          "",     0,      0,      "",     0,      0,      NULL,   QX_FLAG_CMD,    NULL },
 
83
        { "load.off",                   0,      NULL,   "S00R0000\r",   "",     0,      0,      "",     0,      0,      NULL,   QX_FLAG_CMD,    NULL },
 
84
        { "load.on",                    0,      NULL,   "C\r",          "",     0,      0,      "",     0,      0,      NULL,   QX_FLAG_CMD,    NULL },
 
85
        { "shutdown.return",            0,      NULL,   "S%s\r",        "",     0,      0,      "",     0,      0,      NULL,   QX_FLAG_CMD,    blazer_process_command },
 
86
        { "shutdown.stayoff",           0,      NULL,   "S%sR0000\r",   "",     0,      0,      "",     0,      0,      NULL,   QX_FLAG_CMD,    blazer_process_command },
 
87
        { "shutdown.stop",              0,      NULL,   "C\r",          "",     0,      0,      "",     0,      0,      NULL,   QX_FLAG_CMD,    NULL },
 
88
        { "test.battery.start",         0,      NULL,   "T%02d\r",      "",     0,      0,      "",     0,      0,      NULL,   QX_FLAG_CMD,    blazer_process_command },
 
89
        { "test.battery.start.deep",    0,      NULL,   "TL\r",         "",     0,      0,      "",     0,      0,      NULL,   QX_FLAG_CMD,    NULL },
 
90
        { "test.battery.start.quick",   0,      NULL,   "T\r",          "",     0,      0,      "",     0,      0,      NULL,   QX_FLAG_CMD,    NULL },
 
91
        { "test.battery.stop",          0,      NULL,   "CT\r",         "",     0,      0,      "",     0,      0,      NULL,   QX_FLAG_CMD,    NULL },
 
92
 
 
93
        /* Server-side settable vars */
 
94
        { "ups.delay.start",            ST_FLAG_RW,     blazer_r_ondelay,       NULL,   "",     0,      0,      "",     0,      0,      DEFAULT_ONDELAY,        QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE,        blazer_process_setvar },
 
95
        { "ups.delay.shutdown",         ST_FLAG_RW,     blazer_r_offdelay,      NULL,   "",     0,      0,      "",     0,      0,      DEFAULT_OFFDELAY,       QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE,        blazer_process_setvar },
 
96
 
 
97
        /* End of structure. */
 
98
        { NULL,                         0,      NULL,   NULL,           "",     0,      0,      "",     0,      0,      NULL,   0,      NULL }
 
99
};
 
100
 
 
101
/* Testing table */
 
102
#ifdef TESTING
 
103
static testing_t        zinto_testing[] = {
 
104
        { "Q1\r",       "(215.0 195.0 230.0 014 49.0 22.7 30.0 00000000\r" },
 
105
        { "F\r",        "#230.0 000 024.0 50.0\r" },
 
106
        { "FW?\r",      "#NOT_A_LIVE_UPS  TESTING    TESTING   \r" },
 
107
        { "Q\r",        "" },
 
108
        { "S03\r",      "" },
 
109
        { "C\r",        "" },
 
110
        { "S02R0005\r", "" },
 
111
        { "S.5R0000\r", "" },
 
112
        { "T04\r",      "" },
 
113
        { "TL\r",       "" },
 
114
        { "T\r",        "" },
 
115
        { "CT\r",       "" },
 
116
        { NULL }
 
117
};
 
118
#endif  /* TESTING */
 
119
 
 
120
/* Subdriver-specific initups */
 
121
static void     zinto_initups(void)
 
122
{
 
123
 
 
124
        blazer_initups(zinto_qx2nut);
 
125
 
 
126
}
 
127
 
 
128
/* Subdriver interface */
 
129
subdriver_t     zinto_subdriver = {
 
130
        ZINTO_VERSION,
 
131
        blazer_claim,
 
132
        zinto_qx2nut,
 
133
        zinto_initups,
 
134
        NULL,
 
135
        blazer_makevartable,
 
136
        "ACK",
 
137
        NULL,
 
138
#ifdef TESTING
 
139
        zinto_testing,
 
140
#endif  /* TESTING */
 
141
};