Compare commits

..

No commits in common. "pages" and "main" have entirely different histories.
pages ... main

90 changed files with 9381 additions and 6218 deletions

15
.drone.yml Normal file
View file

@ -0,0 +1,15 @@
kind: pipeline
name: default
steps:
- name: build
image: itsblue.dev/plugins/doxygen
settings:
doxyfile: docs/Doxyfile-mcss
- name: publish
image: itsblue.dev/plugins/codeberg-pages-deploy
settings:
folder: docs/html
ssh_key:
from_secret: gitea-ssh-key

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.pro.user*

15
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,15 @@
image: ubuntu
pages:
script:
- cd docs/
- apt update && apt install -y git doxygen python3-pip
- git clone git://github.com/mosra/m.css
- pip3 install jinja2 Pygments
- ./m.css/documentation/doxygen.py ./Doxyfile-mcss
- mv ./html ../public
artifacts:
paths:
- public
only:
- master

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "qt-openssl-encryption"]
path = qt-openssl-encryption
url = https://itsblue.dev/itsblue-development/qt-openssl-encryption.git

674
LICENSE Normal file
View file

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://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.
ScStw shared libraries
Copyright (C) 2020 Itsblue development
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 <http://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:
shared libraries Copyright (C) 2020 Speed climbing stopwatch
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
<http://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
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

3
README.md Normal file
View file

@ -0,0 +1,3 @@
# shared libraries
Some shared libraries for use in the ScStw client

74
ScStwLibraries/.gitignore vendored Normal file
View file

@ -0,0 +1,74 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe
/build/

View file

@ -0,0 +1,81 @@
!isEmpty(SCSTWLIBRARIES_LIB):error("ScStwLibraries.pri already included")
SCSTWLIBRARIES_LIB = 1
QT += multimedia
ScStwLibraries_QML {
QT += qml quickcontrols2
DEFINES += ScStwLibraries_QML
ScStwLibraries_Styling {
DEFINES += ScStwLibraries_Styling
}
}
ScStwLibraries_ClientLibs {
DEFINES += ScStwLibraries_ClientLibs
}
ScStwLibraries_Raspi {
LIBS += -lasound
DEFINES += ScStwLibraries_Raspi
}
INCLUDEPATH += $$PWD/headers $$PWD
SOURCES += \
$$PWD/sources/ScStw.cpp \
$$PWD/sources/scstwsettings.cpp \
$$PWD/sources/scstwsoundplayer.cpp \
$$PWD/sources/scstwlibraries.cpp \
$$PWD/sources/scstwrace.cpp \
$$PWD/sources/scstwtimer.cpp \
$$PWD/sources/scstwsetting.cpp
HEADERS += \
$$PWD/headers/ScStw.hpp \
$$PWD/headers/ScStwLibraries_global.h \
$$PWD/headers/scstwlibraries.h \
$$PWD/headers/scstwrace.h \
$$PWD/headers/scstwsettings.h \
$$PWD/headers/scstwsoundplayer.h \
$$PWD/headers/scstwtimer.h \
$$PWD/headers/scstwsetting.h
ScStwLibraries_ClientLibs {
SOURCES += \
$$PWD/sources/client/scstwclient.cpp \
$$PWD/sources/client/scstwremoterace.cpp \
$$PWD/sources/client/scstwremotetimer.cpp \
$$PWD/sources/client/scstwremotesettings.cpp
HEADERS += \
$$PWD/headers/client/scstwclient.h \
$$PWD/headers/client/scstwremoterace.h \
$$PWD/headers/client/scstwremotetimer.h \
$$PWD/headers/client/scstwremotesettings.h
INCLUDEPATH += $$PWD/headers/client
}
ScStwLibraries_QML {
ScStwLibraries_Styling {
SOURCES += \
$$PWD/sources/styling/scstwapptheme.cpp \
$$PWD/sources/styling/scstwappthememanager.cpp
HEADERS += \
$$PWD/headers/styling/scstwapptheme.h \
$$PWD/headers/styling/scstwappthememanager.h
RESOURCES += \
$$PWD/resources/qml/ScStwStylingQml.qrc \
$$PWD/resources/shared/ScStwStylingShared.qrc \
INCLUDEPATH += $$PWD/headers/styling
}
}
RESOURCES += \
$$PWD/resources/shared/ScStwLibrariesShared.qrc

View file

@ -0,0 +1,253 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef SCSTW_HPP
#define SCSTW_HPP
#include <QObject>
#include <QMap>
#include <QMetaEnum>
/*!
* \mainpage ScStw Libraries documentation
*
* \section intro_sec Introduction
*
* This library is meant for usage with the Speed climbing stopwatch project.
* It contains some helper classes to build a client application for the ScStw basestation with Qt.
*
* \section section Installation
* \code{.sh}
* cd yourRepo
* git submodule add https://git.itsblue.de/ScStw/shared-libraries/
* git submodule update --init --recursive
* \endcode
*
* And in your MyProject.pro include the .pri file:
* \code{.pro}
* include($$PWD/shared-libraries/ScStwLibraries/ScStwLibraries.pri)
* \endcode
*/
/*!
* \brief The ScStw class provides some shared functions and enums for use in the ScStw project.
*/
class ScStw : public QObject {
Q_OBJECT
public:
/*!
* \brief The SignalKey enum contains all signal keys a client can subscribe to
*
* \see ScStw::signalKeyFromInt()
*/
enum SignalKey {
InvalidSignal = -1,
RaceStateChanged = 9000,
TimersChanged = 9001,
ExtensionsChanged = 9002,
CurrentStartDelayChanged = 9003, /*, ProfilesChanged*/
SettingChanged = 9004,
RaceDetailsChanged = 9005
};
Q_ENUM(SignalKey)
/*!
* \brief The SocketCommand enum contains all commands the base station can handle
*
* \see ScStw::socketCommandFromInt()
*/
enum SocketCommand {
InvalidCommand = -1,
InitializeSessionCommand = 1,
StartRaceCommand = 1000,
StopRaceCommand = 1001,
ResetRaceCommand = 1002,
CancelRaceCommand = 1003,
SetTimerDisabledCommand = 1004,
GetRaceStateCommand = 2000,
GetRaceDetailsCommand = 2001,
GetExtensionsCommand = 2006,
GetTimersCommand = 2007,
GetCurrentStartDelayCommand = 2009,
WriteSettingCommand = 3000,
ReadSettingCommand = 3001,
LoginAthleteCommand = 4000,
CreateAthleteCommand = 4001,
DeleteAthleteCommand = 4002,
GetAtheletesCommand = 4003,
GetAthleteResultsCommand = 4004,
UpdateFirmwareCommand = 5000,
UpdateSystemTimeCommand = 5001,
PairExtensionsCommand = 5002
};
Q_ENUM(SocketCommand);
/*!
* \brief The ErrorCode enum contains all error codes that can occur when sending a command to the basestation
*/
enum StatusCode {
Success = 200,
FirmwareAlreadyUpToDateInfo = 304,
AccessDeniedError = 401,
UpdateSignatureInvalidError = 402,
CurrentStateNotVaildForOperationError = 403,
CommandNotFoundError = 404,
RequiredParameterNotGivenError = 405,
TimestampTooSmallError = 406,
ClientSessionAlreadyActiveError = 407,
NoSessionActiveError = 408,
ItemNotFoundError = 409,
LastTimerCannotBeDisabledError = 410,
UpdateFailedError = 500,
Error = 900,
NotConnectedError = 910,
TimeoutError = 911,
SettingNotAccessibleError = 901,
InternalError = 950,
InternalErrorTimerOperationFailed = 951,
ApiVersionNotSupportedError = 952,
CompetitionModeProhibitsThisError = 953,
FirmwareUpdateFormatInvalidError = 954,
TimersNotReadyError = 501 /*!< One or more timer is not ready */
};
Q_ENUM(ScStw::StatusCode)
/*!
* \brief The ExtensionType enum contains all types of extensions
*/
enum ExtensionType {
StartPad,
TopPad
};
Q_ENUM(ExtensionType);
/*!
* \brief The ExtensionState enum contains all possible states of an extension
*/
enum ExtensionState {
ExtensionDisconnected = 0,
ExtensionConnecting = 1,
ExtensionInitialising = 2,
ExtensionConnected = 3
};
Q_ENUM(ExtensionState);
/*!
* \brief The ExtensionBatteryState enum contains all possible battery states of an extension
*/
enum ExtensionBatteryState {
BatteryUnknown = -1,
BatteryCritical = 0,
BatteryWarning = 1,
BatteryFine = 2,
BatteryCharging = 3,
BatteryNotCharging = 4
};
Q_ENUM(ExtensionBatteryState);
/*!
* \brief The PadState enum contains whether a pad is currently pressed or not
*/
enum PadState {
PadNotPressed = 0,
PadPressed = 1
};
Q_ENUM(PadState);
/*!
* \brief SOCKET_MESSAGE_START_KEY contains the key, a message is supposed to start with
*/
static const char* SOCKET_MESSAGE_START_KEY;
/*!
* \brief SOCKET_MESSAGE_END_KEY contains the key, a message is supposed to end with
*/
static const char* SOCKET_MESSAGE_END_KEY;
/*!
* \brief Function to convert an int to a SignalKey
* \param i the int to convert
* \return a SignalKey
*
* \see ScStw::SignalKey
*/
static SignalKey signalKeyFromInt(int i);
/*!
* \brief Function to convert an int to a SocketCommand
* \param i the int to convert
* \return a SocketCommand
*
* \see ScStw::SocketCommand
*/
static SocketCommand socketCommandFromInt(int i);
/*!
* \brief Function to convert an ExtensionType to a string
* \param t the ExtensionType to convert
* \return String
*
* \see ScStwExtensionType
*/
static QString extensionTypeToString(ExtensionType t);
/*!
* \brief Function to compare to string firmware versions in <major>.<minor>.<patch> formar
* \param a version a
* \param b version b
* \return -4: a is of invalid format
* -3: major of a is lower than b
* -2: minor of a is lower than b
* -1: patch of a is lower than b
* 0: a and b are identical
* 1: patch b is lower than a
* 2: minor of b is lower than a
* 3: major of b is lower than a
* 4: b is of invalid format
*/
static int firmwareCompare(QString a, QString b);
/*!
* \brief Function to convert a value to an enum
*/
template <typename Enum>
static Enum toEnumValue(const int &value, bool *ok)
{
QMetaEnum enumeration = QMetaEnum::fromType<Enum>();
return static_cast<Enum>(enumeration.keyToValue(enumeration.valueToKey(value), ok));
}
ScStw() : QObject(nullptr) {};
private:
};
#endif // SCSTW_HPP

View file

@ -0,0 +1,30 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef SCSTWLIBRARIES_GLOBAL_H
#define SCSTWLIBRARIES_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(SCSTWLIBRARIES_LIBRARY)
# define SCSTWLIBRARIES_EXPORT Q_DECL_EXPORT
#else
# define SCSTWLIBRARIES_EXPORT Q_DECL_IMPORT
#endif
#endif // SCSTWCLIENT_GLOBAL_H

View file

@ -0,0 +1,333 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef SCSTWCLIENT_H
#define SCSTWCLIENT_H
#include <QObject>
#include <QTcpSocket>
#include <QDataStream>
#include <QDateTime>
#include <QTimer>
#include <QEventLoop>
#include <QSemaphore>
#include <QThread>
#include <QFuture>
#include <QtConcurrent/QtConcurrent>
#include <string.h>
#include <QByteArray>
#include "ScStw.hpp"
#include "scstwsettings.h"
/*!
* This class is used to connect and talk to the ScStw basestation.
*
* \code{.cpp}
* ScStwClient * client = new ScStwClient();
* client->setIp("192.168.4.1");
* client->connectToHost();
* \endcode
*
* \brief The ScStwClient class
* \author Dorian Zedler
*/
class ScStwClient : public QObject
{
Q_OBJECT
Q_PROPERTY(State state READ getState NOTIFY stateChanged)
Q_PROPERTY(QVariantMap extensions READ getExtensions NOTIFY extensionsChanged)
Q_PROPERTY(QString ipAddress READ getIP WRITE setIP)
public:
/*!
* The constructor
*
* \brief ScStwClient
*/
explicit ScStwClient(
QObject *parent = nullptr,
QList<ScStw::SignalKey> signalSubscriptions = {ScStw::ExtensionsChanged}
);
enum State {DISCONNECTED, CONNECTING, INITIALISING, CONNECTED};
Q_ENUM(State);
const QString API_VERSION = "1.0.0";
private:
// values for the socket connection
QString ip;
ushort port = 3563;
int errors;
const static int ERRORS_UNTIL_DISCONNECT = 4;
QVariantMap extensions;
QList<ScStw::SignalKey> signalSubscriptions;
//---general status values---//
// some meta data of the base station
QString firmwareVersion;
QString apiVersion;
double timeOffset;
// the current state
ScStwClient::State state;
QDateTime *date;
//to get the current time
QTcpSocket *socket;
//socket for communication with the extention
QTimer *timeoutTimer;
QString readBuffer;
unsigned int currentRequestId;
struct WaitingRequest {
QEventLoop * loop;
QJsonObject reply;
};
QMap<int, WaitingRequest> waitingRequests;
public slots:
/*!
* \brief Function to connect to the base station
*/
void connectToHost();
/*!
* \brief Function to disconnect from the basestation
*/
void closeConnection();
/*! socket communication handling */
/*!
* \brief Funtion to send a command to the server (for internal use)
* \param header the command to send
* \param data the data to send
* \param timeout the timeout
* \param useTerminationKeys wether to use the termination keys defined in
*
* \return a variant map containing the Keys "status" and "data"
*/
QVariantMap sendCommand(int header, QJsonValue data = "", int timeout = 3000);
/*! helper functions */
/*!
* \brief Function to write a setting on the base station
* \param key the key to write to
* \param value the value to write to
* \return the status code returned by the command
*/
ScStw::StatusCode writeRemoteSetting(ScStwSettings::BaseStationSetting key, QVariant value);
/*!
* \brief Function to read a setting on the base station
* \param key the key to read from
* \return the value of the key or "false" if the key is not found or an error occured
*/
QVariant readRemoteSetting(ScStwSettings::BaseStationSetting key, ScStw::StatusCode* status = nullptr);
/*! Getter fuctions */
/*!
* \brief Function to get the ip the client will try to connect to.
* \see setIP()
* \return the ip
*/
QString getIP();
/*!
* \brief Function to get the current state of the client
* \return the current state
*/
ScStwClient::State getState();
/*!
* \brief Function to get the extensions and their state from the base station
* \return a list with all configured extensions and their state
*/
QVariantMap getExtensions();
/*!
* \brief Function to get the time offset of the base station relative to the clients time
* \see updateTime()
* \return the time offset in milliseconds
*/
int getTimeOffset();
/*!
* \brief Function to get the current firmware version of the base station
* \see updateFirmware()
* \see isFirmwareUpToDate()
* \return Firmware version as string encoded as <major>.<minor>.<patch>
*/
QString getFirmwareVersion();
/*!
* \brief Function to get the current API version of the base station
* \return
*/
QString getApiVersion();
/*! setter functions */
/*!
* \brief Function to set the ip to connect to
* \see getIP()
* \param ipAdress
*/
void setIP(QString ipAdress);
void addSignalSubscription(ScStw::SignalKey key);
private slots:
/*!
* \brief called when timeout timer times out
*/
void connectionTimeout();
/*!
* \brief Function that is connected to the QAbstractSocket::error slot and used to handle upcoming errors
* \param err the error that occurred
*/
void handleError(QAbstractSocket::SocketError err);
/*!
* \brief Function to init a session at the base station
* \return true or false
*/
bool init();
/*!
* \brief Function to end a session on the base station
*/
void deInit();
/*!
* \brief Funtion to send a command to the server (for internal use)
* \param header the command to send
* \param data the data to send
* \param timeout the timeout
* \param useTerminationKeys wether to use the termination keys defined in
* ScStw::SOCKET_MESSAGE_START_KEY and ScStw::SOCKET_MESSAGE_END_KEY
* \return a variant map containing the Keys "status" and "data"
*/
QVariantMap sendCommand(int header, QJsonValue data, int timeout, bool useTerminationKeys);
/*!
* \brief Function connected to the QAbstractSocket::readyRead signal
*/
void handleReadyRead();
/*!
* \brief Function to process an incoming string and parse the messages contained in it.
* \param message the message sting to parse
*/
void processSocketMessage(QString message);
/*!
* \brief Function that handles a parsed message
* \details This fuction looks up the id of the incoming message and tries to find the according waiting request.
* If it is unable to find an accordin request, the signal ScStwClient::gotUnexpectedMessage(QString message) is called.
* If the recieved message is a signal, the ScStwClient::handleSignal() function is called.
* \see gotUnexpectedMessage()
* \see handleSignal()
* \param reply the massage that needs to be handles
*/
void handleSocketMessage(QString reply);
/*!
* \brief Function to handle a change of the state of the tcp socket
* \details it is connected to the QAbstractSocket::stateChanged signal
* \see stateChanged()
* \param socketState
*/
void handleSocketStateChange(QAbstractSocket::SocketState socketState);
/*!
* \brief Function to handle a signal from the base station.
* \details Called by the ScStwClient::handleSocketMessage function
* \see handleSocketMessage()
* \param data
*/
void handleSignal(QVariantMap data);
/*! Helper Functions */
/*!
* \brief Function used to set the local cache of the baseStation connections.
* \details emits ScStwClient::gotSignal() with a ScStw::ExtensionsChanged signal.
* \see gotSignal()
* \param connections the list to set the chache to
*/
void setExtensions(QVariantMap extensions);
/*!
* \brief Function to set the local state.
* \details emits ScStwClient::stateChanged() when the new state does not match the old one.
* \see stateChanged()
* \param newState the state to change to
*/
void setState(ScStwClient::State newState);
signals:
/*!
* \brief Is emitted, when the connection state changes
*/
void stateChanged();
/*!
* \brief Is emitted, whenever a reply is recieved which does not match any requests
*
* \param reply contains the reply
*/
void gotUnexpectedMessage(QString message);
/*!
* \brief Is emitted, when an update signal from the basestation is recieved
*
* \param data
*/
void gotSignal(ScStw::SignalKey key, QVariant data);
/*!
* \brief Is emitted, when there is any network error
* \param error
*/
void gotError(QAbstractSocket::SocketError error);
/*!
* \brief Is emitted, when the extensions of the base station changed
*/
void extensionsChanged();
};
extern ScStwClient * pGlobalScStwClient;
#endif // SCSTWCLIENT_H

View file

@ -0,0 +1,86 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef SCSTWREMOTEMONITORRACE_H
#define SCSTWREMOTEMONITORRACE_H
#include <QObject>
#include "scstwrace.h"
#include "scstwclient.h"
#include "scstwremotetimer.h"
#include "scstwsoundplayer.h"
class ScStwRemoteRace : public ScStwRace
{
Q_OBJECT
Q_PROPERTY(ScStwClient* scStwClient READ getScStwClient WRITE setScStwClient NOTIFY scStwClientChanged)
public:
ScStwRemoteRace(QObject *parent = nullptr);
ScStwRemoteRace(ScStwClient *scStwClient, ScStwSettings *settings = nullptr, QObject *parent = nullptr);
enum RaceMode {
LOCAL,
REMOTE
};
protected:
double currentStartTotalDelay;
double currentStartDelayStartedAt;
double latestStartDelayProgress;
bool isReadyForNextState;
bool readySoundEnabled;
private:
ScStwClient *scStwClient;
QList<ScStwRemoteTimer*> remoteTimers;
QList<ScStwTimer*> localTimers;
public slots:
ScStw::StatusCode start(bool asyncronous = true);
ScStw::StatusCode cancel();
ScStw::StatusCode stop();
ScStw::StatusCode reset();
ScStw::StatusCode setTimerDisabled(int id, bool disabled);
bool addTimer(ScStwTimer *timer);
QVariantMap getCurrentStartDelay();
bool getIsReadyForNextState();
bool getReadySoundEnabled();
ScStwClient *getScStwClient();
void setScStwClient(ScStwClient *client);
private slots:
void handleBaseStationSignal(ScStw::SignalKey key, QVariant data);
bool refreshRemoteTimers(QVariantList remoteTimers);
void rebuildRemoteTimers(QVariantList remoteTimers);
void refreshDetails(QVariantMap details);
void handleClientStateChange();
void refreshCompetitionMode();
RaceMode getMode();
bool local();
void setTimers(QList<ScStwTimer*> timers, bool deleteOldTimers);
signals:
void scStwClientChanged();
};
#endif // SCSTWREMOTEMONITORRACE_H

View file

@ -0,0 +1,62 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef SCSTWREMOTESETTINGS_H
#define SCSTWREMOTESETTINGS_H
#include <QObject>
#include "scstwsettings.h"
#include "scstwclient.h"
#include <QMetaEnum>
class ScStwRemoteSettings : public ScStwSettings
{
Q_OBJECT
Q_PROPERTY(ScStwClient* scStwClient READ getScStwClient WRITE setScStwClient NOTIFY scStwClientChanged)
public:
ScStwRemoteSettings(QObject * parent = nullptr);
ScStwRemoteSettings(ScStwClient * scStwClient, QObject * parent = nullptr);
enum SettingsMode {
LOCAL,
REMOTE
};
protected:
QVariant readSetting(QString key, int keyInt, int keyLevel);
bool writeSetting(QString key, QVariant value, int keyInt,int keyLevel = -1);
bool setDefaultSetting(QString key, QVariant defaultVariant, int keyInt,int keyLevel = -1);
private:
ScStwClient * scStwClient;
public slots:
ScStwClient *getScStwClient();
void setScStwClient(ScStwClient *client);
private slots:
void handleClientStateChange();
void handleBaseStationSignal(ScStw::SignalKey key, QVariant data);
SettingsMode getMode();
signals:
void scStwClientChanged();
};
#endif // SCSTWREMOTESETTINGS_H

View file

@ -0,0 +1,79 @@
#ifndef SCSTWREMOTETIMER_H
#define SCSTWREMOTETIMER_H
#include <scstwtimer.h>
#include <QObject>
class ScStwRemoteTimer : public ScStwTimer
{
Q_OBJECT
public:
ScStwRemoteTimer(QObject *parent = nullptr);
friend class ScStwRemoteRace;
private:
ScStwTimer::ReadyState readyState;
public slots:
/*!
* \brief Function to get the current ready status of a timer
* \return The current ready status
*/
virtual ScStwTimer::ReadyState getReadyState();
protected slots:
/*!
* \brief Function to dircetly change the start time
*
* Only works when directControlEnabled is set to true!
*
* \param startTime the time to change to
* \return false when directControlEnabled is set to false and the startTime was therefore not modified, true otherwise
*/
void setStartTime(double startTime);
/*!
* \brief Function to dircetly change the stop time
*
* Only works when directControlEnabled is set to true!
*
* \param stopTime the time to change to
* \return false when directControlEnabled is set to false and the stopTime was therefore not modified, true otherwise
*/
void setStopTime(double stopTime);
/*!
* \brief Function to dircetly change the rection time
*
* Only works when directControlEnabled is set to true!
*
* \param reactionTime the time to change to
* \return false when directControlEnabled is set to false and the reactionTime was therefore not modified, true otherwise
*/
void setReactionTime(double rectionTime);
/*!
* \brief Function to dircetly change the letter
*
* Only works when directControlEnabled is set to true!
*
* \param newLetter the letter to change to
* \return false when directControlEnabled is set to false and the letter was therefore not modified, true otherwise
*/
void setLetter(QString newLetter);
void setReadyState(ScStwTimer::ReadyState);
/*!
* \brief Function to change the state of the timer
*
* Doing this will emit the ScStwTimer::stateChanged() signal (only if the new state differs from the current one)
*
* \param newState The new state
*/
void setState(TimerState newState);
};
#endif // SCSTWREMOTETIMER_H

View file

@ -0,0 +1,62 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef SCSTWLIBRARIES_H
#define SCSTWLIBRARIES_H
#include <QObject>
#ifdef ScStwLibraries_QML
#include <QQmlApplicationEngine>
#ifdef ScStwLibraries_Styling
#include "scstwappthememanager.h"
#include "scstwapptheme.h"
#endif
#endif
#include "scstwtimer.h"
#include "scstwrace.h"
#include "scstwsettings.h"
#ifdef ScStwLibraries_ClientLibs
#include "scstwsetting.h"
#include "scstwremoterace.h"
#include "scstwclient.h"
#include "scstwremotesettings.h"
#endif
class ScStwLibraries : public QObject
{
Q_OBJECT
public:
static void init();
#ifdef ScStwLibraries_QML
#ifdef ScStwLibraries_Styling
static void initStyling(QQmlApplicationEngine *engine);
#endif
#endif
private:
explicit ScStwLibraries(QObject *parent = nullptr);
signals:
};
#endif // SCSTWLIBRARIES_H

View file

@ -0,0 +1,190 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef SCSTWRACE_H
#define SCSTWRACE_H
#include <QObject>
#include <QDebug>
#include <QTimer>
#include <QEventLoop>
#include "scstwtimer.h"
#include "scstwsoundplayer.h"
#include "scstwsettings.h"
class ScStwRemoteRace;
/*!
* \brief The ScStwRace class can be used to measure timings of climbing races with multiple lanes at once.
*
* The ScStwRace is a container to manage multiple timers at a time and introduces a propper start sequence
* with start commands ('At your Marks' and 'Ready') and the official IFSC start signal.
*
* ## Basic usage:
*
* \code
* ScStwRace race;
*
* // add two timers
* race.addTimer(new ScStwTimer());
* race.addTimer(new ScStwTimer());
*
* // start a race
* race.start();
* \endcode
*
*/
class ScStwRace : public QObject
{
Q_OBJECT
Q_PROPERTY(RaceState state READ getState NOTIFY stateChanged)
Q_PROPERTY(QVariantList timers READ getTimerDetailList NOTIFY timersChanged)
Q_PROPERTY(QVariantMap currentStartDelay READ getCurrentStartDelay NOTIFY currentStartDelayChanged)
Q_PROPERTY(bool isReadyForNextState READ getIsReadyForNextState NOTIFY isReadyForNextStateChanged)
Q_PROPERTY(bool competitionMode READ getCompetitionMode NOTIFY competitionModeChanged)
Q_PROPERTY(bool readySoundEnabled READ getReadySoundEnabled NOTIFY readySoundEnabledChanged)
Q_PROPERTY(QVariantMap details READ getDetails NOTIFY detailsChanged)
Q_PROPERTY(ScStwSettings* settings READ getSettings WRITE setSettings NOTIFY settingsChanged)
Q_PROPERTY(bool autoRefreshTimerText READ getAutoRefreshTimerText WRITE setAutoRefreshTimerText NOTIFY autoRefreshTimerTextChanged)
public:
explicit ScStwRace(QObject *parent = nullptr);
explicit ScStwRace(ScStwSettings *settings, QObject *parent = nullptr);
friend class ScStwRemoteRace;
enum RaceState { IDLE, PREPAIRING, WAITING, STARTING, RUNNING, STOPPED, INCIDENT };
Q_ENUM(RaceState)
protected:
QList<ScStwTimer *> timers;
void setState(RaceState newState);
private:
RaceState state;
QTimer *startDelayTimer;
QTimer *timerTextRefreshTimer;
QEventLoop *startWaitLoop;
// sounds
ScStwSoundPlayer * soundPlayer;
// settings
ScStwSettings *settings;
bool competitionMode;
bool autoRefreshTimerText;
enum LoopExitTypes {
LoopAutomaticExit = 0,
LoopReadyStateChangeExit = 1,
LoopManualExit = 2,
LoopCancelExit = 3
};
public slots:
/*!
* \brief Function to start the race
*
* \param asyncronous if the function should just start the start sequence and then quit (true)
* or if if should wait until the start sequence is over and quit after that (false)
* \return 200: OK; 904: state not matching
*/
virtual ScStw::StatusCode start(bool asyncronous = true);
/*!
* \brief Function to stop the currently running race
*
* \return 200: OK; 904: state not matching
*/
virtual ScStw::StatusCode stop();
/*!
* \brief Function to reset a stopped race
* \return
*/
virtual ScStw::StatusCode reset();
virtual ScStw::StatusCode cancel();
virtual ScStw::StatusCode setTimerDisabled(int id, bool disabled);
Q_INVOKABLE virtual bool addTimer(ScStwTimer *timer);
// getters
RaceState getState();
virtual QVariantMap getCurrentStartDelay();
QList<ScStwTimer*> getTimers();
QVariantList getTimerDetailList();
QVariantMap getDetails();
bool getCompetitionMode();
virtual bool getReadySoundEnabled();
ScStwSettings* getSettings();
void setSettings(ScStwSettings* settings);
bool getAutoRefreshTimerText();
void setAutoRefreshTimerText(bool autoRefresh);
protected slots:
private slots:
void handleTimerStateChange(ScStwTimer::TimerState newState);
/**
* \brief Function to declare the winner and looser timers after a timer has been stopped
*/
void handleTimerStop();
void handleFalseStart();
void handleTimerWantsToBeDisabledChange(ScStwTimer* timer, bool wantsToBeDisabled);
bool playSoundsAndStartTimers();
ScStwSoundPlayer::PlayResult doDelayAndSoundOfCurrentStartState(double *timeOfSoundPlaybackStart = nullptr);
void technicalIncident();
ScStw::StatusCode setTimerDisabled(ScStwTimer* timer, bool disabled);
virtual void refreshCompetitionMode();
double getSoundVolume();
ScStwSoundPlayer::StartSound getSoundForState(ScStwRace::RaceState state);
bool getSoundEnabledSetting(ScStwSoundPlayer::StartSound sound);
int getSoundDelaySetting(ScStwSoundPlayer::StartSound sound);
bool isStarting();
virtual bool getIsReadyForNextState();
void handleTimerReadyStateChange(ScStwTimer::ReadyState readyState);
signals:
void startTimers();
void stopTimers(int type);
void resetTimers();
void stateChanged(RaceState state);
void currentStartDelayChanged();
void timersChanged();
void isReadyForNextStateChanged();
void detailsChanged();
void competitionModeChanged();
void readySoundEnabledChanged();
void settingsChanged();
void autoRefreshTimerTextChanged();
};
#endif // SCSTWRACE_H

View file

@ -0,0 +1,58 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef SCSTWQMLSETTING_H
#define SCSTWQMLSETTING_H
#include <QObject>
#include <QVariant>
class ScStwSettings;
class ScStwSetting : public QObject
{
Q_OBJECT
Q_PROPERTY(QVariant value READ getValue WRITE setValue NOTIFY valueChanged)
Q_PROPERTY(QVariant readonlyValue READ getValue NOTIFY valueChanged)
protected:
explicit ScStwSetting(int key, int keyLevel, ScStwSettings*scStwSettings, QObject *parent);
friend class ScStwSettings;
int key;
int keyLevel;
bool hasToReload;
private:
QVariant valueCache;
ScStwSettings *scStwSettings;
public slots:
QVariant getValue();
void setValue(QVariant value);
protected slots:
void handleSettingChange(int key, int keyLevel, QVariant value);
signals:
void valueChanged();
};
#endif // SCSTWQMLSETTING_H

View file

@ -0,0 +1,126 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef SCSTWSETTINGS_H
#define SCSTWSETTINGS_H
#include <QObject>
#include <QVariant>
#include <QMetaEnum>
#include <QtDebug>
#include <QFile>
#include <QStandardPaths>
#include <QJsonDocument>
#include <ScStw.hpp>
#include <QDir>
#include <scstwsetting.h>
class ScStwSettings : public QObject
{
Q_OBJECT
public:
explicit ScStwSettings(QObject *parent = nullptr, bool overwriteFileOnErrors = true);
typedef QString(*keyToStringConverter)(int);
typedef QVariant::Type(*keyToTypeConverter)(int);
/*!
* \brief The BaseStationSetting enum contains all settings of the base station that can be changed by a client
*
* \see ScStw::baseStationSettingFromInt()
* \see ScStw::baseStationSettingToString()
* \see ScStw::baseStationSettingFromString()
* \see ScStw::baseStationSettings
*/
enum BaseStationSetting {
InvalidSetting = -1,
ReadySoundEnableSetting,
ReadySoundDelaySetting,
AtYourMarksSoundEnableSetting,
AtYourMarksSoundDelaySetting,
SoundVolumeSetting,
CompetitionModeSetting
};
Q_ENUM(BaseStationSetting)
enum KeyLevelEnum {
KeyLevel = 0
};
Q_ENUM(KeyLevelEnum)
virtual QVariant readSetting(BaseStationSetting key);
Q_INVOKABLE virtual QVariant readSetting(int key, int keyLevel);
virtual bool writeSetting(BaseStationSetting key, QVariant value);
Q_INVOKABLE virtual bool writeSetting(int key, int keyLevel, QVariant value);
virtual bool setDefaultSetting(BaseStationSetting key, QVariant defaultValue);
Q_INVOKABLE virtual bool setDefaultSetting(int key, int keyLevel, QVariant defaultValue);
Q_INVOKABLE ScStwSetting * getSetting(int key, int keyLevel);
static BaseStationSetting keyFromInt(int i) {
QMetaEnum enumeration = QMetaEnum::fromType<BaseStationSetting>();
return static_cast<BaseStationSetting>(enumeration.keyToValue(enumeration.valueToKey(i)));
}
static QString keyToString(int key) {
return QMetaEnum::fromType<BaseStationSetting>().valueToKey(key);
}
static QVariant::Type keyToType(int key) {
QMap<BaseStationSetting, QVariant::Type> types = {
{ReadySoundEnableSetting, QVariant::Bool},
{ReadySoundDelaySetting, QVariant::Double},
{AtYourMarksSoundEnableSetting, QVariant::Bool},
{AtYourMarksSoundDelaySetting, QVariant::Double},
{SoundVolumeSetting, QVariant::Double},
{CompetitionModeSetting, QVariant::Bool}
};
if(types.contains(BaseStationSetting(key)))
return types[BaseStationSetting(key)];
return QVariant::Invalid;
}
protected:
virtual QVariant readSetting(QString key, int keyInt = -1, int keyLevel = -1);
virtual bool writeSetting(QString key, QVariant value, int keyInt = -1,int keyLevel = -1);
virtual bool setDefaultSetting(QString key, QVariant defaultValue, int keyInt,int keyLevel = -1);
bool registerKeyLevelConverters(int keyLevel, keyToStringConverter, keyToTypeConverter);
private:
bool fileIsReadonly;
QFile * settingsFile;
QVariantMap settingsCache;
bool loadSettingsFromFile();
QMap<int, keyToStringConverter> keyToStringConverters;
QMap<int, keyToTypeConverter> keyToTypeConverters;
QMap<int, QMap<int, ScStwSetting*>> internalSettingHandlers;
private slots:
bool writeSettingsToFile();
signals:
void settingChanged(int key, int keyLevel, QVariant value);
};
#endif // SCSTWSETTINGS_H

View file

@ -0,0 +1,146 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef SCSTWSTARTSOUNDPLAYER_H
#define SCSTWSTARTSOUNDPLAYER_H
#include <QObject>
#include <QFile>
#include <QAudioOutput>
#include <QDebug>
#include <QEventLoop>
#include <QTimer>
#include <QDateTime>
#include <QSoundEffect>
#include <QAudioDeviceInfo>
#ifdef ScStwLibraries_Raspi
#include <alsa/asoundlib.h>
#endif
/*!
* \brief The ScStwSoundPlayer class is used for ultra low latency sound playback of the speed clibing start tones and commands
*/
class ScStwSoundPlayer : public QObject
{
Q_OBJECT
public:
/*!
* \brief ScStwSoundPlayer constructor
* \param parent
*/
explicit ScStwSoundPlayer(QObject *parent = nullptr);
enum StartSound {
None = -1,
AtYourMarks = 0,
Ready = 1,
Start = 2,
FalseStart = 3
};
enum PlayResult {
Success = 0,
Cancelled = -1,
Error = -2
};
private:
bool _setSoundVolume(double volume);
void _initializeSondEffect();
/*!
* \brief A map containing all sound files
* 0: AtYourMarksSound
* 1: ReadySound
* 2: StartSound
* 3: FalseStartSound
*/
QMap<StartSound, QVariantMap> soundFiles;
/*!
* \brief The sound effect object
*/
QSoundEffect *soundEffect;
QAudioDeviceInfo *_audioOutputDevice;
/*!
* \brief The QEventLoop used to wait for the sound to finish
*/
QEventLoop *waitLoop;
/*!
* \brief The QTimer to wait for the sound to finish
*/
QTimer *waitTimer;
/*!
* \brief The action that is currently played
*/
StartSound currentlyPlayingSound;
/*!
* \brief Holds the time the playback started at
*/
double playingStartedAt;
public slots:
/*!
* \brief Function to begin playing the sound of a certain state
* \param action The action to play (0: AtYourMarks, 1:Ready, 2:Start)
* \param volume The volume to play at
* \param timeOfStop The time the playback actually started (msecs since epoch)
* \return TODO true if the playback was successfully started, false otherwise
*/
ScStwSoundPlayer::PlayResult play(StartSound sound, double volume, double *timeOfStart = nullptr);
/*!
* \brief Function to wait for the playback to finish
* \param timeOfStop the point in time when the plyback actually stopped (msecs since epoch)
* \return false if there was any error (eg. there was no playback currently), true otherwise
*/
ScStwSoundPlayer::PlayResult waitForSoundFinish(double *timeOfStop = nullptr);
/*!
* \brief Function to cancel the current playback
*
* Note that this function will automatically play the false start tone if the currently playing action is 2
*
* \param volume the volume to play the false start sound at
* \return true if the playback was successfully stopped, false otherwise
*/
bool cancel();
bool isPlaying();
private slots:
signals:
/*!
* \brief Emitted whenever a playback started
*/
void playbackStarted();
};
#endif // SCSTWSTARTSOUNDPLAYER_H

View file

@ -0,0 +1,34 @@
#ifndef SCSTWSTARTSOUNDPLAYER_H
#define SCSTWSTARTSOUNDPLAYER_H
#include <QObject>
#include <QFile>
#include <QAudioOutput>
#include <QDebug>
#include <QEventLoop>
#include <QTimer>
#include <QDateTime>
class ScStwStartSoundPlayer : public QObject
{
Q_OBJECT
public:
explicit ScStwStartSoundPlayer(QObject *parent = nullptr);
private:
QFile *startSoundFile;
QAudioOutput *audioOutput;
QEventLoop *waitLoop;
public slots:
bool play(double volume, double *timeOfStop = nullptr);
//int interrupt();
private slots:
void handleStateChanged(QAudio::State newState);
signals:
};
#endif // SCSTWSTARTSOUNDPLAYER_H

View file

@ -0,0 +1,350 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef SCSTWTIMER_H
#define SCSTWTIMER_H
#include <QObject>
#include <QDateTime>
#include <QDebug>
#include <QTimer>
#include "ScStw.hpp"
class ScStwRace;
class ScStwRemoteRace;
/*!
* \brief The ScStwTimer class is used for advanced time measurement.
*
* It does not work on its own though.
* It is recommended to use it in combination with the ScStwRace class.
*
* ## When using standalone:
*
* \code{.cpp}
* ScStwTimer timer;
* // start the timer
* timer.start();
* // stop the timer
* timer.stop();
* \endcode
*
* The timer will now go into ScStw::WAITING state.
* That indicates that the timer has stopped and the final result has to be assigned by an external handler.
*
* \code{.cpp}
* // assign result 'won'
* timer.setResult(ScStwTimer::WON);
* \endcode
*
* The timer is now in ScStwTimer::WON state.
*
* \code{.cpp}
* // reset the timer
* timer.reset();
* \endcode
*
* The timer is not in ScStwTimer::IDLE state again.
*/
class ScStwTimer : public QObject
{
Q_OBJECT
Q_PROPERTY(QString letter READ getLetter WRITE setLetter)
public:
explicit ScStwTimer(QObject *parent = nullptr);
/*!
* \brief ScStwTimer constructor
* \param parent the parent object
* \param directControlEnabled Defines if protected properties (startTimer, stopTime, reactionTime and state) can be directly set from outside.
* \param letter the letter of the timer (only first char will be used!)
*/
explicit ScStwTimer(QString letter, QObject *parent = nullptr);
friend class ScStwRace;
/*!
* \brief The TimerState enum contains all state the timer can be in
*/
enum TimerState {
IDLE, /*!< Timer is waiting to be started */
STARTING, /*!< Timer is starting and will react with a false start if the climber starts */
RUNNING, /*!< Timer is running */
WAITING, /*!< Timer was stopped and is waiting to be set to either WON or LOST */
WON, /*!< Timer has won */
LOST, /*!< Timer has lost */
FAILING, /*!< Timer encountered a false start and is waiting to be set to either FAILED or WILDCARD */
WILDCARD, /*!< The opponent has done a false start */
FAILED, /*!< A false start occured */
CANCELLED, /*!< Timer was cancelled */
INCIDENT, /*!< There was a technical incident (most likely a disconnected extension) */
DISABLED /*!< Timer is disabled */
};
Q_ENUM(TimerState);
/*!
* \brief The ReadyStatus enum contains all possible reasons for a timer not to be ready (>0) and the case that it is ready (0)
*/
enum ReadyState {
IsReady = 0, /*!< Timer is ready for start */
NotInIdleState, /*!< Timer is not in IDLE state */
IsDisabled, /*!< Timer is disabled */
ExtensionIsNotConnected, /*!< Not all extension of the timer are conneted */
ExtensionBatteryIsCritical, /*!< The battery level of one or more extension is critical or unknown */
ClimberIsNotReady /*!< The startpad of the timer is not triggered */
};
Q_ENUM(ReadyState)
protected:
/*!
* \brief The current state of the timer
*/
TimerState state;
/*!
* \brief The time the timer was started at
*/
double startTime;
/*!
* \brief The time the timer was stopped at
*/
double stopTime;
/*!
* \brief the reaction time of the climber
*/
double reactionTime;
/*!
* \brief The letter (eg. "A" or "B") of the Timer (only one char)
*/
QString letter;
/*!
* \brief Defines if the timer currently wants to be disabled or not
*/
bool wantsToBeDisabled;
public slots:
/*!
* \brief Function to start the timer
*
* To do this, the timer has to be in ScStwTimer::STARTING state!
*
* \return false if the timer was not in the required state and therefore not started, true otherwise
*/
bool start();
/*!
* \brief Function to start the timer at a given point in time (present or future)
*
* To do this, the timer has to be in ScStwTimer::STARTING state!
*
* \param timeOfStart the point in time (msecs since epoch) when the timer is supposted to be started
* \return false if the timer was not in the required state and therefore not started, true otherwise
*/
virtual bool start(double timeOfStart);
/*!
* \brief Function to cancel the timer
*
* To do this, the timer has to be in ScStwTimer::IDLE, ScStwTimer::STARTING or ScStwTimer::RUNNING state!
*
* \return false if the timer was not in the required state and therefore not cancelled, true otherwise
*/
bool cancel();
/*!
* \brief Function to stop the timer
*
* To do this, the timer has to be in ScStwTimer::RUNNING state!
*
* \return false if the timer was not in the required state and therefore not stopped, true otherwise
*/
bool stop();
/*!
* \brief Function to stop the timer at a given point in time (past or future)
*
* To do this, the timer has to be in ScStwTimer::RUNNING state!
*
* \param timeOfStop the point in time (msecs since epoch) when the timer is supposted to be stopped
*
* \return false if the timer was not in the required state and therefore not stopped, true otherwise
*/
bool stop(double timeOfStop);
/*!
* \brief Function to assing the result of the race to the timer
*
* To do this, the timer has to be in ScStwTimer::WAITING state!
*
* \return false if the timer was not in the required state and the result therefore not set, true otherwise
*/
bool setResult(TimerState);
/*!
* \brief Function to reset the timer
*
* To do this, the timer has to be in ScStwTimer::WON or ScSTw::LOST state!
*
* \return false if the timer was not in the required state and therefore not reset, true otherwise
*/
virtual bool reset();
// -- helper functions --
/*!
* \brief Function to get the current state of the timer
* \return current state of the timer
* \see ScStwTimer::TimerState
*/
TimerState getState();
/*!
* \brief Function to get the current time of the timer
*
* To do this, the timer has to be in ScStwTimer::RUNNING, ScStwTimer::WAITING, ScStwTimer::WON or ScSTw::LOST state!
*
* \return The current / final time of the timer or -1 if it is not in the required state
*/
double getCurrentTime();
/*!
* \brief Function to get the reaction time of the climber.
* \return The climbers reaction time
*/
double getReactionTime();
/*!
* \brief Function to get the text, a timer display is supposed to show
* \return The text to show
*/
QString getText();
/*!
* \brief Function to get the letter of the timer
* \return The letter of the timer or ""
*/
QString getLetter();
/*!
* \brief Function to set the letter of the timer
* \param letter the letter
* \return The letter of the timer or ""
*/
void setLetter(QString letter);
/*!
* \brief Function to set if the timer is supposed to be disabled
*
* !!! CAUTION use this function with care, it immidiately changes the state of the timer !!!
* It is recommended to only use this function to change the timers state after the
* ScStwTimer::requestTimerEnableChange() signal was called, during the race,
* the timer is used in, is in IDLE state.
*
* \param disabled if the timer is supposed to be diabled
*/
void setDisabled(bool disabled);
/*!
* \brief Function to check if the timer currently wants to be disabled
* \return true or false
*/
bool getWantsToBeDisabled();
/*!
* \brief Function to get the current ready status of a timer
* \return The current ready status
*/
virtual ScStwTimer::ReadyState getReadyState();
bool isRunning();
bool isDisabled();
protected slots:
/*!
* \brief slot to call when the climber has started
* \param timeOfStart time (msecs since epoch) when the climber started
*/
void handleClimberStart(double timeOfStart);
/*!
* \brief Function to change the state of the timer
*
* Doing this will emit the ScStwTimer::stateChanged() signal (only if the new state differs from the current one)
*
* \param newState The new state
*/
void setState(TimerState newState);
/*!
* \brief Function to set whether the timer currently wants to be disabled
* \param wantsToBeDisabled true or false
*/
void setWantsToBeDisabled(bool wantsToBeDisabled);
/*!
* \brief Function to set the timer into INCIDENT state immidieately
*
* The current state of the timer will be ignored! It can only get out of this state by calling ScStwTimer::reset
*
* \see reset
*/
void technicalIncident();
/*!
* \brief Function to set the timer into WILDCARD state
*
* Only works when the timer is in STARTING state.
*
* \return false if not in STARTING state
*/
bool wildcard();
signals:
/*!
* \brief Emitted when the state of the timer changed
*/
void stateChanged(TimerState state);
/*!
* \brief Emitted when the reaction time changed
*/
void reactionTimeChanged();
/*!
* \brief Emitted when the timer wants its state to be changed by the external handler
* \param timer the timer object
*/
void wantsToBeDisabledChanged(ScStwTimer* timer, bool wantsToBeDisabled);
/*!
* \brief Emitted when the ready state of the timer changes
* \param readyState the new ReadyState
*/
void readyStateChanged(ReadyState readyState);
};
#endif // SCSTWTIMER_H

View file

@ -0,0 +1,61 @@
/****************************************************************************
** ScStw Styling
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef APPTHEME_H
#define APPTHEME_H
#include <QObject>
#include <QVariant>
#include <QFontDatabase>
class ScStwAppTheme : public QObject
{
Q_OBJECT
Q_PROPERTY(QVariant colors READ getColors NOTIFY colorsChanged)
Q_PROPERTY(QVariant icons READ getIcons NOTIFY iconsChanged)
Q_PROPERTY(QVariant fonts READ getFonts NOTIFY fontsChanged)
Q_PROPERTY(QVariant images READ getImages NOTIFY imagesChanged)
public:
explicit ScStwAppTheme(QString name, QVariantMap colors = {}, QVariantMap icons = {}, QVariantMap fonts = {}, QVariantMap images = {}, QObject *parent = nullptr);
private:
QString name;
QVariantMap colors;
QVariantMap icons;
QVariantMap fonts;
QVariantMap images;
signals:
void colorsChanged();
void iconsChanged();
void fontsChanged();
void imagesChanged();
public slots:
QString getName();
QVariant getColors();
QVariant getIcons();
QVariant getFonts();
QVariant getImages();
};
#endif // APPTHEME_H

View file

@ -0,0 +1,53 @@
/****************************************************************************
** ScStw Styling
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef SCSTWAPPTHEMEMANAGER_H
#define SCSTWAPPTHEMEMANAGER_H
#include <QObject>
#include <QColor>
#include "scstwapptheme.h"
class ScStwAppThemeManager : public QObject
{
Q_OBJECT
Q_PROPERTY(ScStwAppTheme* theme READ getTheme NOTIFY themeChanged)
Q_PROPERTY(QString themeName READ getThemeName WRITE setTheme NOTIFY themeChanged)
public:
explicit ScStwAppThemeManager(QObject *parent = nullptr);
private:
QList<ScStwAppTheme*> themes;
ScStwAppTheme* currentTheme;
ScStwAppTheme* findThemeByName(QString themeName);
QString lighter(QString color, double factor);
signals:
void themeChanged();
public slots:
ScStwAppTheme* getTheme();
Q_INVOKABLE bool setTheme(QString themeName);
Q_INVOKABLE QString getThemeName();
};
#endif // SCSTWAPPTHEMEMANAGER_H

View file

@ -0,0 +1,10 @@
<RCC>
<qresource prefix="/">
<file>lib/de/itsblue/ScStw/Styling/Components/BusyIndicator.qml</file>
<file>lib/de/itsblue/ScStw/Styling/Components/FadeAnimation.qml</file>
<file>lib/de/itsblue/ScStw/Styling/Components/Icon.qml</file>
<file>lib/de/itsblue/ScStw/Styling/Components/qmldir</file>
<file>lib/de/itsblue/ScStw/Styling/Components/Test.qml</file>
<file>lib/de/itsblue/ScStw/Styling/Components/TimerColumn.qml</file>
</qresource>
</RCC>

View file

@ -0,0 +1,49 @@
/****************************************************************************
** ScStw Styling
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
import QtQuick 2.0
import QtQuick.Templates 2.0 as T
import QtQuick.Controls 2.0
T.BusyIndicator {
id: control
property var image: "qrc:/images/SpeedHoldBlack.png"
implicitWidth: leftPadding + rightPadding
implicitHeight: topPadding + bottomPadding
contentItem: Item {
Image {
id: holdImage
anchors.fill: parent
source: control.image
fillMode: Image.PreserveAspectFit
}
RotationAnimation {
target: holdImage
running: control.running
duration: 1000
loops: Animation.Infinite
from: 0
to: 360
easing.type: Easing.InOutQuad
}
}
}

View file

@ -0,0 +1,73 @@
/****************************************************************************
** ScStw Styling
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
import QtQuick 2.0
SequentialAnimation {
id: root
property QtObject target
property int fadeDuration: 150
property int fadeDuration_in: fadeDuration
property int fadeDuration_out: fadeDuration
property alias outValueScale: outAnimationScale.to
property alias inValueScale: inAnimationScale.to
property alias outValueOpacity: outAnimationOpacity.to
property alias inValueOpacity: inAnimationOpacity.to
property string easingType: "Quad"
ParallelAnimation {
NumberAnimation { // in the default case, fade scale to 0
id: outAnimationScale
target: root.target
property: "scale"
duration: root.fadeDuration_in
to: 0.9
easing.type: Easing["In"+root.easingType]
}
NumberAnimation { // in the default case, fade scale to 0
id: outAnimationOpacity
target: root.target
property: "opacity"
duration: root.fadeDuration_in
to: 0
easing.type: Easing["In"+root.easingType]
}
}
PropertyAction { } // actually change the property targeted by the Behavior between the 2 other animations
ParallelAnimation {
NumberAnimation { // in the default case, fade scale back to 1
id: inAnimationScale
target: root.target
property: "scale"
duration: root.fadeDuration_out
to: 1
easing.type: Easing["Out"+root.easingType]
}
NumberAnimation { // in the default case, fade scale to 0
id: inAnimationOpacity
target: root.target
property: "opacity"
duration: root.fadeDuration_in
to: 1
easing.type: Easing["In"+root.easingType]
}
}
}

View file

@ -0,0 +1,45 @@
/****************************************************************************
** ScStw Styling
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
import QtQuick 2.0
import QtQuick.Controls 2.0
Item {
id: control
property string fontName
property color color
property string icon: "\uf850"
Label {
anchors.fill: parent
text: control.icon
font.styleName: control.fontName
color: control.color
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
fontSizeMode: Text.Fit
font.pixelSize: height
minimumPixelSize: 1
}
}

View file

@ -0,0 +1,23 @@
/****************************************************************************
** ScStw Styling
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
import QtQuick 2.12
Item {
}

View file

@ -0,0 +1,161 @@
/****************************************************************************
** ScStw Styling
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
import QtQuick 2.0
import QtQuick.Controls 2.0
import de.itsblue.ScStw 2.0
Column {
id: control
property var timers
property var colors
property var fontName
property bool showSecLabel: false
property bool showTimerLetter: true
property double textScale: 1
spacing: 0
Repeater {
id: timerRep
model: control.timers.length
delegate: Item {
id: timerDel
width: parent.width
height: control.height / timerRep.model
Text {
id: timerLetterLa
enabled: control.showTimerLetter && text !== ""
anchors {
left: parent.left
leftMargin: parent.width * 0.03
}
width: parent.width * 0.15
height: parent.height * 0.5
fontSizeMode: Text.Fit
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignLeft
opacity: enabled ? 1:0
text: control.timers[index]["letter"]
color: control.colors.accent
font.pixelSize: height
font.styleName: control.fontName
Behavior on opacity {
NumberAnimation {
duration: 200
}
}
}
Text {
id: timerTextLa
anchors.centerIn: parent
anchors.horizontalCenterOffset: timerLetterLa.enabled ? parent.width * 0.06:0
anchors.verticalCenterOffset: -(parent.height * 0.04 * reactTimeLa.opacity)
width: parent.width * 0.8
height: parent.height * 0.8
color: ([ScStwTimer.WON,ScStwTimer.WILDCARD].indexOf(control.timers[index]["state"]) >= 0 ? control.colors.success :
[ScStwTimer.FAILED,ScStwTimer.LOST].indexOf(control.timers[index]["state"]) >= 0 ? control.colors.error:
control.colors.text)
enabled: control.timers[index]["state"] !== ScStwTimer.DISABLED
text: control.timers[index]["text"]
fontSizeMode: Text.Fit
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: height * control.textScale
font.styleName: control.fontName
minimumPixelSize: 1
}
Text {
id: reactTimeLa
property int rtime: control.timers[index]["reactionTime"]
anchors {
centerIn: parent
verticalCenterOffset: timerTextLa.contentHeight * 0.4 + reactTimeLa.contentHeight * 0.4 + timerTextLa.anchors.verticalCenterOffset
horizontalCenterOffset: parent.width * 0.06
}
width: parent.width * 0.6
height: parent.height * 0.15
scale: enabled ? 1:0.9
opacity: enabled ? 1:0
enabled: control.timers[index]["state"] >= ScStwTimer.STARTING && rtime !== 0
fontSizeMode: Text.Fit
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: "reaction time (ms): " + Math.round(rtime)
color: control.colors.text
font.pixelSize: timerTextLa.font.pixelSize * control.textScale
font.styleName: control.fontName
minimumPixelSize: 1
Behavior on opacity {
NumberAnimation {
duration: 200
}
}
Behavior on scale {
NumberAnimation {
duration: 200
}
}
}
}
}
Behavior on opacity {
NumberAnimation {
duration: 200
}
}
}

View file

@ -0,0 +1,5 @@
module de.itsblue.ScStw.Styling.Components
BusyIndicator 1.0 BusyIndicator.qml
Icon 1.0 Icon.qml
TimerColumn 1.0 TimerColumn.qml
FadeAnimation 1.0 FadeAnimation.qml

View file

@ -0,0 +1,10 @@
<RCC>
<qresource prefix="/">
<file>sound/AtYourMarksSound.wav</file>
<file>sound/IFSC frequenzy and duration conform false start sound.wav</file>
<file>sound/ReadySound.wav</file>
<file>sound/FalseStartSound.wav</file>
<file>sound/StartsignalSound.wav</file>
<file>sound/StartsignalSoundExtended.wav</file>
</qresource>
</RCC>

View file

@ -0,0 +1,10 @@
<RCC>
<qresource prefix="/">
<file>fonts/fa5solid.woff</file>
<file>images/BaseStationBlack.png</file>
<file>images/BaseStationWhite.png</file>
<file>fonts/PTMono-Regular.ttf</file>
<file>images/SpeedHoldBlack.png</file>
<file>images/SpeedHoldWhite.png</file>
</qresource>
</RCC>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,93 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "../headers/ScStw.hpp"
const char *ScStw::SOCKET_MESSAGE_START_KEY = "<message>";
const char *ScStw::SOCKET_MESSAGE_END_KEY = "</message>";
ScStw::SignalKey ScStw::signalKeyFromInt(int i) {
bool ok;
ScStw::SignalKey k = ScStw::toEnumValue<ScStw::SignalKey>(i, &ok);
if(!ok)
return InvalidSignal;
else
return k;
}
ScStw::SocketCommand ScStw::socketCommandFromInt(int i) {
bool ok;
SocketCommand c = ScStw::toEnumValue<ScStw::SocketCommand>(i, &ok);
if(!ok)
return InvalidCommand;
else
return c;
}
QString ScStw::extensionTypeToString(ExtensionType t) {
switch (t) {
case StartPad:
return "StartPad";
case TopPad:
return "TopPad";
default:
return "Invalid";
}
}
int ScStw::firmwareCompare(QString a, QString b) {
/*
* * \return -3: major of a is lower than b
* -2: minor of a is lower than b
* -1: patch of a is lower than b
* 0: a and b are identical
* 1: patch b is lower than a
* 2: minor of b is lower than a
* 3: major of b is lower than a
*/
if(a.count(".") != 2 || a.length() != 5)
return -4;
int aMajor = a.split(".")[0].toInt();
int aMinor = a.split(".")[1].toInt();
int aPatch = a.split(".")[2].toInt();
if(b.count(".") != 2 || a.length() != 5)
return 4;
int bMajor = b.split(".")[0].toInt();
int bMinor = b.split(".")[1].toInt();
int bPatch = b.split(".")[2].toInt();
if(a == b)
return 0;
if(aMajor < bMajor)
return -3;
else
return 3;
if(aMinor < bMinor)
return -2;
else
return 2;
if(aPatch < bPatch)
return -1;
else
return 1;
}

View file

@ -0,0 +1,488 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "scstwclient.h"
ScStwClient * pGlobalScStwClient = nullptr;
ScStwClient::ScStwClient(QObject * parent, QList<ScStw::SignalKey> signalSubscriptions) : QObject(parent)
{
this->state = DISCONNECTED;
this->currentRequestId = 1;
this->extensions = QVariantMap({});
this->signalSubscriptions = signalSubscriptions;
this->socket = new QTcpSocket(this);
this->timeoutTimer = new QTimer(this);
this->timeoutTimer->setSingleShot(true);
connect(this->timeoutTimer, &QTimer::timeout,
[=](){this->handleError(QAbstractSocket::ProxyConnectionTimeoutError);});
connect(this->socket, SIGNAL(error(QAbstractSocket::SocketError)),
this, SLOT(handleError(QAbstractSocket::SocketError)));
connect(this->socket, &QAbstractSocket::stateChanged,
this, &ScStwClient::handleSocketStateChange);
connect(this->socket, &QAbstractSocket::readyRead,
this, &ScStwClient::handleReadyRead);
pGlobalScStwClient = this;
}
void ScStwClient::connectToHost() {
if(this->state != DISCONNECTED)
return;
setState(CONNECTING);
//connect
this->socket->connectToHost(this->ip, this->port);
timeoutTimer->start(3000);
}
void ScStwClient::connectionTimeout() {
if(this->state != CONNECTING)
return;
this->socket->abort();
disconnect(this->timeoutTimer, SIGNAL(timeout()), this, SLOT(connectionTimeout()));
}
bool ScStwClient::init() {
if(this->state != CONNECTING)
return false;
this->setState(INITIALISING);
this->timeoutTimer->stop();
QJsonArray signalSubs;
foreach (ScStw::SignalKey key, this->signalSubscriptions) {
signalSubs.append(key);
}
// init remote session
QJsonObject sessionParams = {{"apiVersion", this->API_VERSION}, {"signalSubscriptions", signalSubs}, {"init", true}, {"usingTerminationKeys", true}};
QVariantMap initResponse = this->sendCommand(1, sessionParams, 3000, false);
if(initResponse["status"] != 200) {
return false;
}
this->apiVersion = initResponse["data"].toMap()["apiVersion"].toString();
qDebug() << "[INFO][CLIENT] base station api version is: " << this->apiVersion;
int compareResult = ScStw::firmwareCompare(this->API_VERSION, this->apiVersion);
//qDebug() << "compare result is: " << compareResult;
if( compareResult == -3 ){
// the client version is out of date!!
this->closeConnection();
return false;
}
else if(compareResult == 3){
// the server version is out of date!!
this->closeConnection();
return false;
}
else if(compareResult == -4){
// the server sent an invalid version
this->closeConnection();
return false;
}
this->firmwareVersion = initResponse["data"].toMap()["firmwareVersion"].toString();
this->timeOffset = initResponse["data"].toMap()["time"].toDouble() - this->date->currentMSecsSinceEpoch();
qDebug() << "[INFO][BaseStation] Init done! firmware: " << this->firmwareVersion << " time offset: " << this->timeOffset;
this->setState(CONNECTED);
return true;
}
void ScStwClient::deInit() {
if(this->state == DISCONNECTED)
return;
this->currentRequestId = 1;
this->firmwareVersion = "";
this->apiVersion = "";
this->setExtensions(QVariantMap({}));
for(WaitingRequest waitingRequest : this->waitingRequests.values())
if(waitingRequest.loop != nullptr)
waitingRequest.loop->exit(ScStw::NotConnectedError);
this->waitingRequests.clear();
this->setState(DISCONNECTED);
}
void ScStwClient::closeConnection()
{
if(this->getState() == DISCONNECTED)
return;
qDebug() << "closing connection";
switch (socket->state())
{
case 0:
socket->disconnectFromHost();
break;
case 2:
socket->abort();
break;
default:
socket->abort();
}
}
// -------------------------------------
// --- socket communication handling ---
// -------------------------------------
QVariantMap ScStwClient::sendCommand(int header, QJsonValue data, int timeout) {
if(this->state != CONNECTED)
return {{"status", ScStw::NotConnectedError}, {"data", "not connected"}};
return this->sendCommand(header, data, timeout, true);
}
QVariantMap ScStwClient::sendCommand(int header, QJsonValue data, int timeout, bool useTerminationKeys) {
if(this->state != CONNECTED && this->state != INITIALISING){
return {{"status", ScStw::NotConnectedError}, {"data", "not connected"}};
}
// pick a new request id that is not already active
do {
if(this->currentRequestId >= 99)
this->currentRequestId = 0;
else
this->currentRequestId ++;
} while(this->waitingRequests.contains(this->currentRequestId));
int thisId = currentRequestId;
//qDebug() << "sending command: " << header << " with data: " << data << " and id: " << thisId;
QEventLoop *loop = new QEventLoop(this);
QTimer *timer = new QTimer(this);
QJsonObject reply;
this->waitingRequests.insert(thisId, {loop, reply});
QJsonObject requestObj;
requestObj.insert("id", thisId);
requestObj.insert("header", header);
requestObj.insert("data", data);
QString jsonRequest = QJsonDocument(requestObj).toJson();
timer->setSingleShot(true);
// quit the loop when the timer times out
connect(timer, &QTimer::timeout, [=]{loop->exit(ScStw::TimeoutError);});
// start the timer before starting to connect
timer->start(timeout);
//write data
if(useTerminationKeys)
socket->write(ScStw::SOCKET_MESSAGE_START_KEY + jsonRequest.toUtf8() + ScStw::SOCKET_MESSAGE_END_KEY);
else
socket->write(jsonRequest.toUtf8());
//wait for an answer to finish (programm gets stuck in here)
ScStw::StatusCode statusCode = ScStw::StatusCode(loop->exec());
// delete the timer
timer->deleteLater();
// find reply and delete the request from waiting list
if(this->waitingRequests.contains(thisId)) {
// request was found
// delete event loop
if(this->waitingRequests[thisId].loop != nullptr) {
this->waitingRequests[thisId].loop->deleteLater();
}
// store reply
reply = this->waitingRequests[thisId].reply;
// remove reply from waiting list
this->waitingRequests.remove(thisId);
}
else {
// some internal error occured
return {{"status", ScStw::InternalError}, {"data", ""}};
}
if(statusCode == ScStw::TimeoutError){
//the time has been triggered -> timeout
return {{"status", ScStw::TimeoutError}, {"data", ""}};
}
else if(statusCode == ScStw::NotConnectedError) {
// connection was closed during request
return {{"status", ScStw::NotConnectedError}, {"data", ""}};
}
delete timer;
return {{"status", reply.value("header").toInt()}, {"data", reply.value("data").toVariant()}};
}
void ScStwClient::handleSocketStateChange(QAbstractSocket::SocketState socketState) {
switch (socketState) {
case QAbstractSocket::UnconnectedState:
{
this->deInit();
break;
}
case QAbstractSocket::ConnectedState:
{
if(!this->init()) {
this->closeConnection();
}
break;
}
default:
{
//qDebug() << "+ --- UNKNOWN SOCKET STATE: " << socketState;
break;
}
}
}
void ScStwClient::handleError(QAbstractSocket::SocketError err)
{
if(err == QAbstractSocket::ProxyConnectionClosedError)
this->closeConnection();
switch (err) {
case QAbstractSocket::ProxyConnectionTimeoutError:
if(this->state == CONNECTING)
this->closeConnection();
break;
default:
break;
}
emit gotError(err);
qDebug() << "got socket error: " << err;
}
void ScStwClient::handleReadyRead() {
//qDebug() << "ready to ready " << socket->bytesAvailable() << " bytes" ;
QString reply = socket->readAll();
//qWarning() << "socket read: " << reply;
processSocketMessage(reply);
}
void ScStwClient::processSocketMessage(QString message) {
//qWarning() << "... processing message now ... : " << message;
QString startKey = ScStw::SOCKET_MESSAGE_START_KEY;
QString endKey = ScStw::SOCKET_MESSAGE_END_KEY;
if(message == ""){
return;
}
if((message.startsWith(startKey) && message.endsWith(endKey)) && (message.count(startKey) == 1 && message.count(endKey) == 1)){
// non-split message ( e.g.: <message>123456789</message>
}
else if(!message.contains(endKey) && (!this->readBuffer.isEmpty() || message.startsWith(startKey))){
// begin of a split message ( e.g.: <message>123 )
// or middle of a split message ( e.g.: 456 )
//qWarning() << "this is a begin or middle of split a message";
this->readBuffer += message;
return;
}
else if(!message.contains(startKey) && message.endsWith(endKey)) {
// end of a split message ( e.g.: 789</message> )
if(!this->readBuffer.isEmpty()){
message = readBuffer + message;
readBuffer.clear();
}
}
else if((message.count(startKey) > 1 || message.count(endKey) > 1) || (message.contains(endKey) && !message.endsWith(endKey) && message.contains(startKey) && !message.startsWith(startKey))) {
// multiple messages in one packet ( e.g.: <message>123456789</message><message>987654321</message> )
// or multiple message fragments in one message ( e.g.: 56789</message><message>987654321</message> or 56789</message><message>98765 )
//qDebug() << "detected multiple messages";
int startOfSecondMessage = message.lastIndexOf(startKey);
// process first part of message
QString firstMessage = message.left(startOfSecondMessage);
this->processSocketMessage(firstMessage);
// process second part of message
QString secondMessage = message.right(message.length() - startOfSecondMessage);
this->processSocketMessage(secondMessage);
return;
}
else {
// invalid message
return;
}
//qWarning() << "... done processing, message: " << message;
this->handleSocketMessage(message);
}
void ScStwClient::handleSocketMessage(QString reply) {
reply.replace(ScStw::SOCKET_MESSAGE_START_KEY, "");
reply.replace(ScStw::SOCKET_MESSAGE_END_KEY, "");
qDebug() << "got message: " << qPrintable(reply);
int id = 0;
QJsonDocument jsonReply = QJsonDocument::fromJson(reply.toUtf8());
QJsonObject replyObj = jsonReply.object();
if(!replyObj.isEmpty()){
id = replyObj.value("id").toInt();
if(id == -1) {
// this message is an update!!
emit this->handleSignal(replyObj.toVariantMap());
return;
}
// this message is the reply to a command!
if(this->waitingRequests.contains(id)){
this->waitingRequests[id].reply = replyObj;
if(this->waitingRequests[id].loop != nullptr){
this->waitingRequests[id].loop->exit(ScStw::Success);
}
return;
}
}
emit gotUnexpectedMessage(reply);
}
void ScStwClient::handleSignal(QVariantMap data) {
// get the signal type
if(ScStw::signalKeyFromInt(data["header"].toInt()) == ScStw::InvalidSignal)
return;
ScStw::SignalKey signalKey = ScStw::signalKeyFromInt(data["header"].toInt());
//qDebug() << "got signal: " << signalKey << " with data: " << data["data"];
switch (signalKey) {
case ScStw::ExtensionsChanged:
{
// the extension connections have changed
// -> handle locally
this->setExtensions(data["data"].toMap());
return;
break;
}
default: {
break;
}
}
// forward to external handlers
emit this->gotSignal(signalKey, data["data"]);
}
// ------------------------
// --- helper functions ---
// ------------------------
ScStw::StatusCode ScStwClient::writeRemoteSetting(ScStwSettings::BaseStationSetting key, QVariant value) {
QJsonArray requestData;
requestData.append(int(key));
requestData.append(QJsonValue::fromVariant(value));
return ScStw::StatusCode(this->sendCommand(3000, requestData)["status"].toInt());
}
QVariant ScStwClient::readRemoteSetting(ScStwSettings::BaseStationSetting key, ScStw::StatusCode* status) {
QVariantMap reply = this->sendCommand(3001, int(key), 10000);
qDebug() << "Setting read status is: " << reply["status"];
if(status != nullptr)
*status = ScStw::StatusCode(reply["status"].toInt());
if(reply["status"] != 200){
return "false";
}
return reply["data"];
}
void ScStwClient::setIP(QString newIp){
this->ip = newIp;
}
QString ScStwClient::getIP()
{
return this->ip;
}
ScStwClient::State ScStwClient::getState()
{
return this->state;
}
void ScStwClient::setState(ScStwClient::State newState){
if(this->state != newState) {
qDebug() << "+--- ScStwClient state changed: " << newState;
this->state = newState;
emit stateChanged();
}
}
QVariantMap ScStwClient::getExtensions() {
return this->extensions;
}
int ScStwClient::getTimeOffset() {
return this->timeOffset;
}
QString ScStwClient::getFirmwareVersion() {
return this->firmwareVersion;
}
QString ScStwClient::getApiVersion() {
return this->apiVersion;
}
void ScStwClient::setExtensions(QVariantMap extensions) {
qDebug() << "[CLIENT][DEBUG] Extensions changed: " << extensions;
if(this->extensions != extensions){
this->extensions = extensions;
emit this->gotSignal(ScStw::ExtensionsChanged, this->getExtensions());
emit this->extensionsChanged();
}
}
void ScStwClient::addSignalSubscription(ScStw::SignalKey key) {
if(!this->signalSubscriptions.contains(key))
this->signalSubscriptions.append(key);
}

View file

@ -0,0 +1,370 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "scstwremoterace.h"
ScStwRemoteRace::ScStwRemoteRace(QObject* parent) : ScStwRemoteRace(nullptr, nullptr, parent)
{
}
ScStwRemoteRace::ScStwRemoteRace(ScStwClient *scStwClient, ScStwSettings *settings, QObject *parent) : ScStwRace(settings, parent)
{
this->isReadyForNextState = true;
this->remoteTimers = {};
this->localTimers = {};
this->setScStwClient(scStwClient);
}
// --------------------------
// --- Main Functionality ---
// --------------------------
ScStw::StatusCode ScStwRemoteRace::start(bool asyncronous) {
if(this->local())
return ScStwRace::start(asyncronous);
if(this->getState() != ScStwRace::IDLE && this->getState() != ScStwRace::WAITING)
return ScStw::CurrentStateNotVaildForOperationError;
qDebug() << "+ --- starting race";
QVariantMap reply = this->scStwClient->sendCommand(ScStw::StartRaceCommand);
return ScStw::StatusCode(reply["status"].toInt());
}
ScStw::StatusCode ScStwRemoteRace::cancel() {
if(this->local())
return ScStwRace::cancel();
if(this->getState() != PREPAIRING && this->getState() != WAITING && this->getState() != STARTING && this->getState() != RUNNING)
return ScStw::CurrentStateNotVaildForOperationError;
qDebug() << "+ --- stopping race";
QVariantMap reply = this->scStwClient->sendCommand(ScStw::CancelRaceCommand);
return ScStw::StatusCode(reply["status"].toInt());
}
ScStw::StatusCode ScStwRemoteRace::stop() {
if(this->local())
return ScStwRace::stop();
if(this->getState() != ScStwRace::RUNNING && this->getState() != ScStwRace::STARTING)
return ScStw::CurrentStateNotVaildForOperationError;
qDebug() << "+ --- stopping race";
QVariantMap reply = this->scStwClient->sendCommand(ScStw::StopRaceCommand);
return ScStw::StatusCode(reply["status"].toInt());
}
ScStw::StatusCode ScStwRemoteRace::reset() {
if(this->local())
return ScStwRace::reset();
if(this->getState() != ScStwRace::STOPPED && this->getState() != ScStwRace::INCIDENT)
return ScStw::CurrentStateNotVaildForOperationError;
qDebug() << "+ --- resetting race";
QVariantMap reply = this->scStwClient->sendCommand(ScStw::ResetRaceCommand);
return ScStw::StatusCode(reply["status"].toInt());
}
ScStw::StatusCode ScStwRemoteRace::setTimerDisabled(int timerId, bool disabled) {
if(this->state != IDLE && this->state != WAITING)
return ScStw::CurrentStateNotVaildForOperationError;
if(timerId < 0 || timerId - 1 > this->timers.length())
return ScStw::ItemNotFoundError;
qDebug() << "+ --- setting timer " << timerId << " to disabled: " << disabled;
QVariantMap requestData = {
{"timerId", timerId},
{"disabled", disabled}
};
QVariantMap reply = this->scStwClient->sendCommand(ScStw::SetTimerDisabledCommand, QJsonValue::fromVariant(requestData));
qDebug() << "+ --- timer disabled command returned: " << reply;
return ScStw::StatusCode(reply["status"].toInt());
}
// -------------------------
// --- Base Station sync ---
// -------------------------
void ScStwRemoteRace::handleClientStateChange() {
switch (this->scStwClient->getState()) {
case ScStwClient::INITIALISING:
// disconnect all local timers from race
this->setTimers({}, false);
// delete all obsolete remote timers
for(ScStwRemoteTimer* oldRemoteTimer : this->remoteTimers)
oldRemoteTimer->deleteLater();
this->remoteTimers.clear();
break;
case ScStwClient::DISCONNECTED:
this->remoteTimers.clear();
this->setTimers(this->localTimers, false);
emit this->timersChanged();
emit this->detailsChanged();
emit this->currentStartDelayChanged();
this->competitionMode = false;
this->setState(IDLE);
break;
default:
break;
}
}
void ScStwRemoteRace::setTimers(QList<ScStwTimer*> timers, bool deleteOldTimers) {
// disconnect all signals of all current timers
//qDebug() << "SETTING TIMERS";
foreach(ScStwTimer *existingTimer, this->timers) {
disconnect(existingTimer, &ScStwTimer::stateChanged, this, &ScStwRace::handleTimerStateChange);
disconnect(existingTimer, &ScStwTimer::stateChanged, this, &ScStwRace::timersChanged);
disconnect(existingTimer, &ScStwTimer::wantsToBeDisabledChanged, this, &ScStwRace::handleTimerWantsToBeDisabledChange);
disconnect(existingTimer, &ScStwTimer::reactionTimeChanged, this, &ScStwRace::timersChanged);
disconnect(existingTimer, &ScStwTimer::readyStateChanged, this, &ScStwRace::handleTimerReadyStateChange);
disconnect(existingTimer, &ScStwTimer::readyStateChanged, this, &ScStwRace::isReadyForNextStateChanged);
if(deleteOldTimers)
existingTimer->deleteLater();
}
this->timers.clear();
for(ScStwTimer* timer : timers) {
this->addTimer(timer);
}
}
ScStwRemoteRace::RaceMode ScStwRemoteRace::getMode() {
if(this->scStwClient == nullptr || this->scStwClient->getState() != ScStwClient::CONNECTED)
return LOCAL;
else
return REMOTE;
}
bool ScStwRemoteRace::local() {
return this->getMode() == LOCAL;
}
/**
* @brief ScStwAppBackend::handleBaseStationUpdate
*
* Function to handle an update, sent by the base station, which indicates
* that some remote value (like a state) has changed
*
* @param data
*/
void ScStwRemoteRace::handleBaseStationSignal(ScStw::SignalKey key, QVariant data) {
switch (key) {
case ScStw::RaceDetailsChanged:
{
this->refreshDetails(data.toMap());
break;
}
default:
return;
}
}
void ScStwRemoteRace::refreshDetails(QVariantMap details) {
// the details of the race have changed:
qDebug() << "RACE DETAILS: " << details;
// competition mode
if(this->competitionMode != details["competitionMode"].toBool()) {
this->competitionMode = details["competitionMode"].toBool();
emit this->competitionModeChanged();
}
// ready sound enabled
if(this->readySoundEnabled != details["readySoundEnabled"].toBool()) {
this->readySoundEnabled = details["readySoundEnabled"].toBool();
emit this->readySoundEnabledChanged();
}
// current start delay
this->currentStartTotalDelay = details["currentStartDelay"].toMap()["total"].toInt();
this->latestStartDelayProgress = details["currentStartDelay"].toMap()["progress"].toDouble();
this->currentStartDelayStartedAt = QDateTime::currentMSecsSinceEpoch() - (this->currentStartTotalDelay * this->latestStartDelayProgress);
emit this->currentStartDelayChanged();
// timers
this->refreshRemoteTimers(details["timers"].toList());
// state
this->setState(ScStwRace::RaceState(details["state"].toInt()));
// isReady
if(this->state == WAITING) {
this->isReadyForNextState = details["isReadyForNextState"].toBool();
emit this->isReadyForNextStateChanged();
}
emit this->detailsChanged();
}
void ScStwRemoteRace::rebuildRemoteTimers(QVariantList remoteTimers) {
qDebug() << "REBUILDING TIMERS";
// delete all current timers
foreach(ScStwTimer * oldTimer, this->timers){
oldTimer->deleteLater();
}
this->remoteTimers.clear();
this->timers.clear();
foreach(QVariant remoteTimer, remoteTimers){
// create a local timer for each remote timer
ScStwRemoteTimer * timer = new ScStwRemoteTimer(this);
this->timers.append(timer);
this->remoteTimers.append(timer);
connect(timer, &ScStwTimer::stateChanged, this, &ScStwRace::timersChanged);
connect(timer, &ScStwTimer::reactionTimeChanged, this, &ScStwRace::timersChanged);
}
}
bool ScStwRemoteRace::refreshRemoteTimers(QVariantList newRemoteTimers) {
qDebug() << "REFRESHING TIMERS";
if(newRemoteTimers.length() != this->remoteTimers.length()){
// local timers are out of sync
this->rebuildRemoteTimers(newRemoteTimers);
qDebug() << "rebuilding remote timers";
}
for(QVariant remoteTimer : newRemoteTimers){
int currId = remoteTimer.toMap()["id"].toInt();
if(this->remoteTimers.length() <= currId)
this->rebuildRemoteTimers(newRemoteTimers);
ScStwTimer::TimerState newState = ScStwTimer::TimerState(remoteTimer.toMap()["state"].toInt());
qDebug() << "refreshing timers: id: " << currId << " state: " << newState << " readyState: " << remoteTimer.toMap()["readyState"].toInt() << " currentTime: " << remoteTimer.toMap()["currentTime"].toDouble();
double currentMSecsSinceEpoch = QDateTime::currentMSecsSinceEpoch();
this->remoteTimers[currId]->setStartTime(currentMSecsSinceEpoch - remoteTimer.toMap()["currentTime"].toDouble());
if(newState >= ScStwTimer::WAITING)
this->remoteTimers[currId]->setStopTime(currentMSecsSinceEpoch);
this->remoteTimers[currId]->setReactionTime(remoteTimer.toMap()["reactionTime"].toDouble());
this->remoteTimers[currId]->setLetter(remoteTimer.toMap()["letter"].toString());
this->remoteTimers[currId]->setReadyState(ScStwTimer::ReadyState(remoteTimer.toMap()["readyState"].toInt()));
this->remoteTimers[currId]->setState(newState);
}
emit this->timersChanged();
return true;
}
bool ScStwRemoteRace::addTimer(ScStwTimer* timer) {
if(this->local()) {
this->localTimers.append(timer);
return ScStwRace::addTimer(timer);
}
return false;
}
QVariantMap ScStwRemoteRace::getCurrentStartDelay() {
if(this->local())
return ScStwRace::getCurrentStartDelay();
QVariantMap currentStartDelay = {
{"total", -1.0},
{"progress", -1.0}
};
if(this->currentStartTotalDelay == -1) {
currentStartDelay["progress"] = this->latestStartDelayProgress;
}
else if(this->getState() == PREPAIRING || this->getState() == WAITING) {
// get the total delay and the delay progress of the next action timer
double elapsed = QDateTime::currentMSecsSinceEpoch() - this->currentStartDelayStartedAt;
currentStartDelay["total"] = this->currentStartTotalDelay;
if(elapsed < 0 || elapsed > currentStartDelay["total"].toDouble()) {
elapsed = currentStartDelay["total"].toDouble();
}
currentStartDelay["progress"] = elapsed / currentStartDelay["total"].toDouble();
}
return currentStartDelay;
}
bool ScStwRemoteRace::getIsReadyForNextState() {
if(this->local())
return ScStwRace::getIsReadyForNextState();
return this->isReadyForNextState;
}
bool ScStwRemoteRace::getReadySoundEnabled() {
if(this->local())
return ScStwRace::getReadySoundEnabled();
return this->readySoundEnabled;
}
void ScStwRemoteRace::refreshCompetitionMode() {
if(this->local())
return ScStwRace::refreshCompetitionMode();
}
ScStwClient* ScStwRemoteRace::getScStwClient() {
return this->scStwClient;
}
void ScStwRemoteRace::setScStwClient(ScStwClient* client) {
if(client == this->scStwClient)
return;
this->scStwClient = client;
if(this->scStwClient != nullptr) {
this->scStwClient->addSignalSubscription(ScStw::RaceDetailsChanged);
connect(this->scStwClient, &ScStwClient::stateChanged, this, &ScStwRemoteRace::handleClientStateChange);
connect(this->scStwClient, &ScStwClient::gotSignal, this, &ScStwRemoteRace::handleBaseStationSignal);
}
}

View file

@ -0,0 +1,104 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "../../headers/client/scstwremotesettings.h"
ScStwRemoteSettings::ScStwRemoteSettings(QObject* parent) : ScStwSettings(parent)
{
this->scStwClient = nullptr;
}
ScStwRemoteSettings::ScStwRemoteSettings(ScStwClient * scStwClient, QObject * parent) : ScStwSettings(parent)
{
this->setScStwClient(scStwClient);
}
ScStwRemoteSettings::SettingsMode ScStwRemoteSettings::getMode() {
if(this->scStwClient == nullptr || this->scStwClient->getState() != ScStwClient::CONNECTED)
return LOCAL;
else
return REMOTE;
}
QVariant ScStwRemoteSettings::readSetting(QString key, int keyInt, int keyLevel) {
if(this->getMode() == LOCAL || keyLevel > ScStwSettings::KeyLevel)
return ScStwSettings::readSetting(key, keyInt, keyLevel);
qDebug() << "Setting read: keyLevel: " << keyLevel << " key: " << key;
ScStw::StatusCode status;
QVariant value = this->scStwClient->readRemoteSetting(ScStwSettings::BaseStationSetting(keyInt), &status);
if(status == ScStw::Success)
return value;
else
return QVariant();
}
bool ScStwRemoteSettings::writeSetting(QString key, QVariant value, int keyInt, int keyLevel) {
if(this->getMode() == LOCAL || keyLevel > ScStwSettings::KeyLevel)
return ScStwSettings::writeSetting(key, value, keyInt, keyLevel);
qDebug() << "Setting write: keyLevel: " << keyLevel << " key: " << key << " value: " << value;
ScStw::StatusCode res = this->scStwClient->writeRemoteSetting(ScStwSettings::BaseStationSetting(keyInt), value);
return res == ScStw::Success;
}
bool ScStwRemoteSettings::setDefaultSetting(QString key, QVariant defaultVariant, int keyInt, int keyLevel) {
if(this->getMode() == LOCAL || keyLevel > ScStwSettings::KeyLevel)
return ScStwSettings::setDefaultSetting(key, defaultVariant, keyInt, keyLevel);
return false;
}
void ScStwRemoteSettings::handleClientStateChange() {
if(this->scStwClient->getState() == ScStwClient::DISCONNECTED)
emit this->settingChanged(-1, ScStwSettings::KeyLevel, QVariant());
// Dont't need to do that when changing to connected,
// as the basestation emits a wildcrd setting changed on connect anyway
}
void ScStwRemoteSettings::handleBaseStationSignal(ScStw::SignalKey key, QVariant data) {
switch (key) {
case ScStw::SettingChanged:
emit this->settingChanged(data.toMap()["key"].toInt(), ScStwSettings::KeyLevel, data.toMap()["value"]);
default:
break;
}
}
ScStwClient* ScStwRemoteSettings::getScStwClient() {
return this->scStwClient;
}
void ScStwRemoteSettings::setScStwClient(ScStwClient* client) {
if(client == this->scStwClient)
return;
this->scStwClient = client;
if(this->scStwClient != nullptr) {
this->scStwClient->addSignalSubscription(ScStw::SettingChanged);
connect(this->scStwClient, &ScStwClient::stateChanged, this, &ScStwRemoteSettings::handleClientStateChange);
connect(this->scStwClient, &ScStwClient::gotSignal, this, &ScStwRemoteSettings::handleBaseStationSignal);
}
}

View file

@ -0,0 +1,42 @@
#include "../../headers/client/scstwremotetimer.h"
ScStwRemoteTimer::ScStwRemoteTimer(QObject *parent) : ScStwTimer(parent)
{
this->readyState = ScStwTimer::getReadyState();
}
ScStwTimer::ReadyState ScStwRemoteTimer::getReadyState() {
return this->readyState;
}
void ScStwRemoteTimer::setStartTime(double startTime) {
this->startTime = startTime;
}
void ScStwRemoteTimer::setStopTime(double stopTime) {
this->stopTime = stopTime;
}
void ScStwRemoteTimer::setReactionTime(double reactionTime) {
this->reactionTime = reactionTime;
emit this->reactionTimeChanged();
}
void ScStwRemoteTimer::setLetter(QString newLetter) {
this->letter = newLetter;
}
void ScStwRemoteTimer::setReadyState(ScStwTimer::ReadyState readyState) {
if(this->readyState != readyState) {
this->readyState = readyState;
emit this->readyStateChanged(readyState);
}
}
void ScStwRemoteTimer::setState(TimerState newState){
if(this->state != newState) {
this->state = newState;
qDebug() << "+ [INFO][REMOTETIMER] timer state changed: " << newState;
emit this->stateChanged(this->state);
}
}

View file

@ -0,0 +1,57 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "../headers/scstwlibraries.h"
ScStwLibraries::ScStwLibraries(QObject *parent) : QObject(parent)
{
}
void ScStwLibraries::init() {
#ifdef ScStwLibraries_QML
qmlRegisterType<ScStw>("de.itsblue.ScStw", 2, 0, "ScStw");
qRegisterMetaType<ScStwSettings::BaseStationSetting>("ScStwSettings::BaseStationSetting");
qRegisterMetaType<ScStw::SocketCommand>("ScStw::SocketCommand");
qRegisterMetaType<ScStw::StatusCode>("ScStw::StatusCode");
qmlRegisterType<ScStwRace>("de.itsblue.ScStw", 2, 0, "ScStwRace");
qmlRegisterType<ScStwTimer>("de.itsblue.ScStw", 2, 0, "ScStwTimer");
#ifdef ScStwLibraries_ClientLibs
qmlRegisterType<ScStwClient>("de.itsblue.ScStw", 2, 0, "ScStwClient");
qmlRegisterType<ScStwSettings>("de.itsblue.ScStw", 2, 0, "ScStwSettings");
qmlRegisterUncreatableType<ScStwSetting>("de.itsblue.ScStw", 2, 0, "ScStwSetting", "The ScStwSetting is manage by a ScStwSettings instance and therefore not creatable");
qmlRegisterType<ScStwRemoteRace>("de.itsblue.ScStw", 2, 0, "ScStwRemoteRace");
qmlRegisterType<ScStwRemoteSettings>("de.itsblue.ScStw", 2, 0, "ScStwRemoteSettings");
#endif
#endif
qRegisterMetaType<ScStw::PadState>("ScStw::PadState");
}
#ifdef ScStwLibraries_QML
#ifdef ScStwLibraries_Styling
void ScStwLibraries::initStyling(QQmlApplicationEngine *engine) {
qmlRegisterUncreatableType<ScStwAppTheme>("de.itsblue.ScStw.Styling", 2, 0, "ScStwAppTheme", "The ScStwAppTheme has to be managed by a ScStwAppTheme manager and is therefore not creatable");
qmlRegisterType<ScStwAppThemeManager>("de.itsblue.ScStw.Styling", 2, 0, "ScStwAppThemeManager");
engine->addImportPath(":/lib");
}
#endif
#endif

View file

@ -0,0 +1,913 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "../headers/scstwrace.h"
ScStwRace::ScStwRace(QObject* parent) : ScStwRace(nullptr, parent)
{
}
ScStwRace::ScStwRace(ScStwSettings *settings, QObject *parent) : QObject(parent)
{
this->state = IDLE;
this->competitionMode = false;
this->autoRefreshTimerText = false;
// configure the loop that waits for the sound effect to finish
this->soundPlayer = new ScStwSoundPlayer();
// configure timer that handles the delay between the start commands
this->startDelayTimer = new QTimer(this);
startDelayTimer->setSingleShot(true);
this->startWaitLoop = new QEventLoop(this);
connect(this->startDelayTimer, &QTimer::timeout, this->startWaitLoop, &QEventLoop::quit);
connect(this, &ScStwRace::currentStartDelayChanged, this, &ScStwRace::detailsChanged);
connect(this, &ScStwRace::timersChanged, this, &ScStwRace::detailsChanged);
connect(this, &ScStwRace::stateChanged, this, &ScStwRace::detailsChanged);
// init settings
this->setSettings(settings);
}
// --------------------------
// --- Main Functionality ---
// --------------------------
ScStw::StatusCode ScStwRace::start(bool asyncronous) {
if(this->state == WAITING) {
if(this->getIsReadyForNextState()) {
this->startWaitLoop->exit(LoopManualExit);
return ScStw::Success;
}
else {
return ScStw::TimersNotReadyError;
}
}
else if(this->state != IDLE) {
return ScStw::CurrentStateNotVaildForOperationError;
}
this->refreshCompetitionMode();
if(!this->getIsReadyForNextState())
return ScStw::TimersNotReadyError;
this->setState(PREPAIRING);
if(asyncronous) {
QTimer::singleShot(1, [=]() {
this->playSoundsAndStartTimers();
});
}
else
this->playSoundsAndStartTimers();
return ScStw::Success;
}
ScStw::StatusCode ScStwRace::stop() {
if(this->state != RUNNING && this->state != STARTING) {
return ScStw::CurrentStateNotVaildForOperationError;
}
if(this->competitionMode)
return this->cancel();
qDebug() << "[INFO][RACE] stopping race";
double timeOfStop = QDateTime::currentMSecsSinceEpoch();
ScStw::StatusCode returnCode = ScStw::Success;
foreach(ScStwTimer *speedTimer, this->timers) {
if(!speedTimer->stop(timeOfStop) && speedTimer->getState() != ScStwTimer::DISABLED) {
returnCode = ScStw::InternalErrorTimerOperationFailed;
}
}
if(returnCode == ScStw::Success) {
this->setState(STOPPED);
}
return returnCode;
}
ScStw::StatusCode ScStwRace::reset() {
if(this->state != STOPPED && this->state != INCIDENT) {
return ScStw::CurrentStateNotVaildForOperationError;
}
qDebug() << "[INFO][RACE] resetting race";
if(this->competitionMode) {
for(int i = 0; i < this->timers.length(); i++)
this->setTimerDisabled(i, false);
}
ScStw::StatusCode returnCode = ScStw::Success;
foreach(ScStwTimer *timer, this->timers) {
if(!timer->reset() && timer->getState() != ScStwTimer::DISABLED && timer->getState() != ScStwTimer::IDLE) {
returnCode = ScStw::InternalErrorTimerOperationFailed;
}
}
if(returnCode == ScStw::Success)
this->setState(IDLE);
this->soundPlayer->cancel();
return returnCode;
}
ScStw::StatusCode ScStwRace::cancel() {
if(this->state != PREPAIRING && this->state != WAITING && this->state != STARTING && this->state != RUNNING)
return ScStw::CurrentStateNotVaildForOperationError;
qDebug() << "[INFO][RACE] cancelling race";
ScStw::StatusCode returnCode = ScStw::Success;
foreach(ScStwTimer *timer, this->timers) {
if(!timer->cancel() && timer->getState() != ScStwTimer::DISABLED)
returnCode = ScStw::InternalErrorTimerOperationFailed;
}
if(returnCode != ScStw::Success)
return returnCode;
this->setState(STOPPED);
this->startWaitLoop->exit(LoopCancelExit);
this->soundPlayer->cancel();
this->startDelayTimer->stop();
emit this->currentStartDelayChanged();
return returnCode;
}
ScStw::StatusCode ScStwRace::setTimerDisabled(int timerId, bool disabled) {
if(timerId < 0 || timerId - 1 > this->timers.length())
return ScStw::ItemNotFoundError;
return this->setTimerDisabled(this->timers[timerId], disabled);
}
ScStw::StatusCode ScStwRace::setTimerDisabled(ScStwTimer* timer, bool disabled) {
//qDebug() << "[INFO][RACE] Setting timer "<< timer->getLetter() << " to disabled: " << disabled << " this state: " << this->state;
if(this->state != IDLE && this->state != WAITING)
return ScStw::CurrentStateNotVaildForOperationError;
if(!this->timers.contains(timer))
return ScStw::ItemNotFoundError;
int enabledTimerCount = 0;
foreach(ScStwTimer *timer, this->timers) {
if(timer->getState() != ScStwTimer::DISABLED)
enabledTimerCount ++;
}
if(disabled && enabledTimerCount <= 1)
return ScStw::LastTimerCannotBeDisabledError;
//qDebug() << "[INFO][RACE] Setting timer "<< timer->getLetter() << " to disabled: " << disabled;
timer->setDisabled(disabled);
emit this->timersChanged();
return ScStw::Success;
}
void ScStwRace::handleTimerReadyStateChange(ScStwTimer::ReadyState readyState) {
if(!this->competitionMode || this->state == IDLE || this->state == STOPPED || this->state == INCIDENT )
return;
qDebug() << "Some ready state changed: " << readyState;
// cancel as a technical incident if extensions are disconnected or run low on battery
if(readyState == ScStwTimer::ExtensionIsNotConnected || readyState == ScStwTimer::ExtensionBatteryIsCritical) {
this->technicalIncident();
return;
}
// only continue if the current state is waiting
if(this->state == WAITING) {
this->startWaitLoop->exit(ScStwRace::LoopReadyStateChangeExit);
emit this->timersChanged();
}
}
bool ScStwRace::playSoundsAndStartTimers() {
if(this->state != PREPAIRING)
return true;
// The check if all timers are ready has already happened at this point
ScStwSoundPlayer::PlayResult res = this->doDelayAndSoundOfCurrentStartState();
if(res == ScStwSoundPlayer::Error) {
qDebug() << "[ERROR][RACE] error playing at your marks sound";
this->technicalIncident();
return false;
}
else if(res == ScStwSoundPlayer::Cancelled) {
return false;
}
// check if the start was cancelled
if(!this->isStarting())
return false;
this->setState(WAITING);
// do climber readiness tests
// if the automatic ready tone is enabled, wait for the climbers to become ready
if(this->competitionMode && this->getSoundEnabledSetting(ScStwSoundPlayer::Ready)) {
qDebug() << "[RACE][INFO] Now waiting for climbers";
// get delay
int minimumReadyDelay = 1000;
if(this->getSoundDelaySetting(ScStwSoundPlayer::Ready) > 1000)
minimumReadyDelay = this->getSoundDelaySetting(ScStwSoundPlayer::Ready);
this->startDelayTimer->setInterval(minimumReadyDelay);
// wait for all climbers to be ready for the ReadyActionDelay, but at least one second continuosly
// the climber ready wait loop will also quit, if the climber steps of the pad
// -> wait for both climbers to stand on the pad for at least one second
bool timerTriggered = true;
do {
if(!this->getIsReadyForNextState()) {
this->startDelayTimer->stop();
timerTriggered = false;
}
else if(this->startDelayTimer->isActive()) {
timerTriggered = true;
}
else {
this->startDelayTimer->stop();
this->startDelayTimer->setInterval(minimumReadyDelay);
this->startDelayTimer->start();
timerTriggered = true;
}
emit this->currentStartDelayChanged();
int loopExitCode = this->startWaitLoop->exec();
switch (loopExitCode) {
case LoopAutomaticExit:
break;
case LoopManualExit:
// prevent manual stop
timerTriggered = false;
break;
case LoopCancelExit:
return false;
}
//qDebug() << "At end of loop: remaining time: " << this->startDelayTimer->remainingTime() << " timer triggered: " << timerTriggered << " ready for next state: " << this->isReadyForNextState();
} while(this->startDelayTimer->remainingTime() > 0 || !timerTriggered || !this->getIsReadyForNextState());
qDebug() << "[DEBUG][RACE] Wait finished, starting now!";
// play ready tone
ScStwSoundPlayer::PlayResult res = this->soundPlayer->play(ScStwSoundPlayer::Ready, this->getSoundVolume());
if(res == ScStwSoundPlayer::Error) {
qDebug() << "[ERROR][RACE] error playing ready sound";
this->technicalIncident();
return false;
}
else if(res == ScStwSoundPlayer::Cancelled) {
return false;
}
}
else if(this->competitionMode) {
// wait for climbers and manual start
int loopExitCode;
do {
loopExitCode = this->startWaitLoop->exec();
if(loopExitCode == LoopCancelExit)
return false;
} while(loopExitCode != LoopManualExit || !this->getIsReadyForNextState());
}
else {
ScStwSoundPlayer::PlayResult res = this->doDelayAndSoundOfCurrentStartState();
if(res == ScStwSoundPlayer::Error) {
qDebug() << "[ERROR][RACE] error playing ready sound";
this->technicalIncident();
return false;
}
else if(res == ScStwSoundPlayer::Cancelled) {
return false;
}
}
// enter starting state
this->setState(STARTING);
// play start tone
double timeOfSoundPlaybackStart;
res = this->doDelayAndSoundOfCurrentStartState(&timeOfSoundPlaybackStart);
if(res == ScStwSoundPlayer::Error) {
qDebug() << "[ERROR][RACE] error playing at your marks sound";
this->technicalIncident();
return false;
}
else if(res == ScStwSoundPlayer::Cancelled) {
return false;
}
// perform start
// start all timers
bool startOk = true;
foreach(ScStwTimer *timer, this->timers) {
if(!timer->start(timeOfSoundPlaybackStart + 3000) && timer->getState() != ScStwTimer::DISABLED) {
startOk = false;
}
}
if(!startOk) {
qDebug() << "[ERROR][RACE] error staring all timers";
this->technicalIncident();
return false;
}
if(this->soundPlayer->waitForSoundFinish() == ScStwSoundPlayer::Error) {
qDebug() << "[ERROR][RACE] start sound wait error";
this->technicalIncident();
return false;
}
// check if a false start occured
if(!this->isStarting())
return false;
this->setState(RUNNING);
return true;
}
ScStwSoundPlayer::PlayResult ScStwRace::doDelayAndSoundOfCurrentStartState(double *timeOfSoundPlaybackStart) {
ScStwSoundPlayer::StartSound sound = this->getSoundForState(this->state);
if(this->getSoundEnabledSetting(sound)) {
if(sound != ScStwSoundPlayer::Start && this->getSoundDelaySetting(sound) > 0) {
// perform the delay before the start
// get delay
int thisSoundDelay = this->getSoundDelaySetting(sound);
// perform next action
if(thisSoundDelay > 0) {
this->startDelayTimer->setInterval(thisSoundDelay);
this->startDelayTimer->start();
emit this->currentStartDelayChanged();
if(this->startWaitLoop->exec() == LoopCancelExit)
return ScStwSoundPlayer::Cancelled;
}
}
if(!this->isStarting())
return ScStwSoundPlayer::Error;
return this->soundPlayer->play(sound, this->getSoundVolume(), timeOfSoundPlaybackStart);
}
return ScStwSoundPlayer::Success;
}
void ScStwRace::setState(RaceState newState) {
if(newState != this->state) {
qDebug() << "[INFO][RACE] state changed: " << newState;
this->state = newState;
emit this->stateChanged(newState);
if(this->state == IDLE) {
this->refreshCompetitionMode();
}
}
}
void ScStwRace::handleTimerStateChange(ScStwTimer::TimerState newState) {
if(
newState == ScStwTimer::WON ||
newState == ScStwTimer::LOST ||
newState == ScStwTimer::WILDCARD ||
newState == ScStwTimer::FAILED ||
this->state == INCIDENT
)
return;
qDebug() << "[INFO][MAIN] handling timer state change";
// check if the race is over
bool raceIsOver = true;
int incidentCount = 0;
foreach(ScStwTimer * timer, this->timers) {
if(timer->getState() < ScStwTimer::WAITING) {
// if the timer is not in stoped state
raceIsOver = false;
}
else if(timer->getState() == ScStwTimer::WAITING)
this->handleTimerStop();
else if (timer->getState() == ScStwTimer::FAILING)
this->handleFalseStart();
else if (timer->getState() == ScStwTimer::INCIDENT)
incidentCount ++;
}
if(incidentCount == this->timers.length()) {
this->setState(INCIDENT);
this->soundPlayer->play(ScStwSoundPlayer::FalseStart, this->getSoundVolume());
}
else if(raceIsOver)
this->setState(STOPPED);
}
void ScStwRace::handleTimerStop() {
if(this->state != RUNNING)
return;
qDebug() << "[INFO][RACE] Got a TIMER STOP";
// find out which timer has won
double lowestStoppedTime = -1;
// iterate through all timers and find the lowest time that was stopped
foreach(ScStwTimer * timer, this->timers) {
qDebug() << "Current stopped time is: " << timer->getCurrentTime();
if(!timer->isRunning() && !timer->isDisabled() && (timer->getCurrentTime() <= lowestStoppedTime || lowestStoppedTime < 0)) {
// this is the timer with the lowest stopped time
lowestStoppedTime = timer->getCurrentTime();
}
}
qDebug() << "LOWEST Stop time is: " << lowestStoppedTime;
// append the timer(s) with the lowest stopped time to the winner list
foreach(ScStwTimer * timer, this->timers) {
if(timer->getCurrentTime() <= lowestStoppedTime)
// this is the timer with the lowest stopped time
timer->setResult(ScStwTimer::WON);
else
timer->setResult(ScStwTimer::LOST);
}
}
void ScStwRace::handleFalseStart() {
if(this->state != STARTING && this->state != RUNNING && this->state != STOPPED)
return;
qDebug() << "[INFO][RACE] Got a FALSE START";
// set lowest to a value that is impossible to reach (start tone is only 3100ms long)
double lowestReactionTime = -4000;
// iterate through all timers and find the lowest reactiontime that was stopped
foreach(ScStwTimer *timer, this->timers) {
if(
timer->getState() >= ScStwTimer::FAILING &&
timer->getState() <= ScStwTimer::FAILED &&
!timer->isDisabled() &&
(
timer->getReactionTime() < lowestReactionTime ||
lowestReactionTime == -4000
)
) {
lowestReactionTime = timer->getReactionTime();
}
}
if(lowestReactionTime == -4000)
// no timer has failed
return;
qDebug() << "LOWEST reaction time is: " << lowestReactionTime;
// find out which timer(s) have lost and which get a wildcard
foreach(ScStwTimer * timer, this->timers) {
qDebug() << "THIS TIMERS reaction time is: " << timer->getReactionTime();
if(
timer->getState() >= ScStwTimer::FAILING &&
timer->getState() <= ScStwTimer::FAILED &&
!timer->isDisabled() &&
timer->getReactionTime() <= lowestReactionTime
) {
// this is the timer with the lowest stopped time
timer->setResult(ScStwTimer::FAILED);
qDebug() << "FOUND BAD TIMER";
}
else {
timer->setResult(ScStwTimer::WILDCARD);
}
}
if(this->state != STOPPED) {
this->setState(STOPPED);
this->soundPlayer->cancel();
this->soundPlayer->play(ScStwSoundPlayer::FalseStart, this->getSoundVolume());
}
}
void ScStwRace::technicalIncident() {
bool raceIsRunning = this->state == RUNNING;
qDebug() << "[ERROR][RACE] Got a technical incident, state is: " << this->state;
if(!raceIsRunning) {
this->startWaitLoop->exit(LoopCancelExit);
if(this->state == STARTING) {
this->soundPlayer->cancel();
this->soundPlayer->play(ScStwSoundPlayer::FalseStart, this->getSoundVolume());
}
this->setState(INCIDENT);
}
foreach(ScStwTimer *timer, this->timers) {
if(raceIsRunning && timer->getReadyState() == ScStwTimer::ExtensionBatteryIsCritical)
continue;
else if(timer->getReadyState() == ScStwTimer::ExtensionIsNotConnected || timer->getReadyState() == ScStwTimer::ExtensionBatteryIsCritical)
timer->technicalIncident();
else if(!raceIsRunning)
timer->setState(ScStwTimer::CANCELLED);
}
}
// ------------------------
// --- helper functions ---
// ------------------------
bool ScStwRace::getIsReadyForNextState() {
if(!this->competitionMode) {
return true;
}
switch (this->state) {
case IDLE: {
foreach (ScStwTimer *timer, this->timers) {
if(timer->getState() == ScStwTimer::DISABLED)
continue;
if(timer->getReadyState() == ScStwTimer::ExtensionIsNotConnected || timer->getReadyState() == ScStwTimer::ExtensionBatteryIsCritical) {
this->technicalIncident();
qDebug() << "[ERROR][RACE] Could not start due to not-ready timers";
return false;
}
}
break;
case WAITING: {
foreach (ScStwTimer *timer, this->timers) {
if(timer->getReadyState() != ScStwTimer::IsReady && timer->getReadyState() != ScStwTimer::IsDisabled)
return false;
}
break;
}
default:
break;;
}
}
return true;
}
/**
* @brief ScStwRace::handleTimerEnable function to enable timers at the right moment to prevent them from bricking the state machine
* @param {ScStwExtensionControlledTimer*} timer timer to be enabled
*/
void ScStwRace::handleTimerWantsToBeDisabledChange(ScStwTimer* timer, bool wantsToBeDisabled) {
//qDebug() << "Handling timer wants to be disabled";
if(this->competitionMode)
return;
if(this->state == IDLE) {
//qDebug() << "Handling timer wants to be disabled: " << wantsToBeDisabled;
this->setTimerDisabled(timer, wantsToBeDisabled);
}
}
void ScStwRace::refreshCompetitionMode() {
if(this->state != IDLE)
return;
bool currentCompetitionMode = false;
if(this->settings != nullptr)
currentCompetitionMode = this->settings->readSetting(ScStwSettings::CompetitionModeSetting).toBool();
if(this->competitionMode != currentCompetitionMode) {
qDebug() << "[INFO][RACE] Setting competition mode to " << currentCompetitionMode;
this->competitionMode = currentCompetitionMode;
}
if(this->competitionMode) {
foreach (ScStwTimer *timer, this->timers) {
timer->setDisabled(false);
}
}
else {
foreach(ScStwTimer* timer, this->timers) {
if(
(timer->getWantsToBeDisabled() && timer->getState() != ScStwTimer::DISABLED) ||
(!timer->getWantsToBeDisabled() && timer->getState() == ScStwTimer::DISABLED)
)
this->handleTimerWantsToBeDisabledChange(timer, timer->getWantsToBeDisabled());
}
}
}
QVariantMap ScStwRace::getCurrentStartDelay() {
QVariantMap currentStartDelay = {
{"total", -1.0},
{"progress", -1.0}
};
switch (this->state) {
case WAITING:
if(!this->getSoundEnabledSetting(ScStwSoundPlayer::Ready))
return currentStartDelay;
if(!this->getIsReadyForNextState()) {
// indicate that we are waiting for climbers and the progress shall be zero
currentStartDelay["progress"] = 0;
return currentStartDelay;
}
break;
case PREPAIRING: {
if(!this->getSoundEnabledSetting(ScStwSoundPlayer::AtYourMarks))
return currentStartDelay;
break;
}
default:
return currentStartDelay;
break;
}
// get the total delay and the delay progress of the next action timer
double remaining = this->startDelayTimer->remainingTime();
if(remaining < 0)
return currentStartDelay;
currentStartDelay["total"] = this->startDelayTimer->interval();
currentStartDelay["progress"] = 1 - (remaining / currentStartDelay["total"].toDouble());
if(currentStartDelay["progress"].toDouble() < 0)
currentStartDelay["progress"] = 0;
return currentStartDelay;
}
bool ScStwRace::addTimer(ScStwTimer *timer) {
if(this->state != IDLE)
return false;
foreach(ScStwTimer *existingTimer, this->timers) {
if(existingTimer == timer)
return true;
}
this->timers.append(timer);
connect(timer, &ScStwTimer::stateChanged, this, &ScStwRace::handleTimerStateChange);
connect(timer, &ScStwTimer::stateChanged, this, &ScStwRace::timersChanged);
connect(timer, &ScStwTimer::wantsToBeDisabledChanged, this, &ScStwRace::handleTimerWantsToBeDisabledChange);
connect(timer, &ScStwTimer::reactionTimeChanged, this, &ScStwRace::timersChanged);
connect(timer, &ScStwTimer::readyStateChanged, this, &ScStwRace::handleTimerReadyStateChange);
connect(timer, &ScStwTimer::readyStateChanged, this, &ScStwRace::isReadyForNextStateChanged);
if(this->competitionMode && timer->getState() == ScStwTimer::DISABLED)
timer->setDisabled(false);
else if(!this->competitionMode)
this->handleTimerWantsToBeDisabledChange(timer, timer->getWantsToBeDisabled());
return true;
}
ScStwRace::RaceState ScStwRace::getState() {
return this->state;
}
QList<ScStwTimer*> ScStwRace::getTimers() {
return this->timers;
}
double ScStwRace::getSoundVolume() {
if(this->settings == nullptr)
return 1;
return this->settings->readSetting(ScStwSettings::SoundVolumeSetting).toDouble();
}
ScStwSoundPlayer::StartSound ScStwRace::getSoundForState(ScStwRace::RaceState state) {
switch (state) {
case PREPAIRING:
return ScStwSoundPlayer::AtYourMarks;
break;
case WAITING:
return ScStwSoundPlayer::Ready;
break;
case STARTING:
return ScStwSoundPlayer::Start;
break;
default:
return ScStwSoundPlayer::StartSound(-1);
}
}
bool ScStwRace::getSoundEnabledSetting(ScStwSoundPlayer::StartSound sound) {
ScStwSettings::BaseStationSetting soundEnabledSetting;
switch (sound) {
case ScStwSoundPlayer::AtYourMarks:
soundEnabledSetting = ScStwSettings::AtYourMarksSoundEnableSetting;
break;
case ScStwSoundPlayer::Ready:
soundEnabledSetting = ScStwSettings::ReadySoundEnableSetting;
break;
case ScStwSoundPlayer::Start:
return true;
break;
default:
return false;
}
if(this->settings == nullptr)
return false;
return this->settings->readSetting(soundEnabledSetting).toBool();
}
int ScStwRace::getSoundDelaySetting(ScStwSoundPlayer::StartSound sound) {
ScStwSettings::BaseStationSetting soundDelaySetting;
switch (sound) {
case ScStwSoundPlayer::AtYourMarks:
soundDelaySetting = ScStwSettings::AtYourMarksSoundDelaySetting;
break;
case ScStwSoundPlayer::Ready:
soundDelaySetting = ScStwSettings::ReadySoundDelaySetting;
break;
case ScStwSoundPlayer::Start:
return 0;
break;
default:
return -1;
}
if(this->settings == nullptr)
return -1;
return this->settings->readSetting(soundDelaySetting).toInt();
}
QVariantList ScStwRace::getTimerDetailList() {
QVariantList tmpTimers;
foreach(ScStwTimer * timer, this->timers) {
QVariantMap tmpTimer;
tmpTimer.insert("id", this->timers.indexOf(timer));
tmpTimer.insert("state", timer->getState());
tmpTimer.insert("currentTime", timer->getCurrentTime());
tmpTimer.insert("reactionTime", timer->getReactionTime());
tmpTimer.insert("letter", timer->getLetter());
tmpTimer.insert("readyState", timer->getReadyState());
tmpTimer.insert("text", timer->getText());
tmpTimers.append(tmpTimer);
}
return tmpTimers;
}
QVariantMap ScStwRace::getDetails() {
QVariantMap tmpDetails;
tmpDetails.insert("state", this->getState());
tmpDetails.insert("competitionMode", this->competitionMode);
tmpDetails.insert("readySoundEnabled", this->getSoundEnabledSetting(ScStwSoundPlayer::Ready));
tmpDetails.insert("currentStartDelay", this->getCurrentStartDelay());
tmpDetails.insert("timers", this->getTimerDetailList());
if(this->state == WAITING)
tmpDetails.insert("isReadyForNextState", this->getIsReadyForNextState());
else
tmpDetails.insert("isReadyForNextState", true);
return tmpDetails;
}
bool ScStwRace::isStarting() {
return this->state == PREPAIRING || this->state == WAITING || this->state == STARTING;
}
bool ScStwRace::getCompetitionMode() {
return this->competitionMode;
}
bool ScStwRace::getReadySoundEnabled() {
return this->getSoundEnabledSetting(ScStwSoundPlayer::Ready);
}
ScStwSettings* ScStwRace::getSettings() {
return this->settings;
}
void ScStwRace::setSettings(ScStwSettings* settings) {
if(settings == this->settings)
return;
this->settings = settings;
this->refreshCompetitionMode();
emit this->settingsChanged();
}
bool ScStwRace::getAutoRefreshTimerText() {
return this->autoRefreshTimerText;
}
void ScStwRace::setAutoRefreshTimerText(bool autoRefresh) {
if(autoRefresh == this->autoRefreshTimerText)
return;
this->autoRefreshTimerText = autoRefresh;
if(this->autoRefreshTimerText) {
this->timerTextRefreshTimer = new QTimer(this);
this->timerTextRefreshTimer->setInterval(1);
this->timerTextRefreshTimer->connect(
this->timerTextRefreshTimer,
&QTimer::timeout,
[=] {
// refresh timer text
if(this->getState() == ScStwRace::RUNNING) {
emit this->timersChanged();
}
// refresh next start action delay progress
if(this->getState() == ScStwRace::WAITING || this->getState() == ScStwRace::PREPAIRING) {
emit this->currentStartDelayChanged();
}
}
);
this->timerTextRefreshTimer->start();
}
else if(this->timerTextRefreshTimer != nullptr) {
this->timerTextRefreshTimer->deleteLater();
}
emit this->autoRefreshTimerTextChanged();
}

View file

@ -0,0 +1,59 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "scstwsetting.h"
#include "scstwsettings.h"
#include <QtDebug>
ScStwSetting::ScStwSetting(int key, int keyLevel, ScStwSettings*scStwSettings, QObject *parent) : QObject(parent)
{
this->scStwSettings = scStwSettings;
connect(this->scStwSettings, &ScStwSettings::settingChanged, this, &ScStwSetting::handleSettingChange);
this->key = key;
this->keyLevel = keyLevel;
this->handleSettingChange(-1, this->keyLevel, QVariant());
}
QVariant ScStwSetting::getValue() {
qDebug() << "Getting setting: " << this->key << " has to reload: " << this->hasToReload;
if(this->hasToReload) {
this->valueCache = this->scStwSettings->readSetting(this->key, this->keyLevel);
this->hasToReload = false;
}
return this->valueCache;
}
void ScStwSetting::setValue(QVariant value) {
if(value != this->valueCache) {
this->scStwSettings->writeSetting(this->key, this->keyLevel, value);
}
}
void ScStwSetting::handleSettingChange(int key, int keyLevel, QVariant value) {
if(keyLevel == this->keyLevel && key == this->key) {
this->valueCache = value;
qDebug() << "value changed!!! key: " << key << " new value " << value;
emit this->valueChanged();
}
else if(key == -1 && this->key != -1 && this->keyLevel != -1 && this->keyLevel == keyLevel) {
qDebug() << "value changed!!! key: " << key << " new value " << value;
this->hasToReload = true;
emit this->valueChanged();
}
}

View file

@ -0,0 +1,184 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "../headers/scstwsettings.h"
ScStwSettings::ScStwSettings(QObject *parent, bool overwriteFileOnErrors) : QObject(parent)
{
#ifdef RASPI
QString path = "/root/.config/ScStwBasestation";
#else
QString path = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
#endif
QDir dir(path);
if(!dir.mkpath(path))
qFatal("[FATAL] Failed to create writable directory for settings at %s", qPrintable(path));
this->settingsFile = new QFile(path + "/settings.json");
this->fileIsReadonly = false;
if(!this->settingsFile->open(QFile::ReadWrite))
qFatal("[FATAL] Couldn't open settings file %s", qPrintable(path + "/settings.json"));
if(this->settingsFile->size() != 0 && !this->loadSettingsFromFile()) {
if(overwriteFileOnErrors) {
this->writeSettingsToFile();
qWarning("[WARNING] Settings file (%s) was of invalid format and therefore overwritten!", qPrintable(path + "/settings.json"));
}
else {
qWarning("[WARNING] Settings file (%s) was of invalid format!", qPrintable(path + "/settings.json"));
this->fileIsReadonly = true;
}
}
connect(this, &ScStwSettings::settingChanged, this, &ScStwSettings::writeSettingsToFile);
this->registerKeyLevelConverters(ScStwSettings::KeyLevel, &ScStwSettings::keyToString, &ScStwSettings::keyToType);
this->setDefaultSetting(ScStwSettings::BaseStationSetting::ReadySoundEnableSetting, false);
this->setDefaultSetting(ScStwSettings::BaseStationSetting::ReadySoundDelaySetting, 0);
this->setDefaultSetting(ScStwSettings::BaseStationSetting::AtYourMarksSoundEnableSetting, false);
this->setDefaultSetting(ScStwSettings::BaseStationSetting::AtYourMarksSoundDelaySetting, 0);
this->setDefaultSetting(ScStwSettings::SoundVolumeSetting, 1);
this->setDefaultSetting(ScStwSettings::CompetitionModeSetting, false);
}
QVariant ScStwSettings::readSetting(BaseStationSetting key) {
return this->readSetting(key, 0);
}
QVariant ScStwSettings::readSetting(int key, int keyLevel) {
if(this->keyToStringConverters.contains(keyLevel))
return this->readSetting(this->keyToStringConverters[keyLevel](key), key, keyLevel);
else
return QVariant();
}
bool ScStwSettings::writeSetting(BaseStationSetting key, QVariant value) {
return this->writeSetting(key, 0, value);
}
bool ScStwSettings::writeSetting(int key, int keyLevel, QVariant value) {
if(this->keyToStringConverters.contains(keyLevel))
return this->writeSetting(this->keyToStringConverters[keyLevel](key), value, key, keyLevel);
else
return false;
}
bool ScStwSettings::setDefaultSetting(BaseStationSetting key, QVariant defaultValue) {
return this->setDefaultSetting(key, 0, defaultValue);
}
bool ScStwSettings::setDefaultSetting(int key, int keyLevel, QVariant defaultValue) {
if(this->keyToStringConverters.contains(keyLevel))
return this->setDefaultSetting(this->keyToStringConverters[keyLevel](key), defaultValue, key, keyLevel);
else
return false;
}
QVariant ScStwSettings::readSetting(QString key, int keyInt, int keyLevel) {
Q_UNUSED(keyInt)
Q_UNUSED(keyLevel)
if(this->settingsCache.contains(key))
return this->settingsCache[key];
else
return QVariant();
}
bool ScStwSettings::writeSetting(QString key, QVariant value, int keyInt, int keyLevel) {
// check if the value type is valid
if(!this->keyToTypeConverters.contains(keyLevel) || !value.convert(this->keyToTypeConverters[keyLevel](keyInt)) || value.type() == QVariant::Invalid) {
return false;
}
// write the setting
if(!this->settingsCache.contains(key))
this->settingsCache.insert(key, value);
else if (this->settingsCache[key] == value)
return true;
else
this->settingsCache[key] = value;
emit this->settingChanged(keyInt, keyLevel, value);
return true;
}
bool ScStwSettings::setDefaultSetting(QString key, QVariant defaultValue, int keyInt, int keyLevel) {
if(!this->settingsCache.contains(key))
return this->writeSetting(key, defaultValue, keyInt, keyLevel);
return true;
}
ScStwSetting * ScStwSettings::getSetting(int key, int keyLevel) {
if(!this->internalSettingHandlers.contains(keyLevel))
this->internalSettingHandlers.insert(keyLevel, {});
if(!this->internalSettingHandlers[keyLevel].contains(key))
this->internalSettingHandlers[keyLevel].insert(key, new ScStwSetting(key, keyLevel, this, this));
return this->internalSettingHandlers[keyLevel][key];
}
bool ScStwSettings::registerKeyLevelConverters(int keyLevel, keyToStringConverter keyToStringConverterFunction, keyToTypeConverter keyToTypeConverterFunction) {
if(this->keyToStringConverters.contains(keyLevel))
return false;
this->keyToStringConverters.insert(keyLevel, keyToStringConverterFunction);
this->keyToTypeConverters.insert(keyLevel, keyToTypeConverterFunction);
return true;
}
/*
* File handling
*/
bool ScStwSettings::writeSettingsToFile() {
if(this->fileIsReadonly) {
qWarning() << "[WARNING][SETTINS] Cannot write changes to file! It has been marked readonly due to parse errors (see above).";
return false;
}
QJsonDocument doc = QJsonDocument::fromVariant(this->settingsCache);
// overwrite file
this->settingsFile->resize(0);
this->settingsFile->reset();
this->settingsFile->write(doc.toJson(QJsonDocument::Indented));
this->settingsFile->flush();
return true;
}
bool ScStwSettings::loadSettingsFromFile() {
QJsonParseError error;
QJsonDocument doc = QJsonDocument::fromJson(this->settingsFile->readAll(), &error);
if(error.error != QJsonParseError::NoError) {
qWarning() << "[ERROR][SETTINGS] Error when parsing settings file: " << error.errorString() << " at offset " << error.offset;
return false;
}
if(doc.toVariant().type() != QVariant::Map)
return false;
this->settingsCache = doc.toVariant().toMap();
return true;
}

View file

@ -0,0 +1,212 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "../headers/scstwsoundplayer.h"
ScStwSoundPlayer::ScStwSoundPlayer(QObject *parent) : QObject(parent)
{
this->waitLoop = new QEventLoop(this);
this->waitTimer = new QTimer(this);
this->soundFiles.insert(AtYourMarks, {{"path","qrc:/sound/AtYourMarksSound.wav"}, {"duration", 1000}});
this->soundFiles.insert(Ready, {{"path","qrc:/sound/ReadySound.wav"}, {"duration", 570}});
this->soundFiles.insert(Start, {{"path","qrc:/sound/StartsignalSoundExtended.wav"}, {"duration", 3200}});
this->soundFiles.insert(FalseStart, {{"path","qrc:/sound/FalseStartSound.wav"}, {"duration", 2000}});
this->_initializeSondEffect();
connect(this, &ScStwSoundPlayer::playbackStarted, this->waitLoop, &QEventLoop::quit);
connect(this->soundEffect, &QSoundEffect::playingChanged, this->waitLoop, &QEventLoop::quit);
}
ScStwSoundPlayer::PlayResult ScStwSoundPlayer::play(ScStwSoundPlayer::StartSound sound, double volume, double *timeOfStart) {
if(!this->soundFiles.contains(sound)) {
qDebug() << "[ERROR][SoundPlayer] Sound file was not found for sound" << sound;
return ScStwSoundPlayer::Error;
}
// stop playback
if(this->soundEffect->isPlaying())
this->soundEffect->stop();
// update currently playing action
this->currentlyPlayingSound = sound;
if(!this->_setSoundVolume(volume))
return Error;
// load
this->soundEffect->setSource(this->soundFiles[sound]["path"].toString());
// wait for the effect to load
QEventLoop loop;
while(this->soundEffect->status() != QSoundEffect::Ready) {
qDebug() << "[DEBUG][Sound] Sound is not ready yet, status is: " << this->soundEffect->status();
QObject::connect(this->soundEffect, &QSoundEffect::statusChanged, &loop, &QEventLoop::quit);
loop.exec();
}
qDebug() << "[DEBUG][Sound] Playing sound now: " << sound;
// start
this->soundEffect->play();
// emit a playback start
emit this->playbackStarted();
// save started at
this->playingStartedAt = QDateTime::currentMSecsSinceEpoch();
// pass the time of start if requested
if(timeOfStart != nullptr) {
*timeOfStart = this->playingStartedAt;
}
if(sound < Start)
return this->waitForSoundFinish();
return ScStwSoundPlayer::Success;
}
bool ScStwSoundPlayer::cancel() {
if(!this->soundEffect->isPlaying() )
return false;
// stop playback
this->soundEffect->stop();
this->waitLoop->exit(-1);
return true;
}
ScStwSoundPlayer::PlayResult ScStwSoundPlayer::waitForSoundFinish(double *timeOfStop) {
if(!this->soundEffect->isPlaying())
return ScStwSoundPlayer::Error;
// wait until the audio output reports the sound is over
if(waitLoop->exec() == -1)
return ScStwSoundPlayer::Cancelled;
// wait until the sound is actually over
// the timeOffset is the buffer time before the audio started!
int timeOffset = this->soundFiles[this->currentlyPlayingSound]["duration"].toDouble() - (QDateTime::currentMSecsSinceEpoch() - playingStartedAt);
if(timeOffset > 0) {
QTimer timer;
timer.singleShot(timeOffset, this->waitLoop, &QEventLoop::quit);
this->waitLoop->exec();
}
// calculate the point in time where the sound playback actually ended
if(timeOfStop != nullptr) {
int latency = this->playingStartedAt + this->soundFiles[this->currentlyPlayingSound]["duration"].toDouble();
*timeOfStop = QDateTime::currentMSecsSinceEpoch() - latency;
}
return ScStwSoundPlayer::Success;
}
bool ScStwSoundPlayer::isPlaying() {
return this->soundEffect->isPlaying();
}
#ifdef ScStwLibraries_Raspi
void ScStwSoundPlayer::_initializeSondEffect() {
this->_audioOutputDevice = nullptr;
for(QAudioDeviceInfo info : QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) {
qDebug() << info.deviceName();
if(info.deviceName().contains("Headphones"))
this->_audioOutputDevice = new QAudioDeviceInfo(info);
}
if(this->_audioOutputDevice == nullptr)
this->_audioOutputDevice = new QAudioDeviceInfo(QAudioDeviceInfo::defaultOutputDevice());
this->soundEffect = new QSoundEffect(*this->_audioOutputDevice, this);
this->soundEffect->setLoopCount(1);
}
#else
void ScStwSoundPlayer::_initializeSondEffect() {
this->_audioOutputDevice = new QAudioDeviceInfo(QAudioDeviceInfo::defaultOutputDevice());
this->soundEffect = new QSoundEffect(*this->_audioOutputDevice, this);
this->soundEffect->setLoopCount(1);
}
#endif
#ifdef ScStwLibraries_Raspi
bool ScStwSoundPlayer::_setSoundVolume(double volume) {
QString cardName = this->_audioOutputDevice->deviceName();
QStringRef shortCardName = cardName.midRef(cardName.indexOf(QLatin1String("="), 0) + 1);
int cardIndex = snd_card_get_index(shortCardName.toLocal8Bit().constData());
QString soundDevice = QString(QLatin1String("hw:%1")).arg(cardIndex);
qDebug() << "[INFO][SoundPlayer] Using audio device: " << soundDevice;
long min, max;
snd_mixer_t *handle;
snd_mixer_selem_id_t *sid;
snd_mixer_elem_t *elem;
if(snd_mixer_open(&handle, 0) < 0) {
qDebug() << "[ERROR][SoundPlayer] Could not open mixer";
return false;
}
if(snd_mixer_selem_register(handle, NULL, NULL) < 0) {
qDebug() << "[ERROR][SoundPlayer] Could not register selem";
return false;
}
if(snd_mixer_attach(handle, soundDevice.toStdString().c_str()) < 0) {
qDebug() << "[ERROR][SoundPlayer] Could not attach mixer";
return false;
}
if(snd_mixer_load(handle) < 0) {
qDebug() << "[ERROR][SoundPlayer] Could not load mixer";
return false;
}
// set volume for all channels
snd_mixer_selem_id_alloca(&sid);
bool success = false;
for (elem = snd_mixer_first_elem(handle); elem; elem = snd_mixer_elem_next(elem)) {
snd_mixer_selem_get_id(elem, sid);
if (!snd_mixer_selem_is_active(elem))
continue;
elem = snd_mixer_find_selem(handle, sid);
if(!elem)
continue;
snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
snd_mixer_selem_set_playback_volume_all(elem, min + (volume) * (max - min));
success = true;
}
snd_mixer_close(handle);
this->soundEffect->setVolume(1);
return success;
}
#else
bool ScStwSoundPlayer::_setSoundVolume(double volume) {
this->soundEffect->setVolume(volume);
return true;
}
#endif

View file

@ -0,0 +1,94 @@
#include "../headers/scstwstartsoundplayer.h"
ScStwStartSoundPlayer::ScStwStartSoundPlayer(QObject *parent) : QObject(parent)
{
this->waitLoop = new QEventLoop();
this->startSoundFile = new QFile(":/sound/StartsignalSound.wav", this);
if(!this->startSoundFile->open(QFile::ReadOnly)) {
qWarning() << "Cannot open audio File!!";
return;
}
// init sound format
QAudioFormat format;
format.setSampleRate(44100);
format.setChannelCount(2);
format.setSampleSize(16);
format.setCodec("audio/pcm");
format.setByteOrder(QAudioFormat::LittleEndian);
format.setSampleType(QAudioFormat::SignedInt);
// check if format is valid
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
if (!info.isFormatSupported(format)) {
qWarning() << "Raw audio format not supported by backend, cannot play audio.";
return;
}
this->audioOutput = new QAudioOutput(format);
this->audioOutput->setCategory("ScStw start sound");
connect(this->audioOutput, SIGNAL(stateChanged(QAudio::State)), this, SLOT(handleStateChanged(QAudio::State)));
}
bool ScStwStartSoundPlayer::play(double volume, double *timeOfStop) {
double st = QDateTime::currentMSecsSinceEpoch();
// update volume
this->audioOutput->setVolume(volume);
// start
this->audioOutput->start(this->startSoundFile);
double ed = QDateTime::currentMSecsSinceEpoch();
qDebug() << "time passed: " << ed-st << " playback elapsed: " << this->audioOutput->elapsedUSecs();
// wait until the audio output reports the sound is over
waitLoop->exec();
qDebug() << "waitLoop exited!! elapsed: " << this->audioOutput->elapsedUSecs() << " processed: " << this->audioOutput->processedUSecs();
// wait until the sound is actually over
// the timeOffset is the buffer time before the audio started!
int timeOffset = ((this->audioOutput->processedUSecs() - this->audioOutput->elapsedUSecs()) / 1000);
if(timeOffset > 0) {
QTimer timer;
timer.singleShot(timeOffset, this->waitLoop, &QEventLoop::quit);
waitLoop->exec();
}
// calculate the point in time where the sound playback actually ended
if(timeOfStop != nullptr) {
int latency = (this->audioOutput->processedUSecs() - this->audioOutput->elapsedUSecs()) / 1000;
*timeOfStop = QDateTime::currentMSecsSinceEpoch() - latency;
}
// check for errors and return
if(this->audioOutput->state() == QAudio::IdleState)
return true;
return false;
}
void ScStwStartSoundPlayer::handleStateChanged(QAudio::State newState)
{
switch (newState) {
case QAudio::IdleState:
// Finished playing (no more data)
qDebug() << "sound reported over!! elapsed: " << this->audioOutput->elapsedUSecs() << " processed: " << this->audioOutput->processedUSecs();
waitLoop->exit();
break;
case QAudio::StoppedState:
// Stopped for other reasons
if (this->audioOutput->error() != QAudio::NoError) {
// Error handling
}
break;
default:
// ... other cases as appropriate
break;
}
}

View file

@ -0,0 +1,320 @@
/****************************************************************************
** ScStw Libraries
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "../headers/scstwtimer.h"
ScStwTimer::ScStwTimer(QObject* parent) : ScStwTimer("", parent)
{
}
ScStwTimer::ScStwTimer(QString letter, QObject *parent) : QObject(parent)
{
if(letter.length() > 1)
this->letter = letter[0];
else
this->letter = letter;
//qDebug() << "Timer created with letter: " << letter;
this->startTime = 0;
this->stopTime = 0;
this->reactionTime = 0;
this->wantsToBeDisabled = false;
this->state = IDLE;
}
bool ScStwTimer::start() {
return this->start(QDateTime::currentMSecsSinceEpoch());
}
bool ScStwTimer::start(double timeOfStart) {
switch (this->state) {
case IDLE: {
// in case of IDLE, start the race!
this->startTime = timeOfStart;
this->stopTime = 0;
if(timeOfStart - QDateTime::currentMSecsSinceEpoch() > 0) {
this->setState(STARTING);
QTimer::singleShot(timeOfStart - QDateTime::currentMSecsSinceEpoch(), [=]() {
if(this->state == STARTING)
this->setState(RUNNING);
});
}
else
this->setState(RUNNING);
return true;
}
default: {
// otherwise the timer is not supposed to be started!
return false;
}
}
}
void ScStwTimer::technicalIncident() {
qDebug() << "[INFO][TIMER] Timer got a technical incident";
this->setState(INCIDENT);
}
bool ScStwTimer::wildcard() {
if(this->state != STARTING)
return false;
this->setState(WILDCARD);
return true;
}
void ScStwTimer::handleClimberStart(double timeOfStart) {
this->reactionTime = timeOfStart - this->startTime;
qDebug() << "+ [INFO][TIMER] reaction time: " << this->reactionTime;
if(this->reactionTime <= 100 && this->reactionTime) {
qDebug() << "[INFO][TIMER] False Start detected: " << "start Time: " << startTime << " reactionTime: " << reactionTime;
this->setState(FAILING);
}
emit this->reactionTimeChanged();
}
bool ScStwTimer::cancel() {
if(!(this->state == IDLE || this->state == STARTING || this->state == RUNNING))
return false;
qDebug() << "[INFO][TIMER] Timer was cancelled";
this->reactionTime = 0;
this->startTime = 0;
this->stopTime = 0;
this->setState(CANCELLED);
return true;
}
bool ScStwTimer::stop() {
return this->stop(QDateTime::currentMSecsSinceEpoch());
}
bool ScStwTimer::stop(double timeOfStop) {
if(this->state != RUNNING)
return false;
this->stopTime = timeOfStop;
// trigger an external state refresh to set the state to either WON or LOST depending on the other timers values (see ScStwRace::refreshTimerStates())
this->setState(WAITING);
qDebug() << "[INFO][TIMER] Stopped: " << "start Time: " << startTime << " stopTime: " << stopTime << " stoppedTime: " << this->getCurrentTime() << " reactionTime: " << reactionTime;
return true;
}
bool ScStwTimer::setResult(TimerState result) {
QList<ScStwTimer::TimerState> allowedStates = {
STARTING,
RUNNING,
WAITING,
WON,
FAILING,
FAILED
};
if(!allowedStates.contains(this->state))
return false;
/* The reasons why it has to accept all these states:
*
* STARTING: To set a timer to WILDCARD when its opponent has done a false start
* RUNNING: To set a timer to WILDCARD when its opponent has done a false start that was received with a delay
* WAITING: To set a timer to either WON or LOST
* WON: To set a timer to LOST when its opponent has won the race but their trigger was delayed
* FAILING: To set a timer to either FAILED or WILDCARD
* FAILED: To set a timer to WILDCARD when its opponent did an earlier false start but their tirgger was delayed
*/
switch (result) {
case LOST:
case WON:
if(this->state == WAITING || this->state == WON) {
this->setState(result);
return true;
}
break;
case WILDCARD:
case FAILED:
if(this->state == STARTING || this->state == RUNNING || this->state == FAILED || this->state == FAILING) {
this->setState(result);
return true;
}
break;
default:
break;
}
return false;
}
bool ScStwTimer::reset() {
if( this->state < WON || this->state == DISABLED ) {
return false;
}
this->startTime = 0;
this->stopTime = 0;
this->reactionTime = 0;
this->setState(IDLE);
return true;
}
ScStwTimer::ReadyState ScStwTimer::getReadyState() {
return this->state == IDLE ? ScStwTimer::IsReady : ScStwTimer::NotInIdleState;
}
// ------------------------
// --- helper functions ---
// ------------------------
void ScStwTimer::setState(TimerState newState) {
if(this->state == DISABLED && newState != IDLE)
return;
if(this->state == INCIDENT && newState != IDLE)
return;
if(this->state != newState) {
this->state = newState;
qDebug() << "[INFO][TIMER] timer state changed: " << newState;
emit this->stateChanged(newState);
}
}
ScStwTimer::TimerState ScStwTimer::getState() {
return this->state;
}
double ScStwTimer::getCurrentTime() {
switch (this->state) {
case RUNNING:
return QDateTime::currentMSecsSinceEpoch() - this->startTime;
default: {
if(this->state == WAITING || this->state == WON || this->state == LOST)
return abs(this->stopTime - this->startTime);
else
return -1;
}
}
}
double ScStwTimer::getReactionTime() {
return this->reactionTime;
}
QString ScStwTimer::getLetter() {
return this->letter;
}
void ScStwTimer::setLetter(QString letter) {
this->letter = letter;
}
QString ScStwTimer::getText() {
QString newText = "";
int newTime = 0;
switch (this->state) {
case ScStwTimer::IDLE:
newTime = 0;
break;
case ScStwTimer::STARTING:
newTime = 0;
break;
case ScStwTimer::RUNNING:
newTime = this->getCurrentTime();
break;
case ScStwTimer::WAITING:
newText = "please wait...";
break;
case ScStwTimer::WON:
newTime = this->getCurrentTime();
break;
case ScStwTimer::LOST:
newTime = this->getCurrentTime();
break;
case ScStwTimer::FAILING:
newText = "please wait...";
break;
case ScStwTimer::FAILED:
newText = "false start";
break;
case ScStwTimer::WILDCARD:
newText = "wildcard";
break;
case ScStwTimer::CANCELLED:
newText = "cancelled";
break;
case ScStwTimer::INCIDENT:
newText = "Technical incident!";
break;
case ScStwTimer::DISABLED:
newText = "---";
break;
}
if(newText == "")
newText = QString::number( newTime / 1000.0, 'f', 3 ).rightJustified(6, '0');
return newText;
}
void ScStwTimer::setDisabled(bool disabled) {
if(this->isDisabled() == disabled)
return;
if(disabled)
this->setState(DISABLED);
else
this->setState(IDLE);
emit this->readyStateChanged(this->getReadyState());
}
void ScStwTimer::setWantsToBeDisabled(bool wantsToBeDisabled) {
if(this->wantsToBeDisabled == wantsToBeDisabled)
return;
qDebug() << "Wants to be disabled changed: " << wantsToBeDisabled;
this->wantsToBeDisabled = wantsToBeDisabled;
emit this->wantsToBeDisabledChanged(this, wantsToBeDisabled);
}
bool ScStwTimer::getWantsToBeDisabled() {
return this->wantsToBeDisabled;
}
bool ScStwTimer::isRunning() {
return this->state == RUNNING;
}
bool ScStwTimer::isDisabled() {
return this->state == DISABLED;
}

View file

@ -0,0 +1,45 @@
/****************************************************************************
** ScStw Styling
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "scstwapptheme.h"
ScStwAppTheme::ScStwAppTheme(QString name, QVariantMap colors, QVariantMap icons, QVariantMap fonts, QVariantMap images, QObject *parent) : QObject(parent)
{
this->name = name;
this->colors = colors;
this->icons = icons;
this->fonts = fonts;
this->images = images;
}
QString ScStwAppTheme::getName() {
return this->name;
}
QVariant ScStwAppTheme::getColors() {
return this->colors;
}
QVariant ScStwAppTheme::getIcons() {
return this->icons;
}
QVariant ScStwAppTheme::getFonts() {
return this->fonts;
}
QVariant ScStwAppTheme::getImages() {
return this->images;
}

View file

@ -0,0 +1,180 @@
/****************************************************************************
** ScStw Styling
** Copyright (C) 2020 Itsblue development
**
** 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 <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "scstwappthememanager.h"
ScStwAppThemeManager::ScStwAppThemeManager(QObject *parent) : QObject(parent)
{
QFontDatabase::addApplicationFont(":/fonts/fa5solid.woff");
QFontDatabase::addApplicationFont(":/fonts/PTMono-Regular.ttf");
QVariantMap icons = {
{"back", "\uf053"},
{"settings", "\uf013"},
{"toppad", "\uf10a"},
{"startpad", "\uf3fa"},
{"profiles", "\uf007"},
{"confirm", "\uf00c"},
{"volumeUp", "\uf028"},
{"volumeDown", "\uf027"}
};
QVariantMap fonts= {
{"icons", "Font Awesome 5 Free"},
{"timers", "PT Mono"}
};
ScStwAppTheme * lightTheme = new ScStwAppTheme (
"Light",
{
{"accent", "#0094ff"},
{"background", "white"},
{"button", "white"},
{"buttonPressed", "lightgrey"},
{"buttonBorder", "grey"},
{"disabledButton", "#d5d5d5"},
{"buttonText", "grey"},
{"buttonPressedText",this->lighter("lightgrey", 0.5)},
{"buttonDisabledText", this->lighter("lightgrey", 0.9)},
{"view", "white"},
{"menu", "#f8f8f8"},
{"delegate1", "#202227"},
{"delegate2", "#202227"},
{"delegateBackground", "white"},
{"delegatePressed", "#dddedf"},
{"text", "black"},
{"textDark", "#232323"},
{"disabledText", "grey"},
{"slider", "#6ccaf2"},
{"success", "#60de26"},
{"error", "#ff0000"},
{"warning", "#e0b928"},
{"line", "grey"},
},
icons,
fonts,
{
{"backIcon", "qrc:/graphics/icons/back_black.png"},
{"settIcon", "qrc:/graphics/icons/settings_black.png"},
{"buzzerIcon", "qrc:/graphics/icons/buzzer_black.png"},
{"startpadIcon", "qrc:/graphics/icons/startpad_black.png"},
{"baseStationIcon", "qrc:/images/BaseStationBlack.png"},
{"profilesIcon", "qrc:/graphics/icons/user_black.png"},
{"confirmIcon", "qrc:/graphics/icons/ok_black.png"},
{"SpeedHold", "qrc:/images/SpeedHoldBlack.png"}
});
ScStwAppTheme *darkTheme = new ScStwAppTheme(
"Dark",
{
{"accent", "#0094ff"},
{"background", "#2d3037"},
{"button", "#202227"},
{"buttonPressed", "#41454f"},
{"buttonBorder", "grey"},
{"disabledButton", "#555555"},
{"buttonText", "white"},
{"buttonPressedText",this->lighter("lightgrey", 0.8)},
{"buttonDisabledText", this->lighter("lightgrey", 0.6)},
{"view", "#202227"},
{"menu", "#292b32"},
{"delegate1", "#202227"},
{"delegate2", "#202227"},
{"delegateBackground", "#202227"},
{"delegatePressed", "#41454f"},
{"text", "#ffffff"},
{"textDark", "#232323"},
{"disabledText", "#777777"},
{"slider", "#6ccaf2"},
{"success", "#6bd43b"},
{"error", "#e03b2f"},
{"warning", "#d6ae1e"},
{"line", "grey"},
{"iconFontName", "Font Awesome 5 Free"},
},
icons,
fonts,
{
{"backIcon", "qrc:/graphics/icons/back.png"},
{"settIcon", "qrc:/graphics/icons/settings.png"},
{"buzzerIcon", "qrc:/graphics/icons/buzzer.png"},
{"startpadIcon", "qrc:/graphics/icons/startpad.png"},
{"baseStationIcon", "qrc:/images/BaseStationWhite.png"},
{"profilesIcon", "qrc:/graphics/icons/user.png"},
{"confirmIcon", "qrc:/graphics/icons/ok.png"},
{"SpeedHold", "qrc:/images/SpeedHoldWhite.png"}
}
);
this->themes.append(lightTheme);
this->themes.append(darkTheme);
this->currentTheme = this->themes[0];
}
ScStwAppTheme* ScStwAppThemeManager::getTheme() {
return this->currentTheme;
}
bool ScStwAppThemeManager::setTheme(QString themeName) {
ScStwAppTheme * foundTheme = this->findThemeByName(themeName);
if(foundTheme == nullptr)
return false;
this->currentTheme = foundTheme;
emit this->themeChanged();
return true;
}
ScStwAppTheme * ScStwAppThemeManager::findThemeByName(QString themeName) {
foreach (ScStwAppTheme *theme, this->themes) {
if(theme->getName() == themeName)
return theme;
}
return nullptr;
}
QString ScStwAppThemeManager::lighter(QString color, double factor) {
QColor qcolor = QColor(color);
qcolor.toHsv();
int h, s, v;
qcolor.getHsv(&h, &s, &v);
qcolor.setHsv(h,s,v * factor);
return qcolor.name();
}
QString ScStwAppThemeManager::getThemeName() {
return this->currentTheme->getName();
}

73
ScStwLibraries/tests/.gitignore vendored Normal file
View file

@ -0,0 +1,73 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe

View file

@ -0,0 +1,10 @@
#include "scstwtestingtimer.h"
ScStwTestingTimer::ScStwTestingTimer()
{
}
void ScStwTestingTimer::handleClimberStart(double timeOfStart) {
ScStwTimer::handleClimberStart(timeOfStart);
}

View file

@ -0,0 +1,14 @@
#ifndef SCSTWTESTINGTIMER_H
#define SCSTWTESTINGTIMER_H
#include <scstwtimer.h>
#include <QObject>
class ScStwTestingTimer : public ScStwTimer
{
public:
ScStwTestingTimer();
void handleClimberStart(double timeOfStart);
};
#endif // SCSTWTESTINGTIMER_H

View file

@ -0,0 +1,19 @@
QT += testlib
QT -= gui
CONFIG += qt console warn_on depend_includepath testcase
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += \
scstwtestingtimer.cpp \
tst_scstwrace.cpp \
tst_scstwtimertests.cpp
# include submodules
CONFIG += ScStwLibraries_QML ScStwLibraries_Styling ScStwLibraries_ClientLibs
include($$PWD/../ScStwLibraries.pri)
HEADERS += \
scstwtestingtimer.h

View file

@ -0,0 +1,49 @@
#include <QtTest>
#include <QDateTime>
#include "scstwrace.h"
// add necessary includes here
class ScStwRaceTests : public QObject
{
Q_OBJECT
public:
ScStwRaceTests();
~ScStwRaceTests();
private slots:
void initTestCase();
void cleanupTestCase();
void basic_cycle();
};
ScStwRaceTests::ScStwRaceTests()
{
}
ScStwRaceTests::~ScStwRaceTests()
{
}
void ScStwRaceTests::initTestCase()
{
}
void ScStwRaceTests::cleanupTestCase()
{
}
void ScStwRaceTests::basic_cycle()
{
}
#include "tst_scstwrace.moc"

View file

@ -0,0 +1,141 @@
#include <QtTest>
#include <QDateTime>
#include "scstwtimer.h"
#include "scstwtestingtimer.h"
// add necessary includes here
class ScStwTimerTests : public QObject
{
Q_OBJECT
public:
ScStwTimerTests();
~ScStwTimerTests();
private slots:
void initTestCase();
void cleanupTestCase();
void basic_cycle_cancelled();
void basic_cycle_won();
void basic_cycle_lost();
void basic_cycle_failed();
void basic_cycle_wildcard();
};
ScStwTimerTests::ScStwTimerTests()
{
}
ScStwTimerTests::~ScStwTimerTests()
{
}
void ScStwTimerTests::initTestCase()
{
}
void ScStwTimerTests::cleanupTestCase()
{
}
void ScStwTimerTests::basic_cycle_cancelled()
{
ScStwTimer timer;
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
timer.start();
QCOMPARE(timer.getState(), ScStwTimer::RUNNING);
QCOMPARE(timer.isRunning(), true);
timer.cancel();
QCOMPARE(timer.getState(), ScStwTimer::CANCELLED);
timer.reset();
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
}
void ScStwTimerTests::basic_cycle_won()
{
ScStwTimer timer;
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
timer.start();
QCOMPARE(timer.getState(), ScStwTimer::RUNNING);
QCOMPARE(timer.isRunning(), true);
timer.stop();
QCOMPARE(timer.getState(), ScStwTimer::WAITING);
timer.setResult(ScStwTimer::WON);
QCOMPARE(timer.getState(), ScStwTimer::WON);
timer.reset();
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
}
void ScStwTimerTests::basic_cycle_lost()
{
ScStwTimer timer;
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
timer.start();
QCOMPARE(timer.getState(), ScStwTimer::RUNNING);
QCOMPARE(timer.isRunning(), true);
timer.stop();
QCOMPARE(timer.getState(), ScStwTimer::WAITING);
timer.setResult(ScStwTimer::LOST);
QCOMPARE(timer.getState(), ScStwTimer::LOST);
timer.reset();
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
}
void ScStwTimerTests::basic_cycle_failed()
{
double startTime = QDateTime::currentMSecsSinceEpoch() + 1000;
ScStwTestingTimer timer;
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
timer.start(startTime);
QCOMPARE(timer.getState(), ScStwTimer::STARTING);
timer.handleClimberStart(startTime - 1000);
QCOMPARE(timer.getState(), ScStwTimer::FAILING);
timer.setResult(ScStwTimer::FAILED);
QCOMPARE(timer.getState(), ScStwTimer::FAILED);
QCOMPARE(timer.getReactionTime(), -1000);
timer.reset();
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
}
void ScStwTimerTests::basic_cycle_wildcard()
{
double startTime = QDateTime::currentMSecsSinceEpoch() + 1000;
ScStwTestingTimer timer;
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
timer.start(startTime);
QCOMPARE(timer.getState(), ScStwTimer::STARTING);
timer.handleClimberStart(startTime - 1000);
QCOMPARE(timer.getState(), ScStwTimer::FAILING);
timer.setResult(ScStwTimer::WILDCARD);
QCOMPARE(timer.getState(), ScStwTimer::WILDCARD);
QCOMPARE(timer.getReactionTime(), -1000);
timer.reset();
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
}
QTEST_APPLESS_MAIN(ScStwTimerTests)
#include "tst_scstwtimertests.moc"

View file

@ -1,118 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>ScStw shared libraries</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
<link rel="stylesheet" href="m-dark+documentation.compiled.css" />
<link rel="icon" href="favicon.png" type="image/png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#0094ff" />
</head>
<body>
<header><nav id="navigation">
<div class="m-container">
<div class="m-row">
<a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m"><img src="favicon.png" alt="" />ScStw shared libraries</a>
<div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
<a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<path id="m-doc-search-icon-path" d="m6 0c-3.31 0-6 2.69-6 6 0 3.31 2.69 6 6 6 1.49 0 2.85-0.541 3.89-1.44-0.0164 0.338 0.147 0.759 0.5 1.15l3.22 3.79c0.552 0.614 1.45 0.665 2 0.115 0.55-0.55 0.499-1.45-0.115-2l-3.79-3.22c-0.392-0.353-0.812-0.515-1.15-0.5 0.895-1.05 1.44-2.41 1.44-3.89 0-3.31-2.69-6-6-6zm0 1.56a4.44 4.44 0 0 1 4.44 4.44 4.44 4.44 0 0 1-4.44 4.44 4.44 4.44 0 0 1-4.44-4.44 4.44 4.44 0 0 1 4.44-4.44z"/>
</svg></a>
<a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
<a id="m-navbar-hide" href="#" title="Hide navigation"></a>
</div>
<div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
<div class="m-row">
<ol class="m-col-t-6 m-col-m-none">
</ol>
<ol class="m-col-t-6 m-col-m-none" start="1">
<li><a href="index.html">Introduction</a></li>
<li><a href="annotated.html" id="m-navbar-current">Classes</a></li>
<li><a href="refman.pdf">Download</a></li>
<li class="m-show-m"><a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<use href="#m-doc-search-icon-path" />
</svg></a></li>
</ol>
</div>
</div>
</div>
</div>
</nav></header>
<main><article>
<div class="m-container m-container-inflatable">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<h1>Classes</h1>
<ul class="m-doc">
<li>class <a href="classScStw.html" class="m-doc">ScStw</a> <span class="m-doc">The <a href="classScStw.html" class="m-doc">ScStw</a> class provides some shared functions and enums for use in the <a href="classScStw.html" class="m-doc">ScStw</a> project.</span></li>
<li>class <a href="classScStwRace.html" class="m-doc">ScStwRace</a> <span class="m-doc">The <a href="classScStwRace.html" class="m-doc">ScStwRace</a> class can be used to measure timings of climbing races with multiple lanes at once.</span></li>
<li>class <a href="classScStwSoundPlayer.html" class="m-doc">ScStwSoundPlayer</a> <span class="m-doc">The <a href="classScStwSoundPlayer.html" class="m-doc">ScStwSoundPlayer</a> class is used for ultra low latency sound playback of the speed clibing start tones and commands.</span></li>
<li>class <a href="classScStwTimer.html" class="m-doc">ScStwTimer</a> <span class="m-doc">The <a href="classScStwTimer.html" class="m-doc">ScStwTimer</a> class is used for advanced time measurement.</span></li>
</ul>
<script>
function toggle(e) {
e.parentElement.className = e.parentElement.className == 'm-doc-collapsible' ?
'm-doc-expansible' : 'm-doc-collapsible';
return false;
}
/* Collapse all nodes marked as such. Doing it via JS instead of
directly in markup so disabling it doesn't harm usability. The list
is somehow regenerated on every iteration and shrinks as I change
the classes. It's not documented anywhere and I'm not sure if this
is the same across browsers, so I am going backwards in that list to
be sure. */
var collapsed = document.getElementsByClassName("collapsed");
for(var i = collapsed.length - 1; i >= 0; --i)
collapsed[i].className = 'm-doc-expansible';
</script>
</div>
</div>
</div>
</article></main>
<div class="m-doc-search" id="search">
<a href="#!" onclick="return hideSearch()"></a>
<div class="m-container">
<div class="m-row">
<div class="m-col-m-8 m-push-m-2">
<div class="m-doc-search-header m-text m-small">
<div><span class="m-label m-default">Tab</span> / <span class="m-label m-default">T</span> to search, <span class="m-label m-default">Esc</span> to close</div>
<div id="search-symbolcount">&hellip;</div>
</div>
<div class="m-doc-search-content">
<form>
<input type="search" name="q" id="search-input" placeholder="Loading &hellip;" disabled="disabled" autofocus="autofocus" autocomplete="off" spellcheck="false" />
</form>
<noscript class="m-text m-danger m-text-center">Unlike everything else in the docs, the search functionality <em>requires</em> JavaScript.</noscript>
<div id="search-help" class="m-text m-dim m-text-center">
<p class="m-noindent">Search for symbols, directories, files, pages or
modules. You can omit any prefix from the symbol or file path; adding a
<code>:</code> or <code>/</code> suffix lists all members of given symbol or
directory.</p>
<p class="m-noindent">Use <span class="m-label m-dim">&darr;</span>
/ <span class="m-label m-dim">&uarr;</span> to navigate through the list,
<span class="m-label m-dim">Enter</span> to go.
<span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
copy a link to the result using <span class="m-label m-dim"></span>
<span class="m-label m-dim">L</span> while <span class="m-label m-dim"></span>
<span class="m-label m-dim">M</span> produces a Markdown link.</p>
</div>
<div id="search-notfound" class="m-text m-warning m-text-center">Sorry, nothing was found.</div>
<ul id="search-results"></ul>
</div>
</div>
</div>
</div>
</div>
<script src="search-v2.js"></script>
<script src="searchdata-v2.js" async="async"></script>
<footer><nav>
<div class="m-container">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<p>ScStw shared libraries. Created with <a href="https://doxygen.org/">Doxygen</a> 1.9.4 and <a href="https://mcss.mosra.cz/">m.css</a>.</p>
</div>
</div>
</div>
</nav></footer>
</body>
</html>

View file

@ -1,492 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>ScStw class | ScStw shared libraries</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
<link rel="stylesheet" href="m-dark+documentation.compiled.css" />
<link rel="icon" href="favicon.png" type="image/png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#0094ff" />
</head>
<body>
<header><nav id="navigation">
<div class="m-container">
<div class="m-row">
<a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m"><img src="favicon.png" alt="" />ScStw shared libraries</a>
<div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
<a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<path id="m-doc-search-icon-path" d="m6 0c-3.31 0-6 2.69-6 6 0 3.31 2.69 6 6 6 1.49 0 2.85-0.541 3.89-1.44-0.0164 0.338 0.147 0.759 0.5 1.15l3.22 3.79c0.552 0.614 1.45 0.665 2 0.115 0.55-0.55 0.499-1.45-0.115-2l-3.79-3.22c-0.392-0.353-0.812-0.515-1.15-0.5 0.895-1.05 1.44-2.41 1.44-3.89 0-3.31-2.69-6-6-6zm0 1.56a4.44 4.44 0 0 1 4.44 4.44 4.44 4.44 0 0 1-4.44 4.44 4.44 4.44 0 0 1-4.44-4.44 4.44 4.44 0 0 1 4.44-4.44z"/>
</svg></a>
<a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
<a id="m-navbar-hide" href="#" title="Hide navigation"></a>
</div>
<div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
<div class="m-row">
<ol class="m-col-t-6 m-col-m-none">
</ol>
<ol class="m-col-t-6 m-col-m-none" start="1">
<li><a href="index.html">Introduction</a></li>
<li><a href="annotated.html">Classes</a></li>
<li><a href="refman.pdf">Download</a></li>
<li class="m-show-m"><a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<use href="#m-doc-search-icon-path" />
</svg></a></li>
</ol>
</div>
</div>
</div>
</div>
</nav></header>
<main><article>
<div class="m-container m-container-inflatable">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<h1>
ScStw <span class="m-thin">class</span>
</h1>
<p>The <a href="classScStw.html" class="m-doc">ScStw</a> class provides some shared functions and enums for use in the <a href="classScStw.html" class="m-doc">ScStw</a> project.</p>
<nav class="m-block m-default">
<h3>Contents</h3>
<ul>
<li>
Reference
<ul>
<li><a href="#pub-types">Public types</a></li>
<li><a href="#pub-static-attribs">Public static variables</a></li>
<li><a href="#pub-static-methods">Public static functions</a></li>
</ul>
</li>
</ul>
</nav>
<section id="pub-types">
<h2><a href="#pub-types">Public types</a></h2>
<dl class="m-doc">
<dt>
<span class="m-doc-wrap-bumper">enum <a href="#ae1e6a4063ef25e60b06a96be66ae98f5" class="m-doc">SignalKey</a> { </span><span class="m-doc-wrap"><a href="#ae1e6a4063ef25e60b06a96be66ae98f5af668e8ab065c88986e8d4834f2665a8c" class="m-doc">InvalidSignal</a> = -1,
<a href="#ae1e6a4063ef25e60b06a96be66ae98f5aa80ebf1833d97d5832995b1ce5a1da58" class="m-doc">RaceStateChanged</a> = 9000,
<a href="#ae1e6a4063ef25e60b06a96be66ae98f5a47d5c3b737a67c16a5a3b3838b1c8c78" class="m-doc">TimersChanged</a> = 9001,
<a href="#ae1e6a4063ef25e60b06a96be66ae98f5a0a0771bdd0619fc4295043b9d434a05a" class="m-doc">ExtensionsChanged</a> = 9002,
<a href="#ae1e6a4063ef25e60b06a96be66ae98f5a58605207be6190ba18724d7ba9eb9b0f" class="m-doc">CurrentStartDelayChanged</a> = 9003,
<a href="#ae1e6a4063ef25e60b06a96be66ae98f5a8e3e0a2a19fce2e083db110623a1328a" class="m-doc">SettingChanged</a> = 9004,
<a href="#ae1e6a4063ef25e60b06a96be66ae98f5ac63926de40b326c3bbdc7d2769095238" class="m-doc">RaceDetailsChanged</a> = 9005 }</span>
</dt>
<dd>The SignalKey enum contains all signal keys a client can subscribe to.</dd>
<dt>
<span class="m-doc-wrap-bumper">enum <a href="#a5423a0a57d880d1f3869b81c2c31435d" class="m-doc">SocketCommand</a> { </span><span class="m-doc-wrap"><a href="#a5423a0a57d880d1f3869b81c2c31435daa8175df1ad5271c45ceb9728c78b4781" class="m-doc">InvalidCommand</a> = -1,
<a href="#a5423a0a57d880d1f3869b81c2c31435da89eca4261bb918b66c86aac4cd54b974" class="m-doc">InitializeSessionCommand</a> = 1,
<a href="#a5423a0a57d880d1f3869b81c2c31435da2e9071f19d6c4323c3e63c230f181915" class="m-doc">StartRaceCommand</a> = 1000,
<a href="#a5423a0a57d880d1f3869b81c2c31435daa610e783673fe122b0d2aa475e2a59eb" class="m-doc">StopRaceCommand</a> = 1001,
<a href="#a5423a0a57d880d1f3869b81c2c31435da54bb9a3f594fc242fb13f67cdd959ecc" class="m-doc">ResetRaceCommand</a> = 1002,
<a href="#a5423a0a57d880d1f3869b81c2c31435da56ceaf707e56ed71d5ad76d2a006d699" class="m-doc">CancelRaceCommand</a> = 1003,
<a href="#a5423a0a57d880d1f3869b81c2c31435dabbb46bc1d8a0da3def761bbe0b3a6a8b" class="m-doc">SetTimerDisabledCommand</a> = 1004,
<a href="#a5423a0a57d880d1f3869b81c2c31435da4feff580b736bf76918a1679b20ef09b" class="m-doc">GetRaceStateCommand</a> = 2000,
<a href="#a5423a0a57d880d1f3869b81c2c31435da0b0811d7d9da70db64c721e0428e1ed8" class="m-doc">GetRaceDetailsCommand</a> = 2001,
<a href="#a5423a0a57d880d1f3869b81c2c31435dacc68f94afda8dd51d214ea72de8f35d9" class="m-doc">GetExtensionsCommand</a> = 2006,
<a href="#a5423a0a57d880d1f3869b81c2c31435dad2ebce11c93924f366c3db2fba4a70eb" class="m-doc">GetTimersCommand</a> = 2007,
<a href="#a5423a0a57d880d1f3869b81c2c31435dac2fc21420cf257d4ee8544ee7ff2c5da" class="m-doc">GetCurrentStartDelayCommand</a> = 2009,
<a href="#a5423a0a57d880d1f3869b81c2c31435da7dfdefe46bb07e4f61a109071cd514f0" class="m-doc">WriteSettingCommand</a> = 3000,
<a href="#a5423a0a57d880d1f3869b81c2c31435da9b21491ad5679551564117fdd8037dfa" class="m-doc">ReadSettingCommand</a> = 3001,
<a href="#a5423a0a57d880d1f3869b81c2c31435da0cd9075af5093deb2440ae88153b8710" class="m-doc">LoginAthleteCommand</a> = 4000,
<a href="#a5423a0a57d880d1f3869b81c2c31435dad8ee0cacc4af2fca0fed7df86cdb9d7b" class="m-doc">CreateAthleteCommand</a> = 4001,
<a href="#a5423a0a57d880d1f3869b81c2c31435daefd2ac3fd192ce7301aa92ec9bfffd91" class="m-doc">DeleteAthleteCommand</a> = 4002,
<a href="#a5423a0a57d880d1f3869b81c2c31435da1e70a71892186a0fdf75776a3436830a" class="m-doc">GetAtheletesCommand</a> = 4003,
<a href="#a5423a0a57d880d1f3869b81c2c31435da7d41c99c0143ba83183d4d125c026937" class="m-doc">GetAthleteResultsCommand</a> = 4004,
<a href="#a5423a0a57d880d1f3869b81c2c31435da7baee66c53c8db6428cfe9b920db0068" class="m-doc">UpdateFirmwareCommand</a> = 5000,
<a href="#a5423a0a57d880d1f3869b81c2c31435dab569d653ad233358e01a5a9feffe992d" class="m-doc">UpdateSystemTimeCommand</a> = 5001,
<a href="#a5423a0a57d880d1f3869b81c2c31435da694deb2480537d40ad462b150f14b367" class="m-doc">PairExtensionsCommand</a> = 5002 }</span>
</dt>
<dd>The SocketCommand enum contains all commands the base station can handle.</dd>
<dt>
<span class="m-doc-wrap-bumper">enum <a href="#ad0a329ddc142cab81bc98e0d40d32068" class="m-doc">StatusCode</a> { </span><span class="m-doc-wrap"><a href="#ad0a329ddc142cab81bc98e0d40d32068ac90bc44b984e9b18f2a0502aaeadbc70" class="m-doc">Success</a> = 200,
<a href="#ad0a329ddc142cab81bc98e0d40d32068a8c5d88049fa4b6772f45334aaaea7ed8" class="m-doc">FirmwareAlreadyUpToDateInfo</a> = 304,
<a href="#ad0a329ddc142cab81bc98e0d40d32068a1402c3028428a1014af069ce5a1b5e5a" class="m-doc">AccessDeniedError</a> = 401,
<a href="#ad0a329ddc142cab81bc98e0d40d32068a38ceb962d98837024c73f7c1ff892650" class="m-doc">UpdateSignatureInvalidError</a> = 402,
<a href="#ad0a329ddc142cab81bc98e0d40d32068ae66e653e8758f291409a03a2e594fb66" class="m-doc">CurrentStateNotVaildForOperationError</a> = 403,
<a href="#ad0a329ddc142cab81bc98e0d40d32068a88cd97a3c92c7827347d838c290a1d1a" class="m-doc">CommandNotFoundError</a> = 404,
<a href="#ad0a329ddc142cab81bc98e0d40d32068afc606bfc04e661c0f3322918d5971b8e" class="m-doc">RequiredParameterNotGivenError</a> = 405,
<a href="#ad0a329ddc142cab81bc98e0d40d32068a3dbfdee6e7375265d4d368da015fff6a" class="m-doc">TimestampTooSmallError</a> = 406,
<a href="#ad0a329ddc142cab81bc98e0d40d32068a4adf2bcdb8d85a40dfa6186b2dc636d8" class="m-doc">ClientSessionAlreadyActiveError</a> = 407,
<a href="#ad0a329ddc142cab81bc98e0d40d32068a295c2b1f44a6f1791df9e62c5e4f09b6" class="m-doc">NoSessionActiveError</a> = 408,
<a href="#ad0a329ddc142cab81bc98e0d40d32068ad8022967fadac3af0477abeb94eefba6" class="m-doc">ItemNotFoundError</a> = 409,
<a href="#ad0a329ddc142cab81bc98e0d40d32068a67a867bdb5323675c8971d506f322dd9" class="m-doc">LastTimerCannotBeDisabledError</a> = 410,
<a href="#ad0a329ddc142cab81bc98e0d40d32068a9856621699e04ac7e336411c34769ef2" class="m-doc">UpdateFailedError</a> = 500,
<a href="#ad0a329ddc142cab81bc98e0d40d32068ad0bcc0ff858abd7ebcf6842662fdad28" class="m-doc">Error</a> = 900,
<a href="#ad0a329ddc142cab81bc98e0d40d32068a8b76f1bc500981c49d4bf1880b02e7cd" class="m-doc">NotConnectedError</a> = 910,
<a href="#ad0a329ddc142cab81bc98e0d40d32068a5f7d9a63e9b48a1f4ca4f212de3998e5" class="m-doc">TimeoutError</a> = 911,
<a href="#ad0a329ddc142cab81bc98e0d40d32068a18b1139de766f9ae6aab6fddb5f2e3f4" class="m-doc">SettingNotAccessibleError</a> = 901,
<a href="#ad0a329ddc142cab81bc98e0d40d32068a4238fbecbd83ec9d9d88503274a4fc55" class="m-doc">InternalError</a> = 950,
<a href="#ad0a329ddc142cab81bc98e0d40d32068a98e06a2ac920230686410995bfb52071" class="m-doc">InternalErrorTimerOperationFailed</a> = 951,
<a href="#ad0a329ddc142cab81bc98e0d40d32068a6983d437713d173257ac8ba9e59a21a1" class="m-doc">ApiVersionNotSupportedError</a> = 952,
<a href="#ad0a329ddc142cab81bc98e0d40d32068aa09b339c976ac6155e57482213b0dacc" class="m-doc">CompetitionModeProhibitsThisError</a> = 953,
<a href="#ad0a329ddc142cab81bc98e0d40d32068afe579c343439c557042b405213c0a767" class="m-doc">FirmwareUpdateFormatInvalidError</a> = 954,
<a href="#ad0a329ddc142cab81bc98e0d40d32068a98d7b4970249f97e6063e98894310fe3" class="m-doc">TimersNotReadyError</a> = 501 }</span>
</dt>
<dd>The ErrorCode enum contains all error codes that can occur when sending a command to the basestation.</dd>
<dt id="afb007a099c165449761afaed23a54c45">
<span class="m-doc-wrap-bumper">enum <a href="#afb007a099c165449761afaed23a54c45" class="m-doc-self">ExtensionType</a> { </span><span class="m-doc-wrap"><a href="#afb007a099c165449761afaed23a54c45a11143192831b8c7c1561b7a5fe49c73b" class="m-doc">StartPad</a>,
<a href="#afb007a099c165449761afaed23a54c45af805ee1d649fb700b311d78a539de5d0" class="m-doc">TopPad</a> }</span>
</dt>
<dd>The ExtensionType enum contains all types of extensions.</dd>
<dt id="a45d2f89b38509f9249c62fcf8615a5e4">
<span class="m-doc-wrap-bumper">enum <a href="#a45d2f89b38509f9249c62fcf8615a5e4" class="m-doc-self">ExtensionState</a> { </span><span class="m-doc-wrap"><a href="#a45d2f89b38509f9249c62fcf8615a5e4ad4bc7e3ba3f8b4bb17565f5c09d0e923" class="m-doc">ExtensionDisconnected</a> = 0,
<a href="#a45d2f89b38509f9249c62fcf8615a5e4ac5e22f94e3075e4f2b42079acee12af0" class="m-doc">ExtensionConnecting</a> = 1,
<a href="#a45d2f89b38509f9249c62fcf8615a5e4a33849788f83325582fed003b0c5cdd53" class="m-doc">ExtensionInitialising</a> = 2,
<a href="#a45d2f89b38509f9249c62fcf8615a5e4a61b99a659b183161287cc5871dacd49c" class="m-doc">ExtensionConnected</a> = 3 }</span>
</dt>
<dd>The ExtensionState enum contains all possible states of an extension.</dd>
<dt id="a834ac2b3f360fa60c7c4ff595901872b">
<span class="m-doc-wrap-bumper">enum <a href="#a834ac2b3f360fa60c7c4ff595901872b" class="m-doc-self">ExtensionBatteryState</a> { </span><span class="m-doc-wrap"><a href="#a834ac2b3f360fa60c7c4ff595901872ba52242d1e8319f37044fc08462c833dab" class="m-doc">BatteryUnknown</a> = -1,
<a href="#a834ac2b3f360fa60c7c4ff595901872ba97904f100f4fe2ced6aad97c28b7e19e" class="m-doc">BatteryCritical</a> = 0,
<a href="#a834ac2b3f360fa60c7c4ff595901872ba80c048b281765407456f0d95134b033f" class="m-doc">BatteryWarning</a> = 1,
<a href="#a834ac2b3f360fa60c7c4ff595901872ba24ae0b56e578f11fb248920033b319c5" class="m-doc">BatteryFine</a> = 2,
<a href="#a834ac2b3f360fa60c7c4ff595901872ba0852dfdec85e155f5def253a26ce9264" class="m-doc">BatteryCharging</a> = 3,
<a href="#a834ac2b3f360fa60c7c4ff595901872ba5d94a347cddac0a18dd2e017ffd903ed" class="m-doc">BatteryNotCharging</a> = 4 }</span>
</dt>
<dd>The ExtensionBatteryState enum contains all possible battery states of an extension.</dd>
<dt id="a7311db682ac8e761198339dd5ba53d44">
<span class="m-doc-wrap-bumper">enum <a href="#a7311db682ac8e761198339dd5ba53d44" class="m-doc-self">PadState</a> { </span><span class="m-doc-wrap"><a href="#a7311db682ac8e761198339dd5ba53d44acb5fd37b5f8d10eb23270d8c346e9c77" class="m-doc">PadNotPressed</a> = 0,
<a href="#a7311db682ac8e761198339dd5ba53d44a251d1dab4490f91a2e42fa54d1fb71b8" class="m-doc">PadPressed</a> = 1 }</span>
</dt>
<dd>The PadState enum contains whether a pad is currently pressed or not.</dd>
</dl>
</section>
<section id="pub-static-attribs">
<h2><a href="#pub-static-attribs">Public static variables</a></h2>
<dl class="m-doc">
<dt id="a55de84e3e91a8e3834a629ed7eb805a7">
static const char* <a href="#a55de84e3e91a8e3834a629ed7eb805a7" class="m-doc-self">SOCKET_MESSAGE_START_KEY</a>
</dt>
<dd>SOCKET_MESSAGE_START_KEY contains the key, a message is supposed to start with.</dd>
<dt id="a8c677bb34fc8286af58b4ace13cf8c89">
static const char* <a href="#a8c677bb34fc8286af58b4ace13cf8c89" class="m-doc-self">SOCKET_MESSAGE_END_KEY</a>
</dt>
<dd>SOCKET_MESSAGE_END_KEY contains the key, a message is supposed to end with.</dd>
</dl>
</section>
<section id="pub-static-methods">
<h2><a href="#pub-static-methods">Public static functions</a></h2>
<dl class="m-doc">
<dt>
<span class="m-doc-wrap-bumper">static auto <a href="#a781770df5498946a23e1d91613c6c5e7" class="m-doc">signalKeyFromInt</a>(</span><span class="m-doc-wrap">int i) -&gt; <a href="classScStw.html#ae1e6a4063ef25e60b06a96be66ae98f5" class="m-doc">SignalKey</a></span>
</dt>
<dd>Function to convert an int to a SignalKey.</dd>
<dt>
<span class="m-doc-wrap-bumper">static auto <a href="#a8102a6fee01f43144d8bf3ebe054b753" class="m-doc">socketCommandFromInt</a>(</span><span class="m-doc-wrap">int i) -&gt; <a href="classScStw.html#a5423a0a57d880d1f3869b81c2c31435d" class="m-doc">SocketCommand</a></span>
</dt>
<dd>Function to convert an int to a SocketCommand.</dd>
<dt>
<span class="m-doc-wrap-bumper">static auto <a href="#ad40564b2338ba1cf01ccacedfd1525ca" class="m-doc">extensionTypeToString</a>(</span><span class="m-doc-wrap"><a href="classScStw.html#afb007a099c165449761afaed23a54c45" class="m-doc">ExtensionType</a> t) -&gt; QString</span>
</dt>
<dd>Function to convert an ExtensionType to a string.</dd>
<dt>
<span class="m-doc-wrap-bumper">static auto <a href="#a4732d5c78f05a171b492efbf1d8e4820" class="m-doc">firmwareCompare</a>(</span><span class="m-doc-wrap">QString a,
QString b) -&gt; int</span>
</dt>
<dd>Function to compare to string firmware versions in &lt;major&gt;.&lt;minor&gt;.&lt;patch&gt; formar.</dd>
<dt id="ad93a64f89f0bec0903e5b78d714b1cb3">
<div class="m-doc-template">template&lt;typename Enum&gt;</div>
<span class="m-doc-wrap-bumper">static auto <a href="#ad93a64f89f0bec0903e5b78d714b1cb3" class="m-doc-self">toEnumValue</a>(</span><span class="m-doc-wrap">const int&amp; value,
bool* ok) -&gt; Enum</span>
</dt>
<dd>Function to convert a value to an enum.</dd>
</dl>
</section>
<section>
<h2>Enum documentation</h2>
<section class="m-doc-details" id="ae1e6a4063ef25e60b06a96be66ae98f5"><div>
<h3>
enum ScStw::<wbr /><a href="#ae1e6a4063ef25e60b06a96be66ae98f5" class="m-doc-self">SignalKey</a>
</h3>
<p>The SignalKey enum contains all signal keys a client can subscribe to.</p>
<aside class="m-note m-default"><h4>See also</h4><p><a href="classScStw.html#a781770df5498946a23e1d91613c6c5e7" class="m-doc">ScStw::<wbr />signalKeyFromInt()</a></p></aside>
</div></section>
<section class="m-doc-details" id="a5423a0a57d880d1f3869b81c2c31435d"><div>
<h3>
enum ScStw::<wbr /><a href="#a5423a0a57d880d1f3869b81c2c31435d" class="m-doc-self">SocketCommand</a>
</h3>
<p>The SocketCommand enum contains all commands the base station can handle.</p>
<aside class="m-note m-default"><h4>See also</h4><p><a href="classScStw.html#a8102a6fee01f43144d8bf3ebe054b753" class="m-doc">ScStw::<wbr />socketCommandFromInt()</a></p></aside>
</div></section>
<section class="m-doc-details" id="ad0a329ddc142cab81bc98e0d40d32068"><div>
<h3>
enum ScStw::<wbr /><a href="#ad0a329ddc142cab81bc98e0d40d32068" class="m-doc-self">StatusCode</a>
</h3>
<p>The ErrorCode enum contains all error codes that can occur when sending a command to the basestation.</p>
<table class="m-table m-fullwidth m-flat m-doc">
<thead><tr><th style="width: 1%">Enumerators</th><th></th></tr></thead>
<tbody>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068ac90bc44b984e9b18f2a0502aaeadbc70" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068ac90bc44b984e9b18f2a0502aaeadbc70">Success</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068a8c5d88049fa4b6772f45334aaaea7ed8" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068a8c5d88049fa4b6772f45334aaaea7ed8">FirmwareAlreadyUpToDateInfo</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068a1402c3028428a1014af069ce5a1b5e5a" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068a1402c3028428a1014af069ce5a1b5e5a">AccessDeniedError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068a38ceb962d98837024c73f7c1ff892650" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068a38ceb962d98837024c73f7c1ff892650">UpdateSignatureInvalidError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068ae66e653e8758f291409a03a2e594fb66" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068ae66e653e8758f291409a03a2e594fb66">CurrentStateNotVaildForOperationError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068a88cd97a3c92c7827347d838c290a1d1a" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068a88cd97a3c92c7827347d838c290a1d1a">CommandNotFoundError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068afc606bfc04e661c0f3322918d5971b8e" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068afc606bfc04e661c0f3322918d5971b8e">RequiredParameterNotGivenError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068a3dbfdee6e7375265d4d368da015fff6a" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068a3dbfdee6e7375265d4d368da015fff6a">TimestampTooSmallError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068a4adf2bcdb8d85a40dfa6186b2dc636d8" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068a4adf2bcdb8d85a40dfa6186b2dc636d8">ClientSessionAlreadyActiveError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068a295c2b1f44a6f1791df9e62c5e4f09b6" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068a295c2b1f44a6f1791df9e62c5e4f09b6">NoSessionActiveError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068ad8022967fadac3af0477abeb94eefba6" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068ad8022967fadac3af0477abeb94eefba6">ItemNotFoundError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068a67a867bdb5323675c8971d506f322dd9" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068a67a867bdb5323675c8971d506f322dd9">LastTimerCannotBeDisabledError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068a9856621699e04ac7e336411c34769ef2" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068a9856621699e04ac7e336411c34769ef2">UpdateFailedError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068ad0bcc0ff858abd7ebcf6842662fdad28" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068ad0bcc0ff858abd7ebcf6842662fdad28">Error</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068a8b76f1bc500981c49d4bf1880b02e7cd" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068a8b76f1bc500981c49d4bf1880b02e7cd">NotConnectedError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068a5f7d9a63e9b48a1f4ca4f212de3998e5" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068a5f7d9a63e9b48a1f4ca4f212de3998e5">TimeoutError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068a18b1139de766f9ae6aab6fddb5f2e3f4" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068a18b1139de766f9ae6aab6fddb5f2e3f4">SettingNotAccessibleError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068a4238fbecbd83ec9d9d88503274a4fc55" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068a4238fbecbd83ec9d9d88503274a4fc55">InternalError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068a98e06a2ac920230686410995bfb52071" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068a98e06a2ac920230686410995bfb52071">InternalErrorTimerOperationFailed</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068a6983d437713d173257ac8ba9e59a21a1" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068a6983d437713d173257ac8ba9e59a21a1">ApiVersionNotSupportedError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068aa09b339c976ac6155e57482213b0dacc" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068aa09b339c976ac6155e57482213b0dacc">CompetitionModeProhibitsThisError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068afe579c343439c557042b405213c0a767" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068afe579c343439c557042b405213c0a767">FirmwareUpdateFormatInvalidError</a></td>
<td>
</td>
</tr>
<tr>
<td><a href="#ad0a329ddc142cab81bc98e0d40d32068a98d7b4970249f97e6063e98894310fe3" class="m-doc-self" id="ad0a329ddc142cab81bc98e0d40d32068a98d7b4970249f97e6063e98894310fe3">TimersNotReadyError</a></td>
<td>
<p>One or more timer is not ready</p>
</td>
</tr>
</tbody>
</table>
</div></section>
</section>
<section>
<h2>Function documentation</h2>
<section class="m-doc-details" id="a781770df5498946a23e1d91613c6c5e7"><div>
<h3>
<span class="m-doc-wrap-bumper">static <a href="classScStw.html#ae1e6a4063ef25e60b06a96be66ae98f5" class="m-doc">SignalKey</a> ScStw::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a781770df5498946a23e1d91613c6c5e7" class="m-doc-self">signalKeyFromInt</a>(</span><span class="m-doc-wrap">int i)</span></span>
</h3>
<p>Function to convert an int to a SignalKey.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">i</td>
<td>the int to convert</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td>a SignalKey</td>
</tr>
</tfoot>
</table>
<aside class="m-note m-default"><h4>See also</h4><p><a href="classScStw.html#ae1e6a4063ef25e60b06a96be66ae98f5" class="m-doc">ScStw::<wbr />SignalKey</a></p></aside>
</div></section>
<section class="m-doc-details" id="a8102a6fee01f43144d8bf3ebe054b753"><div>
<h3>
<span class="m-doc-wrap-bumper">static <a href="classScStw.html#a5423a0a57d880d1f3869b81c2c31435d" class="m-doc">SocketCommand</a> ScStw::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a8102a6fee01f43144d8bf3ebe054b753" class="m-doc-self">socketCommandFromInt</a>(</span><span class="m-doc-wrap">int i)</span></span>
</h3>
<p>Function to convert an int to a SocketCommand.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">i</td>
<td>the int to convert</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td>a SocketCommand</td>
</tr>
</tfoot>
</table>
<aside class="m-note m-default"><h4>See also</h4><p><a href="classScStw.html#a5423a0a57d880d1f3869b81c2c31435d" class="m-doc">ScStw::<wbr />SocketCommand</a></p></aside>
</div></section>
<section class="m-doc-details" id="ad40564b2338ba1cf01ccacedfd1525ca"><div>
<h3>
<span class="m-doc-wrap-bumper">static QString ScStw::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#ad40564b2338ba1cf01ccacedfd1525ca" class="m-doc-self">extensionTypeToString</a>(</span><span class="m-doc-wrap"><a href="classScStw.html#afb007a099c165449761afaed23a54c45" class="m-doc">ExtensionType</a> t)</span></span>
</h3>
<p>Function to convert an ExtensionType to a string.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">t</td>
<td>the ExtensionType to convert</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td>String</td>
</tr>
</tfoot>
</table>
<aside class="m-note m-default"><h4>See also</h4><p>ScStwExtensionType</p></aside>
</div></section>
<section class="m-doc-details" id="a4732d5c78f05a171b492efbf1d8e4820"><div>
<h3>
<span class="m-doc-wrap-bumper">static int ScStw::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a4732d5c78f05a171b492efbf1d8e4820" class="m-doc-self">firmwareCompare</a>(</span><span class="m-doc-wrap">QString a,
QString b)</span></span>
</h3>
<p>Function to compare to string firmware versions in &lt;major&gt;.&lt;minor&gt;.&lt;patch&gt; formar.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">a</td>
<td>version a</td>
</tr>
<tr>
<td>b</td>
<td>version b</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td>-4: a is of invalid format -3: major of a is lower than b -2: minor of a is lower than b -1: patch of a is lower than b 0: a and b are identical 1: patch b is lower than a 2: minor of b is lower than a 3: major of b is lower than a 4: b is of invalid format</td>
</tr>
</tfoot>
</table>
</div></section>
</section>
</div>
</div>
</div>
</article></main>
<div class="m-doc-search" id="search">
<a href="#!" onclick="return hideSearch()"></a>
<div class="m-container">
<div class="m-row">
<div class="m-col-m-8 m-push-m-2">
<div class="m-doc-search-header m-text m-small">
<div><span class="m-label m-default">Tab</span> / <span class="m-label m-default">T</span> to search, <span class="m-label m-default">Esc</span> to close</div>
<div id="search-symbolcount">&hellip;</div>
</div>
<div class="m-doc-search-content">
<form>
<input type="search" name="q" id="search-input" placeholder="Loading &hellip;" disabled="disabled" autofocus="autofocus" autocomplete="off" spellcheck="false" />
</form>
<noscript class="m-text m-danger m-text-center">Unlike everything else in the docs, the search functionality <em>requires</em> JavaScript.</noscript>
<div id="search-help" class="m-text m-dim m-text-center">
<p class="m-noindent">Search for symbols, directories, files, pages or
modules. You can omit any prefix from the symbol or file path; adding a
<code>:</code> or <code>/</code> suffix lists all members of given symbol or
directory.</p>
<p class="m-noindent">Use <span class="m-label m-dim">&darr;</span>
/ <span class="m-label m-dim">&uarr;</span> to navigate through the list,
<span class="m-label m-dim">Enter</span> to go.
<span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
copy a link to the result using <span class="m-label m-dim"></span>
<span class="m-label m-dim">L</span> while <span class="m-label m-dim"></span>
<span class="m-label m-dim">M</span> produces a Markdown link.</p>
</div>
<div id="search-notfound" class="m-text m-warning m-text-center">Sorry, nothing was found.</div>
<ul id="search-results"></ul>
</div>
</div>
</div>
</div>
</div>
<script src="search-v2.js"></script>
<script src="searchdata-v2.js" async="async"></script>
<footer><nav>
<div class="m-container">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<p>ScStw shared libraries. Created with <a href="https://doxygen.org/">Doxygen</a> 1.9.4 and <a href="https://mcss.mosra.cz/">m.css</a>.</p>
</div>
</div>
</div>
</nav></footer>
</body>
</html>

View file

@ -1,175 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>ScStwRace class | ScStw shared libraries</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
<link rel="stylesheet" href="m-dark+documentation.compiled.css" />
<link rel="icon" href="favicon.png" type="image/png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#0094ff" />
</head>
<body>
<header><nav id="navigation">
<div class="m-container">
<div class="m-row">
<a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m"><img src="favicon.png" alt="" />ScStw shared libraries</a>
<div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
<a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<path id="m-doc-search-icon-path" d="m6 0c-3.31 0-6 2.69-6 6 0 3.31 2.69 6 6 6 1.49 0 2.85-0.541 3.89-1.44-0.0164 0.338 0.147 0.759 0.5 1.15l3.22 3.79c0.552 0.614 1.45 0.665 2 0.115 0.55-0.55 0.499-1.45-0.115-2l-3.79-3.22c-0.392-0.353-0.812-0.515-1.15-0.5 0.895-1.05 1.44-2.41 1.44-3.89 0-3.31-2.69-6-6-6zm0 1.56a4.44 4.44 0 0 1 4.44 4.44 4.44 4.44 0 0 1-4.44 4.44 4.44 4.44 0 0 1-4.44-4.44 4.44 4.44 0 0 1 4.44-4.44z"/>
</svg></a>
<a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
<a id="m-navbar-hide" href="#" title="Hide navigation"></a>
</div>
<div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
<div class="m-row">
<ol class="m-col-t-6 m-col-m-none">
</ol>
<ol class="m-col-t-6 m-col-m-none" start="1">
<li><a href="index.html">Introduction</a></li>
<li><a href="annotated.html">Classes</a></li>
<li><a href="refman.pdf">Download</a></li>
<li class="m-show-m"><a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<use href="#m-doc-search-icon-path" />
</svg></a></li>
</ol>
</div>
</div>
</div>
</div>
</nav></header>
<main><article>
<div class="m-container m-container-inflatable">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<h1>
ScStwRace <span class="m-thin">class</span>
</h1>
<p>The <a href="classScStwRace.html" class="m-doc">ScStwRace</a> class can be used to measure timings of climbing races with multiple lanes at once.</p>
<nav class="m-block m-default">
<h3>Contents</h3>
<ul>
<li>
Reference
<ul>
<li><a href="#pub-slots">Public slots</a></li>
</ul>
</li>
</ul>
</nav>
<p>The <a href="classScStwRace.html" class="m-doc">ScStwRace</a> is a container to manage multiple timers at a time and introduces a propper start sequence with start commands (&#x27;At your Marks&#x27; and &#x27;Ready&#x27;) and the official IFSC start signal.</p><h3>Basic usage:</h3><pre class="m-code"><span class="n">ScStwRace</span><span class="w"> </span><span class="n">race</span><span class="p">;</span><span class="w"></span>
<span class="c1">// add two timers</span>
<span class="n">race</span><span class="p">.</span><span class="n">addTimer</span><span class="p">(</span><span class="k">new</span><span class="w"> </span><span class="n">ScStwTimer</span><span class="p">());</span><span class="w"></span>
<span class="n">race</span><span class="p">.</span><span class="n">addTimer</span><span class="p">(</span><span class="k">new</span><span class="w"> </span><span class="n">ScStwTimer</span><span class="p">());</span><span class="w"></span>
<span class="c1">// start a race</span>
<span class="n">race</span><span class="p">.</span><span class="n">start</span><span class="p">();</span><span class="w"></span></pre>
<section id="pub-slots">
<h2><a href="#pub-slots">Public slots</a></h2>
<dl class="m-doc">
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#ad0ce866fd86b91d7b1faf52533ab3c79" class="m-doc">start</a>(</span><span class="m-doc-wrap">bool asyncronous = true) -&gt; <a href="classScStw.html#ad0a329ddc142cab81bc98e0d40d32068" class="m-doc">ScStw::<wbr />StatusCode</a> <span class="m-label m-flat m-warning">virtual</span></span>
</dt>
<dd>Function to start the race.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a86c82494a5c75b0a5abd701c3417d8a9" class="m-doc">stop</a>(</span><span class="m-doc-wrap">) -&gt; <a href="classScStw.html#ad0a329ddc142cab81bc98e0d40d32068" class="m-doc">ScStw::<wbr />StatusCode</a> <span class="m-label m-flat m-warning">virtual</span></span>
</dt>
<dd>Function to stop the currently running race.</dd>
<dt id="ad36060393dcd989bced314a5077f4ea8">
<span class="m-doc-wrap-bumper">auto <a href="#ad36060393dcd989bced314a5077f4ea8" class="m-doc-self">reset</a>(</span><span class="m-doc-wrap">) -&gt; <a href="classScStw.html#ad0a329ddc142cab81bc98e0d40d32068" class="m-doc">ScStw::<wbr />StatusCode</a> <span class="m-label m-flat m-warning">virtual</span></span>
</dt>
<dd>Function to reset a stopped race.</dd>
</dl>
</section>
<section>
<h2>Function documentation</h2>
<section class="m-doc-details" id="ad0ce866fd86b91d7b1faf52533ab3c79"><div>
<h3>
<span class="m-doc-wrap-bumper"><a href="classScStw.html#ad0a329ddc142cab81bc98e0d40d32068" class="m-doc">ScStw::<wbr />StatusCode</a> ScStwRace::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#ad0ce866fd86b91d7b1faf52533ab3c79" class="m-doc-self">start</a>(</span><span class="m-doc-wrap">bool asyncronous = true) <span class="m-label m-warning">virtual</span> <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to start the race.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">asyncronous</td>
<td>if the function should just start the start sequence and then quit (true) or if if should wait until the start sequence is over and quit after that (false)</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td>200: OK; 904: state not matching</td>
</tr>
</tfoot>
</table>
</div></section>
<section class="m-doc-details" id="a86c82494a5c75b0a5abd701c3417d8a9"><div>
<h3>
<span class="m-doc-wrap-bumper"><a href="classScStw.html#ad0a329ddc142cab81bc98e0d40d32068" class="m-doc">ScStw::<wbr />StatusCode</a> ScStwRace::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a86c82494a5c75b0a5abd701c3417d8a9" class="m-doc-self">stop</a>(</span><span class="m-doc-wrap">) <span class="m-label m-warning">virtual</span> <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to stop the currently running race.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>200: OK; 904: state not matching</td>
</tr>
</tfoot>
</table>
</div></section>
</section>
</div>
</div>
</div>
</article></main>
<div class="m-doc-search" id="search">
<a href="#!" onclick="return hideSearch()"></a>
<div class="m-container">
<div class="m-row">
<div class="m-col-m-8 m-push-m-2">
<div class="m-doc-search-header m-text m-small">
<div><span class="m-label m-default">Tab</span> / <span class="m-label m-default">T</span> to search, <span class="m-label m-default">Esc</span> to close</div>
<div id="search-symbolcount">&hellip;</div>
</div>
<div class="m-doc-search-content">
<form>
<input type="search" name="q" id="search-input" placeholder="Loading &hellip;" disabled="disabled" autofocus="autofocus" autocomplete="off" spellcheck="false" />
</form>
<noscript class="m-text m-danger m-text-center">Unlike everything else in the docs, the search functionality <em>requires</em> JavaScript.</noscript>
<div id="search-help" class="m-text m-dim m-text-center">
<p class="m-noindent">Search for symbols, directories, files, pages or
modules. You can omit any prefix from the symbol or file path; adding a
<code>:</code> or <code>/</code> suffix lists all members of given symbol or
directory.</p>
<p class="m-noindent">Use <span class="m-label m-dim">&darr;</span>
/ <span class="m-label m-dim">&uarr;</span> to navigate through the list,
<span class="m-label m-dim">Enter</span> to go.
<span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
copy a link to the result using <span class="m-label m-dim"></span>
<span class="m-label m-dim">L</span> while <span class="m-label m-dim"></span>
<span class="m-label m-dim">M</span> produces a Markdown link.</p>
</div>
<div id="search-notfound" class="m-text m-warning m-text-center">Sorry, nothing was found.</div>
<ul id="search-results"></ul>
</div>
</div>
</div>
</div>
</div>
<script src="search-v2.js"></script>
<script src="searchdata-v2.js" async="async"></script>
<footer><nav>
<div class="m-container">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<p>ScStw shared libraries. Created with <a href="https://doxygen.org/">Doxygen</a> 1.9.4 and <a href="https://mcss.mosra.cz/">m.css</a>.</p>
</div>
</div>
</div>
</nav></footer>
</body>
</html>

View file

@ -1,240 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>ScStwSoundPlayer class | ScStw shared libraries</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
<link rel="stylesheet" href="m-dark+documentation.compiled.css" />
<link rel="icon" href="favicon.png" type="image/png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#0094ff" />
</head>
<body>
<header><nav id="navigation">
<div class="m-container">
<div class="m-row">
<a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m"><img src="favicon.png" alt="" />ScStw shared libraries</a>
<div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
<a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<path id="m-doc-search-icon-path" d="m6 0c-3.31 0-6 2.69-6 6 0 3.31 2.69 6 6 6 1.49 0 2.85-0.541 3.89-1.44-0.0164 0.338 0.147 0.759 0.5 1.15l3.22 3.79c0.552 0.614 1.45 0.665 2 0.115 0.55-0.55 0.499-1.45-0.115-2l-3.79-3.22c-0.392-0.353-0.812-0.515-1.15-0.5 0.895-1.05 1.44-2.41 1.44-3.89 0-3.31-2.69-6-6-6zm0 1.56a4.44 4.44 0 0 1 4.44 4.44 4.44 4.44 0 0 1-4.44 4.44 4.44 4.44 0 0 1-4.44-4.44 4.44 4.44 0 0 1 4.44-4.44z"/>
</svg></a>
<a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
<a id="m-navbar-hide" href="#" title="Hide navigation"></a>
</div>
<div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
<div class="m-row">
<ol class="m-col-t-6 m-col-m-none">
</ol>
<ol class="m-col-t-6 m-col-m-none" start="1">
<li><a href="index.html">Introduction</a></li>
<li><a href="annotated.html">Classes</a></li>
<li><a href="refman.pdf">Download</a></li>
<li class="m-show-m"><a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<use href="#m-doc-search-icon-path" />
</svg></a></li>
</ol>
</div>
</div>
</div>
</div>
</nav></header>
<main><article>
<div class="m-container m-container-inflatable">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<h1>
ScStwSoundPlayer <span class="m-thin">class</span>
</h1>
<p>The <a href="classScStwSoundPlayer.html" class="m-doc">ScStwSoundPlayer</a> class is used for ultra low latency sound playback of the speed clibing start tones and commands.</p>
<nav class="m-block m-default">
<h3>Contents</h3>
<ul>
<li>
Reference
<ul>
<li><a href="#typeless-methods">Constructors, destructors, conversion operators</a></li>
<li><a href="#signals">Signals</a></li>
<li><a href="#pub-slots">Public slots</a></li>
</ul>
</li>
</ul>
</nav>
<section id="typeless-methods">
<h2><a href="#typeless-methods">Constructors, destructors, conversion operators</a></h2>
<dl class="m-doc">
<dt>
<span class="m-doc-wrap-bumper"><a href="#a8fb670ba6b752464f7a2f729803dfc45" class="m-doc">ScStwSoundPlayer</a>(</span><span class="m-doc-wrap">QObject* parent = nullptr) <span class="m-label m-flat m-info">explicit</span> </span>
</dt>
<dd><a href="classScStwSoundPlayer.html" class="m-doc">ScStwSoundPlayer</a> constructor.</dd>
</dl>
</section>
<section id="signals">
<h2><a href="#signals">Signals</a></h2>
<dl class="m-doc">
<dt id="aa2fee0a62891c8375659ec24adc8f15c">
<span class="m-doc-wrap-bumper">void <a href="#aa2fee0a62891c8375659ec24adc8f15c" class="m-doc-self">playbackStarted</a>(</span><span class="m-doc-wrap">)</span>
</dt>
<dd>Emitted whenever a playback started.</dd>
</dl>
</section>
<section id="pub-slots">
<h2><a href="#pub-slots">Public slots</a></h2>
<dl class="m-doc">
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a8406a6f6877a700a6872980ca1497b0e" class="m-doc">play</a>(</span><span class="m-doc-wrap">StartSound sound,
double volume,
double* timeOfStart = nullptr) -&gt; ScStwSoundPlayer::PlayResult</span>
</dt>
<dd>Function to begin playing the sound of a certain state.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a027f45d562b787bfe94872b5fb797575" class="m-doc">waitForSoundFinish</a>(</span><span class="m-doc-wrap">double* timeOfStop = nullptr) -&gt; ScStwSoundPlayer::PlayResult</span>
</dt>
<dd>Function to wait for the playback to finish.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a3e09578b2da014e3a2324e7f3c5549f1" class="m-doc">cancel</a>(</span><span class="m-doc-wrap">) -&gt; bool</span>
</dt>
<dd>Function to cancel the current playback.</dd>
</dl>
</section>
<section>
<h2>Function documentation</h2>
<section class="m-doc-details" id="a8fb670ba6b752464f7a2f729803dfc45"><div>
<h3>
<span class="m-doc-wrap-bumper"> ScStwSoundPlayer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a8fb670ba6b752464f7a2f729803dfc45" class="m-doc-self">ScStwSoundPlayer</a>(</span><span class="m-doc-wrap">QObject* parent = nullptr) <span class="m-label m-info">explicit</span> </span></span>
</h3>
<p><a href="classScStwSoundPlayer.html" class="m-doc">ScStwSoundPlayer</a> constructor.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">parent</td>
<td></td>
</tr>
</tbody>
</table>
</div></section>
<section class="m-doc-details" id="a8406a6f6877a700a6872980ca1497b0e"><div>
<h3>
<span class="m-doc-wrap-bumper">ScStwSoundPlayer::PlayResult ScStwSoundPlayer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a8406a6f6877a700a6872980ca1497b0e" class="m-doc-self">play</a>(</span><span class="m-doc-wrap">StartSound sound,
double volume,
double* timeOfStart = nullptr) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to begin playing the sound of a certain state.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">sound</td>
<td></td>
</tr>
<tr>
<td>volume</td>
<td>The volume to play at</td>
</tr>
<tr>
<td>timeOfStart</td>
<td></td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td>TODO true if the playback was successfully started, false otherwise</td>
</tr>
</tfoot>
</table>
</div></section>
<section class="m-doc-details" id="a027f45d562b787bfe94872b5fb797575"><div>
<h3>
<span class="m-doc-wrap-bumper">ScStwSoundPlayer::PlayResult ScStwSoundPlayer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a027f45d562b787bfe94872b5fb797575" class="m-doc-self">waitForSoundFinish</a>(</span><span class="m-doc-wrap">double* timeOfStop = nullptr) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to wait for the playback to finish.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">timeOfStop</td>
<td>the point in time when the plyback actually stopped (msecs since epoch)</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td>false if there was any error (eg. there was no playback currently), true otherwise</td>
</tr>
</tfoot>
</table>
</div></section>
<section class="m-doc-details" id="a3e09578b2da014e3a2324e7f3c5549f1"><div>
<h3>
<span class="m-doc-wrap-bumper">bool ScStwSoundPlayer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a3e09578b2da014e3a2324e7f3c5549f1" class="m-doc-self">cancel</a>(</span><span class="m-doc-wrap">) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to cancel the current playback.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>true if the playback was successfully stopped, false otherwise</td>
</tr>
</tfoot>
</table>
<p>Note that this function will automatically play the false start tone if the currently playing action is 2</p>
</div></section>
</section>
</div>
</div>
</div>
</article></main>
<div class="m-doc-search" id="search">
<a href="#!" onclick="return hideSearch()"></a>
<div class="m-container">
<div class="m-row">
<div class="m-col-m-8 m-push-m-2">
<div class="m-doc-search-header m-text m-small">
<div><span class="m-label m-default">Tab</span> / <span class="m-label m-default">T</span> to search, <span class="m-label m-default">Esc</span> to close</div>
<div id="search-symbolcount">&hellip;</div>
</div>
<div class="m-doc-search-content">
<form>
<input type="search" name="q" id="search-input" placeholder="Loading &hellip;" disabled="disabled" autofocus="autofocus" autocomplete="off" spellcheck="false" />
</form>
<noscript class="m-text m-danger m-text-center">Unlike everything else in the docs, the search functionality <em>requires</em> JavaScript.</noscript>
<div id="search-help" class="m-text m-dim m-text-center">
<p class="m-noindent">Search for symbols, directories, files, pages or
modules. You can omit any prefix from the symbol or file path; adding a
<code>:</code> or <code>/</code> suffix lists all members of given symbol or
directory.</p>
<p class="m-noindent">Use <span class="m-label m-dim">&darr;</span>
/ <span class="m-label m-dim">&uarr;</span> to navigate through the list,
<span class="m-label m-dim">Enter</span> to go.
<span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
copy a link to the result using <span class="m-label m-dim"></span>
<span class="m-label m-dim">L</span> while <span class="m-label m-dim"></span>
<span class="m-label m-dim">M</span> produces a Markdown link.</p>
</div>
<div id="search-notfound" class="m-text m-warning m-text-center">Sorry, nothing was found.</div>
<ul id="search-results"></ul>
</div>
</div>
</div>
</div>
</div>
<script src="search-v2.js"></script>
<script src="searchdata-v2.js" async="async"></script>
<footer><nav>
<div class="m-container">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<p>ScStw shared libraries. Created with <a href="https://doxygen.org/">Doxygen</a> 1.9.4 and <a href="https://mcss.mosra.cz/">m.css</a>.</p>
</div>
</div>
</div>
</nav></footer>
</body>
</html>

View file

@ -1,814 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>ScStwTimer class | ScStw shared libraries</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
<link rel="stylesheet" href="m-dark+documentation.compiled.css" />
<link rel="icon" href="favicon.png" type="image/png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#0094ff" />
</head>
<body>
<header><nav id="navigation">
<div class="m-container">
<div class="m-row">
<a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m"><img src="favicon.png" alt="" />ScStw shared libraries</a>
<div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
<a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<path id="m-doc-search-icon-path" d="m6 0c-3.31 0-6 2.69-6 6 0 3.31 2.69 6 6 6 1.49 0 2.85-0.541 3.89-1.44-0.0164 0.338 0.147 0.759 0.5 1.15l3.22 3.79c0.552 0.614 1.45 0.665 2 0.115 0.55-0.55 0.499-1.45-0.115-2l-3.79-3.22c-0.392-0.353-0.812-0.515-1.15-0.5 0.895-1.05 1.44-2.41 1.44-3.89 0-3.31-2.69-6-6-6zm0 1.56a4.44 4.44 0 0 1 4.44 4.44 4.44 4.44 0 0 1-4.44 4.44 4.44 4.44 0 0 1-4.44-4.44 4.44 4.44 0 0 1 4.44-4.44z"/>
</svg></a>
<a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
<a id="m-navbar-hide" href="#" title="Hide navigation"></a>
</div>
<div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
<div class="m-row">
<ol class="m-col-t-6 m-col-m-none">
</ol>
<ol class="m-col-t-6 m-col-m-none" start="1">
<li><a href="index.html">Introduction</a></li>
<li><a href="annotated.html">Classes</a></li>
<li><a href="refman.pdf">Download</a></li>
<li class="m-show-m"><a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<use href="#m-doc-search-icon-path" />
</svg></a></li>
</ol>
</div>
</div>
</div>
</div>
</nav></header>
<main><article>
<div class="m-container m-container-inflatable">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<h1>
ScStwTimer <span class="m-thin">class</span>
</h1>
<p>The <a href="classScStwTimer.html" class="m-doc">ScStwTimer</a> class is used for advanced time measurement.</p>
<nav class="m-block m-default">
<h3>Contents</h3>
<ul>
<li>
Reference
<ul>
<li><a href="#pub-types">Public types</a></li>
<li><a href="#typeless-methods">Constructors, destructors, conversion operators</a></li>
<li><a href="#signals">Signals</a></li>
<li><a href="#pub-slots">Public slots</a></li>
<li><a href="#pro-slots">Protected slots</a></li>
<li><a href="#pro-attribs">Protected variables</a></li>
</ul>
</li>
</ul>
</nav>
<p>It does not work on its own though. It is recommended to use it in combination with the <a href="classScStwRace.html" class="m-doc">ScStwRace</a> class.</p><h3>When using standalone:</h3><pre class="m-code"><span class="n">ScStwTimer</span><span class="w"> </span><span class="n">timer</span><span class="p">;</span><span class="w"></span>
<span class="c1">// start the timer</span>
<span class="n">timer</span><span class="p">.</span><span class="n">start</span><span class="p">();</span><span class="w"></span>
<span class="c1">// stop the timer</span>
<span class="n">timer</span><span class="p">.</span><span class="n">stop</span><span class="p">();</span><span class="w"></span></pre><p>The timer will now go into ScStw::WAITING state. That indicates that the timer has stopped and the final result has to be assigned by an external handler.</p><pre class="m-code"><span class="c1">// assign result &#39;won&#39;</span>
<span class="n">timer</span><span class="p">.</span><span class="n">setResult</span><span class="p">(</span><span class="n">ScStwTimer</span><span class="o">::</span><span class="n">WON</span><span class="p">);</span><span class="w"></span></pre><p>The timer is now in <a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4ab3c3d8af8f1690d61dcb5ea0f93bfbeb" class="m-doc">ScStwTimer::<wbr />WON</a> state.</p><pre class="m-code"><span class="c1">// reset the timer</span>
<span class="n">timer</span><span class="p">.</span><span class="n">reset</span><span class="p">();</span><span class="w"></span></pre><p>The timer is not in <a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4a89a624261a53da443c950e23f18b5893" class="m-doc">ScStwTimer::<wbr />IDLE</a> state again.</p>
<section id="pub-types">
<h2><a href="#pub-types">Public types</a></h2>
<dl class="m-doc">
<dt>
<span class="m-doc-wrap-bumper">enum <a href="#ada0d42f8cac92807271e3811899691d4" class="m-doc">TimerState</a> { </span><span class="m-doc-wrap"><a href="#ada0d42f8cac92807271e3811899691d4a89a624261a53da443c950e23f18b5893" class="m-doc">IDLE</a>,
<a href="#ada0d42f8cac92807271e3811899691d4acb0051986bc92cfc3f596268b5d72a20" class="m-doc">STARTING</a>,
<a href="#ada0d42f8cac92807271e3811899691d4a8dd9e579e1c43be3f5736b93e093bea0" class="m-doc">RUNNING</a>,
<a href="#ada0d42f8cac92807271e3811899691d4aa34537cc3504afbce041e685452f9a25" class="m-doc">WAITING</a>,
<a href="#ada0d42f8cac92807271e3811899691d4ab3c3d8af8f1690d61dcb5ea0f93bfbeb" class="m-doc">WON</a>,
<a href="#ada0d42f8cac92807271e3811899691d4a85e5d2220b78dddd93b3b1cb57021007" class="m-doc">LOST</a>,
<a href="#ada0d42f8cac92807271e3811899691d4a7e39397d2ef7dfa99d24bf4edd504f99" class="m-doc">FAILING</a>,
<a href="#ada0d42f8cac92807271e3811899691d4a573d0be22ab41b235152d135a8a744f6" class="m-doc">WILDCARD</a>,
<a href="#ada0d42f8cac92807271e3811899691d4a2f45c51629a91757794ba7bbc5adb9bf" class="m-doc">FAILED</a>,
<a href="#ada0d42f8cac92807271e3811899691d4a5979f37506744b5559ce744ed8904ad3" class="m-doc">CANCELLED</a>,
<a href="#ada0d42f8cac92807271e3811899691d4a8f000f496058711a293671ab5c9d32ba" class="m-doc">INCIDENT</a>,
<a href="#ada0d42f8cac92807271e3811899691d4aa392d2f5e98c5b1c426981c1ab1b27d8" class="m-doc">DISABLED</a> }</span>
</dt>
<dd>The TimerState enum contains all state the timer can be in.</dd>
<dt>
<span class="m-doc-wrap-bumper">enum <a href="#a185f832ed38e2e555af7e74d339c023f" class="m-doc">ReadyState</a> { </span><span class="m-doc-wrap"><a href="#a185f832ed38e2e555af7e74d339c023fad3c2fa7df4332280eff3c365f9a4b894" class="m-doc">IsReady</a> = 0,
<a href="#a185f832ed38e2e555af7e74d339c023fa014a3289e24b7e37fe840ccb0f039197" class="m-doc">NotInIdleState</a>,
<a href="#a185f832ed38e2e555af7e74d339c023faec170fb0f373a61f319994345e68faee" class="m-doc">IsDisabled</a>,
<a href="#a185f832ed38e2e555af7e74d339c023faab1621429f64ecaffe935191a02e975d" class="m-doc">ExtensionIsNotConnected</a>,
<a href="#a185f832ed38e2e555af7e74d339c023fa6974cd0c4b77dfa673a5e1dfe0c3c884" class="m-doc">ExtensionBatteryIsCritical</a>,
<a href="#a185f832ed38e2e555af7e74d339c023faf705a3ca10429a13af06f0a59f7f1ddf" class="m-doc">ClimberIsNotReady</a> }</span>
</dt>
<dd>The ReadyStatus enum contains all possible reasons for a timer not to be ready (&gt;0) and the case that it is ready (0)</dd>
</dl>
</section>
<section id="typeless-methods">
<h2><a href="#typeless-methods">Constructors, destructors, conversion operators</a></h2>
<dl class="m-doc">
<dt>
<span class="m-doc-wrap-bumper"><a href="#a389e15b515cb54db5168c5efcb5f05e4" class="m-doc">ScStwTimer</a>(</span><span class="m-doc-wrap">QString letter,
QObject* parent = nullptr) <span class="m-label m-flat m-info">explicit</span> </span>
</dt>
<dd><a href="classScStwTimer.html" class="m-doc">ScStwTimer</a> constructor.</dd>
</dl>
</section>
<section id="signals">
<h2><a href="#signals">Signals</a></h2>
<dl class="m-doc">
<dt id="a2b99b88e926d1b8cda3e1b3ef87d209b">
<span class="m-doc-wrap-bumper">void <a href="#a2b99b88e926d1b8cda3e1b3ef87d209b" class="m-doc-self">stateChanged</a>(</span><span class="m-doc-wrap"><a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4" class="m-doc">TimerState</a> state)</span>
</dt>
<dd>Emitted when the state of the timer changed.</dd>
<dt id="a013826923879fee7f35a542b58f75754">
<span class="m-doc-wrap-bumper">void <a href="#a013826923879fee7f35a542b58f75754" class="m-doc-self">reactionTimeChanged</a>(</span><span class="m-doc-wrap">)</span>
</dt>
<dd>Emitted when the reaction time changed.</dd>
<dt>
<span class="m-doc-wrap-bumper">void <a href="#af67db37af63f6c999a55b2f76a3e8cda" class="m-doc">wantsToBeDisabledChanged</a>(</span><span class="m-doc-wrap"><a href="classScStwTimer.html" class="m-doc">ScStwTimer</a>* timer,
bool wantsToBeDisabled)</span>
</dt>
<dd>Emitted when the timer wants its state to be changed by the external handler.</dd>
<dt>
<span class="m-doc-wrap-bumper">void <a href="#aafb8547777f4211ef5eddf19637d14c3" class="m-doc">readyStateChanged</a>(</span><span class="m-doc-wrap"><a href="classScStwTimer.html#a185f832ed38e2e555af7e74d339c023f" class="m-doc">ReadyState</a> readyState)</span>
</dt>
<dd>Emitted when the ready state of the timer changes.</dd>
</dl>
</section>
<section id="pub-slots">
<h2><a href="#pub-slots">Public slots</a></h2>
<dl class="m-doc">
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a144ef4f6608e5a05e63dacdc581f0210" class="m-doc">start</a>(</span><span class="m-doc-wrap">) -&gt; bool</span>
</dt>
<dd>Function to start the timer.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a6868b437f85a7ebf6cc059e102c9bcb9" class="m-doc">start</a>(</span><span class="m-doc-wrap">double timeOfStart) -&gt; bool <span class="m-label m-flat m-warning">virtual</span></span>
</dt>
<dd>Function to start the timer at a given point in time (present or future)</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a7409fb5ffe4d1f2e2a46b9f503a36b7c" class="m-doc">cancel</a>(</span><span class="m-doc-wrap">) -&gt; bool</span>
</dt>
<dd>Function to cancel the timer.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#ab7bc9250d1db3046b3832f048bdfff26" class="m-doc">stop</a>(</span><span class="m-doc-wrap">) -&gt; bool</span>
</dt>
<dd>Function to stop the timer.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a55766788bb86f36db8940c3c50149ec0" class="m-doc">stop</a>(</span><span class="m-doc-wrap">double timeOfStop) -&gt; bool</span>
</dt>
<dd>Function to stop the timer at a given point in time (past or future)</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a94c8f03ad0fb44c38c515d77ef810d47" class="m-doc">setResult</a>(</span><span class="m-doc-wrap"><a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4" class="m-doc">TimerState</a>) -&gt; bool</span>
</dt>
<dd>Function to assing the result of the race to the timer.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a1576aaf8ebedd8ed26bc4bbce96b81a8" class="m-doc">reset</a>(</span><span class="m-doc-wrap">) -&gt; bool <span class="m-label m-flat m-warning">virtual</span></span>
</dt>
<dd>Function to reset the timer.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#ab5ab3874a241f57c58b4e5e7ac83d63b" class="m-doc">getState</a>(</span><span class="m-doc-wrap">) -&gt; <a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4" class="m-doc">TimerState</a></span>
</dt>
<dd>Function to get the current state of the timer.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a702bed98a3905c901aefdaefbbd4a5a6" class="m-doc">getCurrentTime</a>(</span><span class="m-doc-wrap">) -&gt; double</span>
</dt>
<dd>Function to get the current time of the timer.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a819e94b9abe6d1073b97008bd7997a60" class="m-doc">getReactionTime</a>(</span><span class="m-doc-wrap">) -&gt; double</span>
</dt>
<dd>Function to get the reaction time of the climber.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#af558c8104846a09ed5f71499544954a3" class="m-doc">getText</a>(</span><span class="m-doc-wrap">) -&gt; QString</span>
</dt>
<dd>Function to get the text, a timer display is supposed to show.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#aab757a3e2b3de1d7da584f9adf17cde3" class="m-doc">getLetter</a>(</span><span class="m-doc-wrap">) -&gt; QString</span>
</dt>
<dd>Function to get the letter of the timer.</dd>
<dt>
<span class="m-doc-wrap-bumper">void <a href="#a40bc97d7842cc65ec7b08d03c022741e" class="m-doc">setDisabled</a>(</span><span class="m-doc-wrap">bool disabled)</span>
</dt>
<dd>Function to set if the timer is supposed to be disabled.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#ae553fde747622fbfc2eb3bf26dafd08a" class="m-doc">getWantsToBeDisabled</a>(</span><span class="m-doc-wrap">) -&gt; bool</span>
</dt>
<dd>Function to check if the timer currently wants to be disabled.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a1d9b182d983a2f6ab03b8e3877376bff" class="m-doc">getReadyState</a>(</span><span class="m-doc-wrap">) -&gt; <a href="classScStwTimer.html#a185f832ed38e2e555af7e74d339c023f" class="m-doc">ScStwTimer::<wbr />ReadyState</a> <span class="m-label m-flat m-warning">virtual</span></span>
</dt>
<dd>Function to get the current ready status of a timer.</dd>
</dl>
</section>
<section id="pro-slots">
<h2><a href="#pro-slots">Protected slots</a></h2>
<dl class="m-doc">
<dt>
<span class="m-doc-wrap-bumper">void <a href="#a89dcba328bf66c1d86ebffb086bea18b" class="m-doc">handleClimberStart</a>(</span><span class="m-doc-wrap">double timeOfStart)</span>
</dt>
<dd>slot to call when the climber has started</dd>
<dt>
<span class="m-doc-wrap-bumper">void <a href="#a10ee4d196dcf71a8a5b1a1770578d367" class="m-doc">setState</a>(</span><span class="m-doc-wrap"><a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4" class="m-doc">TimerState</a> newState)</span>
</dt>
<dd>Function to change the state of the timer.</dd>
<dt>
<span class="m-doc-wrap-bumper">void <a href="#ab1a4c10718873ff80d395a4697ad8e6a" class="m-doc">setWantsToBeDisabled</a>(</span><span class="m-doc-wrap">bool wantsToBeDisabled)</span>
</dt>
<dd>Function to set whether the timer currently wants to be disabled.</dd>
<dt>
<span class="m-doc-wrap-bumper">void <a href="#ab8a2f017d02f979e13282a10ac9c25ab" class="m-doc">technicalIncident</a>(</span><span class="m-doc-wrap">)</span>
</dt>
<dd>Function to set the timer into INCIDENT state immidieately.</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#aaaf67aa1c25ed318404a9236fa56f732" class="m-doc">wildcard</a>(</span><span class="m-doc-wrap">) -&gt; bool</span>
</dt>
<dd>Function to set the timer into WILDCARD state.</dd>
</dl>
</section>
<section id="pro-attribs">
<h2><a href="#pro-attribs">Protected variables</a></h2>
<dl class="m-doc">
<dt id="a47a2e907433f2fe1da321ce018d5e16f">
<a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4" class="m-doc">TimerState</a> <a href="#a47a2e907433f2fe1da321ce018d5e16f" class="m-doc-self">state</a>
</dt>
<dd>The current state of the timer.</dd>
<dt id="a0a0d9c0888889777a537b08800431550">
double <a href="#a0a0d9c0888889777a537b08800431550" class="m-doc-self">startTime</a>
</dt>
<dd>The time the timer was started at.</dd>
<dt id="ae59f354e85585ff9d642258135345538">
double <a href="#ae59f354e85585ff9d642258135345538" class="m-doc-self">stopTime</a>
</dt>
<dd>The time the timer was stopped at.</dd>
<dt id="a019e8b5dc595e637dd3717f3d235e266">
double <a href="#a019e8b5dc595e637dd3717f3d235e266" class="m-doc-self">reactionTime</a>
</dt>
<dd>the reaction time of the climber</dd>
<dt id="a9a37c93552fa1f4e3d47bca99db14a9a">
QString <a href="#a9a37c93552fa1f4e3d47bca99db14a9a" class="m-doc-self">letter</a>
</dt>
<dd>The letter (eg. &quot;A&quot; or &quot;B&quot;) of the Timer (only one char)</dd>
<dt id="aea0fb34cb9b98d12ffa6dec38c60f998">
bool <a href="#aea0fb34cb9b98d12ffa6dec38c60f998" class="m-doc-self">wantsToBeDisabled</a>
</dt>
<dd>Defines if the timer currently wants to be disabled or not.</dd>
</dl>
</section>
<section>
<h2>Enum documentation</h2>
<section class="m-doc-details" id="ada0d42f8cac92807271e3811899691d4"><div>
<h3>
enum ScStwTimer::<wbr /><a href="#ada0d42f8cac92807271e3811899691d4" class="m-doc-self">TimerState</a>
</h3>
<p>The TimerState enum contains all state the timer can be in.</p>
<table class="m-table m-fullwidth m-flat m-doc">
<thead><tr><th style="width: 1%">Enumerators</th><th></th></tr></thead>
<tbody>
<tr>
<td><a href="#ada0d42f8cac92807271e3811899691d4a89a624261a53da443c950e23f18b5893" class="m-doc-self" id="ada0d42f8cac92807271e3811899691d4a89a624261a53da443c950e23f18b5893">IDLE</a></td>
<td>
<p>Timer is waiting to be started</p>
</td>
</tr>
<tr>
<td><a href="#ada0d42f8cac92807271e3811899691d4acb0051986bc92cfc3f596268b5d72a20" class="m-doc-self" id="ada0d42f8cac92807271e3811899691d4acb0051986bc92cfc3f596268b5d72a20">STARTING</a></td>
<td>
<p>Timer is starting and will react with a false start if the climber starts</p>
</td>
</tr>
<tr>
<td><a href="#ada0d42f8cac92807271e3811899691d4a8dd9e579e1c43be3f5736b93e093bea0" class="m-doc-self" id="ada0d42f8cac92807271e3811899691d4a8dd9e579e1c43be3f5736b93e093bea0">RUNNING</a></td>
<td>
<p>Timer is running</p>
</td>
</tr>
<tr>
<td><a href="#ada0d42f8cac92807271e3811899691d4aa34537cc3504afbce041e685452f9a25" class="m-doc-self" id="ada0d42f8cac92807271e3811899691d4aa34537cc3504afbce041e685452f9a25">WAITING</a></td>
<td>
<p>Timer was stopped and is waiting to be set to either WON or LOST</p>
</td>
</tr>
<tr>
<td><a href="#ada0d42f8cac92807271e3811899691d4ab3c3d8af8f1690d61dcb5ea0f93bfbeb" class="m-doc-self" id="ada0d42f8cac92807271e3811899691d4ab3c3d8af8f1690d61dcb5ea0f93bfbeb">WON</a></td>
<td>
<p>Timer has won</p>
</td>
</tr>
<tr>
<td><a href="#ada0d42f8cac92807271e3811899691d4a85e5d2220b78dddd93b3b1cb57021007" class="m-doc-self" id="ada0d42f8cac92807271e3811899691d4a85e5d2220b78dddd93b3b1cb57021007">LOST</a></td>
<td>
<p>Timer has lost</p>
</td>
</tr>
<tr>
<td><a href="#ada0d42f8cac92807271e3811899691d4a7e39397d2ef7dfa99d24bf4edd504f99" class="m-doc-self" id="ada0d42f8cac92807271e3811899691d4a7e39397d2ef7dfa99d24bf4edd504f99">FAILING</a></td>
<td>
<p>Timer encountered a false start and is waiting to be set to either FAILED or WILDCARD</p>
</td>
</tr>
<tr>
<td><a href="#ada0d42f8cac92807271e3811899691d4a573d0be22ab41b235152d135a8a744f6" class="m-doc-self" id="ada0d42f8cac92807271e3811899691d4a573d0be22ab41b235152d135a8a744f6">WILDCARD</a></td>
<td>
<p>The opponent has done a false start</p>
</td>
</tr>
<tr>
<td><a href="#ada0d42f8cac92807271e3811899691d4a2f45c51629a91757794ba7bbc5adb9bf" class="m-doc-self" id="ada0d42f8cac92807271e3811899691d4a2f45c51629a91757794ba7bbc5adb9bf">FAILED</a></td>
<td>
<p>A false start occured</p>
</td>
</tr>
<tr>
<td><a href="#ada0d42f8cac92807271e3811899691d4a5979f37506744b5559ce744ed8904ad3" class="m-doc-self" id="ada0d42f8cac92807271e3811899691d4a5979f37506744b5559ce744ed8904ad3">CANCELLED</a></td>
<td>
<p>Timer was cancelled</p>
</td>
</tr>
<tr>
<td><a href="#ada0d42f8cac92807271e3811899691d4a8f000f496058711a293671ab5c9d32ba" class="m-doc-self" id="ada0d42f8cac92807271e3811899691d4a8f000f496058711a293671ab5c9d32ba">INCIDENT</a></td>
<td>
<p>There was a technical incident (most likely a disconnected extension)</p>
</td>
</tr>
<tr>
<td><a href="#ada0d42f8cac92807271e3811899691d4aa392d2f5e98c5b1c426981c1ab1b27d8" class="m-doc-self" id="ada0d42f8cac92807271e3811899691d4aa392d2f5e98c5b1c426981c1ab1b27d8">DISABLED</a></td>
<td>
<p>Timer is disabled</p>
</td>
</tr>
</tbody>
</table>
</div></section>
<section class="m-doc-details" id="a185f832ed38e2e555af7e74d339c023f"><div>
<h3>
enum ScStwTimer::<wbr /><a href="#a185f832ed38e2e555af7e74d339c023f" class="m-doc-self">ReadyState</a>
</h3>
<p>The ReadyStatus enum contains all possible reasons for a timer not to be ready (&gt;0) and the case that it is ready (0)</p>
<table class="m-table m-fullwidth m-flat m-doc">
<thead><tr><th style="width: 1%">Enumerators</th><th></th></tr></thead>
<tbody>
<tr>
<td><a href="#a185f832ed38e2e555af7e74d339c023fad3c2fa7df4332280eff3c365f9a4b894" class="m-doc-self" id="a185f832ed38e2e555af7e74d339c023fad3c2fa7df4332280eff3c365f9a4b894">IsReady</a></td>
<td>
<p>Timer is ready for start</p>
</td>
</tr>
<tr>
<td><a href="#a185f832ed38e2e555af7e74d339c023fa014a3289e24b7e37fe840ccb0f039197" class="m-doc-self" id="a185f832ed38e2e555af7e74d339c023fa014a3289e24b7e37fe840ccb0f039197">NotInIdleState</a></td>
<td>
<p>Timer is not in IDLE state</p>
</td>
</tr>
<tr>
<td><a href="#a185f832ed38e2e555af7e74d339c023faec170fb0f373a61f319994345e68faee" class="m-doc-self" id="a185f832ed38e2e555af7e74d339c023faec170fb0f373a61f319994345e68faee">IsDisabled</a></td>
<td>
<p>Timer is disabled</p>
</td>
</tr>
<tr>
<td><a href="#a185f832ed38e2e555af7e74d339c023faab1621429f64ecaffe935191a02e975d" class="m-doc-self" id="a185f832ed38e2e555af7e74d339c023faab1621429f64ecaffe935191a02e975d">ExtensionIsNotConnected</a></td>
<td>
<p>Not all extension of the timer are conneted</p>
</td>
</tr>
<tr>
<td><a href="#a185f832ed38e2e555af7e74d339c023fa6974cd0c4b77dfa673a5e1dfe0c3c884" class="m-doc-self" id="a185f832ed38e2e555af7e74d339c023fa6974cd0c4b77dfa673a5e1dfe0c3c884">ExtensionBatteryIsCritical</a></td>
<td>
<p>The battery level of one or more extension is critical or unknown</p>
</td>
</tr>
<tr>
<td><a href="#a185f832ed38e2e555af7e74d339c023faf705a3ca10429a13af06f0a59f7f1ddf" class="m-doc-self" id="a185f832ed38e2e555af7e74d339c023faf705a3ca10429a13af06f0a59f7f1ddf">ClimberIsNotReady</a></td>
<td>
<p>The startpad of the timer is not triggered</p>
</td>
</tr>
</tbody>
</table>
</div></section>
</section>
<section>
<h2>Function documentation</h2>
<section class="m-doc-details" id="a389e15b515cb54db5168c5efcb5f05e4"><div>
<h3>
<span class="m-doc-wrap-bumper"> ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a389e15b515cb54db5168c5efcb5f05e4" class="m-doc-self">ScStwTimer</a>(</span><span class="m-doc-wrap">QString letter,
QObject* parent = nullptr) <span class="m-label m-info">explicit</span> </span></span>
</h3>
<p><a href="classScStwTimer.html" class="m-doc">ScStwTimer</a> constructor.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">letter</td>
<td>the letter of the timer (only first char will be used!)</td>
</tr>
<tr>
<td>parent</td>
<td>the parent object</td>
</tr>
</tbody>
</table>
</div></section>
<section class="m-doc-details" id="af67db37af63f6c999a55b2f76a3e8cda"><div>
<h3>
<span class="m-doc-wrap-bumper">void ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#af67db37af63f6c999a55b2f76a3e8cda" class="m-doc-self">wantsToBeDisabledChanged</a>(</span><span class="m-doc-wrap"><a href="classScStwTimer.html" class="m-doc">ScStwTimer</a>* timer,
bool wantsToBeDisabled) <span class="m-label m-success">signal</span></span></span>
</h3>
<p>Emitted when the timer wants its state to be changed by the external handler.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">timer</td>
<td>the timer object</td>
</tr>
<tr>
<td>wantsToBeDisabled</td>
<td></td>
</tr>
</tbody>
</table>
</div></section>
<section class="m-doc-details" id="aafb8547777f4211ef5eddf19637d14c3"><div>
<h3>
<span class="m-doc-wrap-bumper">void ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#aafb8547777f4211ef5eddf19637d14c3" class="m-doc-self">readyStateChanged</a>(</span><span class="m-doc-wrap"><a href="classScStwTimer.html#a185f832ed38e2e555af7e74d339c023f" class="m-doc">ReadyState</a> readyState) <span class="m-label m-success">signal</span></span></span>
</h3>
<p>Emitted when the ready state of the timer changes.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">readyState</td>
<td>the new ReadyState</td>
</tr>
</tbody>
</table>
</div></section>
<section class="m-doc-details" id="a144ef4f6608e5a05e63dacdc581f0210"><div>
<h3>
<span class="m-doc-wrap-bumper">bool ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a144ef4f6608e5a05e63dacdc581f0210" class="m-doc-self">start</a>(</span><span class="m-doc-wrap">) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to start the timer.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>false if the timer was not in the required state and therefore not started, true otherwise</td>
</tr>
</tfoot>
</table>
<p>To do this, the timer has to be in <a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4acb0051986bc92cfc3f596268b5d72a20" class="m-doc">ScStwTimer::<wbr />STARTING</a> state!</p>
</div></section>
<section class="m-doc-details" id="a6868b437f85a7ebf6cc059e102c9bcb9"><div>
<h3>
<span class="m-doc-wrap-bumper">bool ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a6868b437f85a7ebf6cc059e102c9bcb9" class="m-doc-self">start</a>(</span><span class="m-doc-wrap">double timeOfStart) <span class="m-label m-warning">virtual</span> <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to start the timer at a given point in time (present or future)</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">timeOfStart</td>
<td>the point in time (msecs since epoch) when the timer is supposted to be started</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td>false if the timer was not in the required state and therefore not started, true otherwise</td>
</tr>
</tfoot>
</table>
<p>To do this, the timer has to be in <a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4acb0051986bc92cfc3f596268b5d72a20" class="m-doc">ScStwTimer::<wbr />STARTING</a> state!</p>
</div></section>
<section class="m-doc-details" id="a7409fb5ffe4d1f2e2a46b9f503a36b7c"><div>
<h3>
<span class="m-doc-wrap-bumper">bool ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a7409fb5ffe4d1f2e2a46b9f503a36b7c" class="m-doc-self">cancel</a>(</span><span class="m-doc-wrap">) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to cancel the timer.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>false if the timer was not in the required state and therefore not cancelled, true otherwise</td>
</tr>
</tfoot>
</table>
<p>To do this, the timer has to be in <a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4a89a624261a53da443c950e23f18b5893" class="m-doc">ScStwTimer::<wbr />IDLE</a>, <a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4acb0051986bc92cfc3f596268b5d72a20" class="m-doc">ScStwTimer::<wbr />STARTING</a> or <a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4a8dd9e579e1c43be3f5736b93e093bea0" class="m-doc">ScStwTimer::<wbr />RUNNING</a> state!</p>
</div></section>
<section class="m-doc-details" id="ab7bc9250d1db3046b3832f048bdfff26"><div>
<h3>
<span class="m-doc-wrap-bumper">bool ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#ab7bc9250d1db3046b3832f048bdfff26" class="m-doc-self">stop</a>(</span><span class="m-doc-wrap">) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to stop the timer.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>false if the timer was not in the required state and therefore not stopped, true otherwise</td>
</tr>
</tfoot>
</table>
<p>To do this, the timer has to be in <a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4a8dd9e579e1c43be3f5736b93e093bea0" class="m-doc">ScStwTimer::<wbr />RUNNING</a> state!</p>
</div></section>
<section class="m-doc-details" id="a55766788bb86f36db8940c3c50149ec0"><div>
<h3>
<span class="m-doc-wrap-bumper">bool ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a55766788bb86f36db8940c3c50149ec0" class="m-doc-self">stop</a>(</span><span class="m-doc-wrap">double timeOfStop) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to stop the timer at a given point in time (past or future)</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">timeOfStop</td>
<td>the point in time (msecs since epoch) when the timer is supposted to be stopped</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td>false if the timer was not in the required state and therefore not stopped, true otherwise</td>
</tr>
</tfoot>
</table>
<p>To do this, the timer has to be in <a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4a8dd9e579e1c43be3f5736b93e093bea0" class="m-doc">ScStwTimer::<wbr />RUNNING</a> state!</p>
</div></section>
<section class="m-doc-details" id="a94c8f03ad0fb44c38c515d77ef810d47"><div>
<h3>
<span class="m-doc-wrap-bumper">bool ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a94c8f03ad0fb44c38c515d77ef810d47" class="m-doc-self">setResult</a>(</span><span class="m-doc-wrap"><a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4" class="m-doc">TimerState</a>) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to assing the result of the race to the timer.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>false if the timer was not in the required state and the result therefore not set, true otherwise</td>
</tr>
</tfoot>
</table>
<p>To do this, the timer has to be in <a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4aa34537cc3504afbce041e685452f9a25" class="m-doc">ScStwTimer::<wbr />WAITING</a> state!</p>
</div></section>
<section class="m-doc-details" id="a1576aaf8ebedd8ed26bc4bbce96b81a8"><div>
<h3>
<span class="m-doc-wrap-bumper">bool ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a1576aaf8ebedd8ed26bc4bbce96b81a8" class="m-doc-self">reset</a>(</span><span class="m-doc-wrap">) <span class="m-label m-warning">virtual</span> <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to reset the timer.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>false if the timer was not in the required state and therefore not reset, true otherwise</td>
</tr>
</tfoot>
</table>
<p>To do this, the timer has to be in <a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4ab3c3d8af8f1690d61dcb5ea0f93bfbeb" class="m-doc">ScStwTimer::<wbr />WON</a> or ScSTw::LOST state!</p>
</div></section>
<section class="m-doc-details" id="ab5ab3874a241f57c58b4e5e7ac83d63b"><div>
<h3>
<span class="m-doc-wrap-bumper"><a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4" class="m-doc">TimerState</a> ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#ab5ab3874a241f57c58b4e5e7ac83d63b" class="m-doc-self">getState</a>(</span><span class="m-doc-wrap">) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to get the current state of the timer.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>current state of the timer</td>
</tr>
</tfoot>
</table>
<aside class="m-note m-default"><h4>See also</h4><p><a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4" class="m-doc">ScStwTimer::<wbr />TimerState</a></p></aside>
</div></section>
<section class="m-doc-details" id="a702bed98a3905c901aefdaefbbd4a5a6"><div>
<h3>
<span class="m-doc-wrap-bumper">double ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a702bed98a3905c901aefdaefbbd4a5a6" class="m-doc-self">getCurrentTime</a>(</span><span class="m-doc-wrap">) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to get the current time of the timer.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>The current / final time of the timer or -1 if it is not in the required state</td>
</tr>
</tfoot>
</table>
<p>To do this, the timer has to be in <a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4a8dd9e579e1c43be3f5736b93e093bea0" class="m-doc">ScStwTimer::<wbr />RUNNING</a>, <a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4aa34537cc3504afbce041e685452f9a25" class="m-doc">ScStwTimer::<wbr />WAITING</a>, <a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4ab3c3d8af8f1690d61dcb5ea0f93bfbeb" class="m-doc">ScStwTimer::<wbr />WON</a> or ScSTw::LOST state!</p>
</div></section>
<section class="m-doc-details" id="a819e94b9abe6d1073b97008bd7997a60"><div>
<h3>
<span class="m-doc-wrap-bumper">double ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a819e94b9abe6d1073b97008bd7997a60" class="m-doc-self">getReactionTime</a>(</span><span class="m-doc-wrap">) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to get the reaction time of the climber.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>The climbers reaction time</td>
</tr>
</tfoot>
</table>
</div></section>
<section class="m-doc-details" id="af558c8104846a09ed5f71499544954a3"><div>
<h3>
<span class="m-doc-wrap-bumper">QString ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#af558c8104846a09ed5f71499544954a3" class="m-doc-self">getText</a>(</span><span class="m-doc-wrap">) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to get the text, a timer display is supposed to show.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>The text to show</td>
</tr>
</tfoot>
</table>
</div></section>
<section class="m-doc-details" id="aab757a3e2b3de1d7da584f9adf17cde3"><div>
<h3>
<span class="m-doc-wrap-bumper">QString ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#aab757a3e2b3de1d7da584f9adf17cde3" class="m-doc-self">getLetter</a>(</span><span class="m-doc-wrap">) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to get the letter of the timer.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>The letter of the timer or &quot;&quot;</td>
</tr>
</tfoot>
</table>
</div></section>
<section class="m-doc-details" id="a40bc97d7842cc65ec7b08d03c022741e"><div>
<h3>
<span class="m-doc-wrap-bumper">void ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a40bc97d7842cc65ec7b08d03c022741e" class="m-doc-self">setDisabled</a>(</span><span class="m-doc-wrap">bool disabled) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to set if the timer is supposed to be disabled.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">disabled</td>
<td>if the timer is supposed to be diabled</td>
</tr>
</tbody>
</table>
<p>!!! CAUTION use this function with care, it immidiately changes the state of the timer !!! It is recommended to only use this function to change the timers state after the ScStwTimer::requestTimerEnableChange() signal was called, during the race, the timer is used in, is in IDLE state.</p>
</div></section>
<section class="m-doc-details" id="ae553fde747622fbfc2eb3bf26dafd08a"><div>
<h3>
<span class="m-doc-wrap-bumper">bool ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#ae553fde747622fbfc2eb3bf26dafd08a" class="m-doc-self">getWantsToBeDisabled</a>(</span><span class="m-doc-wrap">) <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to check if the timer currently wants to be disabled.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>true or false</td>
</tr>
</tfoot>
</table>
</div></section>
<section class="m-doc-details" id="a1d9b182d983a2f6ab03b8e3877376bff"><div>
<h3>
<span class="m-doc-wrap-bumper"><a href="classScStwTimer.html#a185f832ed38e2e555af7e74d339c023f" class="m-doc">ScStwTimer::<wbr />ReadyState</a> ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a1d9b182d983a2f6ab03b8e3877376bff" class="m-doc-self">getReadyState</a>(</span><span class="m-doc-wrap">) <span class="m-label m-warning">virtual</span> <span class="m-label m-success">public slot</span></span></span>
</h3>
<p>Function to get the current ready status of a timer.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>The current ready status</td>
</tr>
</tfoot>
</table>
</div></section>
<section class="m-doc-details" id="a89dcba328bf66c1d86ebffb086bea18b"><div>
<h3>
<span class="m-doc-wrap-bumper">void ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a89dcba328bf66c1d86ebffb086bea18b" class="m-doc-self">handleClimberStart</a>(</span><span class="m-doc-wrap">double timeOfStart) <span class="m-label m-warning">protected slot</span></span></span>
</h3>
<p>slot to call when the climber has started</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">timeOfStart</td>
<td>time (msecs since epoch) when the climber started</td>
</tr>
</tbody>
</table>
</div></section>
<section class="m-doc-details" id="a10ee4d196dcf71a8a5b1a1770578d367"><div>
<h3>
<span class="m-doc-wrap-bumper">void ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a10ee4d196dcf71a8a5b1a1770578d367" class="m-doc-self">setState</a>(</span><span class="m-doc-wrap"><a href="classScStwTimer.html#ada0d42f8cac92807271e3811899691d4" class="m-doc">TimerState</a> newState) <span class="m-label m-warning">protected slot</span></span></span>
</h3>
<p>Function to change the state of the timer.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">newState</td>
<td>The new state</td>
</tr>
</tbody>
</table>
<p>Doing this will emit the <a href="classScStwTimer.html#a2b99b88e926d1b8cda3e1b3ef87d209b" class="m-doc">ScStwTimer::<wbr />stateChanged()</a> signal (only if the new state differs from the current one)</p>
</div></section>
<section class="m-doc-details" id="ab1a4c10718873ff80d395a4697ad8e6a"><div>
<h3>
<span class="m-doc-wrap-bumper">void ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#ab1a4c10718873ff80d395a4697ad8e6a" class="m-doc-self">setWantsToBeDisabled</a>(</span><span class="m-doc-wrap">bool wantsToBeDisabled) <span class="m-label m-warning">protected slot</span></span></span>
</h3>
<p>Function to set whether the timer currently wants to be disabled.</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">wantsToBeDisabled</td>
<td>true or false</td>
</tr>
</tbody>
</table>
</div></section>
<section class="m-doc-details" id="ab8a2f017d02f979e13282a10ac9c25ab"><div>
<h3>
<span class="m-doc-wrap-bumper">void ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#ab8a2f017d02f979e13282a10ac9c25ab" class="m-doc-self">technicalIncident</a>(</span><span class="m-doc-wrap">) <span class="m-label m-warning">protected slot</span></span></span>
</h3>
<p>Function to set the timer into INCIDENT state immidieately.</p>
<p>The current state of the timer will be ignored! It can only get out of this state by calling <a href="classScStwTimer.html#a1576aaf8ebedd8ed26bc4bbce96b81a8" class="m-doc">ScStwTimer::<wbr />reset</a></p><aside class="m-note m-default"><h4>See also</h4><p><a href="classScStwTimer.html#a1576aaf8ebedd8ed26bc4bbce96b81a8" class="m-doc">reset</a></p></aside>
</div></section>
<section class="m-doc-details" id="aaaf67aa1c25ed318404a9236fa56f732"><div>
<h3>
<span class="m-doc-wrap-bumper">bool ScStwTimer::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#aaaf67aa1c25ed318404a9236fa56f732" class="m-doc-self">wildcard</a>(</span><span class="m-doc-wrap">) <span class="m-label m-warning">protected slot</span></span></span>
</h3>
<p>Function to set the timer into WILDCARD state.</p>
<table class="m-table m-fullwidth m-flat">
<tfoot>
<tr>
<th style="width: 1%">Returns</th>
<td>false if not in STARTING state</td>
</tr>
</tfoot>
</table>
<p>Only works when the timer is in STARTING state.</p>
</div></section>
</section>
</div>
</div>
</div>
</article></main>
<div class="m-doc-search" id="search">
<a href="#!" onclick="return hideSearch()"></a>
<div class="m-container">
<div class="m-row">
<div class="m-col-m-8 m-push-m-2">
<div class="m-doc-search-header m-text m-small">
<div><span class="m-label m-default">Tab</span> / <span class="m-label m-default">T</span> to search, <span class="m-label m-default">Esc</span> to close</div>
<div id="search-symbolcount">&hellip;</div>
</div>
<div class="m-doc-search-content">
<form>
<input type="search" name="q" id="search-input" placeholder="Loading &hellip;" disabled="disabled" autofocus="autofocus" autocomplete="off" spellcheck="false" />
</form>
<noscript class="m-text m-danger m-text-center">Unlike everything else in the docs, the search functionality <em>requires</em> JavaScript.</noscript>
<div id="search-help" class="m-text m-dim m-text-center">
<p class="m-noindent">Search for symbols, directories, files, pages or
modules. You can omit any prefix from the symbol or file path; adding a
<code>:</code> or <code>/</code> suffix lists all members of given symbol or
directory.</p>
<p class="m-noindent">Use <span class="m-label m-dim">&darr;</span>
/ <span class="m-label m-dim">&uarr;</span> to navigate through the list,
<span class="m-label m-dim">Enter</span> to go.
<span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
copy a link to the result using <span class="m-label m-dim"></span>
<span class="m-label m-dim">L</span> while <span class="m-label m-dim"></span>
<span class="m-label m-dim">M</span> produces a Markdown link.</p>
</div>
<div id="search-notfound" class="m-text m-warning m-text-center">Sorry, nothing was found.</div>
<ul id="search-results"></ul>
</div>
</div>
</div>
</div>
</div>
<script src="search-v2.js"></script>
<script src="searchdata-v2.js" async="async"></script>
<footer><nav>
<div class="m-container">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<p>ScStw shared libraries. Created with <a href="https://doxygen.org/">Doxygen</a> 1.9.4 and <a href="https://mcss.mosra.cz/">m.css</a>.</p>
</div>
</div>
</div>
</nav></footer>
</body>
</html>

5
docs/.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
/html/
/latex/
/xml/
/m.css/
/_build/

2494
docs/Doxyfile Normal file

File diff suppressed because it is too large Load diff

18
docs/Doxyfile-mcss Normal file
View file

@ -0,0 +1,18 @@
@INCLUDE = Doxyfile
GENERATE_HTML = NO
GENERATE_XML = YES
XML_PROGRAMLISTING = NO
SHOW_INCLUDE_FILES = YES
HTML_EXTRA_STYLESHEET = \
https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600 \
../css/m-dark+documentation.compiled.css
M_THEME_COLOR = #0094ff
M_FAVICON = favicon.png
# navbar
M_LINKS_NAVBAR1 =
M_LINKS_NAVBAR2 = "<a href=\"index.html\">Introduction</a>" \
annotated \
"<a href=\"refman.pdf\">Download</a>"

19
docs/Makefile Normal file
View file

@ -0,0 +1,19 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

179
docs/conf.py Normal file
View file

@ -0,0 +1,179 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- Project information -----------------------------------------------------
project = 'ScStwLibraries'
copyright = '2021, Itsblue Development'
author = 'Itsblue Development'
# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = ''
# -- General configuration ---------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'breathe'
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'ScStwLibrariesdoc'
# -- Options for LaTeX output ------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'ScStwLibraries.tex', 'ScStwLibraries Documentation',
'Itsblue Development', 'manual'),
]
# -- Options for manual page output ------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'scstwlibraries', 'ScStwLibraries Documentation',
[author], 1)
]
# -- Options for Texinfo output ----------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'ScStwLibraries', 'ScStwLibraries Documentation',
author, 'ScStwLibraries', 'One line description of project.',
'Miscellaneous'),
]
# -- Options for Epub output -------------------------------------------------
# Bibliographic Dublin Core info.
epub_title = project
# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''
# A unique identification for the text.
#
# epub_uid = ''
# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
# Breathe Configuration
breathe_projects = { "ScStwLibraries": "./xml" }
breathe_default_project = "ScStwLibraries"

BIN
docs/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

23
docs/index.rst Normal file
View file

@ -0,0 +1,23 @@
.. ScStwLibraries documentation master file, created by
sphinx-quickstart on Tue Jul 20 08:56:01 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to ScStwLibraries's documentation!
==========================================
.. toctree::
:maxdepth: 2
:caption: Contents:
.. doxygenindex::
.. doxygenclass:: ScStw
:members:
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 35 KiB

BIN
faviconNoOutline.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -1,114 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>ScStw shared libraries</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
<link rel="stylesheet" href="m-dark+documentation.compiled.css" />
<link rel="icon" href="favicon.png" type="image/png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#0094ff" />
</head>
<body>
<header><nav id="navigation">
<div class="m-container">
<div class="m-row">
<a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m"><img src="favicon.png" alt="" />ScStw shared libraries</a>
<div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
<a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<path id="m-doc-search-icon-path" d="m6 0c-3.31 0-6 2.69-6 6 0 3.31 2.69 6 6 6 1.49 0 2.85-0.541 3.89-1.44-0.0164 0.338 0.147 0.759 0.5 1.15l3.22 3.79c0.552 0.614 1.45 0.665 2 0.115 0.55-0.55 0.499-1.45-0.115-2l-3.79-3.22c-0.392-0.353-0.812-0.515-1.15-0.5 0.895-1.05 1.44-2.41 1.44-3.89 0-3.31-2.69-6-6-6zm0 1.56a4.44 4.44 0 0 1 4.44 4.44 4.44 4.44 0 0 1-4.44 4.44 4.44 4.44 0 0 1-4.44-4.44 4.44 4.44 0 0 1 4.44-4.44z"/>
</svg></a>
<a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
<a id="m-navbar-hide" href="#" title="Hide navigation"></a>
</div>
<div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
<div class="m-row">
<ol class="m-col-t-6 m-col-m-none">
</ol>
<ol class="m-col-t-6 m-col-m-none" start="1">
<li><a href="index.html">Introduction</a></li>
<li><a href="annotated.html">Classes</a></li>
<li><a href="refman.pdf">Download</a></li>
<li class="m-show-m"><a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<use href="#m-doc-search-icon-path" />
</svg></a></li>
</ol>
</div>
</div>
</div>
</div>
</nav></header>
<main><article>
<div class="m-container m-container-inflatable">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<h1>Files</h1>
<ul class="m-doc">
</ul>
<script>
function toggle(e) {
e.parentElement.className = e.parentElement.className == 'm-doc-collapsible' ?
'm-doc-expansible' : 'm-doc-collapsible';
return false;
}
/* Collapse all nodes marked as such. Doing it via JS instead of
directly in markup so disabling it doesn't harm usability. The list
is somehow regenerated on every iteration and shrinks as I change
the classes. It's not documented anywhere and I'm not sure if this
is the same across browsers, so I am going backwards in that list to
be sure. */
var collapsed = document.getElementsByClassName("collapsed");
for(var i = collapsed.length - 1; i >= 0; --i)
collapsed[i].className = 'm-doc-expansible';
</script>
</div>
</div>
</div>
</article></main>
<div class="m-doc-search" id="search">
<a href="#!" onclick="return hideSearch()"></a>
<div class="m-container">
<div class="m-row">
<div class="m-col-m-8 m-push-m-2">
<div class="m-doc-search-header m-text m-small">
<div><span class="m-label m-default">Tab</span> / <span class="m-label m-default">T</span> to search, <span class="m-label m-default">Esc</span> to close</div>
<div id="search-symbolcount">&hellip;</div>
</div>
<div class="m-doc-search-content">
<form>
<input type="search" name="q" id="search-input" placeholder="Loading &hellip;" disabled="disabled" autofocus="autofocus" autocomplete="off" spellcheck="false" />
</form>
<noscript class="m-text m-danger m-text-center">Unlike everything else in the docs, the search functionality <em>requires</em> JavaScript.</noscript>
<div id="search-help" class="m-text m-dim m-text-center">
<p class="m-noindent">Search for symbols, directories, files, pages or
modules. You can omit any prefix from the symbol or file path; adding a
<code>:</code> or <code>/</code> suffix lists all members of given symbol or
directory.</p>
<p class="m-noindent">Use <span class="m-label m-dim">&darr;</span>
/ <span class="m-label m-dim">&uarr;</span> to navigate through the list,
<span class="m-label m-dim">Enter</span> to go.
<span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
copy a link to the result using <span class="m-label m-dim"></span>
<span class="m-label m-dim">L</span> while <span class="m-label m-dim"></span>
<span class="m-label m-dim">M</span> produces a Markdown link.</p>
</div>
<div id="search-notfound" class="m-text m-warning m-text-center">Sorry, nothing was found.</div>
<ul id="search-results"></ul>
</div>
</div>
</div>
</div>
</div>
<script src="search-v2.js"></script>
<script src="searchdata-v2.js" async="async"></script>
<footer><nav>
<div class="m-container">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<p>ScStw shared libraries. Created with <a href="https://doxygen.org/">Doxygen</a> 1.9.4 and <a href="https://mcss.mosra.cz/">m.css</a>.</p>
</div>
</div>
</div>
</nav></footer>
</body>
</html>

View file

@ -1,101 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>ScStw Libraries documentation | ScStw shared libraries</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
<link rel="stylesheet" href="m-dark+documentation.compiled.css" />
<link rel="icon" href="favicon.png" type="image/png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#0094ff" />
</head>
<body>
<header><nav id="navigation">
<div class="m-container">
<div class="m-row">
<a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m"><img src="favicon.png" alt="" />ScStw shared libraries</a>
<div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
<a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<path id="m-doc-search-icon-path" d="m6 0c-3.31 0-6 2.69-6 6 0 3.31 2.69 6 6 6 1.49 0 2.85-0.541 3.89-1.44-0.0164 0.338 0.147 0.759 0.5 1.15l3.22 3.79c0.552 0.614 1.45 0.665 2 0.115 0.55-0.55 0.499-1.45-0.115-2l-3.79-3.22c-0.392-0.353-0.812-0.515-1.15-0.5 0.895-1.05 1.44-2.41 1.44-3.89 0-3.31-2.69-6-6-6zm0 1.56a4.44 4.44 0 0 1 4.44 4.44 4.44 4.44 0 0 1-4.44 4.44 4.44 4.44 0 0 1-4.44-4.44 4.44 4.44 0 0 1 4.44-4.44z"/>
</svg></a>
<a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
<a id="m-navbar-hide" href="#" title="Hide navigation"></a>
</div>
<div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
<div class="m-row">
<ol class="m-col-t-6 m-col-m-none">
</ol>
<ol class="m-col-t-6 m-col-m-none" start="1">
<li><a href="index.html">Introduction</a></li>
<li><a href="annotated.html">Classes</a></li>
<li><a href="refman.pdf">Download</a></li>
<li class="m-show-m"><a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<use href="#m-doc-search-icon-path" />
</svg></a></li>
</ol>
</div>
</div>
</div>
</div>
</nav></header>
<main><article>
<div class="m-container m-container-inflatable">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<h1>
ScStw Libraries documentation
</h1>
<section id="intro_sec"><h2><a href="#intro_sec">Introduction</a></h2><p>This library is meant for usage with the Speed climbing stopwatch project. It contains some helper classes to build a client application for the <a href="classScStw.html" class="m-doc">ScStw</a> basestation with Qt.</p></section><section id="section"><h2><a href="#section">Installation</a></h2><pre class="m-code"><span class="nb">cd</span> yourRepo
git submodule add https://git.itsblue.de/ScStw/shared-libraries/
git submodule update --init --recursive</pre><p>And in your MyProject.pro include the .pri file: <code class="m-code"><span class="nf">include</span><span class="p">(</span><span class="err">$$</span><span class="nv">PWD</span><span class="o">/</span><span class="s s-Atom">shared</span><span class="o">-</span><span class="s s-Atom">libraries</span><span class="o">/</span><span class="nv">ScStwLibraries</span><span class="o">/</span><span class="nv">ScStwLibraries</span><span class="p">.</span><span class="s s-Atom">pri</span><span class="p">)</span></code></p></section>
</div>
</div>
</div>
</article></main>
<div class="m-doc-search" id="search">
<a href="#!" onclick="return hideSearch()"></a>
<div class="m-container">
<div class="m-row">
<div class="m-col-m-8 m-push-m-2">
<div class="m-doc-search-header m-text m-small">
<div><span class="m-label m-default">Tab</span> / <span class="m-label m-default">T</span> to search, <span class="m-label m-default">Esc</span> to close</div>
<div id="search-symbolcount">&hellip;</div>
</div>
<div class="m-doc-search-content">
<form>
<input type="search" name="q" id="search-input" placeholder="Loading &hellip;" disabled="disabled" autofocus="autofocus" autocomplete="off" spellcheck="false" />
</form>
<noscript class="m-text m-danger m-text-center">Unlike everything else in the docs, the search functionality <em>requires</em> JavaScript.</noscript>
<div id="search-help" class="m-text m-dim m-text-center">
<p class="m-noindent">Search for symbols, directories, files, pages or
modules. You can omit any prefix from the symbol or file path; adding a
<code>:</code> or <code>/</code> suffix lists all members of given symbol or
directory.</p>
<p class="m-noindent">Use <span class="m-label m-dim">&darr;</span>
/ <span class="m-label m-dim">&uarr;</span> to navigate through the list,
<span class="m-label m-dim">Enter</span> to go.
<span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
copy a link to the result using <span class="m-label m-dim"></span>
<span class="m-label m-dim">L</span> while <span class="m-label m-dim"></span>
<span class="m-label m-dim">M</span> produces a Markdown link.</p>
</div>
<div id="search-notfound" class="m-text m-warning m-text-center">Sorry, nothing was found.</div>
<ul id="search-results"></ul>
</div>
</div>
</div>
</div>
</div>
<script src="search-v2.js"></script>
<script src="searchdata-v2.js" async="async"></script>
<footer><nav>
<div class="m-container">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<p>ScStw shared libraries. Created with <a href="https://doxygen.org/">Doxygen</a> 1.9.4 and <a href="https://mcss.mosra.cz/">m.css</a>.</p>
</div>
</div>
</div>
</nav></footer>
</body>
</html>

File diff suppressed because it is too large Load diff

View file

@ -1,114 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>ScStw shared libraries</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
<link rel="stylesheet" href="m-dark+documentation.compiled.css" />
<link rel="icon" href="favicon.png" type="image/png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#0094ff" />
</head>
<body>
<header><nav id="navigation">
<div class="m-container">
<div class="m-row">
<a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m"><img src="favicon.png" alt="" />ScStw shared libraries</a>
<div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
<a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<path id="m-doc-search-icon-path" d="m6 0c-3.31 0-6 2.69-6 6 0 3.31 2.69 6 6 6 1.49 0 2.85-0.541 3.89-1.44-0.0164 0.338 0.147 0.759 0.5 1.15l3.22 3.79c0.552 0.614 1.45 0.665 2 0.115 0.55-0.55 0.499-1.45-0.115-2l-3.79-3.22c-0.392-0.353-0.812-0.515-1.15-0.5 0.895-1.05 1.44-2.41 1.44-3.89 0-3.31-2.69-6-6-6zm0 1.56a4.44 4.44 0 0 1 4.44 4.44 4.44 4.44 0 0 1-4.44 4.44 4.44 4.44 0 0 1-4.44-4.44 4.44 4.44 0 0 1 4.44-4.44z"/>
</svg></a>
<a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
<a id="m-navbar-hide" href="#" title="Hide navigation"></a>
</div>
<div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
<div class="m-row">
<ol class="m-col-t-6 m-col-m-none">
</ol>
<ol class="m-col-t-6 m-col-m-none" start="1">
<li><a href="index.html">Introduction</a></li>
<li><a href="annotated.html">Classes</a></li>
<li><a href="refman.pdf">Download</a></li>
<li class="m-show-m"><a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<use href="#m-doc-search-icon-path" />
</svg></a></li>
</ol>
</div>
</div>
</div>
</div>
</nav></header>
<main><article>
<div class="m-container m-container-inflatable">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<h1>Modules</h1>
<ul class="m-doc">
</ul>
<script>
function toggle(e) {
e.parentElement.className = e.parentElement.className == 'm-doc-collapsible' ?
'm-doc-expansible' : 'm-doc-collapsible';
return false;
}
/* Collapse all nodes marked as such. Doing it via JS instead of
directly in markup so disabling it doesn't harm usability. The list
is somehow regenerated on every iteration and shrinks as I change
the classes. It's not documented anywhere and I'm not sure if this
is the same across browsers, so I am going backwards in that list to
be sure. */
var collapsed = document.getElementsByClassName("collapsed");
for(var i = collapsed.length - 1; i >= 0; --i)
collapsed[i].className = 'm-doc-expansible';
</script>
</div>
</div>
</div>
</article></main>
<div class="m-doc-search" id="search">
<a href="#!" onclick="return hideSearch()"></a>
<div class="m-container">
<div class="m-row">
<div class="m-col-m-8 m-push-m-2">
<div class="m-doc-search-header m-text m-small">
<div><span class="m-label m-default">Tab</span> / <span class="m-label m-default">T</span> to search, <span class="m-label m-default">Esc</span> to close</div>
<div id="search-symbolcount">&hellip;</div>
</div>
<div class="m-doc-search-content">
<form>
<input type="search" name="q" id="search-input" placeholder="Loading &hellip;" disabled="disabled" autofocus="autofocus" autocomplete="off" spellcheck="false" />
</form>
<noscript class="m-text m-danger m-text-center">Unlike everything else in the docs, the search functionality <em>requires</em> JavaScript.</noscript>
<div id="search-help" class="m-text m-dim m-text-center">
<p class="m-noindent">Search for symbols, directories, files, pages or
modules. You can omit any prefix from the symbol or file path; adding a
<code>:</code> or <code>/</code> suffix lists all members of given symbol or
directory.</p>
<p class="m-noindent">Use <span class="m-label m-dim">&darr;</span>
/ <span class="m-label m-dim">&uarr;</span> to navigate through the list,
<span class="m-label m-dim">Enter</span> to go.
<span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
copy a link to the result using <span class="m-label m-dim"></span>
<span class="m-label m-dim">L</span> while <span class="m-label m-dim"></span>
<span class="m-label m-dim">M</span> produces a Markdown link.</p>
</div>
<div id="search-notfound" class="m-text m-warning m-text-center">Sorry, nothing was found.</div>
<ul id="search-results"></ul>
</div>
</div>
</div>
</div>
</div>
<script src="search-v2.js"></script>
<script src="searchdata-v2.js" async="async"></script>
<footer><nav>
<div class="m-container">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<p>ScStw shared libraries. Created with <a href="https://doxygen.org/">Doxygen</a> 1.9.4 and <a href="https://mcss.mosra.cz/">m.css</a>.</p>
</div>
</div>
</div>
</nav></footer>
</body>
</html>

View file

@ -1,114 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>ScStw shared libraries</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
<link rel="stylesheet" href="m-dark+documentation.compiled.css" />
<link rel="icon" href="favicon.png" type="image/png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#0094ff" />
</head>
<body>
<header><nav id="navigation">
<div class="m-container">
<div class="m-row">
<a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m"><img src="favicon.png" alt="" />ScStw shared libraries</a>
<div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
<a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<path id="m-doc-search-icon-path" d="m6 0c-3.31 0-6 2.69-6 6 0 3.31 2.69 6 6 6 1.49 0 2.85-0.541 3.89-1.44-0.0164 0.338 0.147 0.759 0.5 1.15l3.22 3.79c0.552 0.614 1.45 0.665 2 0.115 0.55-0.55 0.499-1.45-0.115-2l-3.79-3.22c-0.392-0.353-0.812-0.515-1.15-0.5 0.895-1.05 1.44-2.41 1.44-3.89 0-3.31-2.69-6-6-6zm0 1.56a4.44 4.44 0 0 1 4.44 4.44 4.44 4.44 0 0 1-4.44 4.44 4.44 4.44 0 0 1-4.44-4.44 4.44 4.44 0 0 1 4.44-4.44z"/>
</svg></a>
<a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
<a id="m-navbar-hide" href="#" title="Hide navigation"></a>
</div>
<div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
<div class="m-row">
<ol class="m-col-t-6 m-col-m-none">
</ol>
<ol class="m-col-t-6 m-col-m-none" start="1">
<li><a href="index.html">Introduction</a></li>
<li><a href="annotated.html">Classes</a></li>
<li><a href="refman.pdf">Download</a></li>
<li class="m-show-m"><a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<use href="#m-doc-search-icon-path" />
</svg></a></li>
</ol>
</div>
</div>
</div>
</div>
</nav></header>
<main><article>
<div class="m-container m-container-inflatable">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<h1>Namespaces</h1>
<ul class="m-doc">
</ul>
<script>
function toggle(e) {
e.parentElement.className = e.parentElement.className == 'm-doc-collapsible' ?
'm-doc-expansible' : 'm-doc-collapsible';
return false;
}
/* Collapse all nodes marked as such. Doing it via JS instead of
directly in markup so disabling it doesn't harm usability. The list
is somehow regenerated on every iteration and shrinks as I change
the classes. It's not documented anywhere and I'm not sure if this
is the same across browsers, so I am going backwards in that list to
be sure. */
var collapsed = document.getElementsByClassName("collapsed");
for(var i = collapsed.length - 1; i >= 0; --i)
collapsed[i].className = 'm-doc-expansible';
</script>
</div>
</div>
</div>
</article></main>
<div class="m-doc-search" id="search">
<a href="#!" onclick="return hideSearch()"></a>
<div class="m-container">
<div class="m-row">
<div class="m-col-m-8 m-push-m-2">
<div class="m-doc-search-header m-text m-small">
<div><span class="m-label m-default">Tab</span> / <span class="m-label m-default">T</span> to search, <span class="m-label m-default">Esc</span> to close</div>
<div id="search-symbolcount">&hellip;</div>
</div>
<div class="m-doc-search-content">
<form>
<input type="search" name="q" id="search-input" placeholder="Loading &hellip;" disabled="disabled" autofocus="autofocus" autocomplete="off" spellcheck="false" />
</form>
<noscript class="m-text m-danger m-text-center">Unlike everything else in the docs, the search functionality <em>requires</em> JavaScript.</noscript>
<div id="search-help" class="m-text m-dim m-text-center">
<p class="m-noindent">Search for symbols, directories, files, pages or
modules. You can omit any prefix from the symbol or file path; adding a
<code>:</code> or <code>/</code> suffix lists all members of given symbol or
directory.</p>
<p class="m-noindent">Use <span class="m-label m-dim">&darr;</span>
/ <span class="m-label m-dim">&uarr;</span> to navigate through the list,
<span class="m-label m-dim">Enter</span> to go.
<span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
copy a link to the result using <span class="m-label m-dim"></span>
<span class="m-label m-dim">L</span> while <span class="m-label m-dim"></span>
<span class="m-label m-dim">M</span> produces a Markdown link.</p>
</div>
<div id="search-notfound" class="m-text m-warning m-text-center">Sorry, nothing was found.</div>
<ul id="search-results"></ul>
</div>
</div>
</div>
</div>
</div>
<script src="search-v2.js"></script>
<script src="searchdata-v2.js" async="async"></script>
<footer><nav>
<div class="m-container">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<p>ScStw shared libraries. Created with <a href="https://doxygen.org/">Doxygen</a> 1.9.4 and <a href="https://mcss.mosra.cz/">m.css</a>.</p>
</div>
</div>
</div>
</nav></footer>
</body>
</html>

View file

@ -1,114 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>ScStw shared libraries</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
<link rel="stylesheet" href="m-dark+documentation.compiled.css" />
<link rel="icon" href="favicon.png" type="image/png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#0094ff" />
</head>
<body>
<header><nav id="navigation">
<div class="m-container">
<div class="m-row">
<a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m"><img src="favicon.png" alt="" />ScStw shared libraries</a>
<div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
<a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<path id="m-doc-search-icon-path" d="m6 0c-3.31 0-6 2.69-6 6 0 3.31 2.69 6 6 6 1.49 0 2.85-0.541 3.89-1.44-0.0164 0.338 0.147 0.759 0.5 1.15l3.22 3.79c0.552 0.614 1.45 0.665 2 0.115 0.55-0.55 0.499-1.45-0.115-2l-3.79-3.22c-0.392-0.353-0.812-0.515-1.15-0.5 0.895-1.05 1.44-2.41 1.44-3.89 0-3.31-2.69-6-6-6zm0 1.56a4.44 4.44 0 0 1 4.44 4.44 4.44 4.44 0 0 1-4.44 4.44 4.44 4.44 0 0 1-4.44-4.44 4.44 4.44 0 0 1 4.44-4.44z"/>
</svg></a>
<a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
<a id="m-navbar-hide" href="#" title="Hide navigation"></a>
</div>
<div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
<div class="m-row">
<ol class="m-col-t-6 m-col-m-none">
</ol>
<ol class="m-col-t-6 m-col-m-none" start="1">
<li><a href="index.html">Introduction</a></li>
<li><a href="annotated.html">Classes</a></li>
<li><a href="refman.pdf">Download</a></li>
<li class="m-show-m"><a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<use href="#m-doc-search-icon-path" />
</svg></a></li>
</ol>
</div>
</div>
</div>
</div>
</nav></header>
<main><article>
<div class="m-container m-container-inflatable">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<h1>Pages</h1>
<ul class="m-doc">
</ul>
<script>
function toggle(e) {
e.parentElement.className = e.parentElement.className == 'm-doc-collapsible' ?
'm-doc-expansible' : 'm-doc-collapsible';
return false;
}
/* Collapse all nodes marked as such. Doing it via JS instead of
directly in markup so disabling it doesn't harm usability. The list
is somehow regenerated on every iteration and shrinks as I change
the classes. It's not documented anywhere and I'm not sure if this
is the same across browsers, so I am going backwards in that list to
be sure. */
var collapsed = document.getElementsByClassName("collapsed");
for(var i = collapsed.length - 1; i >= 0; --i)
collapsed[i].className = 'm-doc-expansible';
</script>
</div>
</div>
</div>
</article></main>
<div class="m-doc-search" id="search">
<a href="#!" onclick="return hideSearch()"></a>
<div class="m-container">
<div class="m-row">
<div class="m-col-m-8 m-push-m-2">
<div class="m-doc-search-header m-text m-small">
<div><span class="m-label m-default">Tab</span> / <span class="m-label m-default">T</span> to search, <span class="m-label m-default">Esc</span> to close</div>
<div id="search-symbolcount">&hellip;</div>
</div>
<div class="m-doc-search-content">
<form>
<input type="search" name="q" id="search-input" placeholder="Loading &hellip;" disabled="disabled" autofocus="autofocus" autocomplete="off" spellcheck="false" />
</form>
<noscript class="m-text m-danger m-text-center">Unlike everything else in the docs, the search functionality <em>requires</em> JavaScript.</noscript>
<div id="search-help" class="m-text m-dim m-text-center">
<p class="m-noindent">Search for symbols, directories, files, pages or
modules. You can omit any prefix from the symbol or file path; adding a
<code>:</code> or <code>/</code> suffix lists all members of given symbol or
directory.</p>
<p class="m-noindent">Use <span class="m-label m-dim">&darr;</span>
/ <span class="m-label m-dim">&uarr;</span> to navigate through the list,
<span class="m-label m-dim">Enter</span> to go.
<span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
copy a link to the result using <span class="m-label m-dim"></span>
<span class="m-label m-dim">L</span> while <span class="m-label m-dim"></span>
<span class="m-label m-dim">M</span> produces a Markdown link.</p>
</div>
<div id="search-notfound" class="m-text m-warning m-text-center">Sorry, nothing was found.</div>
<ul id="search-results"></ul>
</div>
</div>
</div>
</div>
</div>
<script src="search-v2.js"></script>
<script src="searchdata-v2.js" async="async"></script>
<footer><nav>
<div class="m-container">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<p>ScStw shared libraries. Created with <a href="https://doxygen.org/">Doxygen</a> 1.9.4 and <a href="https://mcss.mosra.cz/">m.css</a>.</p>
</div>
</div>
</div>
</nav></footer>
</body>
</html>

1
qt-openssl-encryption Submodule

@ -0,0 +1 @@
Subproject commit 05fbf562c3435f3bbff10a68c031ff465e81d337

Binary file not shown.

View file

@ -1,897 +0,0 @@
/*
This file is part of m.css.
Copyright © 2017, 2018, 2019, 2020, 2021, 2022
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
"use strict"; /* it summons the Cthulhu in a proper way, they say */
var Search = {
formatVersion: 2, /* the data filename contains this number too */
dataSize: 0, /* used mainly by tests, not here */
symbolCount: '&hellip;',
trie: null,
map: null,
mapFlagsOffset: null,
typeMap: null,
maxResults: 0,
/* Type sizes and masks. The data is always fetched as 16/32bit number and
then masked to 1, 2, 3 or 4 bytes. Fortunately on LE a mask is enough,
on BE we'd have to read N bytes before and then mask. */
nameSizeBytes: null,
nameSizeMask: null,
resultIdBytes: null,
resultIdMask: null,
fileOffsetBytes: null,
fileOffsetMask: null,
lookaheadBarrierMask: null,
/* Always contains at least the root node offset and then one node offset
per entered character */
searchString: '',
searchStack: [],
/* So items don't get selected right away when a cursor is over results but
only after mouse moves */
mouseMovedSinceLastRender: false,
/* Whether we can go back in history in order to hide the search box or
not. We can't do that if we arrived directly on #search from outside. */
canGoBackToHideSearch: false,
/* Autocompletion in the input field is whitelisted only for character
input (so not deletion, cut, or anything else). This is flipped in the
onkeypress event and reset after each oninput event. */
autocompleteNextInputEvent: false,
init: function(buffer, maxResults) {
let view = new DataView(buffer);
/* The file is too short to contain at least the headers and empty
sections */
if(view.byteLength < 31) {
console.error("Search data too short");
return false;
}
if(view.getUint8(0) != 'M'.charCodeAt(0) ||
view.getUint8(1) != 'C'.charCodeAt(0) ||
view.getUint8(2) != 'S'.charCodeAt(0)) {
console.error("Invalid search data signature");
return false;
}
if(view.getUint8(3) != this.formatVersion) {
console.error("Invalid search data version");
return false;
}
/* Fetch type sizes. The only value that can fail is result ID byte
count, where value of 3 has no assigned meaning. */
let typeSizes = view.getUint8(4, true);
if((typeSizes & 0x01) >> 0 == 0) {
this.fileOffsetBytes = 3;
this.fileOffsetMask = 0x00ffffff;
this.lookaheadBarrierMask = 0x00800000;
} else /* (typeSizes & 0x01) >> 0 == 1 */ {
this.fileOffsetBytes = 4;
this.fileOffsetMask = 0xffffffff;
this.lookaheadBarrierMask = 0x80000000;
}
if((typeSizes & 0x06) >> 1 == 0) {
this.resultIdBytes = 2;
this.resultIdMask = 0x0000ffff;
} else if((typeSizes & 0x06) >> 1 == 1) {
this.resultIdBytes = 3;
this.resultIdMask = 0x00ffffff;
} else if((typeSizes & 0x06) >> 1 == 2) {
this.resultIdBytes = 4;
this.resultIdMask = 0xffffffff;
} else /* (typeSizes & 0x06) >> 1 == 3 */ {
console.error("Invalid search data result ID byte value");
return false;
}
if((typeSizes & 0x08) >> 3 == 0) {
this.nameSizeBytes = 1;
this.nameSizeMask = 0x00ff;
} else /* (typeSizes & 0x08) >> 3 == 1 */ {
this.nameSizeBytes = 2;
this.nameSizeMask = 0xffff;
}
/* Separate the data into the trie and the result / type map. Because
we're reading larger values than there might be and then masking out
the high bytes, keep extra 1/2 byte padding at the end to avoid
OOB errors. */
let mapOffset = view.getUint32(12, true);
let typeMapOffset = view.getUint32(16, true);
/* There may be a 3-byte file offset at the end of the trie which we'll
read as 32-bit, add one safety byte in that case */
this.trie = new DataView(buffer, 20, mapOffset - 20 + (4 - this.fileOffsetBytes));
/* There may be a 3-byte file size (for zero results) which we'll read
as 32-bit, add one safety byte in that case */
this.map = new DataView(buffer, mapOffset, typeMapOffset - mapOffset + (4 - this.fileOffsetBytes));
/* No variable-size types in the type map at the moment */
this.typeMap = new DataView(buffer, typeMapOffset);
/* Offset of the first result map item is after N + 1 offsets and N
flags, calculate flag offset from that */
this.mapFlagsOffset = this.fileOffsetBytes*(((this.map.getUint32(0, true) & this.fileOffsetMask) - this.fileOffsetBytes)/(this.fileOffsetBytes + 1) + 1);
/* Set initial properties */
this.dataSize = buffer.byteLength;
this.symbolCount = view.getUint32(8, true) + " symbols (" + Math.round(this.dataSize/102.4)/10 + " kB)";
this.maxResults = maxResults ? maxResults : 100;
this.searchString = '';
this.searchStack = [this.trie.getUint32(0, true)];
/* istanbul ignore if */
if(typeof document !== 'undefined') {
document.getElementById('search-symbolcount').innerHTML = this.symbolCount;
document.getElementById('search-input').disabled = false;
document.getElementById('search-input').placeholder = "Type something here …";
document.getElementById('search-input').focus();
/* Search for the input value (there might be something already,
for example when going back in the browser) */
let value = document.getElementById('search-input').value;
/* Otherwise check the GET parameters for `q` and fill the input
with that */
if(!value.length) {
var args = decodeURIComponent(window.location.search.substr(1)).trim().split('&');
for(var i = 0; i != args.length; ++i) {
if(args[i].substring(0, 2) != 'q=') continue;
value = document.getElementById('search-input').value = args[i].substring(2);
break;
}
}
if(value.length) Search.searchAndRender(value);
}
return true;
},
download: /* istanbul ignore next */ function(url) {
var req = window.XDomainRequest ? new XDomainRequest() : new XMLHttpRequest();
if(!req) return;
req.open("GET", url, true);
req.responseType = 'arraybuffer';
req.onreadystatechange = function() {
if(req.readyState != 4) return;
Search.init(req.response);
}
req.send();
},
base85decode: function(base85string) {
function charValue(char) {
if(char >= 48 && char < 58) /* 0-9 -> 0-9 */
return char - 48 + 0;
if(char >= 65 && char < 91) /* A-Z -> 10-35 */
return char - 65 + 10;
if(char >= 97 && char < 123) /* a-z -> 36-61 */
return char - 97 + 36;
if(char == 33) /* ! -> 62 */
return 62;
/* skipping 34 (') */
if(char >= 35 && char < 39) /* #-& -> 63-66 */
return char - 35 + 63;
/* skipping 39 (") */
if(char >= 40 && char < 44) /* (-+ -> 67-70 */
return char - 40 + 67;
/* skipping 44 (,) */
if(char == 45) /* - -> 71 */
return 71;
if(char >= 59 && char < 65) /* ;-@ -> 72-77 */
return char - 59 + 72;
if(char >= 94 && char < 97) /* ^-` -> 78-80 */
return char - 94 + 78;
if(char >= 123 && char < 127) /* {-~ -> 81-84 */
return char - 123 + 81;
return 0; /* Interpret padding values as zeros */
}
/* Pad the string for easier decode later. We don't read past the file
end, so it doesn't matter what garbage is there. */
if(base85string.length % 5) {
console.log("Expected properly padded base85 data");
return;
}
let buffer = new ArrayBuffer(base85string.length*4/5);
let data8 = new DataView(buffer);
for(let i = 0; i < base85string.length; i += 5) {
let char1 = charValue(base85string.charCodeAt(i + 0));
let char2 = charValue(base85string.charCodeAt(i + 1));
let char3 = charValue(base85string.charCodeAt(i + 2));
let char4 = charValue(base85string.charCodeAt(i + 3));
let char5 = charValue(base85string.charCodeAt(i + 4));
data8.setUint32(i*4/5, char5 +
char4*85 +
char3*85*85 +
char2*85*85*85 +
char1*85*85*85*85, false); /* BE, yes */
}
return buffer;
},
load: function(base85string) {
return this.init(this.base85decode(base85string));
},
/* http://ecmanaut.blogspot.com/2006/07/encoding-decoding-utf8-in-javascript.html */
toUtf8: function(string) { return unescape(encodeURIComponent(string)); },
fromUtf8: function(string) { return decodeURIComponent(escape(string)); },
autocompletedCharsToUtf8: function(chars) {
/* Strip incomplete UTF-8 chars from the autocompletion end */
for(let i = chars.length - 1; i >= 0; --i) {
let c = chars[i];
/* We're safe, finish */
if(
/* ASCII value at the end */
(c < 128 && i + 1 == chars.length) ||
/* Full two-byte character at the end */
((c & 0xe0) == 0xc0 && i + 2 == chars.length) ||
/* Full three-byte character at the end */
((c & 0xf0) == 0xe0 && i + 3 == chars.length) ||
/* Full four-byte character at the end */
((c & 0xf8) == 0xf0 && i + 4 == chars.length)
) break;
/* Continuing UTF-8 character, go further back */
if((c & 0xc0) == 0x80) continue;
/* Otherwise the character is not complete, drop it from the end */
chars.length = i;
break;
}
/* Convert the autocompleted UTF-8 sequence to a string */
let suggestedTabAutocompletionString = '';
for(let i = 0; i != chars.length; ++i)
suggestedTabAutocompletionString += String.fromCharCode(chars[i]);
return suggestedTabAutocompletionString;
},
/* Returns the values in UTF-8, but input is in whatever shitty 16bit
encoding JS has */
search: function(searchString) {
/* Normalize the search string first, convert to UTF-8 and trim spaces
from the left. From the right they're trimmed only if nothing is
found, see below. */
searchString = this.toUtf8(searchString.toLowerCase().replace(/^\s+/,''));
/* TODO: maybe i could make use of InputEvent.data and others here */
/* Find longest common prefix of previous and current value so we don't
need to needlessly search again */
let max = Math.min(searchString.length, this.searchString.length);
let commonPrefix = 0;
for(; commonPrefix != max; ++commonPrefix)
if(searchString[commonPrefix] != this.searchString[commonPrefix]) break;
/* Drop items off the stack if it has has more than is needed for the
common prefix (it needs to have at least one item, though) */
if(commonPrefix + 1 < this.searchStack.length)
this.searchStack.splice(commonPrefix + 1, this.searchStack.length - commonPrefix - 1);
/* Add new characters from the search string */
let foundPrefix = commonPrefix;
for(; foundPrefix != searchString.length; ++foundPrefix) {
/* Calculate offset and count of children */
let offset = this.searchStack[this.searchStack.length - 1];
/* If there's a lot of results, the result count is a 16bit BE value
instead */
let resultCount = this.trie.getUint8(offset);
let resultCountSize = 1;
if(resultCount & 0x80) {
resultCount = this.trie.getUint16(offset, false) & ~0x8000;
++resultCountSize;
}
let childCount = this.trie.getUint8(offset + resultCountSize);
/* Go through all children and find the next offset */
let childOffset = offset + resultCountSize + 1 + resultCount*this.resultIdBytes;
let found = false;
for(let j = 0; j != childCount; ++j) {
if(String.fromCharCode(this.trie.getUint8(childOffset + j)) != searchString[foundPrefix])
continue;
this.searchStack.push(this.trie.getUint32(childOffset + childCount + j*this.fileOffsetBytes, true) & this.fileOffsetMask & ~this.lookaheadBarrierMask);
found = true;
break;
}
/* Character not found */
if(!found) {
/* If we found everything except spaces at the end, pretend the
spaces aren't there. On the other hand, we *do* want to
try searching with the spaces first -- it can narrow down
the result list for page names or show subpages (which are
after a lookahead barrier that's a space). */
if(!searchString.substr(foundPrefix).trim().length)
searchString = searchString.substr(0, foundPrefix);
break;
}
}
/* Save the whole found prefix for next time */
this.searchString = searchString.substr(0, foundPrefix);
/* If the whole thing was not found, return an empty result and offer
external search */
if(foundPrefix != searchString.length) {
/* istanbul ignore if */
if(typeof document !== 'undefined') {
let link = document.getElementById('search-external');
if(link)
link.href = link.dataset.searchEngine.replace('{query}', encodeURIComponent(searchString));
}
return [[], ''];
}
/* Otherwise gather the results */
let suggestedTabAutocompletionChars = [];
let results = [];
let leaves = [[this.searchStack[this.searchStack.length - 1], 0]];
while(leaves.length) {
/* Pop offset from the queue */
let current = leaves.shift();
let offset = current[0];
let suffixLength = current[1];
/* Calculate child count. If there's a lot of results, the count
"leaks over" to the child count storage. */
/* TODO: hmmm. this is helluvalot duplicated code. hmm. */
let resultCount = this.trie.getUint8(offset);
let resultCountSize = 1;
if(resultCount & 0x80) {
resultCount = this.trie.getUint16(offset, false) & ~0x8000;
++resultCountSize;
}
let childCount = this.trie.getUint8(offset + resultCountSize);
/* Populate the results with all values associated with this node */
for(let i = 0; i != resultCount; ++i) {
let index = this.trie.getUint32(offset + resultCountSize + 1 + i*this.resultIdBytes, true) & this.resultIdMask;
results.push(this.gatherResult(index, suffixLength, 0xffffff)); /* should be enough haha */
/* 'nuff said. */
if(results.length >= this.maxResults)
return [results, this.autocompletedCharsToUtf8(suggestedTabAutocompletionChars)];
}
/* Dig deeper */
let childOffset = offset + resultCountSize + 1 + resultCount*this.resultIdBytes;
for(let j = 0; j != childCount; ++j) {
let offsetBarrier = this.trie.getUint32(childOffset + childCount + j*this.fileOffsetBytes, true) & this.fileOffsetMask;
/* Lookahead barrier, don't dig deeper */
if(offsetBarrier & this.lookaheadBarrierMask) continue;
/* Append to the queue */
leaves.push([offsetBarrier & ~this.lookaheadBarrierMask, suffixLength + 1]);
/* We don't have anything yet and this is the only path
forward, add the char to suggested Tab autocompletion. Can't
extract it from the leftmost 8 bits of offsetBarrier because
that would make it negative, have to load as Uint8 instead.
Also can't use String.fromCharCode(), because later doing
str.charCodeAt() would give me back UTF-16 values, which is
absolutely unwanted when all I want is check for truncated
UTF-8. */
if(!results.length && leaves.length == 1 && childCount == 1)
suggestedTabAutocompletionChars.push(this.trie.getUint8(childOffset + j));
}
}
return [results, this.autocompletedCharsToUtf8(suggestedTabAutocompletionChars)];
},
gatherResult: function(index, suffixLength, maxUrlPrefix) {
let flags = this.map.getUint8(this.mapFlagsOffset + index);
let resultOffset = this.map.getUint32(index*this.fileOffsetBytes, true) & this.fileOffsetMask;
/* The result is an alias, parse the aliased prefix */
let aliasedIndex = null;
if((flags & 0xf0) == 0x00) {
aliasedIndex = this.map.getUint32(resultOffset, true) & this.resultIdMask;
resultOffset += this.resultIdBytes;
}
/* The result has a prefix, parse that first, recursively */
let name = '';
let url = '';
if(flags & (1 << 3)) {
let prefixIndex = this.map.getUint32(resultOffset, true) & this.resultIdMask;
let prefixUrlPrefixLength = Math.min(this.map.getUint16(resultOffset + this.resultIdBytes, true) & this.nameSizeMask, maxUrlPrefix);
let prefix = this.gatherResult(prefixIndex, 0 /*ignored*/, prefixUrlPrefixLength);
name = prefix.name;
url = prefix.url;
resultOffset += this.resultIdBytes + this.nameSizeBytes;
}
/* The result has a suffix, extract its length */
let resultSuffixLength = 0;
if(flags & (1 << 0)) {
resultSuffixLength = this.map.getUint16(resultOffset, true) & this.nameSizeMask;
resultOffset += this.nameSizeBytes;
}
let nextResultOffset = this.map.getUint32((index + 1)*this.fileOffsetBytes, true) & this.fileOffsetMask;
/* Extract name */
let j = resultOffset;
for(; j != nextResultOffset; ++j) {
let c = this.map.getUint8(j);
/* End of null-delimited name */
if(!c) {
++j;
break; /* null-delimited */
}
name += String.fromCharCode(c); /* eheh. IS THIS FAST?! */
}
/* The result is an alias and we're not deep inside resolving a prefix,
extract the aliased name and URL */
/* TODO: this abuses 0xffffff to guess how the call stack is deep and
that's just wrong, fix! */
if(aliasedIndex != null && maxUrlPrefix == 0xffffff) {
let alias = this.gatherResult(aliasedIndex, 0 /* ignored */, 0xffffff); /* should be enough haha */
/* Keeping in UTF-8, as we need that for proper slicing (and concatenating) */
return {name: name,
alias: alias.name,
url: alias.url,
flags: alias.flags,
cssClass: alias.cssClass,
typeName: alias.typeName,
suffixLength: suffixLength + resultSuffixLength};
}
/* Otherwise extract URL from here */
let max = Math.min(j + maxUrlPrefix - url.length, nextResultOffset);
for(; j != max; ++j) {
url += String.fromCharCode(this.map.getUint8(j));
}
/* This is an alias, return what we have, without parsed CSS class and
type name as those are retrieved from the final target type */
if(!(flags >> 4))
return {name: name,
url: url,
flags: flags & 0x0f,
suffixLength: suffixLength + resultSuffixLength};
/* Otherwise, get CSS class and type name for the result label */
let typeMapIndex = (flags >> 4) - 1;
let cssClass = [
/* Keep in sync with _search.py */
'm-default',
'm-primary',
'm-success',
'm-warning',
'm-danger',
'm-info',
'm-dim'
][this.typeMap.getUint8(typeMapIndex*2)];
let typeNameOffset = this.typeMap.getUint8(typeMapIndex*2 + 1);
let nextTypeNameOffset = this.typeMap.getUint8((typeMapIndex + 1)*2 + 1);
let typeName = '';
for(let j = typeNameOffset; j != nextTypeNameOffset; ++j)
typeName += String.fromCharCode(this.typeMap.getUint8(j));
/* Keeping in UTF-8, as we need that for proper slicing (and
concatenating). Strip the type from the flags, as it's now expressed
directly. */
return {name: name,
url: url,
flags: flags & 0x0f,
cssClass: cssClass,
typeName: typeName,
suffixLength: suffixLength + resultSuffixLength};
},
escape: function(name) {
return name.replace(/[\"&<>]/g, function (a) {
return { '"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;' }[a];
});
},
escapeForRtl: function(name) {
/* Besides the obvious escaping of HTML entities we also need
to escape punctuation, because due to the RTL hack to cut
text off on left side the punctuation characters get
reordered (of course). Prepending &lrm; works for most
characters, parentheses we need to *soak* in it. But only
the right ones. And that for some reason needs to be also for &.
Huh. https://en.wikipedia.org/wiki/Right-to-left_mark */
return this.escape(name).replace(/[:=]/g, '&lrm;$&').replace(/(\)|&gt;|&amp;|\/)/g, '&lrm;$&&lrm;');
},
renderResults: /* istanbul ignore next */ function(resultsSuggestedTabAutocompletion) {
if(!this.searchString.length) {
document.getElementById('search-help').style.display = 'block';
document.getElementById('search-results').style.display = 'none';
document.getElementById('search-notfound').style.display = 'none';
return;
}
document.getElementById('search-help').style.display = 'none';
/* Results found */
if(resultsSuggestedTabAutocompletion[0].length) {
let results = resultsSuggestedTabAutocompletion[0];
document.getElementById('search-results').style.display = 'block';
document.getElementById('search-notfound').style.display = 'none';
let list = '';
for(let i = 0; i != results.length; ++i) {
/* Labels + */
list += '<li' + (i ? '' : ' id="search-current"') + '><a href="' + results[i].url + '" onmouseover="selectResult(event)" data-md-link-title="' + this.escape(results[i].name.substr(results[i].name.length - this.searchString.length - results[i].suffixLength)) + '"><div class="m-label m-flat ' + results[i].cssClass + '">' + results[i].typeName + '</div>' + (results[i].flags & 2 ? '<div class="m-label m-danger">deprecated</div>' : '') + (results[i].flags & 4 ? '<div class="m-label m-danger">deleted</div>' : '');
/* Render the alias (cut off from the right) */
if(results[i].alias) {
list += '<div class="m-doc-search-alias"><span class="m-text m-dim">' + this.escape(results[i].name.substr(0, results[i].name.length - this.searchString.length - results[i].suffixLength)) + '</span><span class="m-doc-search-typed">' + this.escape(results[i].name.substr(results[i].name.length - this.searchString.length - results[i].suffixLength, this.searchString.length)) + '</span>' + this.escapeForRtl(results[i].name.substr(results[i].name.length - results[i].suffixLength)) + '<span class="m-text m-dim">: ' + this.escape(results[i].alias) + '</span>';
/* Render the normal thing (cut off from the left, have to
escape for RTL) */
} else {
list += '<div><span class="m-text m-dim">' + this.escapeForRtl(results[i].name.substr(0, results[i].name.length - this.searchString.length - results[i].suffixLength)) + '</span><span class="m-doc-search-typed">' + this.escapeForRtl(results[i].name.substr(results[i].name.length - this.searchString.length - results[i].suffixLength, this.searchString.length)) + '</span>' + this.escapeForRtl(results[i].name.substr(results[i].name.length - results[i].suffixLength));
}
/* The closing */
list += '</div></a></li>';
}
document.getElementById('search-results').innerHTML = this.fromUtf8(list);
document.getElementById('search-current').scrollIntoView(true);
/* Append the suggested tab autocompletion, if any, and if the user
didn't just delete it */
let searchInput = document.getElementById('search-input');
if(this.autocompleteNextInputEvent && resultsSuggestedTabAutocompletion[1].length && searchInput.selectionEnd == searchInput.value.length) {
let suggestedTabAutocompletion = this.fromUtf8(resultsSuggestedTabAutocompletion[1]);
let lengthBefore = searchInput.value.length;
searchInput.value += suggestedTabAutocompletion;
searchInput.setSelectionRange(lengthBefore, searchInput.value.length);
}
/* Nothing found */
} else {
document.getElementById('search-results').innerHTML = '';
document.getElementById('search-results').style.display = 'none';
document.getElementById('search-notfound').style.display = 'block';
}
/* Don't allow things to be selected just by motionless mouse cursor
suddenly appearing over a search result */
this.mouseMovedSinceLastRender = false;
/* Reset autocompletion, if it was allowed. It'll get whitelisted next
time a character gets inserted. */
this.autocompleteNextInputEvent = false;
},
searchAndRender: /* istanbul ignore next */ function(value) {
let prev = performance.now();
let results = this.search(value);
let after = performance.now();
this.renderResults(results);
if(this.searchString.length) {
document.getElementById('search-symbolcount').innerHTML =
results[0].length + (results[0].length >= this.maxResults ? '+' : '') + " results (" + Math.round((after - prev)*10)/10 + " ms)";
} else
document.getElementById('search-symbolcount').innerHTML = this.symbolCount;
},
};
/* istanbul ignore next */
function selectResult(event) {
if(!Search.mouseMovedSinceLastRender) return;
if(event.currentTarget.parentNode.id == 'search-current') return;
let current = document.getElementById('search-current');
current.removeAttribute('id');
event.currentTarget.parentNode.id = 'search-current';
}
/* This is separated from showSearch() because we need non-destructive behavior
when appearing directly on a URL with #search */ /* istanbul ignore next */
function updateForSearchVisible() {
/* Prevent accidental scrolling of the body, prevent page layout jumps */
let scrolledBodyWidth = document.body.offsetWidth;
document.body.style.overflow = 'hidden';
document.body.style.paddingRight = (document.body.offsetWidth - scrolledBodyWidth) + 'px';
document.getElementById('search-input').value = '';
document.getElementById('search-input').focus();
document.getElementById('search-results').style.display = 'none';
document.getElementById('search-notfound').style.display = 'none';
document.getElementById('search-help').style.display = 'block';
}
/* istanbul ignore next */
function showSearch() {
window.location.hash = '#search';
Search.canGoBackToHideSearch = true;
updateForSearchVisible();
document.getElementById('search-symbolcount').innerHTML = Search.symbolCount;
return false;
}
/* istanbul ignore next */
function hideSearch() {
/* If the search box was opened using showSearch(), we can go back in the
history. Otherwise (for example when we landed to #search from a
bookmark or another server), going back would not do the right thing and
in that case we simply replace the current history state. */
if(Search.canGoBackToHideSearch) {
Search.canGoBackToHideSearch = false;
window.history.back();
} else {
window.location.hash = '#!';
window.history.replaceState('', '', window.location.pathname);
}
/* Restore scrollbar, prevent page layout jumps */
document.body.style.overflow = 'auto';
document.body.style.paddingRight = '0';
return false;
}
/* istanbul ignore next */
function copyToKeyboard(text) {
/* Append to the popup, appending to document.body would cause it to
scroll when focused */
let searchPopup = document.getElementsByClassName('m-doc-search')[0];
let textarea = document.createElement("textarea");
textarea.value = text;
searchPopup.appendChild(textarea);
textarea.focus();
textarea.select();
document.execCommand('copy');
searchPopup.removeChild(textarea);
document.getElementById('search-input').focus();
}
/* Only in case we're running in a browser. Why a simple if(document) doesn't
work is beyond me. */ /* istanbul ignore if */
if(typeof document !== 'undefined') {
document.getElementById('search-input').oninput = function(event) {
Search.searchAndRender(document.getElementById('search-input').value);
};
document.onkeydown = function(event) {
/* Search shown */
if(window.location.hash == '#search') {
/* Close the search */
if(event.key == 'Escape') {
hideSearch();
/* Focus the search input, if not already, using T or Tab */
} else if((!document.activeElement || document.activeElement.id != 'search-input') && (event.key.toLowerCase() == 't' || event.key == 'Tab') && !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey) {
document.getElementById('search-input').focus();
return false; /* so T doesn't get entered into the box */
/* Fill in the autocompleted selection */
} else if(event.key == 'Tab' && !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey) {
/* But only if the input has selection at the end */
let input = document.getElementById('search-input');
if(input.selectionEnd == input.value.length && input.selectionStart != input.selectionEnd) {
input.setSelectionRange(input.value.length, input.value.length);
return false; /* so input won't lose focus */
}
/* Select next item */
} else if(event.key == 'ArrowDown') {
let current = document.getElementById('search-current');
if(current) {
let next = current.nextSibling;
if(next) {
current.id = '';
next.id = 'search-current';
next.scrollIntoView(false);
}
}
return false; /* so the keypress doesn't affect input cursor */
/* Select prev item */
} else if(event.key == 'ArrowUp') {
let current = document.getElementById('search-current');
if(current) {
let prev = current.previousSibling;
if(prev) {
current.id = '';
prev.id = 'search-current';
prev.scrollIntoView(false);
}
}
return false; /* so the keypress doesn't affect input cursor */
/* Go to result (if any) */
} else if(event.key == 'Enter') {
let result = document.getElementById('search-current');
if(result) {
result.firstElementChild.click();
/* We might be staying on the same page, so restore scrollbar,
and prevent page layout jumps */
document.body.style.overflow = 'auto';
document.body.style.paddingRight = '0';
}
return false; /* so the form doesn't get sent */
/* Copy (Markdown) link to keyboard */
} else if((event.key.toLowerCase() == 'l' || event.key.toLowerCase() == 'm') && event.metaKey) {
let result = document.getElementById('search-current');
if(result) {
let plain = event.key.toLowerCase() == 'l';
let link = plain ? result.firstElementChild.href :
'[' + result.firstElementChild.dataset.mdLinkTitle + '](' + result.firstElementChild.href + ')';
copyToKeyboard(link);
/* Add CSS class to the element for visual feedback (this
will get removed on keyup), but only if it's not already
there (in case of key repeat, e.g.) */
if(result.className.indexOf('m-doc-search-copied') == -1)
result.className += ' m-doc-search-copied';
console.log("Copied " + (plain ? "link" : "Markdown link") + " to " + result.firstElementChild.dataset.mdLinkTitle);
}
return false; /* so L doesn't get entered into the box */
/* Looks like the user is inserting some text (and not cutting,
copying or whatever), allow autocompletion for the new
character. The oninput event resets this back to false, so this
basically whitelists only keyboard input, including Shift-key
and special chars using right Alt (or equivalent on Mac), but
excluding Ctrl-key, which is usually not for text input. In the
worst case the autocompletion won't be allowed ever, which is
much more acceptable behavior than having no ability to disable
it and annoying the users. */
} else if(event.key != 'Backspace' && event.key != 'Delete' && !event.metaKey && (!event.ctrlKey || event.altKey)
/* Don't ever attempt autocompletion with Android virtual
keyboards, as those report all `event.key`s as
`Unidentified` (on Chrome) or `Process` (on Firefox) with
`event.code` 229 and thus we have no way to tell if a text
is entered or deleted. See this WONTFIX bug for details:
https://bugs.chromium.org/p/chromium/issues/detail?id=118639
Couldn't find any similar bugreport for Firefox, but I
assume the virtual keyboard is to blame.
An alternative is to hook into inputEvent, which has the
data, but ... there's more cursed issues right after that:
- setSelectionRange() in Chrome on Android only renders
stuff, but doesn't actually act as such. Pressing
Backspace will only remove the highlight, but the text
stays here. Only delay-calling it through a timeout will
work as intended. Possibly related SO suggestion (back
then not even the rendering worked properly):
https://stackoverflow.com/a/13235951
Possibly related Chrome bug:
https://bugs.chromium.org/p/chromium/issues/detail?id=32865
- On Firefox Mobile, programmatically changing an input
value (for the autocompletion highlight) will trigger an
input event, leading to search *and* autocompletion being
triggered again. Ultimately that results in newly typed
characters not replacing the autocompletion but rather
inserting before it, corrupting the searched string. This
event has to be explicitly ignored.
- On Firefox Mobile, deleting a highlight with the
backspace key will result in *three* input events instead
of one:
1. `deleteContentBackward` removing the selection (same
as Chrome or desktop Firefox)
2. `deleteContentBackward` removing *the whole word*
that contained the selection (or the whole text if
it's just one word)
3. `insertCompositionText`, adding the word back in,
resulting in the same state as (1).
I have no idea WHY it has to do this (possibly some
REALLY NASTY workaround to trigger correct font shaping?)
but ultimately it results in the autocompletion being
added again right after it got deleted, making this whole
thing VERY annoying to use.
I attempted to work around the above, but it resulted in a
huge amount of browser-specific code that achieves only 90%
of the goal, with certain corner cases still being rather
broken (such as autocompletion randomly triggering when
erasing the text, even though it shouldn't). So disabling
autocompletion on this HELLISH BROKEN PLATFORM is the best
option at the moment. */
&& event.key != 'Unidentified' && event.key != 'Process'
) {
Search.autocompleteNextInputEvent = true;
/* Otherwise reset the flag, because when the user would press e.g.
the 'a' key and then e.g. ArrowRight (which doesn't trigger
oninput), a Backspace after would still result in
autocompleteNextInputEvent, because nothing reset it back. */
} else {
Search.autocompleteNextInputEvent = false;
}
/* Search hidden */
} else {
/* Open the search on the T or Tab key */
if((event.key.toLowerCase() == 't' || event.key == 'Tab') && !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey) {
showSearch();
return false; /* so T doesn't get entered into the box */
}
}
};
document.onkeyup = function(event) {
/* Remove highlight after key is released after a link copy */
if((event.key.toLowerCase() == 'l' || event.key.toLowerCase() == 'm') && event.metaKey) {
let result = document.getElementById('search-current');
if(result) result.className = result.className.replace(' m-doc-search-copied', '');
}
};
/* Allow selecting items by mouse hover only after it moves once the
results are populated. This prevents a random item getting selected if
the cursor is left motionless over the result area. */
document.getElementById('search-results').onmousemove = function() {
Search.mouseMovedSinceLastRender = true;
};
/* If #search is already present in the URL, hide the scrollbar etc. for a
consistent experience */
if(window.location.hash == '#search') updateForSearchVisible();
}
/* For Node.js testing */ /* istanbul ignore else */
if(typeof module !== 'undefined') { module.exports = { Search: Search }; }

File diff suppressed because one or more lines are too long