Initial commit.
This commit is contained in:
commit
a998ec05ee
30
.eslintrc.json
Normal file
30
.eslintrc.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"root": true,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"env": {
|
||||
"es6": true,
|
||||
"node": true,
|
||||
"mocha": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"no-console": "off",
|
||||
"linebreak-style": "off",
|
||||
"quotes": [
|
||||
"error",
|
||||
"double",
|
||||
{ "allowTemplateLiterals": true }
|
||||
],
|
||||
"keyword-spacing": ["error", { "before": true }],
|
||||
"space-before-blocks": ["error"]
|
||||
}
|
||||
}
|
15
.gitignore
vendored
Normal file
15
.gitignore
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
.nyc_output/
|
||||
lib/
|
||||
dist/
|
||||
node_modules/
|
||||
|
||||
# Testing and coverage reports
|
||||
coverage/
|
||||
mochawesome-report/
|
||||
|
||||
|
||||
#Exclude tsc generated files
|
||||
js/*.map
|
||||
js/ts.js
|
3
.mocharc.json
Normal file
3
.mocharc.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"spec": "./tests"
|
||||
}
|
16
.nycrc.json
Normal file
16
.nycrc.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"extends": "@istanbuljs/nyc-config-typescript",
|
||||
"check-coverage": true,
|
||||
"include": [
|
||||
"**/src/*.ts"
|
||||
],
|
||||
"reporter": [
|
||||
"lcov",
|
||||
"cobertura",
|
||||
"text-summary"
|
||||
],
|
||||
"statements": 90,
|
||||
"branches": 90,
|
||||
"functions": 90,
|
||||
"lines": 90
|
||||
}
|
5
.prettierrc
Normal file
5
.prettierrc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"printWidth": 80
|
||||
}
|
674
LICENSE.txt
Normal file
674
LICENSE.txt
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
361
README.md
Normal file
361
README.md
Normal file
@ -0,0 +1,361 @@
|
||||
# Introduction
|
||||
|
||||
This folder has the dpt library written in TS.
|
||||
Original code is in the knx.js library, but it's not exposed.
|
||||
|
||||
From [here](https://www.promotic.eu/en/pmdoc/Subsystems/Comm/PmDrivers/KNXDTypes.htm):
|
||||
|
||||
| Identifier | Name | Size | PROMOTIC data type | Interpretation range | Note |
|
||||
| ---------- | ---------------------------------------- | ------- | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
|
||||
| 1.001 | DPT_Switch | 1 bit | Boolean | 0 = off, 1 = on | |
|
||||
| 1.002 | DPT_Bool | 1 bit | Boolean | 0 = false, 1 = true | |
|
||||
| 1.003 | DPT_Enable | 1 bit | Boolean | 0 = disable, 1 = enable | |
|
||||
| 1.004 | DPT_Ramp | 1 bit | Boolean | 0 = no ramp, 1 = ramp | |
|
||||
| 1.005 | DPT_Alarm | 1 bit | Boolean | 0 = no alarm, 1 = alarm | |
|
||||
| 1.006 | DPT_BinaryValue | 1 bit | Boolean | 0 = low, 1 = high | |
|
||||
| 1.007 | DPT_Step | 1 bit | Boolean | 0 = decrease, 1 = increase | |
|
||||
| 1.008 | DPT_UpDown | 1 bit | Boolean | 0 = up, 1 = down | |
|
||||
| 1.009 | DPT_OpenClose | 1 bit | Boolean | 0 = open, 1 = close | |
|
||||
| 1.010 | DPT_Start | 1 bit | Boolean | 0 = stop, 1 = start | |
|
||||
| 1.011 | DPT_State | 1 bit | Boolean | 0 = inactive, 1 = active | |
|
||||
| 1.012 | DPT_Invert | 1 bit | Boolean | 0 = not inverted, 1 = inverted | |
|
||||
| 1.013 | DPT_DimSendStyle | 1 bit | Boolean | 0 = start-stop, 1 = cyclically | |
|
||||
| 1.014 | DPT_InputSource | 1 bit | Boolean | 0 = fixed, 1 = calculated | |
|
||||
| 1.015 | DPT_Reset | 1 bit | Boolean | 0 = dummy, 1 = trigger | |
|
||||
| 1.016 | DPT_Ack | 1 bit | Boolean | 0 = dummy, 1 = trigger | |
|
||||
| 1.017 | DPT_Trigger | 1 bit | Boolean | 0,1 = trigger | |
|
||||
| 1.018 | DPT_Occupancy | 1 bit | Boolean | 0 = not occupied, 1 = occupied | |
|
||||
| 1.019 | DPT\_Window\_Door | 1 bit | Boolean | 0 = closed, 1 = open | |
|
||||
| 1.021 | DPT_LogicalFunction | 1 bit | Boolean | 0 = OR, 1 = AND | |
|
||||
| 1.022 | DPT\_Scene\_AB | 1 bit | Boolean | 0 = sceneA, 1 = sceneB | |
|
||||
| 1.023 | DPT\_ShutterBlinds\_Mode | 1 bit | Boolean | 0 = UpDown only, 1 = UpDown + StepStop | |
|
||||
| 1.100 | DPT_Heat/Cool | 1 bit | Boolean | 0 = cooling, 1 = heating | |
|
||||
| 2.001 | DPT\_Switch\_Control | 2 bits | Long | C₁V₁<br><br>C = {0 (no control), 1 (control)}; V = {0,1} according to type 1.XXX | |
|
||||
| 2.002 | DPT\_Bool\_Control | 2 bits | Long | C₁V₁<br><br>C = {0 (no control), 1 (control)}; V = {0,1} according to type 1.XXX | |
|
||||
| 2.003 | DPT\_Enable\_Control | 2 bits | Long | C₁V₁<br><br>C = {0 (no control), 1 (control)}; V = {0,1} according to type 1.XXX | |
|
||||
| 2.004 | DPT\_Ramp\_Control | 2 bits | Long | C₁V₁<br><br>C = {0 (no control), 1 (control)}; V = {0,1} according to type 1.XXX | |
|
||||
| 2.005 | DPT\_Alarm\_Control | 2 bits | Long | C₁V₁<br><br>C = {0 (no control), 1 (control)}; V = {0,1} according to type 1.XXX | |
|
||||
| 2.006 | DPT\_BinaryValue\_Control | 2 bits | Long | C₁V₁<br><br>C = {0 (no control), 1 (control)}; V = {0,1} according to type 1.XXX | |
|
||||
| 2.007 | DPT\_Step\_Control | 2 bits | Long | C₁V₁<br><br>C = {0 (no control), 1 (control)}; V = {0,1} according to type 1.XXX | |
|
||||
| 2.008 | DPT\_Direction1\_Control | 2 bits | Long | C₁V₁<br><br>C = {0 (no control), 1 (control)}; V = {0,1} according to type 1.XXX | |
|
||||
| 2.009 | DPT\_Direction2\_Control | 2 bits | Long | C₁V₁<br><br>C = {0 (no control), 1 (control)}; V = {0,1} according to type 1.XXX | |
|
||||
| 2.010 | DPT\_Start\_Control | 2 bits | Long | C₁V₁<br><br>C = {0 (no control), 1 (control)}; V = {0,1} according to type 1.XXX | |
|
||||
| 2.011 | DPT\_State\_Control | 2 bits | Long | C₁V₁<br><br>C = {0 (no control), 1 (control)}; V = {0,1} according to type 1.XXX | |
|
||||
| 2.012 | DPT\_Invert\_Control | 2 bits | Long | C₁V₁<br><br>C = {0 (no control), 1 (control)}; V = {0,1} according to type 1.XXX | |
|
||||
| 3.007 | DPT\_Control\_Dimming | 4 bits | Long | C₁S₃<br><br>C = {0 (decrease), 1 (increase)}; S = \[000..111\] | |
|
||||
| 3.008 | DPT\_Control\_Blinds | 4 bits | Long | C₁S₃<br><br>C = {0 (up), 1 (down)}; S = \[000..111\] | |
|
||||
| 4.001 | DPT\_Char\_ASCII | 1 byte | Long | ASCII character | |
|
||||
| 4.002 | DPT\_Char\_8859_1 | 1 byte | Long | ISO_8859 character | |
|
||||
| 5.001 | DPT_Scaling | 1 byte | Long | \[0 … 100\]% | |
|
||||
| 5.003 | DPT_Angle | 1 byte | Long | \[0 … 360\]° | |
|
||||
| 5.004 | DPT\_Percent\_U8 | 1 byte | Long | \[0 … 255\]% | |
|
||||
| 5.005 | DPT_DecimalFactor | 1 byte | Long | | |
|
||||
| 5.006 | DPT_Tariff | 1 byte | Long | \[0 … 254\] | |
|
||||
| 5.010 | DPT\_Value\_1_Ucount | 1 byte | Long | \[0 … 255\] | |
|
||||
| 6.001 | DPT\_Percent\_V8 | 1 byte | Long | \[-128 … 127\]% | |
|
||||
| 6.010 | DPT\_Value\_1_Count | 1 byte | Long | \[-128 … 127\] | |
|
||||
| 6.020 | DPT\_Status\_Mode3 | 1 byte | Long | A₁B₁C₁D₁E₁F₃<br><br>A,B,C,D,E = {0 (set), 1 (clear)}; F = {001 (mode 0), 010 (mode 1), 100 (mode 2)} | |
|
||||
| 7.001 | DPT\_Value\_2_Ucount | 2 bytes | Long | \[0 … 65535\] pulses | |
|
||||
| 7.002 | DPT_TimePeriodMsec | 2 bytes | Long | \[0 … 65535\] ms | |
|
||||
| 7.003 | DPT_TimePeriod10Msec | 2 bytes | Long | \[0 … 6553,5\] s | k=0,1 |
|
||||
| 7.004 | DPT_TimePeriod100Msec | 2 bytes | Long | \[0 … 655,35\] s | k=0,01 |
|
||||
| 7.005 | DPT_TimePeriodSec | 2 bytes | Long | \[0 … 65535\] s | |
|
||||
| 7.006 | DPT_TimePeriodMin | 2 bytes | Long | \[0 … 65535\] min | |
|
||||
| 7.007 | DPT_TimePeriodHrs | 2 bytes | Long | \[0 … 65535\] h | |
|
||||
| 7.010 | DPT_PropDataType | 2 bytes | Long | \[0 … 65535\] | |
|
||||
| 7.011 | DPT\_Length\_mm | 2 bytes | Long | \[0 … 65535\] mm | |
|
||||
| 7.012 | DPT_UElCurrentmA | 2 bytes | Long | \[0 … 65535\] mA | |
|
||||
| 7.013 | DPT_Brightness | 2 bytes | Long | \[0..65535\] lux | |
|
||||
| 8.001 | DPT\_Value\_2_Count | 2 bytes | Long | \[-32 768 … 32 767\] | |
|
||||
| 8.002 | DPT_DeltaTimeMsec | 2 bytes | Long | \[-32 768 … 32 767\] ms | |
|
||||
| 8.003 | DPT_DeltaTime10Msec | 2 bytes | Long | \[-3276,8 … 3276,7\] s | k=0,1 |
|
||||
| 8.004 | DPT_DeltaTime100Msec | 2 bytes | Long | \[-327,68 … 327,67\] s | k=0,01 |
|
||||
| 8.005 | DPT_DeltaTimeSec | 2 bytes | Long | \[-32 768 … 32 767\] s | |
|
||||
| 8.006 | DPT_DeltaTimeMin | 2 bytes | Long | \[-32 768 … 32 767\] min | |
|
||||
| 8.007 | DPT_DeltaTimeHrs | 2 bytes | Long | \[-32 768 … 32 767\] h | |
|
||||
| 8.010 | DPT\_Percent\_V16 | 2 bytes | Long | \[-327,68 … 327,67\] % | k=0,01 |
|
||||
| 8.011 | DPT\_Rotation\_Angle | 2 bytes | Long | \[-32 768 … 32 767\] ° | |
|
||||
| 9.001 | DPT\_Value\_Temp | 2 bytes | Double | \[-273 … 670760\] °C | |
|
||||
| 9.002 | DPT\_Value\_Tempd | 2 bytes | Double | \[-670760 … 670760\] K | |
|
||||
| 9.003 | DPT\_Value\_Tempa | 2 bytes | Double | \[-670760 … 670760\] K/h | |
|
||||
| 9.004 | DPT\_Value\_Lux | 2 bytes | Double | \[0 … 670760\] Lux | |
|
||||
| 9.005 | DPT\_Value\_Wsp | 2 bytes | Double | \[0 … 670760\] m/s | |
|
||||
| 9.006 | DPT\_Value\_Pres | 2 bytes | Double | \[0 … 670760\] Pa | |
|
||||
| 9.007 | DPT\_Value\_Humidity | 2 bytes | Double | \[0 … 670760\] % | |
|
||||
| 9.008 | DPT\_Value\_AirQuality | 2 bytes | Double | \[0 … 670760\] ppm | |
|
||||
| 9.010 | DPT\_Value\_Time1 | 2 bytes | Double | \[-670760 … 670760\] s | |
|
||||
| 9.011 | DPT\_Value\_Time2 | 2 bytes | Double | \[-670760 … 670760\] ms | |
|
||||
| 9.020 | DPT\_Value\_Volt | 2 bytes | Double | \[-670760 … 670760\] mV | |
|
||||
| 9.021 | DPT\_Value\_Curr | 2 bytes | Double | \[-670760 … 670760\] mA | |
|
||||
| 9.022 | DPT_PowerDensity | 2 bytes | Double | \[-670760 … 670760\] W/m2 | |
|
||||
| 9.023 | DPT_KelvinPerPercent | 2 bytes | Double | \[-670760 … 670760\] K/% | |
|
||||
| 9.024 | DPT_Power | 2 bytes | Double | \[-670760 … 670760\] kW | |
|
||||
| 9.025 | DPT\_Value\_Volume_Flow | 2 bytes | Double | \[-670760 … 670760\] l/h | |
|
||||
| 9.026 | DPT\_Rain\_Amount | 2 bytes | Double | \[-670760 … 670760\] l/m2 | |
|
||||
| 9.027 | DPT\_Value\_Temp_F | 2 bytes | Double | \[-459,6 … 670760\] °F | |
|
||||
| 9.028 | DPT\_Value\_Wsp_kmh | 2 bytes | Double | \[0 … 670760\]km/h | |
|
||||
| 10.001 | DPT_TimeOfDay | 3 bytes | Long | D₃H₅R₁R₁M₆rrS₆<br><br>D = \[0 … 7\]; H = \[0 … 23\]; M = \[0 … 59\]; S = \[0 … 59\]; R = {0} | |
|
||||
| 11.001 | DPT_Date | 3 bytes | Long | R₁R₁R₁D₅R₁R₁R₁R₁M₄R₁Y₇<br><br>D = \[1 … 31\]; M = \[1 … 12\]; Y = \[0 … 99\]; R = {0} | |
|
||||
| 12.001 | DPT\_Value\_4_Ucount | 4 bytes | Long | \[0 … 4 294 967 295\] | |
|
||||
| 13.001 | DPT\_Value\_4_Count | 4 bytes | Long | \[-2 147 483 648 … 2 147 483 647\] | |
|
||||
| 13.002 | DPT\_FlowRate\_m3/h | 4 bytes | Long | \[-2 147 483 648 … 2 147 483 647\] | |
|
||||
| 13.010 | DPT_ActiveEnergy | 4 bytes | Long | \[-2 147 483 648 … 2 147 483 647\] Wh | |
|
||||
| 13.012 | DPT_ReactiveEnergy | 4 bytes | Long | \[-2 147 483 648 … 2 147 483 647\] VAh | |
|
||||
| 13.013 | DPT\_ActiveEnergy\_kWh | 4 bytes | Long | \[-2 147 483 648 … 2 147 483 647\] kWh | |
|
||||
| 13.014 | DPT\_ApparantEnergy\_kVAh | 4 bytes | Long | \[-2 147 483 648 … 2 147 483 647\] kVAh | |
|
||||
| 13.015 | DPT\_ReactiveEnergy\_kVARh | 4 bytes | Long | \[-2 147 483 648 … 2 147 483 647\] kVARh | |
|
||||
| 13.100 | DPT_LongDeltaTimeSec | 4 bytes | Long | \[-2 147 483 648 … 2 147 483 647\] s | |
|
||||
| 14.000 | DPT\_Value\_Acceleration | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.001 | DPT\_Value\_Acceleration_Angular | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.002 | DPT\_Value\_Activation_Energy | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.003 | DPT\_Value\_Activity | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.004 | DPT\_Value\_Mol | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.005 | DPT\_Value\_Amplitude | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.006 | DPT\_Value\_AngleRad | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.007 | DPT\_Value\_AngleDeg | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.008 | DPT\_Value\_Angular_Momentum | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.009 | DPT\_Value\_Angular_Velocity | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.010 | DPT\_Value\_Area | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.011 | DPT\_Value\_Capacitance | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.012 | DPT\_Value\_Charge_DensitySurface | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.013 | DPT\_Value\_Charge_DensityVolume | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.014 | DPT\_Value\_Compressibility | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.015 | DPT\_Value\_Conductance | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.016 | DPT\_Value\_Electrical_Conductivity | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.017 | DPT\_Value\_Density | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.018 | DPT\_Value\_Electric_Charge | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.019 | DPT\_Value\_Electric_Current | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.020 | DPT\_Value\_Electric_CurrentDensity | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.021 | DPT\_Value\_Electric_DipoleMoment | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.022 | DPT\_Value\_Electric_Displacement | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.023 | DPT\_Value\_Electric_FieldStrength | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.024 | DPT\_Value\_Electric_Flux | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.025 | DPT\_Value\_Electric_FluxDensity | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.026 | DPT\_Value\_Electric_Polarization | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.027 | DPT\_Value\_Electric_Potential | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.028 | DPT\_Value\_Electric_PotentialDifference | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.029 | DPT\_Value\_ElectromagneticMoment | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.030 | DPT\_Value\_Electromotive_Force | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.031 | DPT\_Value\_Energy | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.032 | DPT\_Value\_Force | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.033 | DPT\_Value\_Frequency | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.034 | DPT\_Value\_Angular_Frequency | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.035 | DPT\_Value\_Heat_Capacity | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.036 | DPT\_Value\_Heat_FlowRate | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.037 | DPT\_Value\_Heat_Quantity | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.038 | DPT\_Value\_Impedance | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.039 | DPT\_Value\_Length | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.040 | DPT\_Value\_Light_Quantity | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.041 | DPT\_Value\_Luminance | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.042 | DPT\_Value\_Luminous_Flux | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.043 | DPT\_Value\_Luminous_Intensity | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.044 | DPT\_Value\_Magnetic_FieldStrength | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.045 | DPT\_Value\_Magnetic_Flux | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.046 | DPT\_Value\_Magnetic_FluxDensity | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.047 | DPT\_Value\_Magnetic_Moment | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.048 | DPT\_Value\_Magnetic_Polarization | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.049 | DPT\_Value\_Magnetization | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.050 | DPT\_Value\_MagnetomotiveForce | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.051 | DPT\_Value\_Mass | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.052 | DPT\_Value\_MassFlux | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.053 | DPT\_Value\_Momentum | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.054 | DPT\_Value\_Phase_AngleRad | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.055 | DPT\_Value\_Phase_AngleDeg | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.056 | DPT\_Value\_Power | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.057 | DPT\_Value\_Power_Factor | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.058 | DPT\_Value\_Pressure | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.059 | DPT\_Value\_Reactance | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.060 | DPT\_Value\_Resistance | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.061 | DPT\_Value\_Resistivity | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.062 | DPT\_Value\_SelfInductance | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.063 | DPT\_Value\_SolidAngle | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.064 | DPT\_Value\_Sound_Intensity | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.065 | DPT\_Value\_Speed | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.066 | DPT\_Value\_Stress | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.067 | DPT\_Value\_Surface_Tension | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.068 | DPT\_Value\_Common_Temperature | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.069 | DPT\_Value\_Absolute_Temperature | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.070 | DPT\_Value\_TemperatureDifference | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.071 | DPT\_Value\_Thermal_Capacity | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.072 | DPT\_Value\_Thermal_Conductivity | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.073 | DPT\_Value\_ThermoelectricPower | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.074 | DPT\_Value\_Time | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.075 | DPT\_Value\_Torque | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.076 | DPT\_Value\_Volume | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.077 | DPT\_Value\_Volume_Flux | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.078 | DPT\_Value\_Weight | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 14.079 | DPT\_Value\_Work | 4 bytes | Double | Z₁E₈F₂₃<br><br>Z = {0,1}; E = \[0 … 255\]; F = \[0 … 8 388 607\] | |
|
||||
| 15.000 | DPT\_Access\_Data | 4 bytes | Long | U₄V₄W₄X₄Y₄Z₄E₁P₁D₁C₁N₄<br><br>U,V,W,X,Y,Z = \[0 … 9\]; E,P,D,C = {0,1}; N = \[0 … 15\] | |
|
||||
| 17.001 | DPT_SceneNumber | 1 byte | Long | R₁R₁U₆<br><br>R = {0}; U = \[0 … 63\] | |
|
||||
| 18.001 | DPT_SceneControl | 1 byte | Long | C₁R₁U₆<br><br>C = {0,1}; R = {0}; U = \[0 … 63\] | |
|
||||
| 19.001 | DPT_DateTime | 8 bytes | String | U₈R₁R₁R₁R₁M₄R₁R₁R₁D₅W₃H₅R₁R₁S₆R₁R₁S₆E₁F₁G₁I₁J₁K₁L₁N₁O₁R₁R₁R₁R₁R₁R₁R₁<br><br>U = \[0 … 255\]; M = \[1 … 12\]; D = \[1 … 31\]; W = \[0 … 7\]; H = \[0 … 24\]; S = \[0 … 59\]; R = {0}; E,F,G,I,J,K,L,N,O = {0,1} | |
|
||||
| 20.001 | DPT_SCLOMode | 1 byte | Long | \[0 … 3\] | |
|
||||
| 20.002 | DPT_BuildingMode | 1 byte | Long | \[0 … 2\] | |
|
||||
| 20.003 | DPT_OccMode | 1 byte | Long | \[0 … 2\] | |
|
||||
| 20.004 | DPT_Priority | 1 byte | Long | \[0 … 3\] | |
|
||||
| 20.005 | DPT_LightApplicationMode | 1 byte | Long | \[0 … 2\] | |
|
||||
| 20.006 | DPT_ApplicationArea | 1 byte | Long | {0,1,10,11,12,13,14} | |
|
||||
| 20.007 | DPT_AlarmClassType | 1 byte | Long | \[0 … 3\] | |
|
||||
| 20.008 | DPT_PSUMode | 1 byte | Long | \[0 … 2\] | |
|
||||
| 20.011 | DPT\_ErrorClass\_System | 1 byte | Long | \[0 … 18\] | |
|
||||
| 20.012 | DPT\_ErrorClass\_HVAC | 1 byte | Long | \[0 … 4\] | |
|
||||
| 20.013 | DPT\_Time\_Delay | 1 byte | Long | \[0 … 25\] | |
|
||||
| 20.014 | DPT\_Beaufort\_Wind\_Force\_Scale | 1 byte | Long | \[0 … 12\] | |
|
||||
| 20.017 | DPT_SensorSelect | 1 byte | Long | \[0 … 4\] | |
|
||||
| 20.020 | DPT_ActuatorConnectType | 1 byte | Long | \[1 … 2\] | |
|
||||
| 20.100 | DPT_FuelType | 1 byte | Long | \[0 … 3\] | |
|
||||
| 20.101 | DPT_BurnerType | 1 byte | Long | \[0 … 3\] | |
|
||||
| 20.102 | DPT_HVACMode | 1 byte | Long | \[0 … 4\] | |
|
||||
| 20.103 | DPT_DHWMode | 1 byte | Long | \[0 … 4\] | |
|
||||
| 20.104 | DPT_LoadPriority | 1 byte | Long | \[0 … 2\] | |
|
||||
| 20.105 | DPT_HVACContrMode | 1 byte | Long | {\[0 … 17\],20} | |
|
||||
| 20.106 | DPT_HVACEmergMode | 1 byte | Long | \[0 … 5\] | |
|
||||
| 20.107 | DPT_ChangeoverMode | 1 byte | Long | \[0 … 2\] | |
|
||||
| 20.108 | DPT_ValveMode | 1 byte | Long | \[1 … 5\] | |
|
||||
| 20.109 | DPT_DamperMode | 1 byte | Long | \[1 … 4\] | |
|
||||
| 20.110 | DPT_HeaterMode | 1 byte | Long | \[1 … 3\] | |
|
||||
| 20.111 | DPT_FanMode | 1 byte | Long | \[0 … 2\] | |
|
||||
| 20.112 | DPT_MasterSlaveMode | 1 byte | Long | \[0 … 2\] | |
|
||||
| 20.113 | DPT_StatusRoomSetp | 1 byte | Long | \[0 … 2\] | |
|
||||
| 20.120 | DPT_ADAType | 1 byte | Long | \[1 … 2\] | |
|
||||
| 20.121 | DPT_BackupMode | 1 byte | Long | \[0 … 1\] | |
|
||||
| 20.122 | DPT_StartSynchronization | 1 byte | Long | \[0 … 2\] | |
|
||||
| 20.600 | DPT\_Behaviour\_Lock_Unlock | 1 byte | Long | \[0 … 6\] | |
|
||||
| 20.601 | DPT\_Behaviour\_Bus\_Power\_Up_Down | 1 byte | Long | \[0 … 4\] | |
|
||||
| 20.602 | DPT\_DALI\_Fade_Time | 1 byte | Long | \[0 … 15\] | |
|
||||
| 20.603 | DPT_BlinkingMode | 1 byte | Long | \[0 … 2\] | |
|
||||
| 20.604 | DPT_LightControlMode | 1 byte | Long | \[0 … 1\] | |
|
||||
| 20.605 | DPT_SwitchPBModel | 1 byte | Long | \[1 … 2\] | |
|
||||
| 20.606 | DPT_PBAction | 1 byte | Long | \[0 … 3\] | |
|
||||
| 20.607 | DPT_DimmPBModel | 1 byte | Long | \[1 … 4\] | |
|
||||
| 20.608 | DPT_SwitchOnMode | 1 byte | Long | \[0 … 2\] | |
|
||||
| 20.609 | DPT_LoadTypeSet | 1 byte | Long | \[0 … 2\] | |
|
||||
| 20.610 | DPT_LoadTypeDetected | 1 byte | Long | \[0 … 3\] | |
|
||||
| 20.801 | 1 DPT_SABExceptBehaviour | 1 byte | Long | \[0 … 4\] | |
|
||||
| 20.802 | DPT\_SABBehaviour\_Lock_Unlock | 1 byte | Long | \[0 … 6\] | |
|
||||
| 20.803 | DPT_SSSBMode | 1 byte | Long | \[1 … 4\] | |
|
||||
| 20.804 | DPT_BlindsControlMode | 1 byte | Long | \[0 … 1\] | |
|
||||
| 20.1000 | DPT_CommMode | 1 byte | Long | \[0 … 255\] | |
|
||||
| 20.1001 | DPT_AddInfoTypes | 1 byte | Long | {00h,01h,02h,03h,04h,05h,06h,07h,FFh} | |
|
||||
| 20.1002 | DPT\_RF\_ModeSelect | 1 byte | Long | {00h,01h,02h} | |
|
||||
| 20.1003 | DPT\_RF\_FilterSelect | 1 byte | Long | {00h,01h,02h,03h} | |
|
||||
| 21.001 | DPT_StatusGen | 1 byte | Long | B₃F₁E₁D₁C₁A₁<br><br>A,C,D,E,F = {0,1}; B = {000} | |
|
||||
| 21.002 | DPT\_Device\_Control | 1 byte | Long | B₃F₁E₁D₁C₁A₁<br><br>A,C,D,E,F = {0,1}; B = {000} | |
|
||||
| 21.100 | DPT_ForceSign | 1 byte | Long | H₁G₁F₁E₁D₁C₁B₁A₁<br><br>A,B,C,D,E,F,G,H = {0,1} | |
|
||||
| 21.101 | DPT_ForceSignCool | 1 byte | Long | B₁A₇<br><br>B = {0,1}; A = {0000000} | |
|
||||
| 21.102 | DPT_StatusRHC | 1 byte | Long | H₁G₁F₁E₁D₁C₁B₁A₁<br><br>A,B,C,D,E,F,G,H = {0,1} | |
|
||||
| 21.103 | DPT_StatusSDHWC | 1 byte | Long | D₅C₁B₁A₁<br><br>A,B,C = {0,1}; D = {00000} | |
|
||||
| 21.104 | DPT_FuelTypeSet | 1 byte | Long | D₅C₁B₁A₁<br><br>A,B,C = {0,1}; D = {0} | |
|
||||
| 21.105 | DPT_StatusRCC | 1 byte | Long | A₇B₁<br><br>B = {0,1}; A = {0000000} | |
|
||||
| 21.106 | DPT_StatusAHU | 1 byte | Long | E₄D₁C₁B₁A₁<br><br>A,B,C,D = {0,1}, E = {0000} | |
|
||||
| 21.601 | DPT_LightActuatorErrorInfo | 1 byte | Long | H₁G₁F₁E₁D₁C₁B₁A₁<br><br>A,B,C,D,E,F,G = {0,1}, h = {0} | |
|
||||
| 21.1000 | DPT\_RF\_ModeInfo | 1 byte | Long | D₅C₁B₁A₁<br><br>C,B,A = {0,1}, D = {00000} | |
|
||||
| 21.1001 | DPT\_RF\_FilterInfo | 1 byte | Long | D₅C₁B₁A₁<br><br>C,B,A = {0,1} | |
|
||||
| 21.1010 | DPT\_Channel\_Activation_8 | 1 byte | Long | H₁G₁F₁E₁D₁C₁B₁A₁<br><br>H,G,F,E,D,C,B,A = {0,1} | |
|
||||
| 22.100 | DPT_StatusDHWC | 2 bytes | Long | J₈HGFEDCBA<br><br>J = {00000000}; H,G,F,E,D,C,B,A = {0,1} | |
|
||||
| 22.101 | DPT_StatusRHCC | 2 bytes | Long | R₁O₁N₁M₁L₁K₁J₁I₁H₁G₁F₁E₁D₁C₁B₁A₁<br><br>R = {0}; O,N,M,L,K,J,I,H,G,F,E,D,C,B,A = {0,1} | |
|
||||
| 22.1000 | DPT_Media | 2 bytes | Long | E₁₀D₁C₁F₁B₁A₁F₁<br><br>E = {0000000000}; D,C,B,A, = {0,1}; F = {0} | |
|
||||
| 22.1010 | DPT\_Channel\_Activation_16 | 2 bytes | Long | P₁O₁N₁M₁L₁K₁J₁I₁H₁G₁F₁E₁D₁C₁B₁A₁<br><br>P,O,N,M,L,K,J,I,H,G,F,E,D,C,B,A = {0,1} | |
|
||||
| 23.001 | DPT_OnOffAction | 2 bits | Long | {00(off), 01(on), 10(off/on), 11(on/off)} | |
|
||||
| 23.002 | DPT\_Alarm\_Reaction | 2 bits | Long | {00 (no alarm is used), 01 (alarm position is UP), 10 (alarm position is DOWN)} | |
|
||||
| 23.003 | DPT\_UpDown\_Action | 2 bits | Long | {00 (Up), 01 (Down), 01 (UpDown), 11 (DownUp)} | |
|
||||
| 23.102 | DPT\_HVAC\_PB_Action | 2 bits | Long | {00 (Comfort/Economy), 01 (Comfort/Nothing), 10 (Economy/Nothing), 11 (Building prot/Auto)} | |
|
||||
| 25.1000 | DPT_DoubleNibble | 1 byte | Long | B₄N₄<br><br>B = \[0 … 3\], N = \[0 … 3\] | |
|
||||
| 26.001 | SceneInfo | 1 byte | Long | B₁A₂U₆<br><br>B = {0}; A = {0,1}; U = \[0 … 63\] | |
|
||||
| 27.001 | CombinedInfoOnOff | 4 bytes | Long | Σ₁Π₁Λ₁Θ₁Δ₁Γ₁Z₁Y₁X₁W₁V₁U₁T₁S₁R₁Q₁P₁O₁N₁M₁L₁K₁J₁I₁H₁G₁F₁E₁D₁C₁B₁A₁<br><br>Σ,Π,Λ,Θ,Δ,Γ,Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C,B,A = {0,1} | |
|
||||
| 29.010 | ActiveEnergy_V64 | 8 bytes | String | \[-9 223 372 036 854 775 808 … 9 223 372 036 854 775 807\] | |
|
||||
| 29.011 | ApparantEnergy_V64 | 8 bytes | String | \[-9 223 372 036 854 775 808 … 9 223 372 036 854 775 807\] | |
|
||||
| 29.012 | ReactiveEnergy_V64 | 8 bytes | String | \[-9 223 372 036 854 775 808 … 9 223 372 036 854 775 807\] | |
|
||||
| 30.1010 | Channel\_Activation\_24 | 3 bytes | Long | X₁W₁V₁U₁T₁S₁R₁Q₁P₁O₁N₁M₁L₁K₁J₁I₁H₁G₁F₁E₁D₁C₁B₁A₁<br><br>X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C,B,A = {0,1} | |
|
||||
| 31.101 | PB\_Action\_HVAC_Extended | 3 bits | Long | C₁B₁A₁<br><br>C,B,A = {0,1} | |
|
||||
| 200.100 | Heat/Cool_Z | 2 bytes | Long | M₇G₁F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E,G = {0,1}; F = {000}; M = {0000000} | |
|
||||
| 200.101 | BinaryValue_Z | 2 bytes | Long | M₇G₁F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E,G = {0,1}; F = {000}; M = {0000000} | |
|
||||
| 201.100 | HVACMode_Z | 2 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 4\] | |
|
||||
| 201.102 | DHWMode_Z | 2 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 4\] | |
|
||||
| 201.104 | HVACContrMode_Z | 2 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 20\] | |
|
||||
| 201.105 | EnableH/Cstage_Z | 2 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 3\] | |
|
||||
| 201.107 | BuildingMode_Z | 2 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 2\] | |
|
||||
| 201.108 | OccMode_Z | 2 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 2\] | |
|
||||
| 201.109 | HVACEmergMode_Z | 2 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 5\] | |
|
||||
| 202.001 | RelValue_Z | 2 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 255\] | |
|
||||
| 202.002 | UCountValue8_Z | 2 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 255\] | |
|
||||
| 203.002 | TimePeriodMsec_Z | 3 bytes | Long | N₁₆F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 65 535\]ms | |
|
||||
| 203.003 | TimePeriod10Msec_Z | 3 bytes | Long | N₁₆F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 65 535\]ms | k = 0,1 |
|
||||
| 203.004 | TimePeriod100Msec_Z | 3 bytes | Long | N₁₆F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 65 535\]ms | k = 0,01 |
|
||||
| 203.005 | TimePeriodSec_Z | 3 bytes | Long | N₁₆F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 65 535\]s | |
|
||||
| 203.006 | TimePeriodMin_Z | 3 bytes | Long | N₁₆F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 65 535\]min | |
|
||||
| 203.007 | TimePeriodHrs_Z | 3 bytes | Long | N₁₆F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 65 535\]h | |
|
||||
| 203.011 | UFlowRateLiter/h_Z | 3 bytes | Long | N₁₆F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 65 535\]l/h | k = 0,01 |
|
||||
| 203.012 | UCountValue16_Z | 3 bytes | Long | N₁₆F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 65 535\] | |
|
||||
| 203.013 | UElCurrentμA_Z | 3 bytes | Long | N₁₆F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 65 535\]μA | k = 0,01 |
|
||||
| 203.014 | PowerKW_Z | 3 bytes | Long | N₁₆F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 65 535\]kW | |
|
||||
| 203.015 | AtmPressureAbs_Z | 3 bytes | Long | N₁₆F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 1200\]kbar | k = 0,05 |
|
||||
| 203.017 | PercentU16_Z | 3 bytes | Long | N₁₆F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 65 535\]% | k = 0,01 |
|
||||
| 203.100 | HVACAirQual_Z | 3 bytes | Long | N₁₆F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 65 535\]ppm | |
|
||||
| 203.101 | WindSpeed_Z | 3 bytes | Long | N₁₆F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 200\]km/h | k = 0,01 |
|
||||
| 203.102 | SunIntensity_Z | 3 bytes | Long | N₁₆F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 1400\]W/m² | k = 0,05 |
|
||||
| 203.104 | HVACAirFlowAbs_Z | 3 bytes | Long | N₁₆F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[0 … 1400\]m³/h | |
|
||||
| 204.001 | RelSignedValue_Z | 2 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[-100 … 100\]% | |
|
||||
| 205.002 | DeltaTimeMsec_Z | 3 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[-32 768 … 32 767\]ms | |
|
||||
| 205.003 | DeltaTime10Msec_Z | 3 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[-32 768 … 32 767\]ms | k = 0,1 |
|
||||
| 205.004 | DeltaTime100Msec_Z | 3 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[-32 768 … 32 767\]ms | k = 0,01 |
|
||||
| 205.005 | DeltaTimeSec_Z | 3 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[-32 768 … 32 767\]s | |
|
||||
| 205.006 | DeltaTimeMin_Z | 3 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[-32 768 … 32 767\]min | |
|
||||
| 205.007 | DeltaTimeHrs_Z | 3 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[-32 768 … 32 767\]h | |
|
||||
| 205.017 | Percent\_V16\_Z | 3 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[-32 768 … 32 767\]% | k = 0,01 |
|
||||
| 205.100 | TempHVACAbs_Z | 3 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000}; N = \[-273 … 655,34\]°C | k = 0,02 |
|
||||
| 205.101 | TempHVACRel_Z | 3 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000};N = \[-273 … 655,34\]K | k = 0,02 |
|
||||
| 205.102 | HVACAirFlowRel_Z | 3 bytes | Long | N₈F₃E₁D₁C₁B₁A₁<br><br>A,B,C,D,E = {0,1}; F = {000};N = \[-32 768 … 32 767\]K | |
|
||||
| 206.100 | HVACModeNext | 3 bytes | Long | U₁₆N₈<br><br>U = \[0 … 65535\], N=\[0 … 4\] | |
|
||||
| 206.102 | DHWModeNext | 3 bytes | Long | U₁₆N₈<br><br>U = \[0 … 65535\]; N=\[0 … 4\] | |
|
||||
| 206.104 | OccModeNext | 3 bytes | Long | U₁₆N₈<br><br>U = \[0 … 65535\]; N=\[0 … 2\] | |
|
||||
| 206.105 | BuildingModeNext | 3 bytes | Long | U₁₆N₈<br><br>U = \[0 … 65535\]; N=\[0 … 2\] | |
|
||||
| 207.100 | StatusBUC | 2 bytes | Long | U₈G₂F₁E₁D₁C₁B₁A₁<br><br>U = \[0 … 100\]%; G = {00}; F,E,D,C,B,A = {0,1} | |
|
||||
| 207.101 | LockSign | 2 bytes | Long | U₈C₆B₁A₁<br><br>U = \[0 … 100\]%; c = {0}; b,a = {0,1} | |
|
||||
| 207.102 | ValueDemBOC | 2 bytes | Long | U₈C₆B₁A₁<br><br>U = \[0 … 100\]%; C = {000000}; B,A = {0,1} | |
|
||||
| 207.104 | ActPosDemAbs | 2 bytes | Long | U₈E₄D₁C₁B₁A₁<br><br>U = \[0 … 100\]%; E = {0000}; D,C,B,A = {0,1} | |
|
||||
| 207.105 | StatusAct | 2 bytes | Long | U₈;E₄D₁C₁B₁A₁<br><br>U = \[0 … 100\]%; E = {0000}; D,C,B,A = {0,1} | |
|
||||
| 207.600 | StatusLightingActuator | 2 bytes | Long | U₈H₁G₁F₁E₁D₁C₁B₁A₁<br><br>U = \[0 … 100\]%; H,G,F,E,D,C,B,A = {0,1} | |
|
||||
| 209.100 | StatusHPM | 3 bytes | Long | V₁₆F₃E₁D₁C₁B₁A₁<br><br>V=\[-273 … 655,34\]°C; F = {000}; E,D,C,B,A = {0,1} | k = 0,02 |
|
||||
| 209.101 | TempRoomDemAbs | 3 bytes | Long | V₁₆E₄D₁C₁B₁A₁<br><br>V=\[-273 … 655,34\]°C; E = {0000}; D,C,B,A = {0,1} | k = 0,02 |
|
||||
| 209.102 | StatusCPM | 3 bytes | Long | V₁₆E₄D₁C₁B₁A₁<br><br>V=\[-273..655,34\]°C; E = {0000}; D,C,B,A = {0,1} | k = 0,02 |
|
||||
| 209.103 | StatusWTC | 3 bytes | Long | V₁₆D₅C₁B₁A₁<br><br>V=\[-273 … 655,34\]°C; D = {00000}; C,B,A = {0,1} | k = 0,02 |
|
||||
| 210.100 | TempFlowWaterDemAbs | 4 bytes | Long | V₁₆M₄L₁K₁J₁I₁H₁G₁F₁E₁D₁C₁B₁A₁<br><br>V=\[-273 … 655,34\]°C; M = {0000}; L,K,J,I,H,G,F,E,D,C,B,A = {0,1} | k = 0,02 |
|
||||
| 211.100 | EnergyDemWater | 2 bytes | Long | U₈V₈<br><br>U = \[0 … 100\]; N = \[0 … 20\] | |
|
||||
| 212.100 | TempRoomSetpSetShift\[3\] | 6 bytes | String | A₁₆B₁₆C₁₆<br><br>A,B,C = \[-655,34 … 655,34\]K | k = 0,02 |
|
||||
| 212.101 | TempRoomSetpSet\[3\] | 6 bytes | String | A₁₆B₁₆C₁₆<br><br>A,B,C = \[-655,34 … 655,34\]°C | k = 0,02 |
|
||||
| 213.100 | TempRoomSetpSet\[4\] | 8 bytes | String | A₁₆B₁₆C₁₆D₁₆<br><br>A,B,C,D = \[-655,34 … 655,34\]°C | k = 0,02 |
|
||||
| 213.101 | TempDHWSetpSet\[4\] | 8 bytes | String | A₁₆B₁₆C₁₆D₁₆<br><br>A,B,C,D = \[-655,34 … 655,34\]°C | k = 0,02 |
|
||||
| 213.102 | TempRoomSetpSetShift\[4\] | 8 bytes | String | A₁₆B₁₆C₁₆D₁₆<br><br>A,B,C,D = \[-655,34 … 655,34\]K | k = 0,02 |
|
||||
| 214.100 | PowerFlowWaterDemHPM | 4 bytes | Long | V₁₆U₈G₂F₁E₁D₁C₁B₁A₁<br><br>V = \[-273 … 655,34\]°C; U = \[0 … 100\]%; H = {00}; F,E,D,C,B,A = {0,1} | k = 0,02 |
|
||||
| 214.101 | PowerFlowWaterDemCPM | 4 bytes | Long | V₁₆U₈H₅C₁B₁A₁<br><br>V = \[-273 … 655,34\]°C; U = \[0 … 100\]%; D = {00000}; C,B,A = {0,1} | k = 0,02 |
|
||||
| 215.100 | StatusBOC | 5 bytes | String | V₁₆U₈M₄L₁K₁J₁I₁H₁G₁F₁E₁D₁C₁B₁A₁<br><br>V = \[-273 … 655,34\]°C; U = \[0 … 100\]%; M = {0000}; L,K,J,I,H,G,F,E,D,C,B,A = {0,1} | k = 0,02 |
|
||||
| 215.101 | StatusCC | 5 bytes | String | V₁₆U₈J₈H₁G₁F₁E₁D₁C₁B₁A₁<br><br>V = \[-273 … 655,34\]°C; U = \[0 … 100\]%; J = {00000000}; H,G,F,E,D,C,B,A = {0,1} | |
|
||||
| 216.100 | SpecHeatProd | 5 bytes | String | V₁₆U₈N₈D₅C₁B₁A₁<br><br>V = \[0 … 65 535\]kW; U = \[0 … 100\]%; N = \[0..3\]; D = {00000}; C,B,A = {0,1} | |
|
||||
| 217.001 | Version | 2 bytes | Long | U₅V₅W₆<br><br>U = \[0 … 31\], V = \[0..31\], W = \[0 … 63\] | |
|
||||
| 218.001 | VolumeLiter_Z | 5 bytes | String | V₃₂F₃E₁D₁C₁B₁A₁<br><br>E,D,C,B,A = {0,1}; F = {000}; V = \[-2 147 483 648 l … 2 147 483 647\]l | |
|
||||
| 218.002 | FlowRate\_m3/h\_Z | 5 bytes | String | V₃₂F₃E₁D₁C₁B₁A₁<br><br>E,D,C,B,A = {0,1}; F = {000}; V = \[-2 147 483 648 l … 2 147 483 647\]m³/h | |
|
||||
| 219.001 | AlarmInfo | 6 bytes | String | U₈N₈V₈W₈P₂N₁M₁L₁K₁J₁I₁D₅C₁B₁A₁<br><br>U = \[0 … 255\]; N = \[0 … 3\]; V = \[0 … 50\]; W = \[0 … 6\]; P = {00}; D = {00000}; A,B,C,I,J,K,L,M,N = {0,1} | |
|
||||
| 220.100 | TempHVACAbsNext | 4 bytes | Long | U₁₆V₁₆<br><br>U = \[0 … 65535\]; V = \[-273 … 655,34\] | k = 0,02 |
|
||||
| 221.001 | SerNum | 6 bytes | String | N₁₆U₃₂<br><br>U = \[0 … 65535\]; V = \[0 … 4 294 967 295\] | |
|
||||
| 222.100 | TempRoomSetpSetF16\[3\] | 6 bytes | String | G₁₆F₁₆E₁₆<br><br>G,F,E = \[-273 … 670 760\]°C | |
|
||||
| 222.101 | TempRoomSetpSetShiftF16\[3\] | 6 bytes | String | G₁₆F₁₆E₁₆<br><br>G,F,E = \[-670 760 … 670 760\]K | |
|
||||
| 223.100 | EnergyDemAir | 3 bytes | Long | G₈F₈E₈<br><br>G = \[-100 … 100\]; F = \[0 … 20\]; E = \[0 … 5\] | |
|
||||
| 224.100 | TempSupplyAirSetpSet | 6 bytes | String | U₁₆V₁₆F₈E₈<br><br>U,V = \[-273 … 655,34\]; F = \[0 … 20\]; E = \[0 … 5\] | k = 0,02 |
|
||||
| 225.001 | ScalingSpeed | 3 bytes | Long | U₁₆V₈<br><br>U = \[1 … 65 535\]; V = \[0,4 … 100\] | k = 0,4 |
|
||||
| 225.002 | Scaling\_Step\_Time | 3 bytes | Long | U₁₆V₈<br><br>U = \[1 … 65 535\]; V = \[0,4 … 100\] | k = 0,4 |
|
||||
| 225.003 | TariffNext | 3 bytes | Long | U₁₆V₈<br><br>U = \[0 … 65 535\]; V = \[0 … 254\] | |
|
||||
| 229.001 | MeteringValue | 6 bytes | String | V₃₂N₈F₃E₁D₁C₁B₁A₁<br><br>E,D,C,B,A = {0,1}; f,g,h = {000}; V = \[-2 147 483 648 l … 2 147 483 647\]; N = \[0 … 177\]; | |
|
||||
| 230.1000 | MBus_Address | 8 bytes | String | U₁₆V₃₂W₈N₈<br><br>"MBus address", parameters U,V,W,N are manufacturer specific | |
|
||||
| 231.001 | Locale_ASCII | 4 bytes | Long | L₁₆R₁₆<br><br>L - language; R - region | |
|
||||
| 232.600 | Colour_RGB | 3 bytes | Long | R₈G₈B₈<br><br>R,G,B = \[0..255\] | |
|
||||
| 234.001 | LanguageCodeAlpha2 | 2 bytes | Long | A₁₆<br><br>A - language code | |
|
||||
| 234.002 | RegionCodeAlpha2 | 2 bytes | Long | A₁₆<br><br>A - region code | |
|
||||
| 235.001 | Tariff_ActiveEnergy | 6 bytes | String | V₃₂U₈C₆B₁A₁<br><br>V = \[-2 147 483 648 l … 2 147 483 647\]; U = \[0 … 254\]; C = {000000}; B,A = {0,1} | |
|
||||
| 236.001 | Prioritised\_Mode\_Control | 1 byte | Long | B₁P₃M₄<br><br>B = {0,1}; P = \[0 … 7\]; M = \[0 … 15\] | |
|
||||
| 237.600 | DALI\_Control\_Gear_Diagnostic | 2 bytes | Long | M₅L₁K₁J₁H₁G₁A₆<br><br>M = {00000}; L,K,J,H,G = {0,1}; A = \[0 … 63\] | |
|
||||
| 238.001 | SceneConfig | 1 byte | Long | A₁B₁N₆<br><br>A,B = {0,1}; N = \[0 … 63\] | |
|
||||
| 238.600 | DALI_Diagnostic | 1 byte | Long | A₁B₁N₆<br><br>A,B = {0,1}; N = \[0 … 63\] | |
|
||||
| 239.001 | FlaggedScaling | 2 bytes | Long | U₈B₇A₁<br><br>U = \[0 … 100\]; B = {0000000}; A = {0,1} | k = 0,4 |
|
||||
| 240.800 | CombinedPosition | 3 bytes | Long | U₁₆C₆B₁A₁<br><br>U = \[0 … 100\]; C = {000000}; B,A = {0,1} | k = 0,4 |
|
||||
| 241.800 | StatusSAB | 4 bytes | Long | U₈V₈N₁M₁L₃K₁J₁I₁H₁G₁F₁E₁D₁C₁B₁A₁<br><br>U,V = \[0 … 100\]; L = {000}; N,M,K,J,I,H,G,F,E,D,C,B,A = {0,1} | k = 0,4 |
|
2981
package-lock.json
generated
Normal file
2981
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
39
package.json
Normal file
39
package.json
Normal file
@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "dptlib",
|
||||
"version": "0.0.1",
|
||||
"description": "KNX DPT library",
|
||||
"main": "lib/index.js",
|
||||
"devDependencies": {
|
||||
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
||||
"@types/chai": "^4.3.0",
|
||||
"@types/mocha": "^9.1.0",
|
||||
"@types/node": "^17.0.14",
|
||||
"@typescript-eslint/eslint-plugin": "^5.10.2",
|
||||
"@typescript-eslint/parser": "^5.10.2",
|
||||
"chai": "^4.3.6",
|
||||
"eslint": "^8.8.0",
|
||||
"mocha": "^9.2.0",
|
||||
"mochawesome": "^7.1.2",
|
||||
"nyc": "^15.1.0",
|
||||
"prettier": "^2.5.1",
|
||||
"ts-mocha": "^9.0.2",
|
||||
"typescript": "^4.5.5"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"test": "ts-mocha --reporter mochawesome tests/**/*.test.ts",
|
||||
"coverage": "nyc npm test",
|
||||
"lint": "eslint --fix \"**/*.ts\""
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://git.home.lipc.tech/laur/dptlib.git"
|
||||
},
|
||||
"keywords": [
|
||||
"knx",
|
||||
"dpt",
|
||||
"typescript"
|
||||
],
|
||||
"author": "Laur Ivan",
|
||||
"license": "GPL-3.0-or-later"
|
||||
}
|
232
src/DPT1.ts
Normal file
232
src/DPT1.ts
Normal file
@ -0,0 +1,232 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
export class DPT1 implements DPT {
|
||||
id = '1';
|
||||
name = '1-bit value';
|
||||
bufferLength = 1;
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the on/off value
|
||||
*/
|
||||
decoder(buffer: Buffer): number {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT1. Expected ${this.bufferLength}.`);
|
||||
|
||||
const val = buffer.readUInt8(0);
|
||||
if (val !== 0 && val !== 1) {
|
||||
throw new InvalidValueError(`Invalid binary value ${val} for DPT1. Expected 1 or 0`);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: number): Buffer {
|
||||
if (value !== 0 && value !== 1) {
|
||||
throw new InvalidValueError(`Invalid value ${value} for a DPT1. Should be 0 or 1.`);
|
||||
}
|
||||
const buf = Buffer.alloc(this.bufferLength);
|
||||
buf.writeUInt8(value, 0);
|
||||
return buf;
|
||||
}
|
||||
|
||||
subtypes: {
|
||||
// 1.001 on/off
|
||||
'001': {
|
||||
use: 'G',
|
||||
name: 'DPT_Switch',
|
||||
desc: 'switch',
|
||||
enc: { 0: 'Off', 1: 'On' },
|
||||
},
|
||||
|
||||
// 1.002 boolean
|
||||
'002': {
|
||||
use: 'G',
|
||||
name: 'DPT_Bool',
|
||||
desc: 'bool',
|
||||
enc: { 0: 'false', 1: 'true' },
|
||||
},
|
||||
|
||||
// 1.003 enable
|
||||
'003': {
|
||||
use: 'G',
|
||||
name: 'DPT_Enable',
|
||||
desc: 'enable',
|
||||
enc: { 0: 'disable', 1: 'enable' },
|
||||
},
|
||||
|
||||
// 1.004 ramp
|
||||
'004': {
|
||||
use: 'FB',
|
||||
name: 'DPT_Ramp',
|
||||
desc: 'ramp',
|
||||
enc: { 0: 'No ramp', 1: 'Ramp' },
|
||||
},
|
||||
|
||||
// 1.005 alarm
|
||||
'005': {
|
||||
use: 'FB',
|
||||
name: 'DPT_Alarm',
|
||||
desc: 'alarm',
|
||||
enc: { 0: 'No alarm', 1: 'Alarm' },
|
||||
},
|
||||
|
||||
// 1.006 binary value
|
||||
'006': {
|
||||
use: 'FB',
|
||||
name: 'DPT_BinaryValue',
|
||||
desc: 'binary value',
|
||||
enc: { 0: 'Low', 1: 'High' },
|
||||
},
|
||||
|
||||
// 1.007 step
|
||||
'007': {
|
||||
use: 'FB',
|
||||
name: 'DPT_Step',
|
||||
desc: 'step',
|
||||
enc: { 0: 'Decrease', 1: 'Increase' },
|
||||
},
|
||||
|
||||
// 1.008 up/down
|
||||
'008': {
|
||||
use: 'G',
|
||||
name: 'DPT_UpDown',
|
||||
desc: 'up/down',
|
||||
enc: { 0: 'Up', 1: 'Down' },
|
||||
},
|
||||
|
||||
// 1.009 open/close
|
||||
'009': {
|
||||
use: 'G',
|
||||
name: 'DPT_OpenClose',
|
||||
desc: 'open/close',
|
||||
enc: { 0: 'Open', 1: 'Close' },
|
||||
},
|
||||
|
||||
// 1.010 start/stop
|
||||
'010': {
|
||||
use: 'G',
|
||||
name: 'DPT_Start',
|
||||
desc: 'start/stop',
|
||||
enc: { 0: 'Stop', 1: 'Start' },
|
||||
},
|
||||
|
||||
// 1.011 state
|
||||
'011': {
|
||||
use: 'FB',
|
||||
name: 'DPT_State',
|
||||
desc: 'state',
|
||||
enc: { 0: 'Inactive', 1: 'Active' },
|
||||
},
|
||||
|
||||
// 1.012 invert
|
||||
'012': {
|
||||
use: 'FB',
|
||||
name: 'DPT_Invert',
|
||||
desc: 'invert',
|
||||
enc: { 0: 'Not inverted', 1: 'inverted' },
|
||||
},
|
||||
|
||||
// 1.013 dim send style
|
||||
'013': {
|
||||
use: 'FB',
|
||||
name: 'DPT_DimSendStyle',
|
||||
desc: 'dim send style',
|
||||
enc: { 0: 'Start/stop', 1: 'Cyclically' },
|
||||
},
|
||||
|
||||
// 1.014 input source
|
||||
'014': {
|
||||
use: 'FB',
|
||||
name: 'DPT_InputSource',
|
||||
desc: 'input source',
|
||||
enc: { 0: 'Fixed', 1: 'Calculated' },
|
||||
},
|
||||
|
||||
// 1.015 reset
|
||||
'015': {
|
||||
use: 'G',
|
||||
name: 'DPT_Reset',
|
||||
desc: 'reset',
|
||||
enc: { 0: 'no action(dummy)', 1: 'reset command(trigger)' },
|
||||
},
|
||||
|
||||
// 1.016 acknowledge
|
||||
'016': {
|
||||
use: 'G',
|
||||
name: 'DPT_Ack',
|
||||
desc: 'ack',
|
||||
enc: { 0: 'no action(dummy)', 1: 'acknowledge command(trigger)' },
|
||||
},
|
||||
|
||||
// 1.017 trigger
|
||||
'017': {
|
||||
use: 'G',
|
||||
name: 'DPT_Trigger',
|
||||
desc: 'trigger',
|
||||
enc: { 0: 'trigger', 1: 'trigger' },
|
||||
},
|
||||
|
||||
// 1.018 occupied
|
||||
'018': {
|
||||
use: 'G',
|
||||
name: 'DPT_Occupancy',
|
||||
desc: 'occupancy',
|
||||
enc: { 0: 'not occupied', 1: 'occupied' },
|
||||
},
|
||||
|
||||
// 1.019 open window or door
|
||||
'019': {
|
||||
use: 'G',
|
||||
name: 'DPT_WindowDoor',
|
||||
desc: 'open window/door',
|
||||
enc: { 0: 'closed', 1: 'open' },
|
||||
},
|
||||
|
||||
// 1.021 and/or
|
||||
'021': {
|
||||
use: 'FB',
|
||||
name: 'DPT_LogicalFunction',
|
||||
desc: 'and/or',
|
||||
enc: { 0: 'logical function OR', 1: 'logical function AND' },
|
||||
},
|
||||
|
||||
// 1.022 scene A/B
|
||||
'022': {
|
||||
use: 'FB',
|
||||
name: 'DPT_Scene_AB',
|
||||
desc: 'scene A/B',
|
||||
enc: { 0: 'scene A', 1: 'scene B' },
|
||||
},
|
||||
|
||||
// 1.023 shutter/blinds mode
|
||||
'023': {
|
||||
use: 'FB',
|
||||
name: 'DPT_ShutterBlinds_Mode',
|
||||
desc: 'shutter/blinds mode',
|
||||
enc: {
|
||||
0: 'only move Up/Down mode (shutter)',
|
||||
1: 'move Up/Down + StepStop mode (blind)',
|
||||
},
|
||||
},
|
||||
|
||||
// 1.100 cooling/heating ---FIXME---
|
||||
100: {
|
||||
use: '???',
|
||||
name: 'DPT_Heat/Cool',
|
||||
desc: 'heat/cool',
|
||||
enc: { 0: '???', 1: '???' },
|
||||
},
|
||||
};
|
||||
|
||||
}
|
92
src/DPT10.ts
Normal file
92
src/DPT10.ts
Normal file
@ -0,0 +1,92 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
const timeRegexp = /(\d{1,2}):(\d{1,2}):(\d{1,2})/;
|
||||
|
||||
export class DPT10 implements DPT {
|
||||
id = '10';
|
||||
name = 'day of week + time of day';
|
||||
bufferLength = 3;
|
||||
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): Date {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT8. Expected ${this.bufferLength}.`);
|
||||
|
||||
const [dnh, minutes, seconds] = buffer;
|
||||
const dow = (dnh & 0b11100000) >> 5;
|
||||
const hours = dnh & 0b00011111;
|
||||
|
||||
if (hours < 0 || hours > 23)
|
||||
throw new InvalidValueError(`Hours out of range: Expected [0-23], got ${hours}`)
|
||||
if (minutes < 0 || minutes > 59)
|
||||
throw new InvalidValueError(`Minutes out of range: Expected [0-59], got ${minutes}`)
|
||||
if (seconds < 0 || seconds > 59)
|
||||
throw new InvalidValueError(`Seconds out of range: Expected [0-59], got ${seconds}`)
|
||||
|
||||
const d = new Date();
|
||||
if (d.getDay() !== dow)
|
||||
// adjust day of month to get the day of week right
|
||||
d.setDate(d.getDate() + dow - d.getDay());
|
||||
// TODO: Shouldn't this be UTCHours?
|
||||
d.setHours(hours, minutes, seconds);
|
||||
// reset the milliseconds
|
||||
d.setMilliseconds(0)
|
||||
return d;
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: Date | number | string): Buffer {
|
||||
if (value === undefined || value === null)
|
||||
throw new InvalidValueError(`Must supply a Date, number or String for DPT10 time.`);
|
||||
|
||||
let dow, hour, minute, second;
|
||||
// day of week. NOTE: JS Sunday = 0
|
||||
switch (typeof value) {
|
||||
case 'string':
|
||||
// try to parse
|
||||
let match = timeRegexp.exec(value);
|
||||
if (match) {
|
||||
dow = ((new Date().getDay() - 7) % 7) + 7;
|
||||
hour = parseInt(match[1]);
|
||||
minute = parseInt(match[2]);
|
||||
second = parseInt(match[3]);
|
||||
} else {
|
||||
throw new InvalidValueError(`DPT10: invalid time format (${value})`);
|
||||
}
|
||||
break;
|
||||
case 'number':
|
||||
value = new Date(value);
|
||||
default:
|
||||
dow = ((value.getDay() - 7) % 7) + 7;
|
||||
hour = value.getHours();
|
||||
minute = value.getMinutes();
|
||||
second = value.getSeconds();
|
||||
}
|
||||
|
||||
return Buffer.from([(dow << 5) + hour, minute, second]);
|
||||
}
|
||||
|
||||
|
||||
subtypes: {
|
||||
// 10.001 time of day
|
||||
'001': {
|
||||
name: 'DPT_TimeOfDay',
|
||||
desc: 'time of day',
|
||||
},
|
||||
};
|
||||
|
||||
}
|
77
src/DPT11.ts
Normal file
77
src/DPT11.ts
Normal file
@ -0,0 +1,77 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
export class DPT11 implements DPT {
|
||||
id = '11';
|
||||
name = '3-byte date value';
|
||||
bufferLength = 3;
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): Date {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT8. Expected ${this.bufferLength}.`);
|
||||
|
||||
const day = buffer[0] & 31; //0b00011111);
|
||||
const month = buffer[1] & 15; //0b00001111);
|
||||
let year = buffer[2] & 127; //0b01111111);
|
||||
year = year + (year > 89 ? 1900 : 2000);
|
||||
if (
|
||||
day < 1 ||
|
||||
day > 31 ||
|
||||
month < 1 ||
|
||||
month > 12 ||
|
||||
year < 1990 ||
|
||||
year > 2089
|
||||
) {
|
||||
throw new InvalidValueError(`${buffer} => ${day}/${month}/${year} is not valid date according to DPT11, setting to 1990/01/01`);
|
||||
}
|
||||
return new Date(year, month - 1, day);
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: Date | string): Buffer {
|
||||
switch (typeof value) {
|
||||
case 'string':
|
||||
case 'number':
|
||||
value = new Date(value);
|
||||
break;
|
||||
case 'object':
|
||||
// this expects the month property to be zero-based (January = 0, etc.)
|
||||
if (value instanceof Date) break;
|
||||
const { year, month, day } = value;
|
||||
value = new Date(parseInt(year), parseInt(month), parseInt(day));
|
||||
}
|
||||
|
||||
if (isNaN(value.getDate()))
|
||||
throw new InvalidValueError('Must supply a numeric timestamp, Date or String object for DPT11 Date')
|
||||
|
||||
const year = value.getFullYear();
|
||||
return Buffer.from([
|
||||
value.getDate(),
|
||||
value.getMonth() + 1,
|
||||
year - (year >= 2000 ? 2000 : 1900),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
subtypes: {
|
||||
// 11.001 date
|
||||
'001': {
|
||||
name: 'DPT_Date',
|
||||
desc: 'Date',
|
||||
},
|
||||
};
|
||||
|
||||
}
|
48
src/DPT12.ts
Normal file
48
src/DPT12.ts
Normal file
@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
import { buffer } from 'stream/consumers';
|
||||
|
||||
export class DPT12 implements DPT {
|
||||
id = '12';
|
||||
name = '4-byte unsigned value';
|
||||
bufferLength = 4
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): number {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT8. Expected ${this.bufferLength}.`);
|
||||
|
||||
return buffer.readUInt32BE(0);
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: number): Buffer {
|
||||
if (!value)
|
||||
throw new InvalidValueError('Cannot write null value');
|
||||
|
||||
let result = Buffer.alloc(this.bufferLength)
|
||||
result.writeUInt32BE(value)
|
||||
return result;
|
||||
}
|
||||
|
||||
subtypes: {
|
||||
// 12.001 counter pulses
|
||||
"001": {
|
||||
"name": "DPT_Value_4_Ucount",
|
||||
"desc": "counter pulses"
|
||||
}
|
||||
};
|
||||
|
||||
}
|
102
src/DPT13.ts
Normal file
102
src/DPT13.ts
Normal file
@ -0,0 +1,102 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
export class DPT13 implements DPT {
|
||||
id = '13';
|
||||
name = '4-byte signed value';
|
||||
bufferLength = 4;
|
||||
range = [-Math.pow(2, 31), Math.pow(2, 31) - 1]
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): number {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT8. Expected ${this.bufferLength}.`);
|
||||
|
||||
// In 4 bytes, there's no way to exceed the range
|
||||
return buffer.readInt32BE(0)
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: number): Buffer {
|
||||
|
||||
if (value === undefined || value === null || Number.isFinite(value))
|
||||
throw new InvalidValueError(`Value is not viable`)
|
||||
if (Number.isInteger(value))
|
||||
throw new InvalidValueError(`Value ${value} is not an integer`)
|
||||
|
||||
if (value < this.range[0] || value > this.range[1])
|
||||
throw new InvalidValueError(`Value ${value} is out of range`)
|
||||
|
||||
let result = Buffer.alloc(this.bufferLength)
|
||||
result.writeInt32BE(value)
|
||||
return result;
|
||||
}
|
||||
|
||||
subtypes: {
|
||||
// 13.001 counter pulses (signed)
|
||||
"001": {
|
||||
"name": "DPT_Value_4_Count", "desc": "counter pulses (signed)",
|
||||
"unit": "pulses"
|
||||
},
|
||||
|
||||
"002": {
|
||||
"name": "DPT_Value_Activation_Energy", "desc": "activation energy (J/mol)",
|
||||
"unit": "J/mol"
|
||||
},
|
||||
|
||||
// 13.010 active energy (Wh)
|
||||
"010": {
|
||||
"name": "DPT_ActiveEnergy", "desc": "active energy (Wh)",
|
||||
"unit": "Wh"
|
||||
},
|
||||
|
||||
// 13.011 apparent energy (VAh)
|
||||
"011": {
|
||||
"name": "DPT_ApparantEnergy", "desc": "apparent energy (VAh)",
|
||||
"unit": "VAh"
|
||||
},
|
||||
|
||||
// 13.012 reactive energy (VARh)
|
||||
"012": {
|
||||
"name": "DPT_ReactiveEnergy", "desc": "reactive energy (VARh)",
|
||||
"unit": "VARh"
|
||||
},
|
||||
|
||||
// 13.013 active energy (KWh)
|
||||
"013": {
|
||||
"name": "DPT_ActiveEnergy_kWh", "desc": "active energy (kWh)",
|
||||
"unit": "kWh"
|
||||
},
|
||||
|
||||
// 13.014 apparent energy (kVAh)
|
||||
"014": {
|
||||
"name": "DPT_ApparantEnergy_kVAh", "desc": "apparent energy (kVAh)",
|
||||
"unit": "VAh"
|
||||
},
|
||||
|
||||
// 13.015 reactive energy (kVARh)
|
||||
"015": {
|
||||
"name": "DPT_ReactiveEnergy_kVARh", "desc": "reactive energy (kVARh)",
|
||||
"unit": "kVARh"
|
||||
},
|
||||
|
||||
// 13.100 time lag(s)
|
||||
"100": {
|
||||
"name": "DPT_LongDeltaTimeSec", "desc": "time lag(s)",
|
||||
"unit": "s"
|
||||
},
|
||||
};
|
||||
|
||||
}
|
169
src/DPT14.ts
Normal file
169
src/DPT14.ts
Normal file
@ -0,0 +1,169 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
export class DPT14 implements DPT {
|
||||
id = '14';
|
||||
name = '32-bit floating point value';
|
||||
bufferLength = 4;
|
||||
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): number {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT8. Expected ${this.bufferLength}.`);
|
||||
|
||||
return buffer.readFloatBE(0);
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: number): Buffer {
|
||||
if (!value || typeof value != 'number')
|
||||
throw new InvalidValueError(`Invalid value [${value}]`)
|
||||
const apdu_data = Buffer.alloc(this.bufferLength);
|
||||
apdu_data.writeFloatBE(value, 0);
|
||||
return apdu_data;
|
||||
}
|
||||
|
||||
|
||||
subtypes: {
|
||||
// TODO
|
||||
'007': {
|
||||
name: 'DPT_Value_AngleDeg°',
|
||||
desc: 'angle, degree',
|
||||
unit: '°',
|
||||
},
|
||||
|
||||
'019': {
|
||||
name: 'DPT_Value_Electric_Current',
|
||||
desc: 'electric current',
|
||||
unit: 'A',
|
||||
},
|
||||
|
||||
'027': {
|
||||
name: 'DPT_Value_Electric_Potential',
|
||||
desc: 'electric potential',
|
||||
unit: 'V',
|
||||
},
|
||||
|
||||
'028': {
|
||||
name: 'DPT_Value_Electric_PotentialDifference',
|
||||
desc: 'electric potential difference',
|
||||
unit: 'V',
|
||||
},
|
||||
|
||||
'031': {
|
||||
name: 'DPT_Value_Energ',
|
||||
desc: 'energy',
|
||||
unit: 'J',
|
||||
},
|
||||
|
||||
'032': {
|
||||
name: 'DPT_Value_Force',
|
||||
desc: 'force',
|
||||
unit: 'N',
|
||||
},
|
||||
|
||||
'033': {
|
||||
name: 'DPT_Value_Frequency',
|
||||
desc: 'frequency',
|
||||
unit: 'Hz',
|
||||
},
|
||||
|
||||
'036': {
|
||||
name: 'DPT_Value_Heat_FlowRate',
|
||||
desc: 'heat flow rate',
|
||||
unit: 'W',
|
||||
},
|
||||
|
||||
'037': {
|
||||
name: 'DPT_Value_Heat_Quantity',
|
||||
desc: 'heat, quantity of',
|
||||
unit: 'J',
|
||||
},
|
||||
|
||||
'038': {
|
||||
name: 'DPT_Value_Impedance',
|
||||
desc: 'impedance',
|
||||
unit: 'Ω',
|
||||
},
|
||||
|
||||
'039': {
|
||||
name: 'DPT_Value_Length',
|
||||
desc: 'length',
|
||||
unit: 'm',
|
||||
},
|
||||
|
||||
'051': {
|
||||
name: 'DPT_Value_Mass',
|
||||
desc: 'mass',
|
||||
unit: 'kg',
|
||||
},
|
||||
|
||||
'056': {
|
||||
name: 'DPT_Value_Power',
|
||||
desc: 'power',
|
||||
unit: 'W',
|
||||
},
|
||||
|
||||
'065': {
|
||||
name: 'DPT_Value_Speed',
|
||||
desc: 'speed',
|
||||
unit: 'm/s',
|
||||
},
|
||||
|
||||
'066': {
|
||||
name: 'DPT_Value_Stress',
|
||||
desc: 'stress',
|
||||
unit: 'Pa',
|
||||
},
|
||||
|
||||
'067': {
|
||||
name: 'DPT_Value_Surface_Tension',
|
||||
desc: 'surface tension',
|
||||
unit: '1/Nm',
|
||||
},
|
||||
|
||||
'068': {
|
||||
name: 'DPT_Value_Common_Temperature',
|
||||
desc: 'temperature, common',
|
||||
unit: '°C',
|
||||
},
|
||||
|
||||
'069': {
|
||||
name: 'DPT_Value_Absolute_Temperature',
|
||||
desc: 'temperature (absolute)',
|
||||
unit: 'K',
|
||||
},
|
||||
|
||||
'070': {
|
||||
name: 'DPT_Value_TemperatureDifference',
|
||||
desc: 'temperature difference',
|
||||
unit: 'K',
|
||||
},
|
||||
|
||||
'078': {
|
||||
name: 'DPT_Value_Weight',
|
||||
desc: 'weight',
|
||||
unit: 'N',
|
||||
},
|
||||
|
||||
'079': {
|
||||
name: 'DPT_Value_Work',
|
||||
desc: 'work',
|
||||
unit: 'J',
|
||||
},
|
||||
};
|
||||
|
||||
}
|
100
src/DPT15.ts
Normal file
100
src/DPT15.ts
Normal file
@ -0,0 +1,100 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
/**
|
||||
* U 4 bit
|
||||
* V 4 bit
|
||||
* W 4 bit
|
||||
* X 4 bit
|
||||
* Y 4 bit
|
||||
* Z 4 bit
|
||||
* E 1 bit
|
||||
* P 1 bit
|
||||
* D 1 bit
|
||||
* C 1 bit
|
||||
* N 4 bit
|
||||
*
|
||||
* U,V,W,X,Y,Z = [0 … 9]; E,P,D,C = {0,1}; N = [0 … 15]
|
||||
*
|
||||
* Source: https://www.promotic.eu/en/pmdoc/Subsystems/Comm/PmDrivers/KNXDTypes.htm
|
||||
*/
|
||||
export interface DPT15Result {
|
||||
U: number
|
||||
V: number
|
||||
W: number
|
||||
X: number
|
||||
Y: number
|
||||
Z: number
|
||||
E: number
|
||||
P: number
|
||||
D: number
|
||||
C: number
|
||||
N: number
|
||||
}
|
||||
export class DPT15 implements DPT {
|
||||
id = '';
|
||||
name = '4-byte access control data';
|
||||
bufferLength = 4;
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): DPT15Result {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT8. Expected ${this.bufferLength}.`);
|
||||
|
||||
const result: DPT15Result = {
|
||||
U: (buffer[0] & 0xf0) >> 4,
|
||||
V: (buffer[0] & 0x0f),
|
||||
W: (buffer[1] & 0xf0) >> 4,
|
||||
X: (buffer[1] & 0x0f),
|
||||
Y: (buffer[2] & 0xf0) >> 4,
|
||||
Z: (buffer[2] & 0x0f),
|
||||
E: (buffer[3] >> 7) & 0x01,
|
||||
P: (buffer[3] >> 6) & 0x01,
|
||||
D: (buffer[3] >> 5) & 0x01,
|
||||
C: (buffer[3] >> 4) & 0x01,
|
||||
N: (buffer[3] & 0x0f),
|
||||
}
|
||||
|
||||
if (Math.max(result.U, result.V, result.W, result.X, result.Y, result.Z) > 9)
|
||||
throw new InvalidValueError(`Value must be < 9 (U: ${result.U}, V: ${result.V}, W: ${result.W}, X: ${result.X}, y: ${result.Y}, Z: ${result.Z})`)
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: DPT15Result): Buffer {
|
||||
if (value === undefined || value === null)
|
||||
throw new InvalidValueError(`Invalid value [${value}]`)
|
||||
|
||||
if (Math.max(value.U, value.V, value.W, value.X, value.Y, value.Z) > 9)
|
||||
throw new InvalidValueError(`Value must be < 9 (U: ${value.U}, V: ${value.V}, W: ${value.W}, X: ${value.X}, y: ${value.Y}, Z: ${value.Z})`)
|
||||
|
||||
const apdu_data = Buffer.alloc(this.bufferLength);
|
||||
apdu_data.writeUInt8((value.U << 4) + value.V, 0);
|
||||
apdu_data.writeUInt8((value.W << 4) + value.X, 1);
|
||||
apdu_data.writeUInt8((value.Y << 4) + value.Z, 2);
|
||||
apdu_data.writeUInt8((value.E << 7) + (value.P << 6) + (value.D << 5) + (value.C << 4) + value.N, 3);
|
||||
return apdu_data;
|
||||
}
|
||||
|
||||
|
||||
subtypes: {
|
||||
"000": {
|
||||
name: "DPT_Access_Data",
|
||||
desc: "default field"
|
||||
}
|
||||
};
|
||||
|
||||
}
|
59
src/DPT16.ts
Normal file
59
src/DPT16.ts
Normal file
@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
export class DPT16 implements DPT {
|
||||
id = '16';
|
||||
name = '14-character string';
|
||||
bufferLength = 14;
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): string {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT8. Expected ${this.bufferLength}.`);
|
||||
|
||||
|
||||
return buffer.toString('ascii');
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: string): Buffer {
|
||||
if (typeof value !== 'string')
|
||||
throw new InvalidValueError('Must supply a string value')
|
||||
|
||||
const buf = Buffer.alloc(14);
|
||||
buf.write(value, 'ascii');
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
subtypes: {
|
||||
// 16.000 ASCII string
|
||||
'000': {
|
||||
use: 'G',
|
||||
name: 'DPT_String_ASCII',
|
||||
desc: 'ASCII string',
|
||||
force_encoding: 'US-ASCII',
|
||||
},
|
||||
|
||||
// 16.001 ISO-8859-1 string
|
||||
'001': {
|
||||
use: 'G',
|
||||
name: 'DPT_String_8859_1',
|
||||
desc: 'ISO-8859-1 string',
|
||||
force_encoding: 'ISO-8859-1',
|
||||
},
|
||||
};
|
||||
|
||||
}
|
52
src/DPT17.ts
Normal file
52
src/DPT17.ts
Normal file
@ -0,0 +1,52 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
export class DPT17 implements DPT {
|
||||
id = '17';
|
||||
name = 'scene number';
|
||||
bufferLength = 1;
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): number {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT8. Expected ${this.bufferLength}.`);
|
||||
|
||||
// Scene number between 0 and 63
|
||||
return buffer.readUInt8(0) & 0b00111111;
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: number): Buffer {
|
||||
if (value === undefined || value === null)
|
||||
throw new InvalidValueError(`Invalid value [${value}]`)
|
||||
|
||||
if (value > 63)
|
||||
throw new InvalidValueError(`Expected scene number [0, 63]. Got [${value}]`)
|
||||
|
||||
let buf = Buffer.alloc(this.bufferLength)
|
||||
buf.writeUInt8(value, 0)
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
subtypes: {
|
||||
// 17.001 Scene number
|
||||
"001": {
|
||||
use: "G",
|
||||
name: "DPT_SceneNumber", desc: "Scene Number",
|
||||
},
|
||||
};
|
||||
|
||||
}
|
62
src/DPT18.ts
Normal file
62
src/DPT18.ts
Normal file
@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
export interface DPT18Result {
|
||||
activateLearn: number
|
||||
// pad: number // reserved
|
||||
sceneNumber: number
|
||||
}
|
||||
export class DPT18 implements DPT {
|
||||
id = '18';
|
||||
name = '8-bit Scene Activate/Learn + number';
|
||||
bufferLength = 1;
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): DPT18Result {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT8. Expected ${this.bufferLength}.`);
|
||||
|
||||
|
||||
return {
|
||||
activateLearn: (buffer[0] & 0b10000000) >> 7,
|
||||
sceneNumber: buffer[0] & 0b00111111
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: DPT18Result): Buffer {
|
||||
if (value === undefined || value === null)
|
||||
throw new InvalidValueError(`Invalid value [${value}]`)
|
||||
|
||||
if (value.sceneNumber > 63)
|
||||
throw new InvalidValueError(`Expected scene number [0..63]. Got [${value.sceneNumber}]`)
|
||||
|
||||
if (value.activateLearn > 1)
|
||||
throw new InvalidValueError(`Expected scene number [0, 1]. Got [${value.activateLearn}]`)
|
||||
|
||||
let buf = Buffer.alloc(this.bufferLength)
|
||||
buf.writeUInt8((value.activateLearn << 7) + value.sceneNumber)
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
subtypes: {
|
||||
// 9.001 temperature (oC)
|
||||
"001": {
|
||||
name: "DPT_SceneControl", desc: "scene control"
|
||||
}
|
||||
};
|
||||
|
||||
}
|
226
src/DPT19.ts
Normal file
226
src/DPT19.ts
Normal file
@ -0,0 +1,226 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
/**
|
||||
* <strong>19.001</strong> Date & Time
|
||||
*
|
||||
* <pre>
|
||||
* +-7-+-6-+-5-+-4-+-3-+-2-+-1-+-0-+-7-+-6-+-5-+-4-+-3-+-2-+-1-+-0-+
|
||||
* Field Names | (Year) | 0 0 0 0 (Month) |
|
||||
* Encoding | U U U U U U U U | r r r r U U U U |
|
||||
* +-7-+-6-+-5-+-4-+-3-+-2-+-1-+-0-+-7-+-6-+-5-+-4-+-3-+-2-+-1-+-0-+
|
||||
* | 0 0 0 (Day Of Month) | (DayOfWeek) (Hour) |
|
||||
* | r r r U U U U U | U U U U U U U U |
|
||||
* +-7-+-6-+-5-+-4-+-3-+-2-+-1-+-0-+-7-+-6-+-5-+-4-+-3-+-2-+-1-+-0-+
|
||||
* | 0 0 (Minutes) | 0 0 (Seconds) |
|
||||
* | r r U U U U U U | r r U U U U U U |
|
||||
* +-7-+-6-+-5-+-4-+-3-+-2-+-1-+-0-+-7-+-6-+-5-+-4-+-3-+-2-+-1-+-0-+
|
||||
* | F WD NWD NY ND NDoW NT SST| CLQ SRC 0 0 0 0 0 0 |
|
||||
* | B B B B B B B B | B B r r r r r r |
|
||||
* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|
||||
* Format: 8 octets (U<sub>8</sub> [r<sub>4</sub>U<sub>4</sub>] [r<sub>3</sub>U<sub>5</sub>] [r<sub>3</sub>U<sub>5</sub>] [r<sub>2</sub>U<sub>6</sub>] [r<sub>2</sub>U<sub>6</sub>] B<sub>16</sub>)
|
||||
* Encoding:
|
||||
* Year = [0 .. 255]
|
||||
* 0 = year 1900
|
||||
* 255 = year 2155
|
||||
* Month = [1 .. 12]
|
||||
* DayOfMonth = [1 .. 31]
|
||||
* DayOfWeek = [0 .. 7]
|
||||
* 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, 7 = Sunday, 0 = any day
|
||||
* Hour = [0 .. 24]
|
||||
* Minutes = [0 .. 59]
|
||||
* Seconds = [0 .. 59]
|
||||
* (F) Fault = {0, 1}
|
||||
* 0 = Normal (no fault)
|
||||
* 1 = Fault
|
||||
* (WD) WorkingDay = {0, 1}
|
||||
* 0 = No Working Day
|
||||
* 1 = Working Day
|
||||
* (NWD) NoWorkingDay = {0, 1}
|
||||
* 0 = WorkingDay field valid
|
||||
* 1 = WorkingDay field not valid
|
||||
* (NY) NoYear = {0, 1}
|
||||
* 0 = Year field valid
|
||||
* 1 = Year field not valid
|
||||
* (ND) NoDate = {0, 1}
|
||||
* 0 = Month and DayOfMonth fields valid
|
||||
* 1 = Month and DayOfMonth fields not valid
|
||||
* (NDoW) NoDayOfWeek = {0, 1}
|
||||
* 0 = DayOfWeek field valid
|
||||
* 1 = DayOfWeek field not valid
|
||||
* (NT) NoTime = {0, 1}
|
||||
* 0 = Hour, Minutes and Seconds valid
|
||||
* 1 = Hour, Minutes and Seconds not valid
|
||||
* (SST) Standard Summer Time = {0, 1}
|
||||
* 0 = UTC+x (standard time)
|
||||
* 1 = UTC+x +1h (summer daylight saving time)
|
||||
* (CLQ) QualityOfClock = {0, 1}
|
||||
* 0 = Clock without external synchronization signal
|
||||
* 1 = Clock with external synchronization signal (DCF 77, VideoText, ...)
|
||||
* (SRC) SynchronisationSourceReliability = {0, 1}
|
||||
* 0 = Unreliable Synchronisation (mains, local quartz)
|
||||
* 1 = Reliable Synchronisation (radio, internet)
|
||||
* </pre>
|
||||
* <p>
|
||||
* The encoding of the hour is within the range [0 .. 24] instead of [0 .. 23]. When the hour is set to "24", the
|
||||
* values of octet 3 (Minutes) and 2 (Seconds) have to be set to zero.
|
||||
* <p>
|
||||
* "Fault" is set if one ore more supported fields of the Date & Time information are corrupted. "Fault" is set e.g.
|
||||
* power-down if battery backup was not sufficient, after 1st start up of device (clock un-configured) or radio-clock
|
||||
* (DCF 77) had no reception for a very long time. "Fault" is usually cleared automatically by the device if the
|
||||
* local clock is set or clock data is refreshed
|
||||
* <p>
|
||||
* The receiver (e.g. a room unit, MMI) will interpret Date&Time with "Fault" as corrupted and will either ignore
|
||||
* the message or show --:--:-- or blinking 00:00:00 (as known from Video recorders after power-up).
|
||||
*/
|
||||
export class DPT19Result {
|
||||
dateTime: Date = new Date()
|
||||
dayOfWeek: number = undefined
|
||||
f: boolean = false
|
||||
wd: boolean = false
|
||||
nwd: boolean = false
|
||||
ny: boolean = false
|
||||
nd: boolean = false
|
||||
ndow: boolean = false
|
||||
nt: boolean = false
|
||||
sst: boolean = false
|
||||
internalClock: boolean = true // Assume external clock
|
||||
reliability: boolean = false;
|
||||
}
|
||||
export class DPT19 implements DPT {
|
||||
id = '19';
|
||||
name = '8-byte Date+Time';
|
||||
bufferLength = 8;
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): DPT19Result {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT8. Expected ${this.bufferLength}.`);
|
||||
|
||||
const byte8 = buffer.readUInt8(0)
|
||||
const byte7 = buffer.readUInt8(1)
|
||||
const byte6 = buffer.readUInt8(2)
|
||||
const byte5 = buffer.readUInt8(3)
|
||||
const byte4 = buffer.readUInt8(4)
|
||||
const byte3 = buffer.readUInt8(5)
|
||||
const byte2 = buffer.readUInt8(6)
|
||||
const byte1 = buffer.readUInt8(7)
|
||||
|
||||
let year = byte8
|
||||
let month = byte7 & 0xF
|
||||
const dayOfMonth = byte6 & 0x1F
|
||||
let dayOfWeek = byte5 >> 5
|
||||
const hourOfDay = byte5 & 0x1F
|
||||
const minutes = byte4 & 0x3F
|
||||
const seconds = byte3 & 0x3F
|
||||
const f = !!(byte2 & 0x80)
|
||||
const wd = !!(byte2 & 0x40)
|
||||
const nwd = !!(byte2 & 0x20)
|
||||
const ny = !!(byte2 & 0x10)
|
||||
const nd = !!(byte2 & 0x8)
|
||||
const ndow = !!(byte2 & 0x4)
|
||||
const nt = !!(byte2 & 0x2)
|
||||
const suti = !!(byte2 & 0x1)
|
||||
const clq = !!(byte1 & 0x80)
|
||||
const reliability = !!(byte1 & 0x40)
|
||||
|
||||
year += 1900
|
||||
|
||||
// Convert month from knx to JavaScript (12 => 11, 11 => 10, ...)
|
||||
month -= 1
|
||||
|
||||
// Convert day of week from knx to JavaScript (7 => 0, 0 => undefined)
|
||||
if (dayOfWeek === 7) {
|
||||
dayOfWeek = 0
|
||||
} else if (dayOfWeek === 0) {
|
||||
dayOfWeek = undefined
|
||||
}
|
||||
|
||||
// Check minutes and seconds if hours equals 24
|
||||
if (hourOfDay === 24 && (minutes !== 0 || seconds !== 0)) {
|
||||
throw new RangeError('Invalid time (hour of day is 24, but minutes or seconds are not 0)')
|
||||
}
|
||||
|
||||
return {
|
||||
dateTime: new Date(year, month, dayOfMonth, hourOfDay, minutes, seconds),
|
||||
dayOfWeek: dayOfWeek,
|
||||
f: f,
|
||||
wd: wd,
|
||||
nwd: nwd,
|
||||
ny: ny,
|
||||
nd: nd,
|
||||
ndow: ndow,
|
||||
nt: nt,
|
||||
sst: suti,
|
||||
internalClock: clq,
|
||||
reliability: reliability
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: DPT19Result | Date): Buffer {
|
||||
if (value === undefined || value === null)
|
||||
throw new InvalidValueError(`Invalid value [${value}]`)
|
||||
|
||||
let temp: DPT19Result;
|
||||
|
||||
if (value.constructor.name === 'Date') {
|
||||
temp = new DPT19Result()
|
||||
temp.dateTime = value as Date
|
||||
temp.dayOfWeek = (value as Date).getDay()
|
||||
} else {
|
||||
temp = value as DPT19Result
|
||||
}
|
||||
|
||||
let dayOfWeek = temp.dayOfWeek
|
||||
const f = !!temp.f ? 1 : 0
|
||||
const wd = !!temp.wd ? 1 : 0
|
||||
const nwd = !!temp.nwd ? 1 : 0
|
||||
const ny = !!temp.ny ? 1 : 0
|
||||
const nd = !!temp.nd ? 1 : 0
|
||||
const ndow = !!temp.ndow ? 1 : 0
|
||||
const nt = !!temp.nt ? 1 : 0
|
||||
const sst = !!temp.sst ? 1 : 0
|
||||
const clq = !!temp.internalClock ? 1 : 0
|
||||
const reliability = !!temp.reliability ? 1 : 0
|
||||
|
||||
// Convert day of week from JavaScript to knx (0 => 7, undefined => 0)
|
||||
if (typeof dayOfWeek === 'undefined') {
|
||||
dayOfWeek = 0
|
||||
} else if (dayOfWeek === 0) {
|
||||
dayOfWeek = 7
|
||||
}
|
||||
|
||||
const buffer = Buffer.alloc(8, 0)
|
||||
buffer.writeUInt8(temp.dateTime.getFullYear() - 1900, 0)
|
||||
buffer.writeUInt8(temp.dateTime.getMonth() + 1, 1)
|
||||
buffer.writeUInt8(temp.dateTime.getDate(), 2)
|
||||
buffer.writeUInt8((dayOfWeek << 5) | temp.dateTime.getHours(), 3)
|
||||
buffer.writeUInt8(temp.dateTime.getMinutes(), 4)
|
||||
buffer.writeUInt8(temp.dateTime.getSeconds(), 5)
|
||||
buffer.writeUInt8((f << 7) | (wd << 6) | (nwd << 5) | (ny << 4) | (nd << 3) | (ndow << 2) | (nt << 1) | sst, 6)
|
||||
buffer.writeUInt8(clq << 7 | reliability << 6, 7)
|
||||
|
||||
return buffer
|
||||
}
|
||||
subtypes: {
|
||||
// 19.001
|
||||
'001': {
|
||||
name: 'DPT_DateTime',
|
||||
desc: 'datetime',
|
||||
},
|
||||
};
|
||||
|
||||
}
|
140
src/DPT2.ts
Normal file
140
src/DPT2.ts
Normal file
@ -0,0 +1,140 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
export interface DPT2Result {
|
||||
priority: boolean;
|
||||
data: boolean;
|
||||
}
|
||||
|
||||
export class DPT2 implements DPT {
|
||||
id = '2';
|
||||
name = '1-bit value with priority';
|
||||
bufferLength = 1;
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): DPT2Result {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT1. Expected ${this.bufferLength}.`);
|
||||
|
||||
const value = buffer.readUInt8(0)
|
||||
return {
|
||||
priority: ((value & 0b00000010) >> 1) === 1,
|
||||
data: (value & 0b00000001) === 1,
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: DPT2Result): Buffer {
|
||||
if (!value) throw new InvalidValueError('DPT2: cannot write null value');
|
||||
|
||||
return Buffer.from([((value.priority ? 1 : 0) << 1) + ((value.data ? 1 : 0) & 0b00000001)]);
|
||||
}
|
||||
|
||||
subtypes: {
|
||||
// 2.001 switch control
|
||||
'001': {
|
||||
use: 'G',
|
||||
name: 'DPT_Switch_Control',
|
||||
desc: 'switch with priority',
|
||||
enc: { 0: 'Off', 1: 'On' },
|
||||
},
|
||||
// 2.002 boolean control
|
||||
'002': {
|
||||
use: 'G',
|
||||
name: 'DPT_Bool_Control',
|
||||
desc: 'boolean with priority',
|
||||
enc: { 0: 'false', 1: 'true' },
|
||||
},
|
||||
// 2.003 enable control
|
||||
'003': {
|
||||
use: 'FB',
|
||||
name: 'DPT_Emable_Control',
|
||||
desc: 'enable with priority',
|
||||
enc: { 0: 'Disabled', 1: 'Enabled' },
|
||||
},
|
||||
|
||||
// 2.004 ramp control
|
||||
'004': {
|
||||
use: 'FB',
|
||||
name: 'DPT_Ramp_Control',
|
||||
desc: 'ramp with priority',
|
||||
enc: { 0: 'No ramp', 1: 'Ramp' },
|
||||
},
|
||||
|
||||
// 2.005 alarm control
|
||||
'005': {
|
||||
use: 'FB',
|
||||
name: 'DPT_Alarm_Control',
|
||||
desc: 'alarm with priority',
|
||||
enc: { 0: 'No alarm', 1: 'Alarm' },
|
||||
},
|
||||
|
||||
// 2.006 binary value control
|
||||
'006': {
|
||||
use: 'FB',
|
||||
name: 'DPT_BinaryValue_Control',
|
||||
desc: 'binary value with priority',
|
||||
enc: { 0: 'Off', 1: 'On' },
|
||||
},
|
||||
|
||||
// 2.007 step control
|
||||
'007': {
|
||||
use: 'FB',
|
||||
name: 'DPT_Step_Control',
|
||||
desc: 'step with priority',
|
||||
enc: { 0: 'Off', 1: 'On' },
|
||||
},
|
||||
|
||||
// 2.008 Direction1 control
|
||||
'008': {
|
||||
use: 'FB',
|
||||
name: 'DPT_Direction1_Control',
|
||||
desc: 'direction 1 with priority',
|
||||
enc: { 0: 'Off', 1: 'On' },
|
||||
},
|
||||
|
||||
// 2.009 Direction2 control
|
||||
'009': {
|
||||
use: 'FB',
|
||||
name: 'DPT_Direction2_Control',
|
||||
desc: 'direction 2 with priority',
|
||||
enc: { 0: 'Off', 1: 'On' },
|
||||
},
|
||||
|
||||
// 2.010 start control
|
||||
'010': {
|
||||
use: 'FB',
|
||||
name: 'DPT_Start_Control',
|
||||
desc: 'start with priority',
|
||||
enc: { 0: 'No control', 1: 'No control', 2: 'Off', 3: 'On' },
|
||||
},
|
||||
|
||||
// 2.011 state control
|
||||
'011': {
|
||||
use: 'FB',
|
||||
name: 'DPT_Switch_Control',
|
||||
desc: 'switch',
|
||||
enc: { 0: 'No control', 1: 'No control', 2: 'Off', 3: 'On' },
|
||||
},
|
||||
|
||||
// 2.012 invert control
|
||||
'012': {
|
||||
use: 'FB',
|
||||
name: 'DPT_Switch_Control',
|
||||
desc: 'switch',
|
||||
enc: { 0: 'No control', 1: 'No control', 2: 'Off', 3: 'On' },
|
||||
},
|
||||
};
|
||||
}
|
94
src/DPT20.ts
Normal file
94
src/DPT20.ts
Normal file
@ -0,0 +1,94 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
/**
|
||||
* Original at https://github.com/pitschr/knx-core/blob/main/src/main/java/li/pitschmann/knx/core/datapoint/DPT20.java
|
||||
*
|
||||
* Data Point Type 20 for '8-Bit Enumeration' (1 Octet)
|
||||
*
|
||||
* <pre>
|
||||
* +-7-+-6-+-5-+-4-+-3-+-2-+-1-+-0-+
|
||||
* Field Names | (Field 1) |
|
||||
* Encoding | N N N N N N N N |
|
||||
* +---+---+---+---+---+---+---+---+
|
||||
* Format: 8 bit (N<sub>8</sub>)
|
||||
* </pre>
|
||||
*/
|
||||
export class DPT20 implements DPT {
|
||||
id = '20';
|
||||
name = '8-Bit Enumeration';
|
||||
bufferLength = 1;
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): number {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT8. Expected ${this.bufferLength}.`);
|
||||
|
||||
return buffer.readUInt8(0);
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: number): Buffer {
|
||||
if (value === undefined || value === null)
|
||||
throw new InvalidValueError(`Invalid value [${value}]`)
|
||||
|
||||
return Buffer.from([value & 0xff])
|
||||
}
|
||||
|
||||
|
||||
subtypes: {
|
||||
// 20.001 SCLO Mode
|
||||
1: {
|
||||
name: 'SCLO_Mode',
|
||||
desc: '',
|
||||
unit: '',
|
||||
scalar_range: {
|
||||
0: 'Autonomous',
|
||||
1: 'Slave',
|
||||
2: 'Master'
|
||||
},
|
||||
range: undefined,
|
||||
},
|
||||
|
||||
// 20.001 Building Mode
|
||||
2: {
|
||||
name: 'Building_Mode',
|
||||
desc: '',
|
||||
unit: '',
|
||||
scalar_range: {
|
||||
0: 'Building in use',
|
||||
1: 'Building not used',
|
||||
2: 'Building protection'
|
||||
},
|
||||
range: undefined,
|
||||
},
|
||||
|
||||
// 20.102 HVAC mode
|
||||
102: {
|
||||
name: 'HVAC_Mode',
|
||||
desc: '',
|
||||
unit: '',
|
||||
scalar_range: {
|
||||
0: 'Auto',
|
||||
1: 'Comfort',
|
||||
2: 'Standby',
|
||||
3: 'Economy',
|
||||
4: 'Building protection'
|
||||
},
|
||||
range: undefined,
|
||||
},
|
||||
};
|
||||
|
||||
}
|
101
src/DPT21.ts
Normal file
101
src/DPT21.ts
Normal file
@ -0,0 +1,101 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
/**
|
||||
* Original at https://github.com/pitschr/knx-core/blob/main/src/main/java/li/pitschmann/knx/core/datapoint/DPT21.java
|
||||
* * Data Point Type 21 for 8-Bits flagged messages
|
||||
*
|
||||
* <pre>
|
||||
* +-7-+-6-+-5-+-4-+-3-+-2-+-1-+-0-+
|
||||
* Field Names | b b b b b b b b |
|
||||
* Encoding | B B B B B B B B |
|
||||
* +---+---+---+---+---+---+---+---+
|
||||
* Format: 8 bits (B<sub>8</sub>)
|
||||
* </pre>
|
||||
*/
|
||||
export class DPT21 implements DPT {
|
||||
id = '';
|
||||
name = '';
|
||||
bufferLength = 0;
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): boolean[] {
|
||||
if (buffer.length !== 2)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT8. Expected 2.`);
|
||||
|
||||
const result = [
|
||||
!!(buffer[0] & 0x80),
|
||||
!!(buffer[0] & 0x40),
|
||||
!!(buffer[0] & 0x20),
|
||||
!!(buffer[0] & 0x10),
|
||||
!!(buffer[0] & 0x08),
|
||||
!!(buffer[0] & 0x04),
|
||||
!!(buffer[0] & 0x02),
|
||||
!!(buffer[0] & 0x01),
|
||||
]
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: boolean[]): Buffer {
|
||||
if (value === undefined || value === null)
|
||||
throw new InvalidValueError(`Invalid value [${value}]`)
|
||||
|
||||
if (value.length != 8)
|
||||
throw new InvalidValueError(`Value length should be 8. Got ${value.length}.`)
|
||||
|
||||
const b7 = value[0] ? 1 : 0
|
||||
const b6 = value[0] ? 1 : 0
|
||||
const b5 = value[0] ? 1 : 0
|
||||
const b4 = value[0] ? 1 : 0
|
||||
const b3 = value[0] ? 1 : 0
|
||||
const b2 = value[0] ? 1 : 0
|
||||
const b1 = value[0] ? 1 : 0
|
||||
const b0 = value[0] ? 1 : 0
|
||||
|
||||
const buf = Buffer.from([
|
||||
b7 << 7 |
|
||||
b6 << 6 |
|
||||
b5 << 5 |
|
||||
b4 << 4 |
|
||||
b3 << 3 |
|
||||
b2 << 2 |
|
||||
b1 << 1 |
|
||||
b0
|
||||
])
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
subtypes: {
|
||||
// 21.001 status - 5 bits
|
||||
"001": {
|
||||
"name": "DPT_StatusGen",
|
||||
"desc": "General Status",
|
||||
"unit": "",
|
||||
"scalar_range": undefined,
|
||||
"range": undefined
|
||||
},
|
||||
// 21.002 control - 3 bits
|
||||
"002": {
|
||||
"name": "DPT_Device_Control",
|
||||
"desc": "Device Control",
|
||||
"unit": "",
|
||||
"scalar_range": undefined,
|
||||
"range": undefined
|
||||
}
|
||||
};
|
||||
|
||||
}
|
66
src/DPT232.ts
Normal file
66
src/DPT232.ts
Normal file
@ -0,0 +1,66 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
export interface DPT232Result {
|
||||
red: number,
|
||||
green: number,
|
||||
blue: number
|
||||
}
|
||||
export class DPT232 implements DPT {
|
||||
id = '232';
|
||||
name = 'RGB array';
|
||||
bufferLength = 3
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the on/off value
|
||||
*/
|
||||
decoder(buffer: Buffer): DPT232Result {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT1. Expected ${this.bufferLength}.`);
|
||||
|
||||
const result: DPT232Result = {
|
||||
red: buffer.readUInt8(0),
|
||||
green: buffer.readUInt8(1),
|
||||
blue: buffer.readUInt8(2),
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: DPT232Result): Buffer {
|
||||
if (value === undefined || value === null)
|
||||
throw new InvalidValueError('Cannot write null value');
|
||||
|
||||
if (value.red < 0 || value.red > 255)
|
||||
throw new InvalidValueError(`Red component out of range ${value.red}`);
|
||||
if (value.blue < 0 || value.blue > 255)
|
||||
throw new InvalidValueError(`Blue component out of range ${value.blue}`);
|
||||
if (value.green < 0 || value.green > 255)
|
||||
throw new InvalidValueError(`Green component out of range ${value.green}`);
|
||||
|
||||
let buffer = Buffer.alloc(this.bufferLength)
|
||||
buffer.writeUInt8(value.red, 0)
|
||||
buffer.writeUInt8(value.green, 1)
|
||||
buffer.writeUInt8(value.blue, 2)
|
||||
|
||||
return buffer
|
||||
}
|
||||
|
||||
subtypes: {
|
||||
'600': {
|
||||
name: 'RGB',
|
||||
desc: 'RGB color triplet',
|
||||
unit: '',
|
||||
},
|
||||
};
|
||||
}
|
39
src/DPT237.ts
Normal file
39
src/DPT237.ts
Normal file
@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
export class DPT237 implements DPT {
|
||||
id = '';
|
||||
name = '';
|
||||
bufferLength = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): number {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT8. Expected ${this.bufferLength}.`);
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: number): Buffer {
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
subtypes: {
|
||||
};
|
||||
|
||||
}
|
74
src/DPT238.ts
Normal file
74
src/DPT238.ts
Normal file
@ -0,0 +1,74 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
export class DPT238 implements DPT {
|
||||
id = '238';
|
||||
name = '8-bit unsigned value';
|
||||
bufferLength = 1
|
||||
|
||||
decoder(buffer: Buffer): number {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT1. Expected ${this.bufferLength}.`);
|
||||
|
||||
return buffer.readUInt8(0)
|
||||
}
|
||||
|
||||
encoder(value: number): Buffer {
|
||||
if (!value)
|
||||
throw new InvalidValueError('DPT5: cannot write null value');
|
||||
|
||||
let buf = Buffer.alloc(this.bufferLength);
|
||||
buf.writeUInt8(value, 0)
|
||||
return buf;
|
||||
|
||||
}
|
||||
|
||||
subtypes: {
|
||||
// 20.102 HVAC mode
|
||||
102: {
|
||||
name: 'HVAC_Mode',
|
||||
desc: '',
|
||||
unit: '',
|
||||
//scalar_range: [,],
|
||||
//range: [,],
|
||||
},
|
||||
|
||||
// 5.003 angle (degrees 0=0, ff=360)
|
||||
'003': {
|
||||
name: 'DPT_Angle',
|
||||
desc: 'angle degrees',
|
||||
unit: '°',
|
||||
scalar_range: [0, 360],
|
||||
},
|
||||
|
||||
// 5.004 percentage (0..255%)
|
||||
'004': {
|
||||
name: 'DPT_Percent_U8',
|
||||
desc: 'percent',
|
||||
unit: '%',
|
||||
},
|
||||
|
||||
// 5.005 ratio (0..255)
|
||||
'005': {
|
||||
name: 'DPT_DecimalFactor',
|
||||
desc: 'ratio',
|
||||
unit: 'ratio',
|
||||
},
|
||||
|
||||
// 5.006 tariff (0..255)
|
||||
'006': {
|
||||
name: 'DPT_Tariff',
|
||||
desc: 'tariff',
|
||||
unit: 'tariff',
|
||||
},
|
||||
|
||||
// 5.010 counter pulses (0..255)
|
||||
'010': {
|
||||
name: 'DPT_Value_1_Ucount',
|
||||
desc: 'counter pulses',
|
||||
unit: 'pulses',
|
||||
},
|
||||
}
|
||||
}
|
64
src/DPT3.ts
Normal file
64
src/DPT3.ts
Normal file
@ -0,0 +1,64 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
export interface DPT3Result {
|
||||
decr_incr: number;
|
||||
data: number;
|
||||
}
|
||||
|
||||
export class DPT3 implements DPT {
|
||||
id = '3';
|
||||
name = '4-bit relative dimming control';
|
||||
bufferLength = 1;
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): DPT3Result {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT1. Expected ${this.bufferLength}.`);
|
||||
|
||||
const value = buffer.readUInt8(0)
|
||||
return {
|
||||
decr_incr: (value & 0b00001000) >> 3,
|
||||
data: value & 0b00000111,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: DPT3Result): Buffer {
|
||||
if (!value)
|
||||
throw new InvalidValueError('DPT3: cannot write null value');
|
||||
|
||||
if (value.decr_incr > 1)
|
||||
throw new InvalidValueError(`DPT3: Invalid increment/decrement value: ${value.decr_incr}. Expected 1 or 0.`);
|
||||
|
||||
return Buffer.from([(value.decr_incr << 3) + (value.data & 0b00000111)]);
|
||||
|
||||
}
|
||||
|
||||
subtypes: {
|
||||
// 3.007 dimming control
|
||||
'007': {
|
||||
name: 'DPT_Control_Dimming',
|
||||
desc: 'dimming control',
|
||||
},
|
||||
|
||||
// 3.008 blind control
|
||||
'008': {
|
||||
name: 'DPT_Control_Blinds',
|
||||
desc: 'blinds control',
|
||||
},
|
||||
};
|
||||
|
||||
}
|
57
src/DPT4.ts
Normal file
57
src/DPT4.ts
Normal file
@ -0,0 +1,57 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
export class DPT4 implements DPT {
|
||||
id = '4';
|
||||
name = '8-bit character';
|
||||
bufferLength = 1;
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): string {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT1. Expected ${this.bufferLength}.`);
|
||||
|
||||
return String.fromCharCode(buffer[0]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: string): Buffer {
|
||||
if (!value)
|
||||
throw new InvalidValueError('DPT4: cannot write null value');
|
||||
|
||||
const apdu_data = value.charCodeAt(0);
|
||||
if (apdu_data > 255)
|
||||
throw new InvalidValueError('DPT4: must supply an ASCII character');
|
||||
|
||||
return Buffer.from([apdu_data]);
|
||||
}
|
||||
|
||||
subtypes: {
|
||||
// 4.001 character (ASCII)
|
||||
'001': {
|
||||
name: 'DPT_Char_ASCII',
|
||||
desc: 'ASCII character (0-127)',
|
||||
range: [0, 127],
|
||||
use: 'G',
|
||||
},
|
||||
// 4.002 character (ISO-8859-1)
|
||||
'002': {
|
||||
name: 'DPT_Char_8859_1',
|
||||
desc: 'ISO-8859-1 character (0..255)',
|
||||
use: 'G',
|
||||
},
|
||||
};
|
||||
|
||||
}
|
73
src/DPT5.ts
Normal file
73
src/DPT5.ts
Normal file
@ -0,0 +1,73 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
export class DPT5 implements DPT {
|
||||
id = '5';
|
||||
name = '8-bit unsigned value';
|
||||
bufferLength = 1;
|
||||
|
||||
decoder(buffer: Buffer): number {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT1. Expected ${this.bufferLength}.`);
|
||||
|
||||
return buffer.readUInt8(0)
|
||||
}
|
||||
|
||||
encoder(value: number): Buffer {
|
||||
if (!value)
|
||||
throw new InvalidValueError('DPT5: cannot write null value');
|
||||
|
||||
let buf = Buffer.alloc(1);
|
||||
buf.writeUInt8(value, 0)
|
||||
return buf;
|
||||
|
||||
}
|
||||
|
||||
subtypes: {
|
||||
// 5.001 percentage (0=0..ff=100%)
|
||||
"001": {
|
||||
"name": "DPT_Scaling",
|
||||
"desc": "percent",
|
||||
"unit": "%",
|
||||
"scalar_range": [0, 100]
|
||||
},
|
||||
|
||||
// 5.003 angle (degrees 0=0, ff=360)
|
||||
"003": {
|
||||
"name": "DPT_Angle",
|
||||
"desc": "angle degrees",
|
||||
"unit": "°",
|
||||
"scalar_range": [0, 360]
|
||||
},
|
||||
|
||||
// 5.004 percentage (0..255%)
|
||||
"004": {
|
||||
"name": "DPT_Percent_U8",
|
||||
"desc": "percent",
|
||||
"unit": "%",
|
||||
},
|
||||
|
||||
// 5.005 ratio (0..255)
|
||||
"005": {
|
||||
"name": "DPT_DecimalFactor",
|
||||
"desc": "ratio",
|
||||
"unit": "ratio",
|
||||
},
|
||||
|
||||
// 5.006 tariff (0..255)
|
||||
"006": {
|
||||
"name": "DPT_Tariff",
|
||||
"desc": "tariff",
|
||||
"unit": "tariff",
|
||||
},
|
||||
|
||||
// 5.010 counter pulses (0..255)
|
||||
"010": {
|
||||
"name": "DPT_Value_1_Ucount",
|
||||
"desc": "counter pulses",
|
||||
"unit": "pulses",
|
||||
},
|
||||
}
|
||||
}
|
58
src/DPT6.ts
Normal file
58
src/DPT6.ts
Normal file
@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
export class DPT6 implements DPT {
|
||||
id = '6';
|
||||
name = "8-bit signed value";
|
||||
bufferLength = 1;
|
||||
range = [-128, 127];
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): number {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT1. Expected ${this.bufferLength}.`);
|
||||
|
||||
const value = buffer.readInt8(0)
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: number): Buffer {
|
||||
if (!value)
|
||||
throw new InvalidValueError('DPT6: cannot write null value');
|
||||
|
||||
if (value < this.range[0] || value > this.range[1])
|
||||
throw new InvalidValueError(`DPT6: Value ${value} out of range [${this.range[0]}, ${this.range[1]}].`);
|
||||
|
||||
let buf = Buffer.alloc(this.bufferLength);
|
||||
buf.writeInt8(value, 0)
|
||||
return buf;
|
||||
}
|
||||
|
||||
subtypes: {
|
||||
// 6.001 percentage (-128%..127%)
|
||||
"001": {
|
||||
"name": "DPT_Switch", "desc": "percent",
|
||||
"unit": "%",
|
||||
},
|
||||
|
||||
// 6.002 counter pulses (-128..127)
|
||||
"010": {
|
||||
"name": "DPT_Bool", "desc": "counter pulses",
|
||||
"unit": "pulses"
|
||||
},
|
||||
};
|
||||
}
|
134
src/DPT7.ts
Normal file
134
src/DPT7.ts
Normal file
@ -0,0 +1,134 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
export class DPT7 implements DPT {
|
||||
id = '7';
|
||||
name = '16-bit unsigned value';
|
||||
bufferLength = 2
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): number {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT1. Expected ${this.bufferLength}.`);
|
||||
|
||||
const value = buffer.readUInt16BE(0)
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: number): Buffer {
|
||||
if (!value)
|
||||
throw new InvalidValueError('DPT7: cannot write null value');
|
||||
|
||||
if (value < 0)
|
||||
throw new InvalidValueError(`DPT7: Cannot write negative value ${value}`);
|
||||
|
||||
let buf = Buffer.alloc(this.bufferLength);
|
||||
buf.writeUInt16BE(value, 0)
|
||||
return buf;
|
||||
}
|
||||
|
||||
subtypes: {
|
||||
// 7.001 pulses
|
||||
"001": {
|
||||
"use": "G",
|
||||
"name": "DPT_Value_2_Ucount",
|
||||
"desc": "pulses",
|
||||
"unit": "pulses"
|
||||
},
|
||||
|
||||
// 7.002 time(ms)
|
||||
"002": {
|
||||
"use": "G",
|
||||
"name": "DPT_TimePeriodMsec",
|
||||
"desc": "time (ms)",
|
||||
"unit": "milliseconds"
|
||||
},
|
||||
|
||||
// 7.003 time (10ms)
|
||||
"003": {
|
||||
"use": "G",
|
||||
"name": "DPT_TimePeriod10Msec",
|
||||
"desc": "time (10ms)",
|
||||
"unit": "centiseconds"
|
||||
},
|
||||
|
||||
// 7.004 time (100ms)
|
||||
"004": {
|
||||
"use": "G",
|
||||
"name": "DPT_TimePeriod100Msec",
|
||||
"desc": "time (100ms)",
|
||||
"unit": "deciseconds"
|
||||
},
|
||||
|
||||
// 7.005 time (sec)
|
||||
"005": {
|
||||
"use": "G",
|
||||
"name": "DPT_TimePeriodSec",
|
||||
"desc": "time (s)",
|
||||
"unit": "seconds"
|
||||
},
|
||||
|
||||
// 7.006 time (min)
|
||||
"006": {
|
||||
"use": "G",
|
||||
"name": "DPT_TimePeriodMin",
|
||||
"desc": "time (min)",
|
||||
"unit": "minutes"
|
||||
},
|
||||
|
||||
// 7.007 time (hour)
|
||||
"007": {
|
||||
"use": "G",
|
||||
"name": "DPT_TimePeriodHrs",
|
||||
"desc": "time (hrs)",
|
||||
"unit": "hours"
|
||||
},
|
||||
|
||||
// 7.010 DPT_PropDataType
|
||||
// not to be used in runtime communications!
|
||||
"010": {
|
||||
"use": "FB",
|
||||
"name": "DPT_PropDataType",
|
||||
"desc": "Identifier Interface Object Property data type "
|
||||
},
|
||||
|
||||
// 7.011
|
||||
"011": {
|
||||
"use": "FB SAB",
|
||||
"name": "DPT_Length_mm",
|
||||
"desc": "Length in mm",
|
||||
"unit": "mm"
|
||||
},
|
||||
|
||||
// 7.012
|
||||
"012": {
|
||||
"use": "FB",
|
||||
"name": "DPT_UEICurrentmA",
|
||||
"desc": "bus power supply current (mA)",
|
||||
"unit": "mA"
|
||||
},
|
||||
|
||||
// 7.013
|
||||
"013": {
|
||||
"use": "FB",
|
||||
"name": "DPT_Brightness",
|
||||
"desc": "interior brightness",
|
||||
"unit": "lux"
|
||||
}
|
||||
};
|
||||
|
||||
}
|
111
src/DPT8.ts
Normal file
111
src/DPT8.ts
Normal file
@ -0,0 +1,111 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
export class DPT8 implements DPT {
|
||||
id = '8';
|
||||
name = '16-bit signed value';
|
||||
bufferLength = 2;
|
||||
"range" = [-32768, 32767];
|
||||
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the DPT value
|
||||
*/
|
||||
decoder(buffer: Buffer): number {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT1. Expected ${this.bufferLength}.`);
|
||||
|
||||
const value = buffer.readInt16BE(0)
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: number): Buffer {
|
||||
if (!value)
|
||||
throw new InvalidValueError('DPT8: cannot write null value');
|
||||
|
||||
if (value < this.range[0] || value > this.range[1])
|
||||
throw new InvalidValueError(`DPT6: Value ${value} out of range [${this.range[0]}, ${this.range[1]}].`);
|
||||
|
||||
let buf = Buffer.alloc(this.bufferLength);
|
||||
buf.writeInt16BE(value, 0)
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
subtypes: {
|
||||
// 8.001 pulses difference
|
||||
"001": {
|
||||
"name": "DPT_Value_2_Count",
|
||||
"desc": "pulses",
|
||||
"unit": "pulses"
|
||||
},
|
||||
|
||||
// 8.002 time lag (ms)
|
||||
"002": {
|
||||
"name": "DPT_DeltaTimeMsec",
|
||||
"desc": "time lag(ms)",
|
||||
"unit": "milliseconds"
|
||||
},
|
||||
|
||||
// 8.003 time lag (10ms)
|
||||
"003": {
|
||||
"name": "DPT_DeltaTime10Msec",
|
||||
"desc": "time lag(10ms)",
|
||||
"unit": "centiseconds"
|
||||
},
|
||||
|
||||
// 8.004 time lag (100ms)
|
||||
"004": {
|
||||
"name": "DPT_DeltaTime100Msec",
|
||||
"desc": "time lag(100ms)",
|
||||
"unit": "deciseconds"
|
||||
},
|
||||
|
||||
// 8.005 time lag (sec)
|
||||
"005": {
|
||||
"name": "DPT_DeltaTimeSec",
|
||||
"desc": "time lag(s)",
|
||||
"unit": "seconds"
|
||||
},
|
||||
|
||||
// 8.006 time lag (min)
|
||||
"006": {
|
||||
"name": "DPT_DeltaTimeMin",
|
||||
"desc": "time lag(min)",
|
||||
"unit": "minutes"
|
||||
},
|
||||
|
||||
// 8.007 time lag (hour)
|
||||
"007": {
|
||||
"name": "DPT_DeltaTimeHrs",
|
||||
"desc": "time lag(hrs)",
|
||||
"unit": "hours"
|
||||
},
|
||||
|
||||
// 8.010 percentage difference (%)
|
||||
"010": {
|
||||
"name": "DPT_Percent_V16",
|
||||
"desc": "percentage difference",
|
||||
"unit": "%"
|
||||
},
|
||||
|
||||
// 8.011 rotation angle (deg)
|
||||
"011": {
|
||||
"name": "DPT_RotationAngle",
|
||||
"desc": "angle(degrees)",
|
||||
"unit": "°"
|
||||
},
|
||||
};
|
||||
|
||||
}
|
232
src/DPT9.ts
Normal file
232
src/DPT9.ts
Normal file
@ -0,0 +1,232 @@
|
||||
'use strict';
|
||||
import { BufferLengthError } from './errors/BufferLengthError';
|
||||
import { InvalidValueError } from './errors/InvalidValueError';
|
||||
import { DPT } from './definitions';
|
||||
|
||||
function ldexp(mantissa: number, exponent: number): number {
|
||||
return exponent > 1023 // avoid multiplying by infinity
|
||||
? mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023)
|
||||
: exponent < -1074 // avoid multiplying by zero
|
||||
? mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074)
|
||||
: mantissa * Math.pow(2, exponent);
|
||||
}
|
||||
function frexp(value: number): number[] {
|
||||
if (value === 0) return [0, 0];
|
||||
const data = new DataView(new ArrayBuffer(8));
|
||||
data.setFloat64(0, value);
|
||||
let bits = (data.getUint32(0) >>> 20) & 0x7ff;
|
||||
if (bits === 0) {
|
||||
data.setFloat64(0, value * Math.pow(2, 64));
|
||||
bits = ((data.getUint32(0) >>> 20) & 0x7ff) - 64;
|
||||
}
|
||||
const exponent = bits - 1022;
|
||||
const mantissa = ldexp(value, -exponent);
|
||||
return [mantissa, exponent];
|
||||
};
|
||||
|
||||
export class DPT9 implements DPT {
|
||||
id = '9';
|
||||
name = '16-bit floating point value';
|
||||
bufferLength = 2;
|
||||
/**
|
||||
* Decode a buffer
|
||||
*
|
||||
* @param buffer the buffer
|
||||
* @returns the on/off value
|
||||
*/
|
||||
decoder(buffer: Buffer): number {
|
||||
if (buffer.length !== this.bufferLength)
|
||||
throw new BufferLengthError(`Invalid buffer length ${buffer.length}/${buffer} for DPT1. Expected ${this.bufferLength}.`);
|
||||
|
||||
const sign = buffer[0] >> 7;
|
||||
const exponent = (buffer[0] & 0b01111000) >> 3;
|
||||
let mantissa = 256 * (buffer[0] & 0b00000111) + buffer[1];
|
||||
if (sign) mantissa = ~(mantissa ^ 2047);
|
||||
|
||||
return parseFloat(ldexp(0.01 * mantissa, exponent).toPrecision(15));
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode a buffer
|
||||
*
|
||||
* @param value the value to be converted to buffer
|
||||
* @returns the buffer
|
||||
*/
|
||||
encoder(value: number): Buffer {
|
||||
if (value === undefined || value === null)
|
||||
throw new InvalidValueError('DPT9: cannot write null value');
|
||||
|
||||
if (!isFinite(value))
|
||||
throw new InvalidValueError('DPT9: cannot write non-numeric or undefined value');
|
||||
|
||||
const arr = frexp(value);
|
||||
const [mantissa, exponent] = arr;
|
||||
// find the minimum exponent that will upsize the normalized mantissa (0,5 to 1 range)
|
||||
// in order to fit in 11 bits ([-2048, 2047])
|
||||
let max_mantissa = 0;
|
||||
let e: number
|
||||
for (e = exponent; e >= -15; e--) {
|
||||
max_mantissa = ldexp(100 * mantissa, e);
|
||||
if (max_mantissa > -2048 && max_mantissa < 2047) break;
|
||||
}
|
||||
const sign = mantissa < 0 ? 1 : 0;
|
||||
const mant = mantissa < 0 ? ~(max_mantissa ^ 2047) : max_mantissa;
|
||||
const exp = exponent - e;
|
||||
// yucks
|
||||
return Buffer.from([(sign << 7) + (exp << 3) + (mant >> 8), mant % 256]);
|
||||
}
|
||||
|
||||
subtypes: {
|
||||
// 9.001 temperature (oC)
|
||||
'001': {
|
||||
name: 'DPT_Value_Temp',
|
||||
desc: 'temperature',
|
||||
unit: '°C',
|
||||
range: [-273, 670760],
|
||||
},
|
||||
|
||||
// 9.002 temperature difference (oC)
|
||||
'002': {
|
||||
name: 'DPT_Value_Tempd',
|
||||
desc: 'temperature difference',
|
||||
unit: '°C',
|
||||
range: [-670760, 670760],
|
||||
},
|
||||
|
||||
// 9.003 kelvin/hour (K/h)
|
||||
'003': {
|
||||
name: 'DPT_Value_Tempa',
|
||||
desc: 'kelvin/hour',
|
||||
unit: '°K/h',
|
||||
range: [-670760, 670760],
|
||||
},
|
||||
|
||||
// 9.004 lux (Lux)
|
||||
'004': {
|
||||
name: 'DPT_Value_Lux',
|
||||
desc: 'lux',
|
||||
unit: 'lux',
|
||||
range: [0, 670760],
|
||||
},
|
||||
|
||||
// 9.005 speed (m/s)
|
||||
'005': {
|
||||
name: 'DPT_Value_Wsp',
|
||||
desc: 'wind speed',
|
||||
unit: 'm/s',
|
||||
range: [0, 670760],
|
||||
},
|
||||
|
||||
// 9.006 pressure (Pa)
|
||||
'006': {
|
||||
name: 'DPT_Value_Pres',
|
||||
desc: 'pressure',
|
||||
unit: 'Pa',
|
||||
range: [0, 670760],
|
||||
},
|
||||
|
||||
// 9.007 humidity (%)
|
||||
'007': {
|
||||
name: 'DPT_Value_Humidity',
|
||||
desc: 'humidity',
|
||||
unit: '%',
|
||||
range: [0, 670760],
|
||||
},
|
||||
|
||||
// 9.008 parts/million (ppm)
|
||||
'008': {
|
||||
name: 'DPT_Value_AirQuality',
|
||||
desc: 'air quality',
|
||||
unit: 'ppm',
|
||||
range: [0, 670760],
|
||||
},
|
||||
|
||||
// 9.010 time (s)
|
||||
'010': {
|
||||
name: 'DPT_Value_Time1',
|
||||
desc: 'time(sec)',
|
||||
unit: 's',
|
||||
range: [-670760, 670760],
|
||||
},
|
||||
|
||||
// 9.011 time (ms)
|
||||
'011': {
|
||||
name: 'DPT_Value_Time2',
|
||||
desc: 'time(msec)',
|
||||
unit: 'ms',
|
||||
range: [-670760, 670760],
|
||||
},
|
||||
|
||||
// 9.020 voltage (mV)
|
||||
'020': {
|
||||
name: 'DPT_Value_Volt',
|
||||
desc: 'voltage',
|
||||
unit: 'mV',
|
||||
range: [-670760, 670760],
|
||||
},
|
||||
|
||||
// 9.021 current (mA)
|
||||
'021': {
|
||||
name: 'DPT_Value_Curr',
|
||||
desc: 'current',
|
||||
unit: 'mA',
|
||||
range: [-670760, 670760],
|
||||
},
|
||||
|
||||
// 9.022 power density (W/m2)
|
||||
'022': {
|
||||
name: 'DPT_PowerDensity',
|
||||
desc: 'power density',
|
||||
unit: 'W/m²',
|
||||
range: [-670760, 670760],
|
||||
},
|
||||
|
||||
// 9.023 kelvin/percent (K/%)
|
||||
'023': {
|
||||
name: 'DPT_KelvinPerPercent',
|
||||
desc: 'Kelvin / %',
|
||||
unit: 'K/%',
|
||||
range: [-670760, 670760],
|
||||
},
|
||||
|
||||
// 9.024 power (kW)
|
||||
'024': {
|
||||
name: 'DPT_Power',
|
||||
desc: 'power (kW)',
|
||||
unit: 'kW',
|
||||
range: [-670760, 670760],
|
||||
},
|
||||
|
||||
// 9.025 volume flow (l/h)
|
||||
'025': {
|
||||
name: 'DPT_Value_Volume_Flow',
|
||||
desc: 'volume flow',
|
||||
unit: 'l/h',
|
||||
range: [-670760, 670760],
|
||||
},
|
||||
|
||||
// 9.026 rain amount (l/m2)
|
||||
'026': {
|
||||
name: 'DPT_Rain_Amount',
|
||||
desc: 'rain amount',
|
||||
unit: 'l/m²',
|
||||
range: [-670760, 670760],
|
||||
},
|
||||
|
||||
// 9.027 temperature (Fahrenheit)
|
||||
'027': {
|
||||
name: 'DPT_Value_Temp_F',
|
||||
desc: 'temperature (F)',
|
||||
unit: '°F',
|
||||
range: [-459.6, 670760],
|
||||
},
|
||||
|
||||
// 9.028 wind speed (km/h)
|
||||
'028': {
|
||||
name: 'DPT_Value_Wsp_kmh',
|
||||
desc: 'wind speed (km/h)',
|
||||
unit: 'km/h',
|
||||
range: [0, 670760],
|
||||
},
|
||||
};
|
||||
}
|
113
src/DataPointType.ts
Normal file
113
src/DataPointType.ts
Normal file
@ -0,0 +1,113 @@
|
||||
'use strict';
|
||||
|
||||
import { Encoder, Decoder, DPT } from './definitions';
|
||||
|
||||
import { DPT1 } from './DPT1';
|
||||
import { DPT2 } from './DPT2';
|
||||
import { DPT3 } from './DPT3';
|
||||
import { DPT4 } from './DPT4';
|
||||
import { DPT5 } from './DPT5';
|
||||
import { DPT6 } from './DPT6';
|
||||
import { DPT7 } from './DPT7';
|
||||
import { DPT8 } from './DPT8';
|
||||
import { DPT9 } from './DPT9';
|
||||
import { DPT10 } from './DPT10';
|
||||
import { DPT11 } from './DPT11';
|
||||
import { DPT12 } from './DPT12';
|
||||
import { DPT13 } from './DPT13';
|
||||
import { DPT14 } from './DPT14';
|
||||
import { DPT15 } from './DPT15';
|
||||
import { DPT16 } from './DPT16';
|
||||
import { DPT17 } from './DPT17';
|
||||
import { DPT18 } from './DPT18';
|
||||
import { DPT19 } from './DPT19';
|
||||
import { DPT20 } from './DPT20';
|
||||
import { DPT21 } from './DPT21';
|
||||
//import { DPT22 } from './DPT22';
|
||||
import { DPT232 } from './DPT232';
|
||||
import { DPT237 } from './DPT237';
|
||||
import { DPT238 } from './DPT238';
|
||||
|
||||
export class DataPointType {
|
||||
|
||||
get type(): string {
|
||||
return this._type;
|
||||
}
|
||||
|
||||
get subtype(): string {
|
||||
return this._subtype;
|
||||
}
|
||||
|
||||
/**
|
||||
* @property {DPTYPE} DPT1
|
||||
* @property {DPTYPE} DPT2
|
||||
* @property {DPTYPE} DPT3
|
||||
* @property {DPTYPE} DPT4
|
||||
* @property {DPTYPE} DPT5
|
||||
* @property {DPTYPE} DPT6
|
||||
* @property {DPTYPE} DPT7
|
||||
* @property {DPTYPE} DPT8
|
||||
* @property {DPTYPE} DPT9
|
||||
* @property {DPTYPE} DPT10
|
||||
* @property {DPTYPE} DPT11
|
||||
* @property {DPTYPE} DPT12
|
||||
* @property {DPTYPE} DPT13
|
||||
* @property {DPTYPE} DPT14
|
||||
* @property {DPTYPE} DPT15
|
||||
* @property {DPTYPE} DPT16
|
||||
* @property {DPTYPE} DPT17
|
||||
* @property {DPTYPE} DPT18
|
||||
* @property {DPTYPE} DPT19
|
||||
* @property {DPTYPE} DPT20
|
||||
*/
|
||||
static get TYPES(): { [index: string]: DPT | null } {
|
||||
return {
|
||||
DPT1: new DPT1(),
|
||||
DPT2: new DPT2(),
|
||||
DPT3: new DPT3(),
|
||||
DPT4: new DPT4(),
|
||||
DPT5: new DPT5(),
|
||||
DPT6: new DPT6(),
|
||||
DPT7: new DPT7(),
|
||||
DPT8: new DPT8(),
|
||||
DPT9: new DPT9(),
|
||||
DPT10: new DPT10(),
|
||||
DPT11: new DPT11(),
|
||||
DPT12: new DPT12(),
|
||||
DPT13: new DPT13(),
|
||||
DPT14: new DPT14(),
|
||||
DPT15: new DPT15(),
|
||||
DPT16: new DPT16(),
|
||||
DPT17: new DPT17(),
|
||||
DPT18: new DPT18(),
|
||||
DPT19: new DPT19(),
|
||||
DPT20: new DPT20(),
|
||||
DPT21: new DPT21(),
|
||||
//DPT22: new DPT22(),
|
||||
|
||||
DPT232: new DPT232(),
|
||||
DPT237: new DPT237(),
|
||||
DPT238: new DPT238()
|
||||
};
|
||||
}
|
||||
|
||||
constructor(private _type: string, private _subtype: string, private _encoder: Encoder, private _decoder: Decoder) {
|
||||
}
|
||||
|
||||
static validType(text: string): boolean {
|
||||
const m = text.toUpperCase().match(/(?:DPT)?(\d+)(\.(\d+))?/);
|
||||
return m != null;
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `${this.type}.${this.subtype}`;
|
||||
}
|
||||
|
||||
decode(buffer: Buffer): string | number {
|
||||
return this._decoder(buffer);
|
||||
}
|
||||
|
||||
encode(value: string | number): Buffer {
|
||||
return this._encoder(value);
|
||||
}
|
||||
}
|
35
src/definitions.ts
Normal file
35
src/definitions.ts
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Definitions for the KNX library
|
||||
*/
|
||||
|
||||
export type Encoder = (value: any) => Buffer;
|
||||
export type Decoder = (buffer: Buffer) => any;
|
||||
|
||||
/**
|
||||
* @property {string} use
|
||||
* @property {string} name
|
||||
* @property {string} desc
|
||||
* @property {any} enc
|
||||
*/
|
||||
export interface DPTSubType {
|
||||
use?: string;
|
||||
name: string;
|
||||
desc: string;
|
||||
enc?: any;
|
||||
|
||||
unit?: string;
|
||||
range?: number[];
|
||||
}
|
||||
|
||||
/**
|
||||
* DPT generic interface
|
||||
*/
|
||||
export interface DPT {
|
||||
id: string;
|
||||
name: string;
|
||||
bufferLength: number;
|
||||
subtypes: { [index: string]: DPTSubType };
|
||||
|
||||
decoder: Decoder;
|
||||
encoder: Encoder;
|
||||
}
|
2
src/errors/BufferLengthError.ts
Normal file
2
src/errors/BufferLengthError.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export class BufferLengthError extends Error {
|
||||
}
|
2
src/errors/InvalidValueError.ts
Normal file
2
src/errors/InvalidValueError.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export class InvalidValueError extends Error {
|
||||
}
|
67
tests/DPT1.test.ts
Normal file
67
tests/DPT1.test.ts
Normal file
@ -0,0 +1,67 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT1 } from "../src/DPT1"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
let bufferTrue = Buffer.from([1])
|
||||
let bufferFalse = Buffer.from([0])
|
||||
let bufferInvalid = Buffer.from([5])
|
||||
let bufferEmpty = Buffer.from([])
|
||||
let bufferBiggerSize = Buffer.from([1, 0])
|
||||
|
||||
|
||||
describe("Test DPT1", (): void => {
|
||||
|
||||
let dpt = new DPT1();
|
||||
|
||||
it("Decode true", async function () {
|
||||
const value = dpt.decoder(bufferTrue)
|
||||
expect(value).is.equal(1);
|
||||
});
|
||||
|
||||
it("Decode false", async function () {
|
||||
const value = dpt.decoder(bufferFalse)
|
||||
expect(value).is.equal(0);
|
||||
});
|
||||
|
||||
it("Decode invalid value buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferInvalid)
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
|
||||
it("Decode empty buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferEmpty)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
it("Decode oversized buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferBiggerSize)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
it("encode true", async function () {
|
||||
const value = dpt.encoder(1)
|
||||
expect(compareBuffers(value, bufferTrue)).is.true;
|
||||
});
|
||||
|
||||
it("encode false", async function () {
|
||||
const value = dpt.encoder(0)
|
||||
expect(compareBuffers(value, bufferFalse)).is.true;
|
||||
});
|
||||
|
||||
it("encode invalid", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder(5)
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
});
|
106
tests/DPT10.test.ts
Normal file
106
tests/DPT10.test.ts
Normal file
@ -0,0 +1,106 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT10 } from "../src/DPT10"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
let date = new Date(Date.parse('04 Mar 2022 00:12:00 GMT'))
|
||||
let dayOfWeek = date.getDay()
|
||||
let hour = date.getHours()
|
||||
let minute = date.getMinutes()
|
||||
let second = date.getSeconds()
|
||||
let bufferValue = Buffer.from([(dayOfWeek << 5) + hour, minute, second])
|
||||
|
||||
let today = new Date()
|
||||
today.setDate(today.getDate() + dayOfWeek - today.getDay())
|
||||
today.setHours(hour)
|
||||
today.setMinutes(minute)
|
||||
today.setSeconds(second)
|
||||
today.setMilliseconds(0)
|
||||
|
||||
|
||||
let bufferEmpty = Buffer.from([])
|
||||
let bufferBiggerSize = Buffer.from([0xff, 0xff, 0x63, 0xc0])
|
||||
|
||||
|
||||
describe("Test DPT10", (): void => {
|
||||
|
||||
let dpt = new DPT10();
|
||||
|
||||
it("Decode buffer acceptable", async function () {
|
||||
expect(dpt.decoder(bufferValue).getTime()).is.equal(today.getTime());
|
||||
});
|
||||
|
||||
it("Decode empty buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferEmpty)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
it("Decode oversized buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferBiggerSize)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
it("Decode invalid buffers", async function () {
|
||||
let bufferErrorHour = Buffer.from([(dayOfWeek << 5) + 24, minute, second])
|
||||
let bufferErrorMinute = Buffer.from([(dayOfWeek << 5) + hour, 70, second])
|
||||
let bufferErrorSecond = Buffer.from([(dayOfWeek << 5) + hour, minute, 70])
|
||||
|
||||
var test_bufferErrorHour = function () {
|
||||
const value = dpt.decoder(bufferErrorHour)
|
||||
}
|
||||
var test_bufferErrorMinute = function () {
|
||||
const value = dpt.decoder(bufferErrorMinute)
|
||||
}
|
||||
var test_bufferErrorSecond = function () {
|
||||
const value = dpt.decoder(bufferErrorSecond)
|
||||
}
|
||||
|
||||
expect(test_bufferErrorHour).to.throw(InvalidValueError);
|
||||
expect(test_bufferErrorMinute).to.throw(InvalidValueError);
|
||||
expect(test_bufferErrorSecond).to.throw(InvalidValueError);
|
||||
});
|
||||
|
||||
|
||||
/* Encoder tests */
|
||||
it("encode valid date", async function () {
|
||||
expect(compareBuffers(dpt.encoder(date), bufferValue)).is.true;
|
||||
});
|
||||
|
||||
it("encode valid number", async function () {
|
||||
expect(compareBuffers(dpt.encoder(date.getTime()), bufferValue)).is.true;
|
||||
});
|
||||
|
||||
it("encode valid string", async function () {
|
||||
|
||||
let todayTest = new Date()
|
||||
|
||||
todayTest.setHours(hour)
|
||||
todayTest.setMinutes(minute)
|
||||
todayTest.setSeconds(second)
|
||||
todayTest.setMilliseconds(0)
|
||||
let todayBuffer = dpt.encoder(todayTest)
|
||||
|
||||
expect(compareBuffers(dpt.encoder(`${hour}:${minute}:${second}`), todayBuffer)).is.true;
|
||||
});
|
||||
|
||||
it("encode invalid string", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder("10-10-10")
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
|
||||
it("encode undefined", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder(undefined)
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
});
|
13
tests/DPT11.test.ts
Normal file
13
tests/DPT11.test.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT11 } from "../src/DPT11"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
describe("Test DPT11", (): void => {
|
||||
|
||||
let dpt = new DPT11();
|
||||
|
||||
});
|
13
tests/DPT12.test.ts
Normal file
13
tests/DPT12.test.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT12 } from "../src/DPT12"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
describe("Test DPT12", (): void => {
|
||||
|
||||
let dpt = new DPT12();
|
||||
|
||||
});
|
13
tests/DPT13.test.ts
Normal file
13
tests/DPT13.test.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT13 } from "../src/DPT13"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
describe("Test DPT13", (): void => {
|
||||
|
||||
let dpt = new DPT13();
|
||||
|
||||
});
|
13
tests/DPT14.test.ts
Normal file
13
tests/DPT14.test.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT14 } from "../src/DPT14"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
describe("Test DPT14", (): void => {
|
||||
|
||||
let dpt = new DPT14();
|
||||
|
||||
});
|
103
tests/DPT15.test.ts
Normal file
103
tests/DPT15.test.ts
Normal file
@ -0,0 +1,103 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT15, DPT15Result } from "../src/DPT15"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
describe("Test DPT15", (): void => {
|
||||
|
||||
let dpt = new DPT15();
|
||||
|
||||
let value: DPT15Result = {
|
||||
U: 0x03,
|
||||
V: 0x09,
|
||||
W: 0x04,
|
||||
X: 0x08,
|
||||
Y: 0x00,
|
||||
Z: 0x02,
|
||||
E: 0x01,
|
||||
P: 0x00,
|
||||
D: 0x01,
|
||||
C: 0x00,
|
||||
N: 0x05
|
||||
}
|
||||
|
||||
let bufferValid = Buffer.from([0x39, 0x48, 0x02, 0xa5])
|
||||
let bufferInvalid = Buffer.from([0x39, 0xc8, 0xa2, 0xa5])
|
||||
|
||||
let bufferEmpty = Buffer.from([])
|
||||
let bufferBiggerSize = Buffer.from([0xff, 0xff, 0x63, 0xc0, 0x00])
|
||||
|
||||
it("Decode buffer acceptable", async function () {
|
||||
const decoded = dpt.decoder(bufferValid)
|
||||
expect(decoded.U).is.equal(value.U);
|
||||
expect(decoded.V).is.equal(value.V);
|
||||
expect(decoded.W).is.equal(value.W);
|
||||
expect(decoded.X).is.equal(value.X);
|
||||
expect(decoded.Y).is.equal(value.Y);
|
||||
expect(decoded.Z).is.equal(value.Z);
|
||||
expect(decoded.E).is.equal(value.E);
|
||||
expect(decoded.P).is.equal(value.P);
|
||||
expect(decoded.D).is.equal(value.D);
|
||||
expect(decoded.C).is.equal(value.C);
|
||||
expect(decoded.N).is.equal(value.N);
|
||||
});
|
||||
|
||||
it("Decode empty buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferEmpty)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
it("Decode oversized buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferBiggerSize)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
it("Decode invalid buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferInvalid)
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
|
||||
/* Encoder */
|
||||
|
||||
it("encode valid", async function () {
|
||||
expect(compareBuffers(dpt.encoder(value), bufferValid)).is.true;
|
||||
});
|
||||
|
||||
it("encode undefined", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder(undefined)
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
|
||||
|
||||
it("encode invalid", async function () {
|
||||
var testFunction = function () {
|
||||
let invalidValue: DPT15Result = {
|
||||
U: 0x03,
|
||||
V: 0x0a, // invalid value as per spec
|
||||
W: 0x04,
|
||||
X: 0x08,
|
||||
Y: 0x00,
|
||||
Z: 0x02,
|
||||
E: 0x01,
|
||||
P: 0x00,
|
||||
D: 0x01,
|
||||
C: 0x00,
|
||||
N: 0x05
|
||||
}
|
||||
const result = dpt.encoder(invalidValue)
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
|
||||
});
|
13
tests/DPT16.test.ts
Normal file
13
tests/DPT16.test.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT16 } from "../src/DPT16"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
describe("Test DPT16", (): void => {
|
||||
|
||||
let dpt = new DPT16();
|
||||
|
||||
});
|
13
tests/DPT17.test.ts
Normal file
13
tests/DPT17.test.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT17 } from "../src/DPT17"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
describe("Test DPT17", (): void => {
|
||||
|
||||
let dpt = new DPT17();
|
||||
|
||||
});
|
13
tests/DPT18.test.ts
Normal file
13
tests/DPT18.test.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT18 } from "../src/DPT18"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
describe("Test DPT18", (): void => {
|
||||
|
||||
let dpt = new DPT18();
|
||||
|
||||
});
|
13
tests/DPT19.test.ts
Normal file
13
tests/DPT19.test.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT19 } from "../src/DPT19"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
describe("Test DPT19", (): void => {
|
||||
|
||||
let dpt = new DPT19();
|
||||
|
||||
});
|
74
tests/DPT2.test.ts
Normal file
74
tests/DPT2.test.ts
Normal file
@ -0,0 +1,74 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT2 } from "../src/DPT2"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
let bufferZeroZero = Buffer.from([0])
|
||||
let bufferZeroOne = Buffer.from([1])
|
||||
let bufferOneZero = Buffer.from([2])
|
||||
let bufferOneOne = Buffer.from([3])
|
||||
|
||||
let bufferEmpty = Buffer.from([])
|
||||
let bufferBiggerSize = Buffer.from([1, 0])
|
||||
|
||||
|
||||
describe("Test DPT2", (): void => {
|
||||
|
||||
let dpt = new DPT2();
|
||||
|
||||
it("Decode buffer00", async function () {
|
||||
const value = dpt.decoder(bufferZeroZero)
|
||||
expect(value.data).is.false;
|
||||
expect(value.priority).is.false;
|
||||
});
|
||||
|
||||
it("Decode buffer01", async function () {
|
||||
const value = dpt.decoder(bufferZeroOne)
|
||||
expect(value.data).is.true;
|
||||
expect(value.priority).is.false;
|
||||
});
|
||||
|
||||
it("Decode buffer10", async function () {
|
||||
const value = dpt.decoder(bufferOneZero)
|
||||
expect(value.data).is.false;
|
||||
expect(value.priority).is.true;
|
||||
});
|
||||
|
||||
it("Decode buffer11", async function () {
|
||||
const value = dpt.decoder(bufferOneOne)
|
||||
expect(value.data).is.true;
|
||||
expect(value.priority).is.true;
|
||||
});
|
||||
|
||||
|
||||
it("Decode empty buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferEmpty)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
it("Decode oversized buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferBiggerSize)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
it("encode true", async function () {
|
||||
expect(compareBuffers(dpt.encoder({ data: false, priority: false }), bufferZeroZero)).is.true;
|
||||
expect(compareBuffers(dpt.encoder({ data: false, priority: true }), bufferOneZero)).is.true;
|
||||
expect(compareBuffers(dpt.encoder({ data: true, priority: false }), bufferZeroOne)).is.true;
|
||||
expect(compareBuffers(dpt.encoder({ data: true, priority: true }), bufferOneOne)).is.true;
|
||||
});
|
||||
|
||||
it("encode invalid", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder(undefined)
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
});
|
13
tests/DPT20.test.ts
Normal file
13
tests/DPT20.test.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT20 } from "../src/DPT20"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
describe("Test DPT20", (): void => {
|
||||
|
||||
let dpt = new DPT20();
|
||||
|
||||
});
|
13
tests/DPT21.test.ts
Normal file
13
tests/DPT21.test.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT21 } from "../src/DPT21"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
describe("Test DPT21", (): void => {
|
||||
|
||||
let dpt = new DPT21();
|
||||
|
||||
});
|
85
tests/DPT232.test.ts
Normal file
85
tests/DPT232.test.ts
Normal file
@ -0,0 +1,85 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT232, DPT232Result } from "../src/DPT232"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
let value: DPT232Result = { red: 127, green: 200, blue: 20 }
|
||||
|
||||
let buffer = Buffer.from([127, 200, 20])
|
||||
|
||||
|
||||
let bufferEmpty = Buffer.from([])
|
||||
let bufferBiggerSize = Buffer.from([0xff, 0xff, 0x63, 0xc0])
|
||||
|
||||
describe("Test DPT232", (): void => {
|
||||
|
||||
let dpt = new DPT232();
|
||||
|
||||
it("Decode buffer acceptable", async function () {
|
||||
const v = dpt.decoder(buffer)
|
||||
expect(v.red).is.equal(value.red);
|
||||
expect(v.green).is.equal(value.green);
|
||||
expect(v.blue).is.equal(value.blue);
|
||||
});
|
||||
|
||||
|
||||
it("Decode empty buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferEmpty)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
it("Decode oversized buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferBiggerSize)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
/* Encoder tests */
|
||||
it("encode valid", async function () {
|
||||
expect(compareBuffers(dpt.encoder(value), buffer)).is.true;
|
||||
});
|
||||
|
||||
it("encode invalid", async function () {
|
||||
var testFunctionRedPlus = function () {
|
||||
const value = dpt.encoder({ red: 300, green: 0, blue: 0 })
|
||||
}
|
||||
var testFunctionRedMinus = function () {
|
||||
const value = dpt.encoder({ red: -2, green: 0, blue: 0 })
|
||||
}
|
||||
|
||||
var testFunctionGreenPlus = function () {
|
||||
const value = dpt.encoder({ green: 300, red: 0, blue: 0 })
|
||||
}
|
||||
var testFunctionGreenMinus = function () {
|
||||
const value = dpt.encoder({ green: -2, red: 0, blue: 0 })
|
||||
}
|
||||
|
||||
var testFunctionBluePlus = function () {
|
||||
const value = dpt.encoder({ blue: 300, green: 0, red: 0 })
|
||||
}
|
||||
var testFunctionBlueMinus = function () {
|
||||
const value = dpt.encoder({ blue: -2, green: 0, red: 0 })
|
||||
}
|
||||
|
||||
|
||||
expect(testFunctionRedPlus).to.throw(InvalidValueError);
|
||||
expect(testFunctionRedMinus).to.throw(InvalidValueError);
|
||||
expect(testFunctionGreenPlus).to.throw(InvalidValueError);
|
||||
expect(testFunctionGreenMinus).to.throw(InvalidValueError);
|
||||
expect(testFunctionBluePlus).to.throw(InvalidValueError);
|
||||
expect(testFunctionBlueMinus).to.throw(InvalidValueError);
|
||||
});
|
||||
|
||||
it("encode undefined", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder(undefined)
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
});
|
13
tests/DPT237.test.ts
Normal file
13
tests/DPT237.test.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT237 } from "../src/DPT237"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
describe("Test DPT237", (): void => {
|
||||
|
||||
let dpt = new DPT237();
|
||||
|
||||
});
|
55
tests/DPT238.test.ts
Normal file
55
tests/DPT238.test.ts
Normal file
@ -0,0 +1,55 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT238 } from "../src/DPT238"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
let bufferA = Buffer.from([65])
|
||||
let bufferMax = Buffer.from([254])
|
||||
|
||||
let bufferEmpty = Buffer.from([])
|
||||
let bufferBiggerSize = Buffer.from([1, 0])
|
||||
|
||||
describe("Test DPT238", (): void => {
|
||||
|
||||
let dpt = new DPT238();
|
||||
|
||||
it("Decode buffer common", async function () {
|
||||
const value = dpt.decoder(bufferA)
|
||||
expect(value).is.equal(65);
|
||||
});
|
||||
|
||||
it("Decode buffer max", async function () {
|
||||
const value = dpt.decoder(bufferMax)
|
||||
expect(value).is.equal(254);
|
||||
});
|
||||
|
||||
it("Decode empty buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferEmpty)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
it("Decode oversized buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferBiggerSize)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
/* Encoder tests */
|
||||
it("encode valid", async function () {
|
||||
expect(compareBuffers(dpt.encoder(65), bufferA)).is.true;
|
||||
expect(compareBuffers(dpt.encoder(254), bufferMax)).is.true;
|
||||
});
|
||||
|
||||
it("encode undefined", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder(undefined)
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
});
|
82
tests/DPT3.test.ts
Normal file
82
tests/DPT3.test.ts
Normal file
@ -0,0 +1,82 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT3 } from "../src/DPT3"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
let bufferDecZero = Buffer.from([0])
|
||||
let bufferDecValue = Buffer.from([5])
|
||||
let bufferIncZero = Buffer.from([8])
|
||||
let bufferIncValue = Buffer.from([13])
|
||||
|
||||
let bufferEmpty = Buffer.from([])
|
||||
let bufferBiggerSize = Buffer.from([1, 0])
|
||||
|
||||
describe("Test DPT3", (): void => {
|
||||
|
||||
let dpt = new DPT3();
|
||||
|
||||
it("Decode buffer dec-zero", async function () {
|
||||
const value = dpt.decoder(bufferDecZero)
|
||||
expect(value.data).is.equal(0);
|
||||
expect(value.decr_incr).is.equal(0);
|
||||
});
|
||||
|
||||
it("Decode buffer dec-value", async function () {
|
||||
const value = dpt.decoder(bufferDecValue)
|
||||
expect(value.data).is.equal(5);
|
||||
expect(value.decr_incr).is.equal(0);
|
||||
});
|
||||
|
||||
it("Decode buffer inc-zero", async function () {
|
||||
const value = dpt.decoder(bufferIncZero)
|
||||
expect(value.data).is.equal(0);
|
||||
expect(value.decr_incr).is.equal(1);
|
||||
});
|
||||
|
||||
it("Decode buffer inc-value", async function () {
|
||||
const value = dpt.decoder(bufferIncValue)
|
||||
expect(value.data).is.equal(5);
|
||||
expect(value.decr_incr).is.equal(1);
|
||||
});
|
||||
|
||||
it("Decode empty buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferEmpty)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
it("Decode oversized buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferBiggerSize)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
/* Encode tests */
|
||||
it("encode valid", async function () {
|
||||
expect(compareBuffers(dpt.encoder({ data: 0, decr_incr: 0 }), bufferDecZero)).is.true;
|
||||
expect(compareBuffers(dpt.encoder({ data: 5, decr_incr: 0 }), bufferDecValue)).is.true;
|
||||
expect(compareBuffers(dpt.encoder({ data: 0, decr_incr: 1 }), bufferIncZero)).is.true;
|
||||
expect(compareBuffers(dpt.encoder({ data: 5, decr_incr: 1 }), bufferIncValue)).is.true;
|
||||
});
|
||||
|
||||
it("encode invalid", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder({ data: 0, decr_incr: 3 })
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
|
||||
it("encode undefined", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder(undefined)
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
|
||||
|
||||
});
|
57
tests/DPT4.test.ts
Normal file
57
tests/DPT4.test.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT4 } from "../src/DPT4"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
let bufferA = Buffer.from([65])
|
||||
|
||||
let bufferEmpty = Buffer.from([])
|
||||
let bufferBiggerSize = Buffer.from([1, 0])
|
||||
|
||||
describe("Test DPT4", (): void => {
|
||||
|
||||
let dpt = new DPT4();
|
||||
|
||||
it("Decode buffer with letter [A]", async function () {
|
||||
const value = dpt.decoder(bufferA)
|
||||
expect(value).is.equal('A');
|
||||
});
|
||||
|
||||
it("Decode empty buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferEmpty)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
it("Decode oversized buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferBiggerSize)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
/* Encoder tests */
|
||||
it("encode valid", async function () {
|
||||
expect(compareBuffers(dpt.encoder('A'), bufferA)).is.true;
|
||||
});
|
||||
|
||||
it("encode invalid", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder("\u03c0")
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
|
||||
it("encode undefined", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder(undefined)
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
|
||||
|
||||
});
|
55
tests/DPT5.test.ts
Normal file
55
tests/DPT5.test.ts
Normal file
@ -0,0 +1,55 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT5 } from "../src/DPT5"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
let bufferA = Buffer.from([65])
|
||||
let bufferMax = Buffer.from([254])
|
||||
|
||||
let bufferEmpty = Buffer.from([])
|
||||
let bufferBiggerSize = Buffer.from([1, 0])
|
||||
|
||||
describe("Test DPT5", (): void => {
|
||||
|
||||
let dpt = new DPT5();
|
||||
|
||||
it("Decode buffer common", async function () {
|
||||
const value = dpt.decoder(bufferA)
|
||||
expect(value).is.equal(65);
|
||||
});
|
||||
|
||||
it("Decode buffer max", async function () {
|
||||
const value = dpt.decoder(bufferMax)
|
||||
expect(value).is.equal(254);
|
||||
});
|
||||
|
||||
it("Decode empty buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferEmpty)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
it("Decode oversized buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferBiggerSize)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
/* Encoder tests */
|
||||
it("encode valid", async function () {
|
||||
expect(compareBuffers(dpt.encoder(65), bufferA)).is.true;
|
||||
expect(compareBuffers(dpt.encoder(254), bufferMax)).is.true;
|
||||
});
|
||||
|
||||
it("encode undefined", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder(undefined)
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
});
|
66
tests/DPT6.test.ts
Normal file
66
tests/DPT6.test.ts
Normal file
@ -0,0 +1,66 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT6 } from "../src/DPT6"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
let value: number = 65
|
||||
let overflowValue: number = 4000
|
||||
|
||||
let bufferPositive = Buffer.from([value])
|
||||
let bufferNegative = Buffer.from([-value])
|
||||
|
||||
let bufferEmpty = Buffer.from([])
|
||||
let bufferBiggerSize = Buffer.from([1, 0])
|
||||
|
||||
describe("Test DPT6", (): void => {
|
||||
|
||||
let dpt = new DPT6();
|
||||
|
||||
it("Decode buffer acceptable", async function () {
|
||||
expect(dpt.decoder(bufferPositive)).is.equal(value);
|
||||
expect(dpt.decoder(bufferNegative)).is.equal(-value);
|
||||
});
|
||||
|
||||
|
||||
it("Decode empty buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferEmpty)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
it("Decode oversized buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferBiggerSize)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
/* Encoder tests */
|
||||
it("encode valid", async function () {
|
||||
expect(compareBuffers(dpt.encoder(value), bufferPositive)).is.true;
|
||||
expect(compareBuffers(dpt.encoder(-value), bufferNegative)).is.true;
|
||||
});
|
||||
|
||||
it("encode invalid", async function () {
|
||||
var testFunction1 = function () {
|
||||
const value = dpt.encoder(-overflowValue)
|
||||
}
|
||||
var testFunction2 = function () {
|
||||
const value = dpt.encoder(overflowValue)
|
||||
}
|
||||
|
||||
expect(testFunction1).to.throw(InvalidValueError);
|
||||
expect(testFunction2).to.throw(InvalidValueError);
|
||||
});
|
||||
|
||||
it("encode undefined", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder(undefined)
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
});
|
63
tests/DPT7.test.ts
Normal file
63
tests/DPT7.test.ts
Normal file
@ -0,0 +1,63 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT7 } from "../src/DPT7"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
let bufferA = Buffer.from([1, 0])
|
||||
let bufferMax = Buffer.from([255, 255])
|
||||
|
||||
let bufferEmpty = Buffer.from([])
|
||||
let bufferBiggerSize = Buffer.from([1, 0, 2, 4])
|
||||
|
||||
describe("Test DPT7", (): void => {
|
||||
|
||||
let dpt = new DPT7();
|
||||
|
||||
it("Decode buffer common", async function () {
|
||||
const value = dpt.decoder(bufferA)
|
||||
expect(value).is.equal(256);
|
||||
});
|
||||
|
||||
it("Decode buffer max", async function () {
|
||||
const value = dpt.decoder(bufferMax)
|
||||
expect(value).is.equal(65535);
|
||||
});
|
||||
|
||||
it("Decode empty buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferEmpty)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
it("Decode oversized buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferBiggerSize)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
/* Encoder tests */
|
||||
it("encode valid", async function () {
|
||||
expect(compareBuffers(dpt.encoder(256), bufferA)).is.true;
|
||||
expect(compareBuffers(dpt.encoder(65535), bufferMax)).is.true;
|
||||
});
|
||||
|
||||
it("encode invalid", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder(-200)
|
||||
}
|
||||
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
|
||||
it("encode undefined", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder(undefined)
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
});
|
66
tests/DPT8.test.ts
Normal file
66
tests/DPT8.test.ts
Normal file
@ -0,0 +1,66 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT8 } from "../src/DPT8"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
let value: number = 256
|
||||
let overflowValue: number = 40000
|
||||
|
||||
let bufferPositive = Buffer.from([1, 0])
|
||||
let bufferNegative = Buffer.from([255, 0])
|
||||
|
||||
let bufferEmpty = Buffer.from([])
|
||||
let bufferBiggerSize = Buffer.from([0xff, 0xff, 0x63, 0xc0])
|
||||
|
||||
describe("Test DPT8", (): void => {
|
||||
|
||||
let dpt = new DPT8();
|
||||
|
||||
it("Decode buffer acceptable", async function () {
|
||||
expect(dpt.decoder(bufferPositive)).is.equal(value);
|
||||
expect(dpt.decoder(bufferNegative)).is.equal(-value);
|
||||
});
|
||||
|
||||
|
||||
it("Decode empty buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferEmpty)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
it("Decode oversized buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferBiggerSize)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
/* Encoder tests */
|
||||
it("encode valid", async function () {
|
||||
expect(compareBuffers(dpt.encoder(value), bufferPositive)).is.true;
|
||||
expect(compareBuffers(dpt.encoder(-value), bufferNegative)).is.true;
|
||||
});
|
||||
|
||||
it("encode invalid", async function () {
|
||||
var testFunction1 = function () {
|
||||
const value = dpt.encoder(-overflowValue)
|
||||
}
|
||||
var testFunction2 = function () {
|
||||
const value = dpt.encoder(overflowValue)
|
||||
}
|
||||
|
||||
expect(testFunction1).to.throw(InvalidValueError);
|
||||
expect(testFunction2).to.throw(InvalidValueError);
|
||||
});
|
||||
|
||||
it("encode undefined", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder(undefined)
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
});
|
62
tests/DPT9.test.ts
Normal file
62
tests/DPT9.test.ts
Normal file
@ -0,0 +1,62 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { DPT9 } from "../src/DPT9"
|
||||
import { BufferLengthError } from "../src/errors/BufferLengthError";
|
||||
import { InvalidValueError } from "../src/errors/InvalidValueError";
|
||||
|
||||
import { compareBuffers } from "./util"
|
||||
|
||||
let value: number = 21.08
|
||||
let valuemin: number = 1.0e-15
|
||||
let bufferValue = Buffer.from([0x0C, 0x1E])
|
||||
let bufferZero = Buffer.from([0x00, 0x00])
|
||||
let bufferNegative = Buffer.from([0x8b, 0xe2])
|
||||
|
||||
let bufferEmpty = Buffer.from([])
|
||||
let bufferBiggerSize = Buffer.from([0xff, 0xff, 0x63, 0xc0])
|
||||
|
||||
describe("Test DPT9", (): void => {
|
||||
|
||||
let dpt = new DPT9();
|
||||
|
||||
it("Decode buffer acceptable", async function () {
|
||||
expect(dpt.decoder(bufferZero)).is.equal(0);
|
||||
expect(dpt.decoder(bufferValue)).is.equal(value);
|
||||
expect(dpt.decoder(bufferNegative)).is.equal(-value);
|
||||
});
|
||||
|
||||
|
||||
it("Decode empty buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferEmpty)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
it("Decode oversized buffer", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.decoder(bufferBiggerSize)
|
||||
}
|
||||
expect(testFunction).to.throw(BufferLengthError);
|
||||
});
|
||||
|
||||
/* Encoder tests */
|
||||
it("encode valid", async function () {
|
||||
expect(compareBuffers(dpt.encoder(0), bufferZero)).is.true;
|
||||
expect(compareBuffers(dpt.encoder(value), bufferValue)).is.true;
|
||||
expect(compareBuffers(dpt.encoder(-value), bufferNegative)).is.true;
|
||||
});
|
||||
|
||||
it("encode undefined", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder(undefined)
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
it("encode infinite", async function () {
|
||||
var testFunction = function () {
|
||||
const value = dpt.encoder(Infinity)
|
||||
}
|
||||
expect(testFunction).to.throw(InvalidValueError);
|
||||
});
|
||||
});
|
28
tests/util.ts
Normal file
28
tests/util.ts
Normal file
@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
export function bufferToString(buffer: Buffer): string {
|
||||
let result = '['
|
||||
for (let i = 0; i < buffer.length; i++) {
|
||||
if (i != 0)
|
||||
result += ', '
|
||||
result += `${buffer[i]}`
|
||||
}
|
||||
result += ']'
|
||||
return result
|
||||
}
|
||||
|
||||
export function compareBuffers(b1: Buffer, b2: Buffer): boolean {
|
||||
if (b1.length != b2.length)
|
||||
throw new Error(`Different buffer lengths: b1: ${b1.length}, b2: ${b2.length}`)
|
||||
|
||||
for (let i = 0; i < b1.length; i++) {
|
||||
const v1 = b1[i];
|
||||
const v2 = b2[i];
|
||||
|
||||
if (typeof v1 != typeof v2)
|
||||
throw new Error(`Different type values: ${typeof v1}, ${typeof v2} @${i} - ${bufferToString(b1)} ${bufferToString(b2)}`)
|
||||
if (v1 != v2)
|
||||
throw new Error(`Different values: ${v1}, ${v2} @${i} - ${bufferToString(b1)} ${bufferToString(b2)}`)
|
||||
}
|
||||
return true;
|
||||
}
|
40
tsconfig.json
Normal file
40
tsconfig.json
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"outDir": "lib",
|
||||
"rootDir": "src",
|
||||
"removeComments": true,
|
||||
"strict": false,
|
||||
"noImplicitAny": true,
|
||||
"moduleResolution": "node",
|
||||
"strictNullChecks": false,
|
||||
"resolveJsonModule": true,
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
],
|
||||
"esModuleInterop": true,
|
||||
"experimentalDecorators": true,
|
||||
"downlevelIteration": true,
|
||||
"emitDecoratorMetadata": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"lib",
|
||||
"**/*.spec.ts"
|
||||
],
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"src/types.d.ts"
|
||||
],
|
||||
"ts-node": {
|
||||
"files": true
|
||||
},
|
||||
}
|
Loading…
Reference in New Issue
Block a user