mirror of
https://codeberg.org/portospaceteam/ground-dashboard.git
synced 2024-12-01 02:32:25 +00:00
Receive data in dashboard
This commit is contained in:
parent
a9214847c4
commit
12f414b166
96
LICENSE
96
LICENSE
@ -1,48 +1,48 @@
|
|||||||
AFFERO GENERAL PUBLIC LICENSE
|
AFFERO GENERAL PUBLIC LICENSE
|
||||||
Version 1, March 2002 Copyright © 2002 Affero Inc.
|
Version 1, March 2002 Copyright © 2002 Affero Inc.
|
||||||
510 Third Street - Suite 225, San Francisco, CA 94107, USA
|
510 Third Street - Suite 225, San Francisco, CA 94107, USA
|
||||||
This license is a modified version of the GNU General Public License copyright (C) 1989, 1991 Free Software Foundation, Inc. made with their permission. Section 2(d) has been added to cover use of software over a computer network.
|
This license is a modified version of the GNU General Public License copyright (C) 1989, 1991 Free Software Foundation, Inc. made with their permission. Section 2(d) has been added to cover use of software over a computer network.
|
||||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||||
Preamble
|
Preamble
|
||||||
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the Affero General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This Public License applies to most of Affero's software and to any other program whose authors commit to using it. (Some other Affero software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
|
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the Affero General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This Public License applies to most of Affero's software and to any other program whose authors commit to using it. (Some other Affero software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
|
||||||
When we speak of free software, we are referring to freedom, not price. This General Public License is designed to make sure that you have the freedom to distribute copies of free software (and charge for this service 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.
|
When we speak of free software, we are referring to freedom, not price. This General Public License is designed to make sure that you have the freedom to distribute copies of free software (and charge for this service 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 make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
|
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
|
||||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. 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.
|
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. 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.
|
||||||
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
|
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
|
||||||
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
|
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
|
||||||
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
|
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
|
||||||
The precise terms and conditions for copying, distribution and modification follow.
|
The precise terms and conditions for copying, distribution and modification follow.
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this Affero General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
|
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this Affero General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
|
||||||
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
|
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
|
||||||
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
|
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
|
||||||
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
|
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
|
||||||
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
|
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
|
||||||
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
|
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
|
||||||
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
|
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
|
||||||
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
|
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
|
||||||
d) If the Program as you received it is intended to interact with users through a computer network and if, in the version you received, any user interacting with the Program was given the opportunity to request transmission to that user of the Program's complete source code, you must not remove that facility from your modified version of the Program or work based on the Program, and must offer an equivalent opportunity for all users interacting with your Program through a computer network to request immediate transmission by HTTP of the complete source code of your modified version or other derivative work.
|
d) If the Program as you received it is intended to interact with users through a computer network and if, in the version you received, any user interacting with the Program was given the opportunity to request transmission to that user of the Program's complete source code, you must not remove that facility from your modified version of the Program or work based on the Program, and must offer an equivalent opportunity for all users interacting with your Program through a computer network to request immediate transmission by HTTP of the complete source code of your modified version or other derivative work.
|
||||||
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
|
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
|
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
|
||||||
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
|
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
|
||||||
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
|
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
|
||||||
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
|
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
|
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
|
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
|
||||||
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
|
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
|
||||||
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
|
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
|
||||||
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
|
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
|
||||||
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
|
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
|
||||||
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
|
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
|
||||||
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
|
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
|
||||||
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
|
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
|
||||||
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
|
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
|
||||||
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
|
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
|
||||||
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
|
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
|
||||||
9. Affero Inc. may publish revised and/or new versions of the Affero 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.
|
9. Affero Inc. may publish revised and/or new versions of the Affero 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 a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by Affero, Inc. If the Program does not specify a version number of this License, you may choose any version ever published by Affero, Inc.
|
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by Affero, Inc. If the Program does not specify a version number of this License, you may choose any version ever published by Affero, Inc.
|
||||||
You may also choose to redistribute modified versions of this program under any version of the Free Software Foundation's GNU General Public License version 3 or higher, so long as that version of the GNU GPL includes terms and conditions substantially equivalent to those of this license.
|
You may also choose to redistribute modified versions of this program under any version of the Free Software Foundation's GNU General Public License version 3 or higher, so long as that version of the GNU GPL includes terms and conditions substantially equivalent to those of this license.
|
||||||
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by Affero, Inc., write to us; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
|
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by Affero, Inc., write to us; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
|
||||||
NO WARRANTY
|
NO WARRANTY
|
||||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
|
||||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE 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.
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE 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.
|
||||||
|
10
ground/.gitignore
vendored
10
ground/.gitignore
vendored
@ -1,5 +1,5 @@
|
|||||||
src
|
src
|
||||||
data
|
data
|
||||||
build
|
build
|
||||||
bin
|
bin
|
||||||
pkg
|
pkg
|
||||||
|
@ -1,200 +1,120 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
)
|
)
|
||||||
|
|
||||||
func basePressure(stream FlightData) float64 {
|
func basePressure(stream FlightData) float64 {
|
||||||
pressures := make([]float64, 0)
|
|
||||||
for _, segment := range stream.AllSegments() {
|
return 0
|
||||||
if segment.Computed.SmoothedPressure > 0 {
|
}
|
||||||
pressures = append(pressures, segment.Computed.SmoothedPressure)
|
|
||||||
}
|
func altitude(bp float64, raw RawDataSegment) float64 {
|
||||||
if len(pressures) >= 10 {
|
if bp == 0 {
|
||||||
var sum float64 = 0
|
return 0
|
||||||
for _, v := range pressures {
|
}
|
||||||
sum += v
|
return nanSafe(0.0)
|
||||||
}
|
}
|
||||||
return nanSafe(sum / float64(len(pressures)))
|
|
||||||
}
|
func normalizedPressure(raw RawDataSegment) float64 {
|
||||||
}
|
return nanSafe(0.0)
|
||||||
return 0
|
}
|
||||||
}
|
|
||||||
|
func velocity(stream FlightData, bp float64, raw RawDataSegment) float64 {
|
||||||
func altitude(bp float64, raw RawDataSegment) float64 {
|
return 0.0
|
||||||
if bp == 0 {
|
}
|
||||||
return 0
|
|
||||||
}
|
func yaw(raw RawDataSegment) float64 {
|
||||||
return nanSafe(44307.7 * (1 - math.Pow((raw.Pressure/100)/bp, 0.190284)))
|
return nanSafe(0.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func normalizedPressure(raw RawDataSegment) float64 {
|
func pitch(raw RawDataSegment) float64 {
|
||||||
return nanSafe(raw.Pressure / 100.0)
|
return nanSafe(0.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func velocity(stream FlightData, bp float64, raw RawDataSegment) float64 {
|
func toRadians(degrees float64) float64 {
|
||||||
altitude := altitude(bp, raw)
|
return nanSafe(0.0)
|
||||||
segments := stream.AllSegments()
|
}
|
||||||
for i := len(segments) - 1; i >= 0; i -= 1 {
|
|
||||||
if segments[i].Computed.Altitude != altitude {
|
func toDegrees(radians float64) float64 {
|
||||||
return nanSafe((altitude - segments[i].Computed.Altitude) / (raw.Timestamp - segments[i].Raw.Timestamp))
|
return nanSafe(0.0)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return 0.0
|
func bearing(origin Coordinate, raw RawDataSegment) float64 {
|
||||||
}
|
if origin.Lat == 0 || origin.Lon == 0 || raw.Coordinate.Lat == 0 || raw.Coordinate.Lon == 0 {
|
||||||
|
return 0
|
||||||
func yaw(raw RawDataSegment) float64 {
|
}
|
||||||
return nanSafe(math.Atan2(-1.0*raw.Acceleration.X, raw.Acceleration.Z) * (180.0 / math.Pi))
|
|
||||||
}
|
startLat := toRadians(origin.Lat)
|
||||||
|
startLng := toRadians(origin.Lon)
|
||||||
func pitch(raw RawDataSegment) float64 {
|
destLat := toRadians(raw.Coordinate.Lon)
|
||||||
return nanSafe(math.Atan2(-1.0*raw.Acceleration.Y, raw.Acceleration.Z) * (180.0 / math.Pi))
|
destLng := toRadians(raw.Coordinate.Lon)
|
||||||
}
|
|
||||||
|
y := math.Sin(destLng-startLng) * math.Cos(destLat)
|
||||||
func toRadians(degrees float64) float64 {
|
x := math.Cos(startLat)*math.Sin(destLat) - math.Sin(startLat)*math.Cos(destLat)*math.Cos(destLng-startLng)
|
||||||
return nanSafe(degrees * math.Pi / 180)
|
brng := math.Atan2(y, x)
|
||||||
}
|
brng = toDegrees(brng)
|
||||||
|
return nanSafe(math.Mod(brng+360, 360))
|
||||||
func toDegrees(radians float64) float64 {
|
}
|
||||||
return nanSafe(radians * 180 / math.Pi)
|
|
||||||
}
|
func distance(origin Coordinate, raw RawDataSegment) float64 {
|
||||||
|
return 0.0
|
||||||
func bearing(origin Coordinate, raw RawDataSegment) float64 {
|
}
|
||||||
if origin.Lat == 0 || origin.Lon == 0 || raw.Coordinate.Lat == 0 || raw.Coordinate.Lon == 0 {
|
|
||||||
return 0
|
func dataRate(stream FlightData) float64 {
|
||||||
}
|
|
||||||
|
return nanSafe(0.0)
|
||||||
startLat := toRadians(origin.Lat)
|
}
|
||||||
startLng := toRadians(origin.Lon)
|
|
||||||
destLat := toRadians(raw.Coordinate.Lon)
|
func averageComputedValue(seconds float64, stream FlightData, raw RawDataSegment, computed ComputedDataSegment, accessor func(seg ComputedDataSegment) float64) float64 {
|
||||||
destLng := toRadians(raw.Coordinate.Lon)
|
total := accessor(computed)
|
||||||
|
return nanSafe(total)
|
||||||
y := math.Sin(destLng-startLng) * math.Cos(destLat)
|
}
|
||||||
x := math.Cos(startLat)*math.Sin(destLat) - math.Sin(startLat)*math.Cos(destLat)*math.Cos(destLng-startLng)
|
|
||||||
brng := math.Atan2(y, x)
|
func determineFlightMode(stream FlightData, raw RawDataSegment, computed ComputedDataSegment) FlightMode {
|
||||||
brng = toDegrees(brng)
|
switch int(raw.FlightPhase) {
|
||||||
return nanSafe(math.Mod(brng+360, 360))
|
case 1:
|
||||||
}
|
return ModeWaitingLaunch
|
||||||
|
case 2:
|
||||||
func distance(origin Coordinate, raw RawDataSegment) float64 {
|
return ModeLaunch
|
||||||
if origin.Lat == 0 || origin.Lon == 0 || raw.Coordinate.Lat == 0 || raw.Coordinate.Lon == 0 {
|
case 4:
|
||||||
return 0
|
return ModeLowVelocity
|
||||||
}
|
case 5:
|
||||||
R := 6371e3
|
return ModeNoseOver
|
||||||
φ1 := origin.Lat * math.Pi / 180
|
case 6:
|
||||||
φ2 := raw.Coordinate.Lat * math.Pi / 180
|
return ModeDrogueFired
|
||||||
Δφ := (raw.Coordinate.Lat - origin.Lat) * math.Pi / 180
|
case 7:
|
||||||
Δλ := (raw.Coordinate.Lon - origin.Lon) * math.Pi / 180
|
return ModeMainFired
|
||||||
a := math.Sin(Δφ/2)*math.Sin(Δφ/2) + math.Cos(φ1)*math.Cos(φ2)*math.Sin(Δλ/2)*math.Sin(Δλ/2)
|
case 8:
|
||||||
c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
|
return ModeFailsafe
|
||||||
return nanSafe(R * c)
|
case 9:
|
||||||
}
|
return ModeLanding
|
||||||
|
default:
|
||||||
func dataRate(stream FlightData) float64 {
|
return "UNKNOWN";
|
||||||
totalsMap := make(map[int]float64)
|
}
|
||||||
for _, timestamp := range stream.Time() {
|
}
|
||||||
second := int(math.Floor(timestamp))
|
|
||||||
if total, ok := totalsMap[second]; ok {
|
func ComputeDataSegment(stream FlightData, raw RawDataSegment) (ComputedDataSegment, float64, Coordinate) {
|
||||||
totalsMap[second] = total + 1
|
bp := 0.0
|
||||||
} else {
|
|
||||||
totalsMap[second] = 1
|
origin := raw.Coordinate
|
||||||
}
|
|
||||||
}
|
computed := ComputedDataSegment{
|
||||||
total := 0.0
|
Altitude: raw.Altitude,
|
||||||
for _, secondTotal := range totalsMap {
|
Velocity: raw.Velocity,
|
||||||
total += secondTotal
|
Yaw: 0,
|
||||||
}
|
Pitch: 0,
|
||||||
return nanSafe(total / float64(len(totalsMap)))
|
Bearing: 0,
|
||||||
}
|
Distance: 0,
|
||||||
|
DataRate: dataRate(stream),
|
||||||
func averageComputedValue(seconds float64, stream FlightData, raw RawDataSegment, computed ComputedDataSegment, accessor func(seg ComputedDataSegment) float64) float64 {
|
SmoothedAltitude: raw.Altitude,
|
||||||
total := accessor(computed)
|
SmoothedVelocity: raw.Velocity,
|
||||||
n := 1.0
|
SmoothedPressure: 0.0,
|
||||||
i := len(stream.AllSegments()) - 1
|
SmoothedTemperature: raw.Temperature,
|
||||||
for i >= 0 && raw.Timestamp-stream.Time()[i] <= seconds {
|
SmoothedVerticalAcceleration: 0.0,
|
||||||
total += accessor(stream.AllSegments()[i].Computed)
|
}
|
||||||
n++
|
|
||||||
i--
|
computed.FlightMode = determineFlightMode(stream, raw, computed)
|
||||||
}
|
|
||||||
return nanSafe(total / n)
|
return computed, bp, origin
|
||||||
}
|
}
|
||||||
|
|
||||||
func determineFlightMode(stream FlightData, raw RawDataSegment, computed ComputedDataSegment) FlightMode {
|
|
||||||
length := len(stream.AllSegments())
|
|
||||||
if length == 0 {
|
|
||||||
return ModePrelaunch
|
|
||||||
}
|
|
||||||
lastMode := stream.AllSegments()[length-1].Computed.FlightMode
|
|
||||||
avgVelocity := averageComputedValue(1, stream, raw, computed, func(seg ComputedDataSegment) float64 {
|
|
||||||
return seg.SmoothedVelocity
|
|
||||||
})
|
|
||||||
avgAcceleration := averageComputedValue(1, stream, raw, computed, func(seg ComputedDataSegment) float64 {
|
|
||||||
return seg.SmoothedVerticalAcceleration
|
|
||||||
})
|
|
||||||
if lastMode == ModePrelaunch && avgVelocity > 5 {
|
|
||||||
return ModeAscentPowered
|
|
||||||
}
|
|
||||||
if lastMode == ModeAscentPowered && avgAcceleration < 0 && avgVelocity > 0 {
|
|
||||||
return ModeAscentUnpowered
|
|
||||||
}
|
|
||||||
if (lastMode == ModeAscentPowered || lastMode == ModeAscentUnpowered) && avgVelocity < 0 {
|
|
||||||
return ModeDescentFreefall
|
|
||||||
}
|
|
||||||
if lastMode == ModeDescentFreefall && math.Abs(avgAcceleration) < 0.5 {
|
|
||||||
return ModeDescentParachute
|
|
||||||
}
|
|
||||||
if (lastMode == ModeDescentFreefall || lastMode == ModeDescentParachute) && math.Abs(avgAcceleration) < 0.5 && math.Abs(avgVelocity) < 0.5 {
|
|
||||||
return ModeRecovery
|
|
||||||
}
|
|
||||||
return lastMode
|
|
||||||
}
|
|
||||||
|
|
||||||
func ComputeDataSegment(stream FlightData, raw RawDataSegment) (ComputedDataSegment, float64, Coordinate) {
|
|
||||||
bp := stream.BasePressure()
|
|
||||||
if bp == 0 {
|
|
||||||
bp = basePressure(stream)
|
|
||||||
}
|
|
||||||
|
|
||||||
origin := stream.Origin()
|
|
||||||
if origin.Lat == 0 && origin.Lon == 0 && raw.Coordinate.Lat != 0 && raw.Coordinate.Lon != 0 {
|
|
||||||
origin = raw.Coordinate
|
|
||||||
}
|
|
||||||
|
|
||||||
alt := altitude(bp, raw)
|
|
||||||
vel := velocity(stream, bp, raw)
|
|
||||||
press := normalizedPressure(raw)
|
|
||||||
|
|
||||||
smoothedAlt := alt
|
|
||||||
smoothedVel := vel
|
|
||||||
smoothedVertAccel := 0.0
|
|
||||||
smoothedPress := press
|
|
||||||
smoothedTemp := raw.Temperature
|
|
||||||
s := len(stream.AllSegments())
|
|
||||||
if s > 0 {
|
|
||||||
alpha := 0.5
|
|
||||||
smoothedAlt = smoothed(alpha, alt, stream.SmoothedAltitude()[s-1])
|
|
||||||
smoothedVel = smoothed(alpha, vel, stream.SmoothedVelocity()[s-1])
|
|
||||||
smoothedPress = smoothed(alpha, press, stream.SmoothedPressure()[s-1])
|
|
||||||
smoothedTemp = smoothed(alpha, raw.Temperature, stream.SmoothedTemperature()[s-1])
|
|
||||||
smoothedVertAccel = (smoothedVel - stream.SmoothedVelocity()[s-1]) / (raw.Timestamp - stream.Time()[s-1])
|
|
||||||
}
|
|
||||||
|
|
||||||
computed := ComputedDataSegment{
|
|
||||||
Altitude: alt,
|
|
||||||
Velocity: vel,
|
|
||||||
Yaw: yaw(raw),
|
|
||||||
Pitch: pitch(raw),
|
|
||||||
Bearing: bearing(origin, raw),
|
|
||||||
Distance: distance(origin, raw),
|
|
||||||
DataRate: dataRate(stream),
|
|
||||||
SmoothedAltitude: smoothedAlt,
|
|
||||||
SmoothedVelocity: smoothedVel,
|
|
||||||
SmoothedPressure: smoothedPress,
|
|
||||||
SmoothedTemperature: smoothedTemp,
|
|
||||||
SmoothedVerticalAcceleration: smoothedVertAccel,
|
|
||||||
}
|
|
||||||
|
|
||||||
computed.FlightMode = determineFlightMode(stream, raw, computed)
|
|
||||||
|
|
||||||
return computed, bp, origin
|
|
||||||
}
|
|
||||||
|
@ -1,176 +0,0 @@
|
|||||||
package core
|
|
||||||
|
|
||||||
import (
|
|
||||||
"math"
|
|
||||||
"math/rand"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestBasePressureSet(t *testing.T) {
|
|
||||||
segments, avg := makeDataSeries(0)
|
|
||||||
b := basePressure(&FlightDataConcrete{
|
|
||||||
Base: 0,
|
|
||||||
Segments: segments,
|
|
||||||
OriginCoordinate: Coordinate{},
|
|
||||||
})
|
|
||||||
assert.Equal(t, b, avg)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAltitudeNoBase(t *testing.T) {
|
|
||||||
alt := altitude(0, RawDataSegment{
|
|
||||||
Pressure: rand.Float64(),
|
|
||||||
})
|
|
||||||
assert.Equal(t, alt, 0.0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAltitudeBase(t *testing.T) {
|
|
||||||
alt := altitude(1012, RawDataSegment{
|
|
||||||
Pressure: 1010,
|
|
||||||
})
|
|
||||||
assert.Equal(t, alt, 25868.260058108597)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNormalizedPressure(t *testing.T) {
|
|
||||||
p := rand.Float64() * 1000
|
|
||||||
v := normalizedPressure(RawDataSegment{Pressure: p})
|
|
||||||
assert.Equal(t, v, p/100)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestVelocity(t *testing.T) {
|
|
||||||
bp := 1012.0
|
|
||||||
segments, _ := makeDataSeries(bp)
|
|
||||||
val := (rand.Float64()*20 + 1000) * 100.0
|
|
||||||
seg := RawDataSegment{
|
|
||||||
Timestamp: float64(len(segments)),
|
|
||||||
Pressure: val,
|
|
||||||
}
|
|
||||||
vel := velocity(&FlightDataConcrete{
|
|
||||||
Base: 0,
|
|
||||||
Segments: segments,
|
|
||||||
OriginCoordinate: Coordinate{},
|
|
||||||
}, bp, seg)
|
|
||||||
vel1 := (altitude(bp, seg) - segments[len(segments)-1].Computed.Altitude) / (seg.Timestamp - segments[len(segments)-1].Raw.Timestamp)
|
|
||||||
assert.Equal(t, vel, vel1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestYaw(t *testing.T) {
|
|
||||||
val := yaw(RawDataSegment{
|
|
||||||
Acceleration: XYZ{
|
|
||||||
X: 100,
|
|
||||||
Y: 110,
|
|
||||||
Z: 120,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
assert.Equal(t, val, -39.80557109226519)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPitch(t *testing.T) {
|
|
||||||
val := pitch(RawDataSegment{
|
|
||||||
Acceleration: XYZ{
|
|
||||||
X: 100,
|
|
||||||
Y: 110,
|
|
||||||
Z: 120,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
assert.Equal(t, val, -42.51044707800084)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestToDegrees(t *testing.T) {
|
|
||||||
val := toDegrees(math.Pi)
|
|
||||||
assert.Equal(t, val, 180.0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestToRadians(t *testing.T) {
|
|
||||||
val := toRadians(90)
|
|
||||||
assert.Equal(t, val, math.Pi/2)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestBearing(t *testing.T) {
|
|
||||||
origin := Coordinate{
|
|
||||||
38.811423646113546,
|
|
||||||
-77.054951464077,
|
|
||||||
}
|
|
||||||
seg := RawDataSegment{
|
|
||||||
Coordinate: Coordinate{
|
|
||||||
38,
|
|
||||||
-77,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
b := bearing(origin, seg)
|
|
||||||
assert.Equal(t, b, 179.9862686631269)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDistance(t *testing.T) {
|
|
||||||
origin := Coordinate{
|
|
||||||
38.811423646113546,
|
|
||||||
-77.054951464077,
|
|
||||||
}
|
|
||||||
seg := RawDataSegment{
|
|
||||||
Coordinate: Coordinate{
|
|
||||||
38,
|
|
||||||
-77,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
b := distance(origin, seg)
|
|
||||||
assert.Equal(t, b, 90353.15173806295)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDataRate(t *testing.T) {
|
|
||||||
segments, _ := makeDataSeries(0)
|
|
||||||
rate := dataRate(&FlightDataConcrete{
|
|
||||||
Segments: segments,
|
|
||||||
})
|
|
||||||
assert.Equal(t, rate, 1.0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestComputeDataSegment(t *testing.T) {
|
|
||||||
segments, avg := makeDataSeries(0)
|
|
||||||
segment, bp, origin := ComputeDataSegment(&FlightDataConcrete{
|
|
||||||
Segments: segments,
|
|
||||||
OriginCoordinate: Coordinate{37, -76},
|
|
||||||
}, RawDataSegment{
|
|
||||||
WriteProgress: 1.0,
|
|
||||||
Timestamp: float64(len(segments) + 1),
|
|
||||||
Pressure: 1014.0,
|
|
||||||
Temperature: 30.0,
|
|
||||||
Acceleration: XYZ{1, 2, 3},
|
|
||||||
Magnetic: XYZ{1, 2, 3},
|
|
||||||
Coordinate: Coordinate{38, -77},
|
|
||||||
GPSInfo: GPSInfo{0.0, 0.0},
|
|
||||||
Rssi: 0,
|
|
||||||
})
|
|
||||||
assert.Equal(t, bp, avg)
|
|
||||||
assert.NotEqual(t, origin.Lat, 0.0)
|
|
||||||
assert.NotEqual(t, origin.Lon, 0.0)
|
|
||||||
assert.NotEqual(t, segment.Altitude, 0.0)
|
|
||||||
assert.NotEqual(t, segment.Velocity, 0.0)
|
|
||||||
assert.NotEqual(t, segment.Yaw, 0.0)
|
|
||||||
assert.NotEqual(t, segment.Pitch, 0.0)
|
|
||||||
assert.NotEqual(t, segment.Bearing, 0.0)
|
|
||||||
assert.NotEqual(t, segment.Distance, 0.0)
|
|
||||||
assert.NotEqual(t, segment.DataRate, 0.0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func makeDataSeries(bp float64) ([]DataSegment, float64) {
|
|
||||||
series := make([]DataSegment, 10)
|
|
||||||
total := 0.0
|
|
||||||
for i := 0; i < len(series); i++ {
|
|
||||||
val := rand.Float64()*20 + 1000
|
|
||||||
total += val
|
|
||||||
series[i] = DataSegment{
|
|
||||||
RawDataSegment{
|
|
||||||
Timestamp: float64(i),
|
|
||||||
Pressure: val * 100.0,
|
|
||||||
},
|
|
||||||
ComputedDataSegment{
|
|
||||||
Altitude: altitude(bp, RawDataSegment{
|
|
||||||
Pressure: val * 100.0,
|
|
||||||
}),
|
|
||||||
SmoothedPressure: val,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return series, total / float64(len(series))
|
|
||||||
}
|
|
@ -1,26 +1,25 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ModePrelaunch = "P"
|
ModeWaitingLaunch = "WT"
|
||||||
ModeAscentPowered = "AP"
|
ModeLaunch = "LD"
|
||||||
ModeAscentUnpowered = "AU"
|
ModeLowVelocity = "LV"
|
||||||
ModeDescentFreefall = "DF"
|
ModeNoseOver = "AP"
|
||||||
ModeDescentParachute = "DP"
|
ModeDrogueFired = "DR"
|
||||||
ModeRecovery = "R"
|
ModeMainFired = "MN"
|
||||||
)
|
ModeFailsafe = "FS"
|
||||||
|
ModeLanding = "TD"
|
||||||
const (
|
)
|
||||||
IndexTimestamp = 0
|
|
||||||
IndexPressure = 1
|
const (
|
||||||
IndexTemperature = 2
|
IndexFlightTime = 0
|
||||||
IndexAccelerationX = 3
|
IndexFightPhase = 1
|
||||||
IndexAccelerationY = 4
|
IndexAltitude = 2
|
||||||
IndexAccelerationZ = 5
|
IndexVelocity = 3
|
||||||
IndexMagneticX = 6
|
IndexAcceleration = 4
|
||||||
IndexMagneticY = 7
|
IndexTemperature = 5
|
||||||
IndexMagneticZ = 8
|
IndexCoordinateLat = 6
|
||||||
IndexCoordinateLat = 9
|
IndexCoordinateLon = 7
|
||||||
IndexCoordinateLon = 10
|
IndexGpsQuality = 8
|
||||||
IndexGpsQuality = 11
|
IndexGpsSats = 9
|
||||||
IndexGpsSats = 12
|
)
|
||||||
)
|
|
||||||
|
@ -1,85 +1,85 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
func NewFlightData() FlightDataConcrete {
|
func NewFlightData() FlightDataConcrete {
|
||||||
return FlightDataConcrete{0, make([]DataSegment, 0), Coordinate{}}
|
return FlightDataConcrete{0, make([]DataSegment, 0), Coordinate{}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FlightDataConcrete) AppendData(segments []DataSegment) {
|
func (f *FlightDataConcrete) AppendData(segments []DataSegment) {
|
||||||
f.Segments = append(f.Segments, segments...)
|
f.Segments = append(f.Segments, segments...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FlightDataConcrete) SetBasePressure(bp float64) {
|
func (f *FlightDataConcrete) SetBasePressure(bp float64) {
|
||||||
f.Base = bp
|
f.Base = bp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FlightDataConcrete) SetOrigin(coord Coordinate) {
|
func (f *FlightDataConcrete) SetOrigin(coord Coordinate) {
|
||||||
f.OriginCoordinate = coord
|
f.OriginCoordinate = coord
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FlightDataConcrete) AllSegments() []DataSegment {
|
func (f *FlightDataConcrete) AllSegments() []DataSegment {
|
||||||
return f.Segments
|
return f.Segments
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FlightDataConcrete) BasePressure() float64 {
|
func (f *FlightDataConcrete) BasePressure() float64 {
|
||||||
return f.Base
|
return f.Base
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FlightDataConcrete) SmoothedAltitude() []float64 {
|
func (f *FlightDataConcrete) SmoothedAltitude() []float64 {
|
||||||
return singleFlightDataElement(f, func(segment DataSegment) float64 {
|
return singleFlightDataElement(f, func(segment DataSegment) float64 {
|
||||||
return segment.Computed.SmoothedAltitude
|
return segment.Computed.SmoothedAltitude
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FlightDataConcrete) SmoothedVelocity() []float64 {
|
func (f *FlightDataConcrete) SmoothedVelocity() []float64 {
|
||||||
return singleFlightDataElement(f, func(segment DataSegment) float64 {
|
return singleFlightDataElement(f, func(segment DataSegment) float64 {
|
||||||
return segment.Computed.SmoothedVelocity
|
return segment.Computed.SmoothedVelocity
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FlightDataConcrete) SmoothedTemperature() []float64 {
|
func (f *FlightDataConcrete) SmoothedTemperature() []float64 {
|
||||||
return singleFlightDataElement(f, func(segment DataSegment) float64 {
|
return singleFlightDataElement(f, func(segment DataSegment) float64 {
|
||||||
return segment.Computed.SmoothedTemperature
|
return segment.Computed.SmoothedTemperature
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FlightDataConcrete) SmoothedPressure() []float64 {
|
func (f *FlightDataConcrete) SmoothedPressure() []float64 {
|
||||||
return singleFlightDataElement(f, func(segment DataSegment) float64 {
|
return singleFlightDataElement(f, func(segment DataSegment) float64 {
|
||||||
return segment.Computed.SmoothedPressure
|
return segment.Computed.SmoothedPressure
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FlightDataConcrete) GpsQuality() []float64 {
|
func (f *FlightDataConcrete) GpsQuality() []float64 {
|
||||||
return singleFlightDataElement(f, func(segment DataSegment) float64 {
|
return singleFlightDataElement(f, func(segment DataSegment) float64 {
|
||||||
return segment.Raw.GPSInfo.Quality
|
return segment.Raw.GPSInfo.Quality
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FlightDataConcrete) GpsSats() []float64 {
|
func (f *FlightDataConcrete) GpsSats() []float64 {
|
||||||
return singleFlightDataElement(f, func(segment DataSegment) float64 {
|
return singleFlightDataElement(f, func(segment DataSegment) float64 {
|
||||||
return segment.Raw.GPSInfo.Sats
|
return segment.Raw.GPSInfo.Sats
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FlightDataConcrete) Time() []float64 {
|
func (f *FlightDataConcrete) Time() []float64 {
|
||||||
return singleFlightDataElement(f, func(segment DataSegment) float64 {
|
return singleFlightDataElement(f, func(segment DataSegment) float64 {
|
||||||
return segment.Raw.Timestamp
|
return 0.0
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FlightDataConcrete) Rssi() []float64 {
|
func (f *FlightDataConcrete) Rssi() []float64 {
|
||||||
return singleFlightDataElement(f, func(segment DataSegment) float64 {
|
return singleFlightDataElement(f, func(segment DataSegment) float64 {
|
||||||
return float64(segment.Raw.Rssi)
|
return float64(segment.Raw.Rssi)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FlightDataConcrete) Origin() Coordinate {
|
func (f *FlightDataConcrete) Origin() Coordinate {
|
||||||
return f.OriginCoordinate
|
return f.OriginCoordinate
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FlightDataConcrete) FlightModes() []FlightMode {
|
func (f *FlightDataConcrete) FlightModes() []FlightMode {
|
||||||
data := make([]FlightMode, len(f.AllSegments()))
|
data := make([]FlightMode, len(f.AllSegments()))
|
||||||
for i, segment := range f.AllSegments() {
|
for i, segment := range f.AllSegments() {
|
||||||
data[i] = segment.Computed.FlightMode
|
data[i] = segment.Computed.FlightMode
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
module core
|
module core
|
||||||
|
|
||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require github.com/stretchr/testify v1.7.0
|
require github.com/stretchr/testify v1.7.0
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
@ -1,77 +1,77 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
type FlightMode string
|
type FlightMode string
|
||||||
|
|
||||||
type Coordinate struct {
|
type Coordinate struct {
|
||||||
Lat float64 `json:"lat"`
|
Lat float64 `json:"lat"`
|
||||||
Lon float64 `json:"lon"`
|
Lon float64 `json:"lon"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GPSInfo struct {
|
type GPSInfo struct {
|
||||||
Quality float64 `json:"quality"`
|
Quality float64 `json:"quality"`
|
||||||
Sats float64 `json:"sats"`
|
Sats float64 `json:"sats"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type XYZ struct {
|
type XYZ struct {
|
||||||
X float64 `json:"x"`
|
X float64 `json:"x"`
|
||||||
Y float64 `json:"y"`
|
Y float64 `json:"y"`
|
||||||
Z float64 `json:"z"`
|
Z float64 `json:"z"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RawDataSegment struct {
|
type RawDataSegment struct {
|
||||||
WriteProgress float64 `json:"writeProgress"`
|
FlightTime float64 `json:"flightTime"`
|
||||||
Timestamp float64 `json:"timestamp"`
|
FlightPhase float64 `json:"flightPhase"`
|
||||||
Pressure float64 `json:"pressure"`
|
Altitude float64 `json:"altitude"`
|
||||||
Temperature float64 `json:"temperature"`
|
Velocity float64 `json:"velocity"`
|
||||||
Acceleration XYZ `json:"acceleration"`
|
Acceleration float64 `json:"accelereation"`
|
||||||
Magnetic XYZ `json:"magnetic"`
|
Temperature float64 `json:"temperature"`
|
||||||
Coordinate Coordinate `json:"coordinate"`
|
Coordinate Coordinate `json:"coordinate"`
|
||||||
GPSInfo GPSInfo `json:"gpsInfo"`
|
GPSInfo GPSInfo `json:"gpsInfo"`
|
||||||
Rssi int16 `json:"rssi"`
|
Rssi int16 `json:"rssi"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ComputedDataSegment struct {
|
type ComputedDataSegment struct {
|
||||||
Altitude float64 `json:"altitude"`
|
Altitude float64 `json:"altitude"`
|
||||||
Velocity float64 `json:"velocity"`
|
Velocity float64 `json:"velocity"`
|
||||||
SmoothedVerticalAcceleration float64 `json:"smoothedVerticalAcceleration"`
|
SmoothedVerticalAcceleration float64 `json:"smoothedVerticalAcceleration"`
|
||||||
Yaw float64 `json:"yaw"`
|
Yaw float64 `json:"yaw"`
|
||||||
Pitch float64 `json:"pitch"`
|
Pitch float64 `json:"pitch"`
|
||||||
Bearing float64 `json:"bearing"`
|
Bearing float64 `json:"bearing"`
|
||||||
Distance float64 `json:"distance"`
|
Distance float64 `json:"distance"`
|
||||||
DataRate float64 `json:"dataRate"`
|
DataRate float64 `json:"dataRate"`
|
||||||
SmoothedAltitude float64 `json:"smoothedAltitude"`
|
SmoothedAltitude float64 `json:"smoothedAltitude"`
|
||||||
SmoothedVelocity float64 `json:"smoothedVelocity"`
|
SmoothedVelocity float64 `json:"smoothedVelocity"`
|
||||||
SmoothedPressure float64 `json:"smoothedPressure"`
|
SmoothedPressure float64 `json:"smoothedPressure"`
|
||||||
SmoothedTemperature float64 `json:"smoothedTemperature"`
|
SmoothedTemperature float64 `json:"smoothedTemperature"`
|
||||||
FlightMode FlightMode `json:"flightMode"`
|
FlightMode FlightMode `json:"flightMode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DataSegment struct {
|
type DataSegment struct {
|
||||||
Raw RawDataSegment `json:"raw"`
|
Raw RawDataSegment `json:"raw"`
|
||||||
Computed ComputedDataSegment `json:"computed"`
|
Computed ComputedDataSegment `json:"computed"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FlightDataConcrete struct {
|
type FlightDataConcrete struct {
|
||||||
Base float64
|
Base float64
|
||||||
Segments []DataSegment
|
Segments []DataSegment
|
||||||
OriginCoordinate Coordinate
|
OriginCoordinate Coordinate
|
||||||
}
|
}
|
||||||
|
|
||||||
type FlightData interface {
|
type FlightData interface {
|
||||||
// IngestNewSegment(bytes []byte) ([]DataSegment, error)
|
// IngestNewSegment(bytes []byte) ([]DataSegment, error)
|
||||||
AppendData(segments []DataSegment)
|
AppendData(segments []DataSegment)
|
||||||
SetBasePressure(bp float64)
|
SetBasePressure(bp float64)
|
||||||
SetOrigin(coord Coordinate)
|
SetOrigin(coord Coordinate)
|
||||||
AllSegments() []DataSegment
|
AllSegments() []DataSegment
|
||||||
BasePressure() float64
|
BasePressure() float64
|
||||||
Origin() Coordinate
|
Origin() Coordinate
|
||||||
Time() []float64
|
Time() []float64
|
||||||
SmoothedAltitude() []float64
|
SmoothedAltitude() []float64
|
||||||
SmoothedVelocity() []float64
|
SmoothedVelocity() []float64
|
||||||
SmoothedTemperature() []float64
|
SmoothedTemperature() []float64
|
||||||
SmoothedPressure() []float64
|
SmoothedPressure() []float64
|
||||||
GpsQuality() []float64
|
GpsQuality() []float64
|
||||||
GpsSats() []float64
|
GpsSats() []float64
|
||||||
Rssi() []float64
|
Rssi() []float64
|
||||||
FlightModes() []FlightMode
|
FlightModes() []FlightMode
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import "math"
|
import "math"
|
||||||
|
|
||||||
func singleFlightDataElement(ds FlightData, accessor func(DataSegment) float64) []float64 {
|
func singleFlightDataElement(ds FlightData, accessor func(DataSegment) float64) []float64 {
|
||||||
data := make([]float64, len(ds.AllSegments()))
|
data := make([]float64, len(ds.AllSegments()))
|
||||||
for i, segment := range ds.AllSegments() {
|
for i, segment := range ds.AllSegments() {
|
||||||
data[i] = accessor(segment)
|
data[i] = accessor(segment)
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
func smoothed(alpha float64, xt float64, stm1 float64) float64 {
|
func smoothed(alpha float64, xt float64, stm1 float64) float64 {
|
||||||
return alpha*xt + (1-alpha)*stm1
|
return alpha*xt + (1-alpha)*stm1
|
||||||
}
|
}
|
||||||
|
|
||||||
func nanSafe(val float64) float64 {
|
func nanSafe(val float64) float64 {
|
||||||
if math.IsNaN(val) {
|
if math.IsNaN(val) {
|
||||||
return 0.0
|
return 0.0
|
||||||
}
|
}
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
.PHONY: generate_test_data run
|
.PHONY: generate_test_data run
|
||||||
|
|
||||||
OS=$(shell uname)
|
OS=$(shell uname)
|
||||||
ARCH=$(shell arch)
|
ARCH=$(shell arch)
|
||||||
|
|
||||||
install:
|
install:
|
||||||
go get ./...
|
go get ./...
|
||||||
go get -t ./...
|
go get -t ./...
|
||||||
|
|
||||||
run:
|
run:
|
||||||
go run . $(source)
|
go run . $(source)
|
||||||
|
|
||||||
build:
|
build:
|
||||||
go build -o build/white-vest-dashboard-$(OS)-$(ARCH) .
|
go build -o build/white-vest-dashboard-$(OS)-$(ARCH) .
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go test .
|
go test .
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf build
|
rm -rf build
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PointsPerDataFrame = 2
|
PointsPerDataFrame = 1
|
||||||
)
|
)
|
||||||
|
@ -1,78 +1,78 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jacobsa/go-serial/serial"
|
"github.com/jacobsa/go-serial/serial"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DataProvider / DataProviderFile
|
// DataProvider / DataProviderFile
|
||||||
|
|
||||||
func NewDataProviderFile(path string) (DataProvider, error) {
|
func NewDataProviderFile(path string) (DataProvider, error) {
|
||||||
fileBytes, err := ioutil.ReadFile(path)
|
fileBytes, err := ioutil.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
dsBytes := make([][]byte, 0)
|
dsBytes := make([][]byte, 0)
|
||||||
rangeStart := 0
|
rangeStart := 0
|
||||||
for i, b := range fileBytes {
|
for i, b := range fileBytes {
|
||||||
if b == '\n' {
|
if b == '\n' {
|
||||||
segment := fileBytes[rangeStart:i]
|
segment := fileBytes[rangeStart:i]
|
||||||
dsBytes = append(dsBytes, segment)
|
dsBytes = append(dsBytes, segment)
|
||||||
rangeStart = i + 1
|
rangeStart = i + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return DataProviderFile{dsBytes}, nil
|
return DataProviderFile{dsBytes}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f DataProviderFile) Stream() <-chan []byte {
|
func (f DataProviderFile) Stream() <-chan []byte {
|
||||||
channel := make(chan []byte, 256)
|
channel := make(chan []byte, 256)
|
||||||
go func() {
|
go func() {
|
||||||
lastLine := 0
|
lastLine := 0
|
||||||
for {
|
for {
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
if lastLine >= len(f.Bytes) {
|
if lastLine >= len(f.Bytes) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
channel <- f.Bytes[lastLine]
|
channel <- f.Bytes[lastLine]
|
||||||
lastLine += 1
|
lastLine += 1
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return channel
|
return channel
|
||||||
}
|
}
|
||||||
|
|
||||||
// DataProvider / DataProviderSerial
|
// DataProvider / DataProviderSerial
|
||||||
|
|
||||||
func NewDataProviderSerial(input string, speed uint) (DataProviderSerial, error) {
|
func NewDataProviderSerial(input string, speed uint) (DataProviderSerial, error) {
|
||||||
options := serial.OpenOptions{
|
options := serial.OpenOptions{
|
||||||
PortName: input,
|
PortName: input,
|
||||||
BaudRate: speed,
|
BaudRate: speed,
|
||||||
DataBits: 8,
|
DataBits: 8,
|
||||||
StopBits: 1,
|
StopBits: 1,
|
||||||
MinimumReadSize: 4,
|
MinimumReadSize: 4,
|
||||||
}
|
}
|
||||||
port, err := serial.Open(options)
|
port, err := serial.Open(options)
|
||||||
return DataProviderSerial{port}, err
|
return DataProviderSerial{port}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f DataProviderSerial) Stream() <-chan []byte {
|
func (f DataProviderSerial) Stream() <-chan []byte {
|
||||||
channel := make(chan []byte, 256)
|
channel := make(chan []byte, 256)
|
||||||
go func() {
|
go func() {
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
for {
|
for {
|
||||||
readBytes := make([]byte, 1024)
|
readBytes := make([]byte, 1024)
|
||||||
n, _ := f.Port.Read(readBytes)
|
n, _ := f.Port.Read(readBytes)
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
if readBytes[i] == '\n' {
|
if readBytes[i] == '\n' {
|
||||||
channel <- buffer.Bytes()
|
channel <- buffer.Bytes()
|
||||||
buffer = *bytes.NewBuffer([]byte{})
|
buffer = *bytes.NewBuffer([]byte{})
|
||||||
} else {
|
} else {
|
||||||
buffer.WriteByte(readBytes[i])
|
buffer.WriteByte(readBytes[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return channel
|
return channel
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/gizak/termui/v3 v3.1.0 h1:ZZmVDgwHl7gR7elfKf1xc4IudXZ5qqfDh4wExk4Iajc=
|
github.com/gizak/termui/v3 v3.1.0 h1:ZZmVDgwHl7gR7elfKf1xc4IudXZ5qqfDh4wExk4Iajc=
|
||||||
github.com/gizak/termui/v3 v3.1.0/go.mod h1:bXQEBkJpzxUAKf0+xq9MSWAvWZlE7c+aidmyFlkYTrY=
|
github.com/gizak/termui/v3 v3.1.0/go.mod h1:bXQEBkJpzxUAKf0+xq9MSWAvWZlE7c+aidmyFlkYTrY=
|
||||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/jacobsa/go-serial v0.0.0-20180131005756-15cf729a72d4 h1:G2ztCwXov8mRvP0ZfjE6nAlaCX2XbykaeHdbT6KwDz0=
|
github.com/jacobsa/go-serial v0.0.0-20180131005756-15cf729a72d4 h1:G2ztCwXov8mRvP0ZfjE6nAlaCX2XbykaeHdbT6KwDz0=
|
||||||
github.com/jacobsa/go-serial v0.0.0-20180131005756-15cf729a72d4/go.mod h1:2RvX5ZjVtsznNZPEt4xwJXNJrM3VTZoQf7V6gk0ysvs=
|
github.com/jacobsa/go-serial v0.0.0-20180131005756-15cf729a72d4/go.mod h1:2RvX5ZjVtsznNZPEt4xwJXNJrM3VTZoQf7V6gk0ysvs=
|
||||||
github.com/mattn/go-runewidth v0.0.2 h1:UnlwIPBGaTZfPQ6T1IGzPI0EkYAQmT9fAEJ/poFC63o=
|
github.com/mattn/go-runewidth v0.0.2 h1:UnlwIPBGaTZfPQ6T1IGzPI0EkYAQmT9fAEJ/poFC63o=
|
||||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM=
|
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM=
|
||||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
|
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
|
||||||
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d h1:x3S6kxmy49zXVVyhcnrFqxvNVCBPb2KZ9hV2RBdS840=
|
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d h1:x3S6kxmy49zXVVyhcnrFqxvNVCBPb2KZ9hV2RBdS840=
|
||||||
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
|
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyXrprv2+DKfkJY+2LJJw=
|
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyXrprv2+DKfkJY+2LJJw=
|
||||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
@ -1,73 +1,73 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSegmentToString(ds core.DataSegment) string {
|
func dataSegmentToString(ds core.DataSegment) string {
|
||||||
bytes, err := json.Marshal(ds)
|
bytes, err := json.Marshal(ds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
} else {
|
} else {
|
||||||
return string(bytes)
|
return string(bytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateLogFilePath() (string, error) {
|
func generateLogFilePath() (string, error) {
|
||||||
dirname, err := os.UserHomeDir()
|
dirname, err := os.UserHomeDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
tstamp := time.Now().Unix()
|
tstamp := time.Now().Unix()
|
||||||
filename := fmt.Sprintf("whitevest_%d.log", tstamp)
|
filename := fmt.Sprintf("whitevest_%d.log", tstamp)
|
||||||
return path.Join(dirname, filename), nil
|
return path.Join(dirname, filename), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLogger() LoggerControl {
|
func NewLogger() LoggerControl {
|
||||||
logger := Logger{
|
logger := Logger{
|
||||||
DataChannel: make(chan core.DataSegment, 100),
|
DataChannel: make(chan core.DataSegment, 100),
|
||||||
ContinueRunning: true,
|
ContinueRunning: true,
|
||||||
Mutex: sync.Mutex{},
|
Mutex: sync.Mutex{},
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
logPath, err := generateLogFilePath()
|
logPath, err := generateLogFilePath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
file, err := os.Create(logPath)
|
file, err := os.Create(logPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
for {
|
for {
|
||||||
ds := <-logger.DataChannel
|
ds := <-logger.DataChannel
|
||||||
_, err = file.WriteString(dataSegmentToString(ds))
|
_, err = file.WriteString(dataSegmentToString(ds))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
logger.Mutex.Lock()
|
logger.Mutex.Lock()
|
||||||
if !logger.ContinueRunning {
|
if !logger.ContinueRunning {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logger.Mutex.Unlock()
|
logger.Mutex.Unlock()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return &logger
|
return &logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Logger) Kill() {
|
func (l *Logger) Kill() {
|
||||||
l.Mutex.Lock()
|
l.Mutex.Lock()
|
||||||
l.ContinueRunning = false
|
l.ContinueRunning = false
|
||||||
l.Mutex.Unlock()
|
l.Mutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Logger) Log(ds core.DataSegment) {
|
func (l *Logger) Log(ds core.DataSegment) {
|
||||||
l.DataChannel <- ds
|
l.DataChannel <- ds
|
||||||
}
|
}
|
||||||
|
@ -1,47 +1,47 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
OUTPUT_TYPE_TEXT = "text"
|
OUTPUT_TYPE_TEXT = "text"
|
||||||
OUTPUT_TYPE_WEB = "web"
|
OUTPUT_TYPE_WEB = "web"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var input = flag.String("input", "", "input (file or device)")
|
var input = flag.String("input", "", "input (file or device)")
|
||||||
var output = flag.String("output", OUTPUT_TYPE_WEB, "output style (web, text)")
|
var output = flag.String("output", OUTPUT_TYPE_WEB, "output style (web, text)")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
var provider DataProvider
|
var provider DataProvider
|
||||||
var err error
|
var err error
|
||||||
if *input == "" {
|
if *input == "" {
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
return
|
return
|
||||||
} else if strings.HasPrefix(*input, "/dev/") {
|
} else if strings.HasPrefix(*input, "/dev/") {
|
||||||
var providerSerial DataProviderSerial
|
var providerSerial DataProviderSerial
|
||||||
providerSerial, err = NewDataProviderSerial(*input, 9600)
|
providerSerial, err = NewDataProviderSerial(*input, 9600)
|
||||||
provider = providerSerial
|
provider = providerSerial
|
||||||
} else {
|
} else {
|
||||||
provider, err = NewDataProviderFile(*input)
|
provider, err = NewDataProviderFile(*input)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
df := core.NewFlightData()
|
df := core.NewFlightData()
|
||||||
logger := NewLogger()
|
logger := NewLogger()
|
||||||
defer logger.Kill()
|
defer logger.Kill()
|
||||||
switch *output {
|
switch *output {
|
||||||
case OUTPUT_TYPE_TEXT:
|
case OUTPUT_TYPE_TEXT:
|
||||||
err = StartTextLogger(provider, &df, logger)
|
err = StartTextLogger(provider, &df, logger)
|
||||||
case OUTPUT_TYPE_WEB:
|
case OUTPUT_TYPE_WEB:
|
||||||
err = StartWeb(provider, &df, logger)
|
err = StartWeb(provider, &df, logger)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,233 +1,227 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
ui "github.com/gizak/termui/v3"
|
ui "github.com/gizak/termui/v3"
|
||||||
"github.com/gizak/termui/v3/widgets"
|
"github.com/gizak/termui/v3/widgets"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
const SecondsWindow = 20
|
const SecondsWindow = 20
|
||||||
|
|
||||||
//go:embed static/**
|
//go:embed static/**
|
||||||
var static embed.FS
|
var static embed.FS
|
||||||
|
|
||||||
type staticFS struct {
|
type staticFS struct {
|
||||||
content embed.FS
|
content embed.FS
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c staticFS) Open(name string) (fs.File, error) {
|
func (c staticFS) Open(name string) (fs.File, error) {
|
||||||
return c.content.Open(path.Join("static", name))
|
return c.content.Open(path.Join("static", name))
|
||||||
}
|
}
|
||||||
|
|
||||||
func StartTextLogger(p DataProvider, ds core.FlightData, logger LoggerControl) error {
|
func StartTextLogger(p DataProvider, ds core.FlightData, logger LoggerControl) error {
|
||||||
if err := ui.Init(); err != nil {
|
if err := ui.Init(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer ui.Close()
|
defer ui.Close()
|
||||||
|
|
||||||
headers := []string{
|
headers := []string{
|
||||||
"Time",
|
"Time",
|
||||||
"Prog",
|
"Phase",
|
||||||
"Pressure",
|
"Altitude",
|
||||||
"Temp",
|
"Velocity",
|
||||||
"Accel X",
|
"Acceleration",
|
||||||
"Accel Y",
|
"Temperature",
|
||||||
"Accel Z",
|
"Latitude",
|
||||||
"Mag X",
|
"longitude",
|
||||||
"Mag Y",
|
"GPS Quality",
|
||||||
"Mag Z",
|
"GPS Sats",
|
||||||
"Lat",
|
"Qual",
|
||||||
"Lon",
|
"RSSI",
|
||||||
"Sats",
|
}
|
||||||
"Qual",
|
|
||||||
"RSSI",
|
grid := ui.NewGrid()
|
||||||
}
|
termWidth, termHeight := ui.TerminalDimensions()
|
||||||
|
grid.SetRect(0, 0, termWidth, termHeight)
|
||||||
grid := ui.NewGrid()
|
|
||||||
termWidth, termHeight := ui.TerminalDimensions()
|
table := widgets.NewTable()
|
||||||
grid.SetRect(0, 0, termWidth, termHeight)
|
table.Title = "Data Stream"
|
||||||
|
table.Rows = [][]string{headers}
|
||||||
table := widgets.NewTable()
|
|
||||||
table.Title = "Data Stream"
|
errorsui := widgets.NewList()
|
||||||
table.Rows = [][]string{headers}
|
errorsui.Title = "Errors"
|
||||||
|
errorsui.Rows = []string{}
|
||||||
errorsui := widgets.NewList()
|
errorsui.WrapText = false
|
||||||
errorsui.Title = "Errors"
|
errorsList := make([]error, 0)
|
||||||
errorsui.Rows = []string{}
|
|
||||||
errorsui.WrapText = false
|
grid.Set(
|
||||||
errorsList := make([]error, 0)
|
ui.NewRow(0.8,
|
||||||
|
ui.NewCol(1.0, table),
|
||||||
grid.Set(
|
),
|
||||||
ui.NewRow(0.8,
|
ui.NewRow(0.2,
|
||||||
ui.NewCol(1.0, table),
|
ui.NewCol(1.0, errorsui),
|
||||||
),
|
),
|
||||||
ui.NewRow(0.2,
|
)
|
||||||
ui.NewCol(1.0, errorsui),
|
|
||||||
),
|
uiEvents := ui.PollEvents()
|
||||||
)
|
streamChannel := p.Stream()
|
||||||
|
|
||||||
uiEvents := ui.PollEvents()
|
renderTable := func() {
|
||||||
streamChannel := p.Stream()
|
data := ds.AllSegments()
|
||||||
|
|
||||||
renderTable := func() {
|
if len(data) == 0 {
|
||||||
data := ds.AllSegments()
|
ui.Render(grid)
|
||||||
|
return
|
||||||
if len(data) == 0 {
|
}
|
||||||
ui.Render(grid)
|
nRows := (table.Inner.Dy() + 1) / 2
|
||||||
return
|
if nRows <= 0 {
|
||||||
}
|
nRows = 10
|
||||||
nRows := (table.Inner.Dy() + 1) / 2
|
}
|
||||||
if nRows <= 0 {
|
if nRows > len(data)+1 {
|
||||||
nRows = 10
|
nRows = len(data) + 1
|
||||||
}
|
}
|
||||||
if nRows > len(data)+1 {
|
rows := make([][]string, nRows)
|
||||||
nRows = len(data) + 1
|
rows[0] = headers
|
||||||
}
|
for i := 0; i < nRows-1; i++ {
|
||||||
rows := make([][]string, nRows)
|
j := len(data) - nRows + 1 + i
|
||||||
rows[0] = headers
|
seg := data[j]
|
||||||
for i := 0; i < nRows-1; i++ {
|
rows[i+1] = []string{
|
||||||
j := len(data) - nRows + 1 + i
|
fmt.Sprintf("%0.2f", seg.Raw.FlightTime),
|
||||||
seg := data[j]
|
fmt.Sprintf("%0.2f", seg.Raw.FlightPhase),
|
||||||
rows[i+1] = []string{
|
fmt.Sprintf("%0.2f", seg.Raw.Altitude),
|
||||||
fmt.Sprintf("%0.2f", seg.Raw.Timestamp),
|
fmt.Sprintf("%0.2f", seg.Raw.Velocity),
|
||||||
fmt.Sprintf("%0.2f", seg.Raw.WriteProgress),
|
fmt.Sprintf("%0.2f", seg.Raw.Acceleration),
|
||||||
fmt.Sprintf("%0.2f", seg.Raw.Pressure),
|
fmt.Sprintf("%0.2f", seg.Raw.Temperature),
|
||||||
fmt.Sprintf("%0.2f", seg.Raw.Temperature),
|
fmt.Sprintf("%0.2f", seg.Raw.Coordinate.Lat),
|
||||||
fmt.Sprintf("%0.2f", seg.Raw.Acceleration.X),
|
fmt.Sprintf("%0.2f", seg.Raw.Coordinate.Lon),
|
||||||
fmt.Sprintf("%0.2f", seg.Raw.Acceleration.Y),
|
fmt.Sprintf("%0.2f", seg.Raw.GPSInfo.Sats),
|
||||||
fmt.Sprintf("%0.2f", seg.Raw.Acceleration.Z),
|
fmt.Sprintf("%0.2f", seg.Raw.GPSInfo.Quality),
|
||||||
fmt.Sprintf("%0.2f", seg.Raw.Magnetic.X),
|
fmt.Sprintf("%d", seg.Raw.Rssi),
|
||||||
fmt.Sprintf("%0.2f", seg.Raw.Magnetic.Y),
|
}
|
||||||
fmt.Sprintf("%0.2f", seg.Raw.Magnetic.Z),
|
}
|
||||||
fmt.Sprintf("%0.2f", seg.Raw.Coordinate.Lat),
|
table.Rows = rows
|
||||||
fmt.Sprintf("%0.2f", seg.Raw.Coordinate.Lon),
|
ui.Render(grid)
|
||||||
fmt.Sprintf("%0.2f", seg.Raw.GPSInfo.Sats),
|
}
|
||||||
fmt.Sprintf("%0.2f", seg.Raw.GPSInfo.Quality),
|
|
||||||
fmt.Sprintf("%d", seg.Raw.Rssi),
|
renderErrors := func() {
|
||||||
}
|
if len(errorsList) == 0 {
|
||||||
}
|
ui.Render(grid)
|
||||||
table.Rows = rows
|
return
|
||||||
ui.Render(grid)
|
}
|
||||||
}
|
|
||||||
|
nRows := errorsui.Inner.Dy()
|
||||||
renderErrors := func() {
|
if nRows <= 0 {
|
||||||
if len(errorsList) == 0 {
|
nRows = 10
|
||||||
ui.Render(grid)
|
}
|
||||||
return
|
if nRows > len(errorsList) {
|
||||||
}
|
nRows = len(errorsList)
|
||||||
|
}
|
||||||
nRows := errorsui.Inner.Dy()
|
rows := make([]string, nRows)
|
||||||
if nRows <= 0 {
|
for i := 0; i < nRows; i++ {
|
||||||
nRows = 10
|
j := len(errorsList) - nRows + i
|
||||||
}
|
rows[i] = fmt.Sprint(errorsList[j])
|
||||||
if nRows > len(errorsList) {
|
}
|
||||||
nRows = len(errorsList)
|
errorsui.Rows = rows
|
||||||
}
|
|
||||||
rows := make([]string, nRows)
|
ui.Render(grid)
|
||||||
for i := 0; i < nRows; i++ {
|
}
|
||||||
j := len(errorsList) - nRows + i
|
|
||||||
rows[i] = fmt.Sprint(errorsList[j])
|
renderTable()
|
||||||
}
|
|
||||||
errorsui.Rows = rows
|
for {
|
||||||
|
select {
|
||||||
ui.Render(grid)
|
case e := <-uiEvents:
|
||||||
}
|
switch e.ID {
|
||||||
|
case "q", "<C-c>":
|
||||||
renderTable()
|
return nil
|
||||||
|
}
|
||||||
for {
|
case bytes := <-streamChannel:
|
||||||
select {
|
latestSegments, basePressure, origin, err := bytesToDataSegment(ds, bytes)
|
||||||
case e := <-uiEvents:
|
if err != nil {
|
||||||
switch e.ID {
|
errorsList = append(errorsList, err)
|
||||||
case "q", "<C-c>":
|
renderErrors()
|
||||||
return nil
|
} else {
|
||||||
}
|
ds.AppendData(latestSegments)
|
||||||
case bytes := <-streamChannel:
|
ds.SetBasePressure(basePressure)
|
||||||
latestSegments, basePressure, origin, err := bytesToDataSegment(ds, bytes)
|
ds.SetOrigin(origin)
|
||||||
if err != nil {
|
renderTable()
|
||||||
errorsList = append(errorsList, err)
|
for _, seg := range latestSegments {
|
||||||
renderErrors()
|
logger.Log(seg)
|
||||||
} else {
|
}
|
||||||
ds.AppendData(latestSegments)
|
}
|
||||||
ds.SetBasePressure(basePressure)
|
}
|
||||||
ds.SetOrigin(origin)
|
}
|
||||||
renderTable()
|
}
|
||||||
for _, seg := range latestSegments {
|
|
||||||
logger.Log(seg)
|
func StartWeb(p DataProvider, ds core.FlightData, logger LoggerControl) error {
|
||||||
}
|
var mutex sync.Mutex
|
||||||
}
|
var upgrader = websocket.Upgrader{}
|
||||||
}
|
http.HandleFunc("/api/data", func(w http.ResponseWriter, req *http.Request) {
|
||||||
}
|
c, err := upgrader.Upgrade(w, req, nil)
|
||||||
}
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
func StartWeb(p DataProvider, ds core.FlightData, logger LoggerControl) error {
|
return
|
||||||
var mutex sync.Mutex
|
}
|
||||||
var upgrader = websocket.Upgrader{}
|
defer c.Close()
|
||||||
http.HandleFunc("/api/data", func(w http.ResponseWriter, req *http.Request) {
|
mutex.Lock()
|
||||||
c, err := upgrader.Upgrade(w, req, nil)
|
data := ds.AllSegments()
|
||||||
if err != nil {
|
lastLength := len(data)
|
||||||
fmt.Println(err)
|
err = c.WriteJSON(data)
|
||||||
return
|
mutex.Unlock()
|
||||||
}
|
if err != nil {
|
||||||
defer c.Close()
|
fmt.Println(err)
|
||||||
mutex.Lock()
|
return
|
||||||
data := ds.AllSegments()
|
}
|
||||||
lastLength := len(data)
|
for {
|
||||||
err = c.WriteJSON(data)
|
mutex.Lock()
|
||||||
mutex.Unlock()
|
data = ds.AllSegments()
|
||||||
if err != nil {
|
if len(data) > lastLength {
|
||||||
fmt.Println(err)
|
err = c.WriteJSON(data[lastLength:])
|
||||||
return
|
if err != nil {
|
||||||
}
|
fmt.Println(err)
|
||||||
for {
|
mutex.Unlock()
|
||||||
mutex.Lock()
|
return
|
||||||
data = ds.AllSegments()
|
}
|
||||||
if len(data) > lastLength {
|
lastLength = len(data)
|
||||||
err = c.WriteJSON(data[lastLength:])
|
}
|
||||||
if err != nil {
|
mutex.Unlock()
|
||||||
fmt.Println(err)
|
time.Sleep(1 * time.Second)
|
||||||
mutex.Unlock()
|
}
|
||||||
return
|
})
|
||||||
}
|
if os.Getenv("DEV_MODE") == "" {
|
||||||
lastLength = len(data)
|
http.Handle("/", http.FileServer(http.FS(staticFS{static})))
|
||||||
}
|
} else {
|
||||||
mutex.Unlock()
|
http.Handle("/", http.FileServer(http.Dir("dashboard/static")))
|
||||||
time.Sleep(1 * time.Second)
|
}
|
||||||
}
|
go func() {
|
||||||
})
|
streamChannel := p.Stream()
|
||||||
if os.Getenv("DEV_MODE") == "" {
|
for {
|
||||||
http.Handle("/", http.FileServer(http.FS(staticFS{static})))
|
bytes := <-streamChannel
|
||||||
} else {
|
latestSegments, basePressure, origin, err := bytesToDataSegment(ds, bytes)
|
||||||
http.Handle("/", http.FileServer(http.Dir("dashboard/static")))
|
if err != nil {
|
||||||
}
|
fmt.Println(err)
|
||||||
go func() {
|
} else {
|
||||||
streamChannel := p.Stream()
|
mutex.Lock()
|
||||||
for {
|
ds.AppendData(latestSegments)
|
||||||
bytes := <-streamChannel
|
ds.SetBasePressure(basePressure)
|
||||||
latestSegments, basePressure, origin, err := bytesToDataSegment(ds, bytes)
|
ds.SetOrigin(origin)
|
||||||
if err != nil {
|
mutex.Unlock()
|
||||||
fmt.Println(err)
|
for _, seg := range latestSegments {
|
||||||
} else {
|
logger.Log(seg)
|
||||||
mutex.Lock()
|
}
|
||||||
ds.AppendData(latestSegments)
|
}
|
||||||
ds.SetBasePressure(basePressure)
|
}
|
||||||
ds.SetOrigin(origin)
|
}()
|
||||||
mutex.Unlock()
|
|
||||||
for _, seg := range latestSegments {
|
return http.ListenAndServe(":8080", nil)
|
||||||
logger.Log(seg)
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
return http.ListenAndServe(":8080", nil)
|
|
||||||
}
|
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width" />
|
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width" />
|
||||||
<title></title>
|
<title></title>
|
||||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
|
||||||
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
|
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
|
||||||
crossorigin=""/>
|
crossorigin=""/>
|
||||||
<link href="style/style.css" rel="stylesheet" />
|
<link href="style/style.css" rel="stylesheet" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="main"></div>
|
<div id="main"></div>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.5.1/dist/chart.min.js" integrity="sha256-bC3LCZCwKeehY6T4fFi9VfOU0gztUa+S4cnkIhVPZ5E=" crossorigin="anonymous"></script>
|
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.5.1/dist/chart.min.js" integrity="sha256-bC3LCZCwKeehY6T4fFi9VfOU0gztUa+S4cnkIhVPZ5E=" crossorigin="anonymous"></script>
|
||||||
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
|
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
|
||||||
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
|
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
|
||||||
crossorigin=""></script>
|
crossorigin=""></script>
|
||||||
<script type="text/javascript" src="js/util.js"></script>
|
<script type="text/javascript" src="js/util.js"></script>
|
||||||
<script type="text/javascript" src="js/widget.js"></script>
|
<script type="text/javascript" src="js/widget.js"></script>
|
||||||
<script type="text/javascript" src="js/lineChartWidget.js"></script>
|
<script type="text/javascript" src="js/lineChartWidget.js"></script>
|
||||||
<script type="text/javascript" src="js/kvTableWidget.js"></script>
|
<script type="text/javascript" src="js/kvTableWidget.js"></script>
|
||||||
<script type="text/javascript" src="js/mapWidget.js"></script>
|
<script type="text/javascript" src="js/mapWidget.js"></script>
|
||||||
<script type="text/javascript" src="js/missionInfoWidget.js"></script>
|
<script type="text/javascript" src="js/missionInfoWidget.js"></script>
|
||||||
<script type="text/javascript" src="js/attitudeWidget.js"></script>
|
<script type="text/javascript" src="js/attitudeWidget.js"></script>
|
||||||
<script type="text/javascript" src="js/dashboard.js"></script>
|
<script type="text/javascript" src="js/dashboard.js"></script>
|
||||||
<script type="text/javascript" src="js/main.js"></script>
|
<script type="text/javascript" src="js/main.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
class AttitudeWidget extends Widget {
|
class AttitudeWidget extends Widget {
|
||||||
update(data) {
|
update(data) {
|
||||||
const angle = this.extractor(data)
|
const angle = this.extractor(data)
|
||||||
this.setDetails(angle.toFixed(2) + '°')
|
this.setDetails(angle.toFixed(2) + '°')
|
||||||
this.arrow.style.transform = `rotate(${angle}deg)`
|
this.arrow.style.transform = `rotate(${angle}deg)`
|
||||||
}
|
}
|
||||||
|
|
||||||
initDOM() {
|
initDOM() {
|
||||||
const attitudeContainer = document.createElement('div')
|
const attitudeContainer = document.createElement('div')
|
||||||
attitudeContainer.className = 'attitude-container'
|
attitudeContainer.className = 'attitude-container'
|
||||||
this.arrow = document.createElement('div')
|
this.arrow = document.createElement('div')
|
||||||
this.arrow.className = 'attitude-arrow'
|
this.arrow.className = 'attitude-arrow'
|
||||||
attitudeContainer.appendChild(this.arrow)
|
attitudeContainer.appendChild(this.arrow)
|
||||||
return attitudeContainer
|
return attitudeContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
initContent() {}
|
initContent() {}
|
||||||
}
|
}
|
||||||
|
@ -1,96 +1,96 @@
|
|||||||
const signalTimeout = 5000
|
const signalTimeout = 5000
|
||||||
|
|
||||||
class Dashboard {
|
class Dashboard {
|
||||||
constructor(parent) {
|
constructor(parent) {
|
||||||
this.parent = parent
|
this.parent = parent
|
||||||
this.children = []
|
this.children = []
|
||||||
this.lastUpdate = null
|
this.lastUpdate = null
|
||||||
this.timeout = null
|
this.timeout = null
|
||||||
this.data = []
|
this.data = []
|
||||||
}
|
}
|
||||||
|
|
||||||
attach() {
|
attach() {
|
||||||
this.container = document.createElement('div')
|
this.container = document.createElement('div')
|
||||||
this.container.className = 'dashboard'
|
this.container.className = 'dashboard'
|
||||||
this.parent.appendChild(this.container)
|
this.parent.appendChild(this.container)
|
||||||
|
|
||||||
this.children = [
|
this.children = [
|
||||||
new MissionInfoWidget('Flight Info', this.container, makeInfoExtractor()),
|
new MissionInfoWidget('Flight Info', this.container, makeInfoExtractor()),
|
||||||
new LineChartWidget('Altitude', 'm', this.container, makeXYExtractor('computed', 'smoothedAltitude')),
|
new LineChartWidget('Altitude', 'm', this.container, makeXYExtractor('computed', 'smoothedAltitude')),
|
||||||
new LineChartWidget('Velocity', 'm/s', this.container, makeXYExtractor('computed', 'smoothedVelocity')),
|
new LineChartWidget('Velocity', 'm/s', this.container, makeXYExtractor('computed', 'smoothedVelocity')),
|
||||||
new LineChartWidget('Temperature', '°C', this.container, makeXYExtractor('computed', 'smoothedTemperature')),
|
new LineChartWidget('Temperature', '°C', this.container, makeXYExtractor('computed', 'smoothedTemperature')),
|
||||||
new LineChartWidget('Pressure', 'mBar', this.container, makeXYExtractor('computed', 'smoothedPressure')),
|
new LineChartWidget('Pressure', 'mBar', this.container, makeXYExtractor('computed', 'smoothedPressure')),
|
||||||
new AttitudeWidget('Pitch', this.container, makeSingleExtractor('computed', 'pitch')),
|
new AttitudeWidget('Pitch', this.container, makeSingleExtractor('computed', 'pitch')),
|
||||||
new AttitudeWidget('Yaw', this.container, makeSingleExtractor('computed', 'yaw')),
|
new AttitudeWidget('Yaw', this.container, makeSingleExtractor('computed', 'yaw')),
|
||||||
new LineChartWidget('RSSI', 'RSSI', this.container, makeXYExtractor('raw', 'rssi')),
|
new LineChartWidget('RSSI', 'RSSI', this.container, makeXYExtractor('raw', 'rssi')),
|
||||||
new KVTableWidget('Signal Stats', ['Data Points', 'Data Rate', 'Last Event Age', 'Receiving', 'RSSI', 'GPS Num Stats', 'GPS Signal Quality'], this.container, (d) => this.signalStatsExtractor(d)),
|
new KVTableWidget('Signal Stats', ['Data Points', 'Data Rate', 'Last Event Age', 'Receiving', 'RSSI', 'GPS Num Stats', 'GPS Signal Quality'], this.container, (d) => this.signalStatsExtractor(d)),
|
||||||
new MapWidget('Location', this.container, makeCoordinateExtractor()),
|
new MapWidget('Location', this.container, makeCoordinateExtractor()),
|
||||||
]
|
]
|
||||||
this.children.forEach(c => c.attach())
|
this.children.forEach(c => c.attach())
|
||||||
}
|
}
|
||||||
|
|
||||||
update(data) {
|
update(data) {
|
||||||
if (this.timeout) {
|
if (this.timeout) {
|
||||||
clearTimeout(this.timeout)
|
clearTimeout(this.timeout)
|
||||||
this.timeout = null
|
this.timeout = null
|
||||||
}
|
}
|
||||||
if (data !== null) {
|
if (data !== null) {
|
||||||
this.data = data
|
this.data = data
|
||||||
this.container.classList.add('receiving')
|
this.container.classList.add('receiving')
|
||||||
} else {
|
} else {
|
||||||
this.container.classList.remove('receiving')
|
this.container.classList.remove('receiving')
|
||||||
}
|
}
|
||||||
this.children.forEach(child => child.update(this.data))
|
this.children.forEach(child => child.update(this.data))
|
||||||
if (data !== null) {
|
if (data !== null) {
|
||||||
this.lastUpdate = new Date()
|
this.lastUpdate = new Date()
|
||||||
}
|
}
|
||||||
this.timeout = setTimeout(() => this.update(null), signalTimeout)
|
this.timeout = setTimeout(() => this.update(null), signalTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
signalStatsExtractor(data) {
|
signalStatsExtractor(data) {
|
||||||
if (data.length === 0) {
|
if (data.length === 0) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
const lastEventAge = this.lastUpdate === null ? null : (new Date().getTime() - this.lastUpdate.getTime())
|
const lastEventAge = this.lastUpdate === null ? null : (new Date().getTime() - this.lastUpdate.getTime())
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
key: 'Data Points',
|
key: 'Data Points',
|
||||||
value: data.length,
|
value: data.length,
|
||||||
normal: data.length > 0
|
normal: data.length > 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'Data Rate',
|
key: 'Data Rate',
|
||||||
value: data[data.length - 1].computed.dataRate.toFixed(2) + '/s',
|
value: data[data.length - 1].computed.dataRate.toFixed(2) + '/s',
|
||||||
normal: data[data.length - 1].computed.dataRate > 1
|
normal: data[data.length - 1].computed.dataRate > 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'Last Event Age',
|
key: 'Last Event Age',
|
||||||
value: lastEventAge === null ? 'Never' : (lastEventAge / 1000).toFixed(2) + 's',
|
value: lastEventAge === null ? 'Never' : (lastEventAge / 1000).toFixed(2) + 's',
|
||||||
normal: lastEventAge !== null && lastEventAge < signalTimeout
|
normal: lastEventAge !== null && lastEventAge < signalTimeout
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'Receiving',
|
key: 'Receiving',
|
||||||
value: lastEventAge !== null && lastEventAge < signalTimeout ? 'Yes' : 'No',
|
value: lastEventAge !== null && lastEventAge < signalTimeout ? 'Yes' : 'No',
|
||||||
normal: lastEventAge !== null && lastEventAge < signalTimeout
|
normal: lastEventAge !== null && lastEventAge < signalTimeout
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'RSSI',
|
key: 'RSSI',
|
||||||
value: data[data.length - 1].raw.rssi,
|
value: data[data.length - 1].raw.rssi,
|
||||||
normal: data[data.length - 1].raw.rssi > -70
|
normal: data[data.length - 1].raw.rssi > -70
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'GPS Num Stats',
|
key: 'GPS Num Stats',
|
||||||
value: data[data.length - 1].raw.gpsInfo.sats,
|
value: data[data.length - 1].raw.gpsInfo.sats,
|
||||||
normal: data[data.length - 1].raw.gpsInfo.sats > 0
|
normal: data[data.length - 1].raw.gpsInfo.sats > 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'GPS Signal Quality',
|
key: 'GPS Signal Quality',
|
||||||
value: data[data.length - 1].raw.gpsInfo.quality,
|
value: data[data.length - 1].raw.gpsInfo.quality,
|
||||||
normal: data[data.length - 1].raw.gpsInfo.quality > 0
|
normal: data[data.length - 1].raw.gpsInfo.quality > 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,54 +1,54 @@
|
|||||||
class KVTableWidget extends Widget {
|
class KVTableWidget extends Widget {
|
||||||
constructor(title, keys, parent, extractor) {
|
constructor(title, keys, parent, extractor) {
|
||||||
super(title, parent, extractor)
|
super(title, parent, extractor)
|
||||||
this.keys = keys
|
this.keys = keys
|
||||||
}
|
}
|
||||||
|
|
||||||
update(data) {
|
update(data) {
|
||||||
const extractedData = this.extractor(data)
|
const extractedData = this.extractor(data)
|
||||||
extractedData.forEach(({key, value, normal}) => {
|
extractedData.forEach(({key, value, normal}) => {
|
||||||
if (this.valueTds[key]) {
|
if (this.valueTds[key]) {
|
||||||
this.valueTds[key].textContent = value
|
this.valueTds[key].textContent = value
|
||||||
if (normal) {
|
if (normal) {
|
||||||
this.valueTds[key].classList.add('normal')
|
this.valueTds[key].classList.add('normal')
|
||||||
} else {
|
} else {
|
||||||
this.valueTds[key].classList.remove('normal')
|
this.valueTds[key].classList.remove('normal')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
initDOM() {
|
initDOM() {
|
||||||
const table = document.createElement('table')
|
const table = document.createElement('table')
|
||||||
table.className = 'kv-table'
|
table.className = 'kv-table'
|
||||||
const thead = document.createElement('thead')
|
const thead = document.createElement('thead')
|
||||||
table.appendChild(thead)
|
table.appendChild(thead)
|
||||||
const tr = document.createElement('tr')
|
const tr = document.createElement('tr')
|
||||||
thead.appendChild(tr)
|
thead.appendChild(tr)
|
||||||
const headers = ['Attribute', 'Value']
|
const headers = ['Attribute', 'Value']
|
||||||
headers.forEach(h => {
|
headers.forEach(h => {
|
||||||
const th = document.createElement('th')
|
const th = document.createElement('th')
|
||||||
th.textContent = h
|
th.textContent = h
|
||||||
tr.appendChild(th)
|
tr.appendChild(th)
|
||||||
})
|
})
|
||||||
const tbody = document.createElement('tbody')
|
const tbody = document.createElement('tbody')
|
||||||
table.appendChild(tbody)
|
table.appendChild(tbody)
|
||||||
this.valueTds = {}
|
this.valueTds = {}
|
||||||
this.keys.forEach(key => {
|
this.keys.forEach(key => {
|
||||||
const tr = document.createElement('tr')
|
const tr = document.createElement('tr')
|
||||||
tbody.appendChild(tr)
|
tbody.appendChild(tr)
|
||||||
const keyTd = document.createElement('td')
|
const keyTd = document.createElement('td')
|
||||||
keyTd.textContent = key
|
keyTd.textContent = key
|
||||||
tr.appendChild(keyTd)
|
tr.appendChild(keyTd)
|
||||||
const valueTd = document.createElement('td')
|
const valueTd = document.createElement('td')
|
||||||
valueTd.className = 'kv-table-value'
|
valueTd.className = 'kv-table-value'
|
||||||
tr.appendChild(valueTd)
|
tr.appendChild(valueTd)
|
||||||
this.valueTds[key] = valueTd
|
this.valueTds[key] = valueTd
|
||||||
})
|
})
|
||||||
return table
|
return table
|
||||||
}
|
}
|
||||||
|
|
||||||
initContent() {
|
initContent() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,69 +1,69 @@
|
|||||||
class LineChartWidget extends Widget {
|
class LineChartWidget extends Widget {
|
||||||
constructor(title, units, parent, extractor) {
|
constructor(title, units, parent, extractor) {
|
||||||
super(title, parent, extractor)
|
super(title, parent, extractor)
|
||||||
this.units = units
|
this.units = units
|
||||||
}
|
}
|
||||||
|
|
||||||
update(data) {
|
update(data) {
|
||||||
const extractedData = this.extractor(data)
|
const extractedData = this.extractor(data)
|
||||||
this.chart.data.datasets[0].data = extractedData
|
this.chart.data.datasets[0].data = extractedData
|
||||||
this.chart.update()
|
this.chart.update()
|
||||||
if (extractedData.length > 0) {
|
if (extractedData.length > 0) {
|
||||||
this.setDetails(`${extractedData[extractedData.length - 1].y.toFixed(2)} ${this.units}`)
|
this.setDetails(`${extractedData[extractedData.length - 1].y.toFixed(2)} ${this.units}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initDOM() {
|
initDOM() {
|
||||||
this.canvas = document.createElement('canvas')
|
this.canvas = document.createElement('canvas')
|
||||||
return this.canvas
|
return this.canvas
|
||||||
}
|
}
|
||||||
|
|
||||||
initContent() {
|
initContent() {
|
||||||
const ctx = this.canvas.getContext('2d')
|
const ctx = this.canvas.getContext('2d')
|
||||||
this.chart = new Chart(ctx, {
|
this.chart = new Chart(ctx, {
|
||||||
type: 'scatter',
|
type: 'scatter',
|
||||||
data: {
|
data: {
|
||||||
datasets: [{
|
datasets: [{
|
||||||
data: [],
|
data: [],
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
responsive: true,
|
responsive: true,
|
||||||
maintainAspectRatio: true,
|
maintainAspectRatio: true,
|
||||||
aspectRatio: 1,
|
aspectRatio: 1,
|
||||||
showLine: true,
|
showLine: true,
|
||||||
elements: {
|
elements: {
|
||||||
point: {
|
point: {
|
||||||
radius: 0
|
radius: 0
|
||||||
},
|
},
|
||||||
line: {
|
line: {
|
||||||
borderColor: '#000',
|
borderColor: '#000',
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
plugins: {
|
plugins: {
|
||||||
legend: {
|
legend: {
|
||||||
display: false
|
display: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
animation: {
|
animation: {
|
||||||
duration: 0,
|
duration: 0,
|
||||||
},
|
},
|
||||||
scales: {
|
scales: {
|
||||||
x: {
|
x: {
|
||||||
title: {
|
title: {
|
||||||
display: true,
|
display: true,
|
||||||
text: 'Seconds'
|
text: 'Seconds'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
y: {
|
y: {
|
||||||
title: {
|
title: {
|
||||||
display: true,
|
display: true,
|
||||||
text: this.units
|
text: this.units
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
(() => {
|
(() => {
|
||||||
let data = []
|
let data = []
|
||||||
const dashboard = new Dashboard(document.getElementById('main'))
|
const dashboard = new Dashboard(document.getElementById('main'))
|
||||||
dashboard.attach()
|
dashboard.attach()
|
||||||
const webSocket = new WebSocket(`ws://${window.location.host}/api/data`)
|
const webSocket = new WebSocket(`ws://${window.location.host}/api/data`)
|
||||||
webSocket.onmessage = (e) => {
|
webSocket.onmessage = (e) => {
|
||||||
data = data.concat(JSON.parse(e.data))
|
data = data.concat(JSON.parse(e.data))
|
||||||
dashboard.update(data)
|
console.log( "DATA :" + data)
|
||||||
}
|
dashboard.update(data)
|
||||||
})()
|
}
|
||||||
|
})()
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
class MapWidget extends Widget {
|
class MapWidget extends Widget {
|
||||||
constructor(title, parent, extractor) {
|
constructor(title, parent, extractor) {
|
||||||
super(title, parent, extractor)
|
super(title, parent, extractor)
|
||||||
}
|
}
|
||||||
|
|
||||||
update(data) {
|
update(data) {
|
||||||
const mapData = this.extractor(data)
|
const mapData = this.extractor(data)
|
||||||
this.map.setView(mapData.coordinates, this.map.getZoom())
|
this.map.setView(mapData.coordinates, this.map.getZoom())
|
||||||
this.marker.setLatLng(mapData.coordinates)
|
this.marker.setLatLng(mapData.coordinates)
|
||||||
this.setDetails(`Bearing: ${mapData.bearing.toFixed(2)}°, Distance: ${mapData.distance.toFixed(2)}m`)
|
this.setDetails(`Bearing: ${mapData.bearing.toFixed(2)}°, Distance: ${mapData.distance.toFixed(2)}m`)
|
||||||
}
|
}
|
||||||
|
|
||||||
initDOM() {
|
initDOM() {
|
||||||
this.mapContainer = document.createElement('div')
|
this.mapContainer = document.createElement('div')
|
||||||
this.mapContainer.className = 'map-container'
|
this.mapContainer.className = 'map-container'
|
||||||
return this.mapContainer
|
return this.mapContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
initContent() {
|
initContent() {
|
||||||
this.map = L.map(this.mapContainer).setView([0,0], 17)
|
this.map = L.map(this.mapContainer).setView([0,0], 17)
|
||||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||||
}).addTo(this.map)
|
}).addTo(this.map)
|
||||||
this.marker = L.circle([0,0], {
|
this.marker = L.circle([0,0], {
|
||||||
color: 'red',
|
color: 'red',
|
||||||
fillColor: '#f03',
|
fillColor: '#f03',
|
||||||
fillOpacity: 0.5,
|
fillOpacity: 0.5,
|
||||||
radius: 5
|
radius: 5
|
||||||
}).addTo(this.map)
|
}).addTo(this.map)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,36 +1,38 @@
|
|||||||
const modeMap = {
|
const modeMap = {
|
||||||
'P': 'Prelaunch',
|
"WT": "Waiting for Launch",
|
||||||
'AP': 'Powered Ascent',
|
"LD": "Launch Detected",
|
||||||
'AU': 'Unpowered Ascent',
|
"LV": "Low velocity Detected",
|
||||||
'DF': 'Freefall Descent',
|
"AP": "Nose-Over",
|
||||||
'DP': 'Parachute Descent',
|
"DR": "Drogue Fired",
|
||||||
'R': 'Recovery'
|
"MN": "Main Fired",
|
||||||
}
|
"FS": "Failsafe Triggered ",
|
||||||
|
"TD": "Landing Detected"
|
||||||
class MissionInfoWidget extends Widget {
|
}
|
||||||
update(data) {
|
|
||||||
const extractedData = this.extractor(data)
|
class MissionInfoWidget extends Widget {
|
||||||
this.time.textContent = formatSeconds(extractedData.time)
|
update(data) {
|
||||||
this.mode.textContent = modeMap[extractedData.mode]
|
const extractedData = this.extractor(data)
|
||||||
this.mode.className = ['mission-info-mode', 'mission-info-mode-' + extractedData.mode.toLowerCase()].join(' ')
|
this.time.textContent = formatSeconds(extractedData.time)
|
||||||
}
|
this.mode.textContent = modeMap[extractedData.mode]
|
||||||
|
this.mode.className = ['mission-info-mode', 'mission-info-mode-' + extractedData.mode.toLowerCase()].join(' ')
|
||||||
initDOM() {
|
}
|
||||||
const container = document.createElement('div')
|
|
||||||
container.className = 'mission-info-container'
|
initDOM() {
|
||||||
|
const container = document.createElement('div')
|
||||||
this.time = document.createElement('div')
|
container.className = 'mission-info-container'
|
||||||
this.time.className = 'mission-info-time'
|
|
||||||
container.appendChild(this.time)
|
this.time = document.createElement('div')
|
||||||
|
this.time.className = 'mission-info-time'
|
||||||
this.mode = document.createElement('div')
|
container.appendChild(this.time)
|
||||||
this.mode.className = 'mission-info-mode'
|
|
||||||
container.appendChild(this.mode)
|
this.mode = document.createElement('div')
|
||||||
|
this.mode.className = 'mission-info-mode'
|
||||||
return container
|
container.appendChild(this.mode)
|
||||||
}
|
|
||||||
|
return container
|
||||||
initContent() {
|
}
|
||||||
|
|
||||||
}
|
initContent() {
|
||||||
}
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,39 +1,38 @@
|
|||||||
function makeXYExtractor(propType, propName) {
|
function makeXYExtractor(propType, propName) {
|
||||||
return (data) => data.map(segment => ({
|
return (data) => data.map(segment => ({
|
||||||
x: segment.raw.timestamp,
|
x: segment.raw.flightTime,
|
||||||
y: segment[propType][propName]
|
y: segment[propType][propName]
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeCoordinateExtractor() {
|
function makeCoordinateExtractor() {
|
||||||
return (data) => ({
|
return (data) => ({
|
||||||
coordinates: [data[data.length - 1].raw.coordinate.lat, data[data.length - 1].raw.coordinate.lon],
|
coordinates: [data[data.length - 1].raw.coordinate.lat, data[data.length - 1].raw.coordinate.lon],
|
||||||
bearing: data[data.length - 1].computed.bearing,
|
bearing: data[data.length - 1].computed.bearing,
|
||||||
distance: data[data.length - 1].computed.distance
|
distance: data[data.length - 1].computed.distance
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeInfoExtractor() {
|
function makeInfoExtractor() {
|
||||||
return (data) => ({
|
return (data) => ({
|
||||||
pcnt: data[data.length - 1].raw.cameraProgress,
|
time: data[data.length - 1].raw.flightTime,
|
||||||
time: data[data.length - 1].raw.timestamp,
|
mode: data[data.length - 1].computed.flightMode
|
||||||
mode: data[data.length - 1].computed.flightMode
|
})
|
||||||
})
|
}
|
||||||
}
|
|
||||||
|
function makeSingleExtractor(propType, propName) {
|
||||||
function makeSingleExtractor(propType, propName) {
|
return (data) => data[data.length - 1][propType][propName]
|
||||||
return (data) => data[data.length - 1][propType][propName]
|
}
|
||||||
}
|
|
||||||
|
function formatSeconds(time) {
|
||||||
function formatSeconds(time) {
|
const hrs = ~~(time / 3600)
|
||||||
const hrs = ~~(time / 3600)
|
const mins = ~~((time % 3600) / 60)
|
||||||
const mins = ~~((time % 3600) / 60)
|
const secs = ~~time % 60
|
||||||
const secs = ~~time % 60
|
let ret = ''
|
||||||
let ret = ''
|
if (hrs > 0) {
|
||||||
if (hrs > 0) {
|
ret += '' + hrs + ':' + (mins < 10 ? '0' : '')
|
||||||
ret += '' + hrs + ':' + (mins < 10 ? '0' : '')
|
}
|
||||||
}
|
ret += '' + mins + ':' + (secs < 10 ? '0' : '')
|
||||||
ret += '' + mins + ':' + (secs < 10 ? '0' : '')
|
ret += '' + secs
|
||||||
ret += '' + secs
|
return ret
|
||||||
return ret
|
}
|
||||||
}
|
|
||||||
|
@ -1,44 +1,44 @@
|
|||||||
class Widget {
|
class Widget {
|
||||||
constructor(title, parent, extractor) {
|
constructor(title, parent, extractor) {
|
||||||
this.title = title
|
this.title = title
|
||||||
this.parent = parent
|
this.parent = parent
|
||||||
this.extractor = extractor
|
this.extractor = extractor
|
||||||
}
|
}
|
||||||
|
|
||||||
attach() {
|
attach() {
|
||||||
const widget = document.createElement('div')
|
const widget = document.createElement('div')
|
||||||
widget.className = 'widget'
|
widget.className = 'widget'
|
||||||
|
|
||||||
const header = document.createElement('div')
|
const header = document.createElement('div')
|
||||||
header.className = 'widget-header'
|
header.className = 'widget-header'
|
||||||
widget.appendChild(header)
|
widget.appendChild(header)
|
||||||
|
|
||||||
const title = document.createElement('div')
|
const title = document.createElement('div')
|
||||||
title.className = 'widget-title'
|
title.className = 'widget-title'
|
||||||
title.textContent = this.title
|
title.textContent = this.title
|
||||||
header.appendChild(title)
|
header.appendChild(title)
|
||||||
|
|
||||||
this.details = document.createElement('div')
|
this.details = document.createElement('div')
|
||||||
this.details.className = 'widget-details'
|
this.details.className = 'widget-details'
|
||||||
header.appendChild(this.details)
|
header.appendChild(this.details)
|
||||||
|
|
||||||
const content = document.createElement('div')
|
const content = document.createElement('div')
|
||||||
content.className = 'widget-content'
|
content.className = 'widget-content'
|
||||||
content.appendChild(this.initDOM())
|
content.appendChild(this.initDOM())
|
||||||
widget.appendChild(content)
|
widget.appendChild(content)
|
||||||
|
|
||||||
this.parent.appendChild(widget)
|
this.parent.appendChild(widget)
|
||||||
|
|
||||||
this.initContent()
|
this.initContent()
|
||||||
}
|
}
|
||||||
|
|
||||||
setDetails(details) {
|
setDetails(details) {
|
||||||
this.details.textContent = details
|
this.details.textContent = details
|
||||||
}
|
}
|
||||||
|
|
||||||
update(data) {}
|
update(data) {}
|
||||||
|
|
||||||
initDOM() {}
|
initDOM() {}
|
||||||
|
|
||||||
initContent() {}
|
initContent() {}
|
||||||
}
|
}
|
||||||
|
@ -1,162 +1,162 @@
|
|||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dashboard {
|
.dashboard {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||||
grid-gap: 10px;
|
grid-gap: 10px;
|
||||||
font-family: 'Courier New', Courier, monospace;
|
font-family: 'Courier New', Courier, monospace;
|
||||||
border: solid 5px red;
|
border: solid 5px red;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dashboard.receiving {
|
.dashboard.receiving {
|
||||||
border-color: green;
|
border-color: green;
|
||||||
}
|
}
|
||||||
|
|
||||||
.widget {
|
.widget {
|
||||||
border: solid 1px black;
|
border: solid 1px black;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-evenly;
|
justify-content: space-evenly;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.widget-header {
|
.widget-header {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
background: black;
|
background: black;
|
||||||
color: white;
|
color: white;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
}
|
}
|
||||||
|
|
||||||
.widget-title {
|
.widget-title {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.widget-details {
|
.widget-details {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.widget-content {
|
.widget-content {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
position: relative;
|
position: relative;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.widget-content table {
|
.widget-content table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.widget-content table th {
|
.widget-content table th {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.map-container {
|
.map-container {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.attitude-container {
|
.attitude-container {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 10px;
|
right: 10px;
|
||||||
left: 10px;
|
left: 10px;
|
||||||
height: 0;
|
height: 0;
|
||||||
padding-bottom: 100%;
|
padding-bottom: 100%;
|
||||||
background: gray;
|
background: gray;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
}
|
}
|
||||||
|
|
||||||
.attitude-arrow {
|
.attitude-arrow {
|
||||||
width: 0;
|
width: 0;
|
||||||
height: 0;
|
height: 0;
|
||||||
border-left: 30px solid transparent;
|
border-left: 30px solid transparent;
|
||||||
border-right: 30px solid transparent;
|
border-right: 30px solid transparent;
|
||||||
border-bottom: 200px solid white;
|
border-bottom: 200px solid white;
|
||||||
margin-top: 100%;
|
margin-top: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mission-info-container {
|
.mission-info-container {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mission-info-time {
|
.mission-info-time {
|
||||||
font-size: 5em;
|
font-size: 5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mission-info-mode {
|
.mission-info-mode {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
min-width: 75%;
|
min-width: 75%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mission-info-mode-p {
|
.mission-info-mode-p {
|
||||||
background-color: gray;
|
background-color: gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mission-info-mode-ap {
|
.mission-info-mode-ap {
|
||||||
background-color: green;
|
background-color: green;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mission-info-mode-au {
|
.mission-info-mode-au {
|
||||||
background-color: yellow;
|
background-color: yellow;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mission-info-mode-df {
|
.mission-info-mode-df {
|
||||||
background-color: red;
|
background-color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mission-info-mode-dp {
|
.mission-info-mode-dp {
|
||||||
background-color: orange;
|
background-color: orange;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mission-info-mode-r {
|
.mission-info-mode-r {
|
||||||
background-color: blue;
|
background-color: blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
.kv-table td {
|
.kv-table td {
|
||||||
border: solid 1px gray;
|
border: solid 1px gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
.kv-table thead {
|
.kv-table thead {
|
||||||
background: black;
|
background: black;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.kv-table-value {
|
.kv-table-value {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
background: red;
|
background: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
.kv-table-value.normal {
|
.kv-table-value.normal {
|
||||||
background: green;
|
background: green;
|
||||||
}
|
}
|
||||||
|
@ -1,98 +1,93 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"math"
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func telemetryFloatFromByteIndex(bytes []byte, index int) float64 {
|
func telemetryFloatFromByteIndex(bytes []byte, index int) float64 {
|
||||||
start := 8 * index
|
start := 8 * index
|
||||||
end := start + 8
|
end := start + 8
|
||||||
if start >= len(bytes) || end >= len(bytes) {
|
if start >= len(bytes) || end >= len(bytes) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
bits := binary.LittleEndian.Uint64(bytes[start:end])
|
bits := binary.LittleEndian.Uint64(bytes[start:end])
|
||||||
float := math.Float64frombits(bits)
|
float := math.Float64frombits(bits)
|
||||||
return float
|
return float
|
||||||
}
|
}
|
||||||
|
|
||||||
func telemetryIntFromBytes(b []byte) int16 {
|
func telemetryIntFromBytes(b []byte) int16 {
|
||||||
buffer := bytes.NewReader(b)
|
buffer := bytes.NewReader(b)
|
||||||
if len(b) != 2 {
|
if len(b) != 2 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
var val int16
|
var val int16
|
||||||
binary.Read(buffer, binary.LittleEndian, &val)
|
binary.Read(buffer, binary.LittleEndian, &val)
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeTelemetryBytes(bytes []byte) ([]byte, []byte, error) {
|
func decodeTelemetryBytes(bytes []byte) ([]byte, []byte, error) {
|
||||||
parts := strings.Split(string(bytes), ",")
|
|
||||||
if len(parts) != 3 || parts[0] != "T" {
|
parts := strings.Split(string(bytes), ",")
|
||||||
return nil, nil, errors.New("bad telemetry")
|
if len(parts) != 3 || parts[0] != "T" {
|
||||||
}
|
return nil, nil, errors.New(string(bytes))
|
||||||
telemetryBytes, err := base64.StdEncoding.DecodeString(parts[1])
|
}
|
||||||
if err != nil {
|
telemetryBytes, err := base64.StdEncoding.DecodeString(parts[1])
|
||||||
return nil, nil, err
|
|
||||||
}
|
if err != nil {
|
||||||
rssiBytes, err := base64.StdEncoding.DecodeString(parts[2])
|
return nil, nil, err
|
||||||
if err != nil {
|
}
|
||||||
return nil, nil, err
|
rssiBytes, err := base64.StdEncoding.DecodeString(parts[2])
|
||||||
}
|
if err != nil {
|
||||||
return telemetryBytes, rssiBytes, nil
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
return telemetryBytes, rssiBytes, nil
|
||||||
func bytesToDataSegment(stream core.FlightData, bytes []byte) ([]core.DataSegment, float64, core.Coordinate, error) {
|
}
|
||||||
telemetryBytes, rssiBytes, err := decodeTelemetryBytes(bytes)
|
|
||||||
if err != nil {
|
func bytesToDataSegment(stream core.FlightData, bytes []byte) ([]core.DataSegment, float64, core.Coordinate, error) {
|
||||||
return nil, 0, core.Coordinate{}, err
|
telemetryBytes, rssiBytes, err := decodeTelemetryBytes(bytes)
|
||||||
}
|
if err != nil {
|
||||||
|
return nil, 0, core.Coordinate{}, err
|
||||||
segments := make([]core.DataSegment, PointsPerDataFrame)
|
}
|
||||||
var basePressure float64
|
|
||||||
var origin core.Coordinate
|
segments := make([]core.DataSegment, PointsPerDataFrame)
|
||||||
for i := len(segments) - 1; i >= 0; i-- {
|
var basePressure float64
|
||||||
offset := 1 + (i * 13)
|
var origin core.Coordinate
|
||||||
raw := core.RawDataSegment{
|
for i := len(segments) - 1; i >= 0; i-- {
|
||||||
WriteProgress: telemetryFloatFromByteIndex(telemetryBytes, 0),
|
offset := (i * 10)
|
||||||
Timestamp: telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexTimestamp),
|
raw := core.RawDataSegment{
|
||||||
Pressure: telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexPressure),
|
FlightTime: telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexFlightTime),
|
||||||
Temperature: telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexTemperature),
|
FlightPhase: telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexFightPhase),
|
||||||
Acceleration: core.XYZ{
|
Altitude: telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexAltitude),
|
||||||
telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexAccelerationX),
|
Velocity: telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexVelocity),
|
||||||
telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexAccelerationY),
|
Acceleration: telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexAcceleration),
|
||||||
telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexAccelerationZ),
|
Temperature: telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexTemperature),
|
||||||
},
|
|
||||||
Magnetic: core.XYZ{
|
Coordinate: core.Coordinate{
|
||||||
telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexMagneticX),
|
telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexCoordinateLat),
|
||||||
telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexMagneticY),
|
telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexCoordinateLon),
|
||||||
telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexMagneticZ),
|
},
|
||||||
},
|
GPSInfo: core.GPSInfo{
|
||||||
Coordinate: core.Coordinate{
|
telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexGpsQuality),
|
||||||
telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexCoordinateLat),
|
telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexGpsSats),
|
||||||
telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexCoordinateLon),
|
},
|
||||||
},
|
Rssi: telemetryIntFromBytes(rssiBytes),
|
||||||
GPSInfo: core.GPSInfo{
|
}
|
||||||
telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexGpsQuality),
|
|
||||||
telemetryFloatFromByteIndex(telemetryBytes, offset+core.IndexGpsSats),
|
var computed core.ComputedDataSegment
|
||||||
},
|
computed, basePressure, origin = core.ComputeDataSegment(stream, raw)
|
||||||
Rssi: telemetryIntFromBytes(rssiBytes),
|
|
||||||
}
|
segments[i] = core.DataSegment{
|
||||||
|
raw,
|
||||||
var computed core.ComputedDataSegment
|
computed,
|
||||||
computed, basePressure, origin = core.ComputeDataSegment(stream, raw)
|
}
|
||||||
|
}
|
||||||
segments[i] = core.DataSegment{
|
|
||||||
raw,
|
return segments, basePressure, origin, nil
|
||||||
computed,
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return segments, basePressure, origin, nil
|
|
||||||
}
|
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/base64"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestTelemetryFloatFromByteIndex(t *testing.T) {
|
|
||||||
b64 := "AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAhA"
|
|
||||||
data, _ := base64.StdEncoding.DecodeString(b64)
|
|
||||||
n := telemetryFloatFromByteIndex(data, 1)
|
|
||||||
assert.Equal(t, n, 2.0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestTelemetryIntFromBytes(t *testing.T) {
|
|
||||||
n := telemetryIntFromBytes([]byte{0x01, 0x00})
|
|
||||||
assert.Equal(t, n, int16(1))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDecodeTelemetryBytes(t *testing.T) {
|
|
||||||
telemetryBytes, rssiBytes, err := decodeTelemetryBytes([]byte("T,wcqhRbbz3T8NAIDUU3JoQGzPymub5/dAAQAM3C/rIkCoKRPINnrovxg/EbSXB+Y/qdDM1YdeMMD+XHTRRRctQAAAAAAAgELAT6wPjfWhL0D2QZYFE2dDQCC4yhMIQ1PAAAAAAAAAAAAAAAAAAAAAAA==,//8="))
|
|
||||||
assert.NotNil(t, telemetryBytes)
|
|
||||||
assert.NotNil(t, rssiBytes)
|
|
||||||
assert.Nil(t, err)
|
|
||||||
}
|
|
@ -1,31 +1,31 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Logger struct {
|
type Logger struct {
|
||||||
DataChannel chan core.DataSegment
|
DataChannel chan core.DataSegment
|
||||||
ContinueRunning bool
|
ContinueRunning bool
|
||||||
Mutex sync.Mutex
|
Mutex sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
type LoggerControl interface {
|
type LoggerControl interface {
|
||||||
Kill()
|
Kill()
|
||||||
Log(core.DataSegment)
|
Log(core.DataSegment)
|
||||||
}
|
}
|
||||||
|
|
||||||
type DataProvider interface {
|
type DataProvider interface {
|
||||||
Stream() <-chan []byte
|
Stream() <-chan []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
type DataProviderFile struct {
|
type DataProviderFile struct {
|
||||||
Bytes [][]byte
|
Bytes [][]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
type DataProviderSerial struct {
|
type DataProviderSerial struct {
|
||||||
Port io.ReadWriteCloser
|
Port io.ReadWriteCloser
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
.PHONY: generate_test_data run
|
.PHONY: generate_test_data run
|
||||||
|
|
||||||
OS=$(shell uname)
|
OS=$(shell uname)
|
||||||
ARCH=$(shell arch)
|
ARCH=$(shell arch)
|
||||||
|
|
||||||
install:
|
install:
|
||||||
go get ./...
|
go get ./...
|
||||||
go get -t ./...
|
go get -t ./...
|
||||||
|
|
||||||
run:
|
run:
|
||||||
go run . $(source)
|
go run . $(source)
|
||||||
|
|
||||||
build:
|
build:
|
||||||
go build -o build/white-vest-tools-$(OS)-$(ARCH) .
|
go build -o build/white-vest-tools-$(OS)-$(ARCH) .
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go test .
|
go test .
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf build
|
rm -rf build
|
||||||
|
@ -1,47 +1,47 @@
|
|||||||
package charts
|
package charts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
"github.com/wcharczuk/go-chart/v2"
|
"github.com/wcharczuk/go-chart/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AltitudeChart struct {
|
type AltitudeChart struct {
|
||||||
filePath string
|
filePath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAltitudeChart(f string) ChartTask {
|
func NewAltitudeChart(f string) ChartTask {
|
||||||
return AltitudeChart{f}
|
return AltitudeChart{f}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c AltitudeChart) Generate(offsetSeconds float64, fd []core.DataSegment) error {
|
func (c AltitudeChart) Generate(offsetSeconds float64, fd []core.DataSegment) error {
|
||||||
graph := chart.Chart{
|
graph := chart.Chart{
|
||||||
Series: []chart.Series{
|
Series: []chart.Series{
|
||||||
chart.ContinuousSeries{
|
chart.ContinuousSeries{
|
||||||
Name: "Altitude",
|
Name: "Altitude",
|
||||||
XValues: singleFlightDataElement(fd, func(d core.DataSegment) float64 { return d.Raw.Timestamp - offsetSeconds }),
|
XValues: singleFlightDataElement(fd, func(d core.DataSegment) float64 { return d.Raw.flightTime - offsetSeconds }),
|
||||||
YValues: singleFlightDataElement(fd, func(d core.DataSegment) float64 { return d.Computed.SmoothedAltitude }),
|
YValues: singleFlightDataElement(fd, func(d core.DataSegment) float64 { return d.Computed.SmoothedAltitude }),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
XAxis: chart.XAxis{
|
XAxis: chart.XAxis{
|
||||||
Name: "Seconds",
|
Name: "Seconds",
|
||||||
},
|
},
|
||||||
YAxis: chart.YAxis{
|
YAxis: chart.YAxis{
|
||||||
Name: "Meters",
|
Name: "Meters",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer := bytes.NewBuffer([]byte{})
|
buffer := bytes.NewBuffer([]byte{})
|
||||||
err := graph.Render(chart.PNG, buffer)
|
err := graph.Render(chart.PNG, buffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = os.WriteFile(c.filePath, buffer.Bytes(), 0777)
|
err = os.WriteFile(c.filePath, buffer.Bytes(), 0777)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package charts
|
package charts
|
||||||
|
|
||||||
import "github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
import "github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
|
|
||||||
type ChartTask interface {
|
type ChartTask interface {
|
||||||
Generate(offsetSeconds float64, fd []core.DataSegment) error
|
Generate(offsetSeconds float64, fd []core.DataSegment) error
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package charts
|
package charts
|
||||||
|
|
||||||
import "github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
import "github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
|
|
||||||
func singleFlightDataElement(fd []core.DataSegment, accessor func(core.DataSegment) float64) []float64 {
|
func singleFlightDataElement(fd []core.DataSegment, accessor func(core.DataSegment) float64) []float64 {
|
||||||
data := make([]float64, len(fd))
|
data := make([]float64, len(fd))
|
||||||
for i, segment := range fd {
|
for i, segment := range fd {
|
||||||
data[i] = accessor(segment)
|
data[i] = accessor(segment)
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
@ -1,47 +1,47 @@
|
|||||||
package charts
|
package charts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
"github.com/wcharczuk/go-chart/v2"
|
"github.com/wcharczuk/go-chart/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type VelocityChart struct {
|
type VelocityChart struct {
|
||||||
filePath string
|
filePath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewVelocityChart(f string) ChartTask {
|
func NewVelocityChart(f string) ChartTask {
|
||||||
return VelocityChart{f}
|
return VelocityChart{f}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c VelocityChart) Generate(offsetSeconds float64, fd []core.DataSegment) error {
|
func (c VelocityChart) Generate(offsetSeconds float64, fd []core.DataSegment) error {
|
||||||
graph := chart.Chart{
|
graph := chart.Chart{
|
||||||
Series: []chart.Series{
|
Series: []chart.Series{
|
||||||
chart.ContinuousSeries{
|
chart.ContinuousSeries{
|
||||||
Name: "Velocity",
|
Name: "Velocity",
|
||||||
XValues: singleFlightDataElement(fd, func(d core.DataSegment) float64 { return d.Raw.Timestamp - offsetSeconds }),
|
XValues: singleFlightDataElement(fd, func(d core.DataSegment) float64 { return d.Raw.flightTime - offsetSeconds }),
|
||||||
YValues: singleFlightDataElement(fd, func(d core.DataSegment) float64 { return d.Computed.SmoothedVelocity }),
|
YValues: singleFlightDataElement(fd, func(d core.DataSegment) float64 { return d.Computed.SmoothedVelocity }),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
XAxis: chart.XAxis{
|
XAxis: chart.XAxis{
|
||||||
Name: "Seconds",
|
Name: "Seconds",
|
||||||
},
|
},
|
||||||
YAxis: chart.YAxis{
|
YAxis: chart.YAxis{
|
||||||
Name: "Meters/Second",
|
Name: "Meters/Second",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer := bytes.NewBuffer([]byte{})
|
buffer := bytes.NewBuffer([]byte{})
|
||||||
err := graph.Render(chart.PNG, buffer)
|
err := graph.Render(chart.PNG, buffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = os.WriteFile(c.filePath, buffer.Bytes(), 0777)
|
err = os.WriteFile(c.filePath, buffer.Bytes(), 0777)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,82 +1,82 @@
|
|||||||
package conversion
|
package conversion
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/cheggaaa/pb/v3"
|
"github.com/cheggaaa/pb/v3"
|
||||||
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
type InboardReader struct {
|
type InboardReader struct {
|
||||||
filePath string
|
filePath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewInboardReader(f string) InboardReader {
|
func NewInboardReader(f string) InboardReader {
|
||||||
return InboardReader{f}
|
return InboardReader{f}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i InboardReader) Read(showProgress bool) (core.FlightData, error) {
|
func (i InboardReader) Read(showProgress bool) (core.FlightData, error) {
|
||||||
f, err := os.Open(i.filePath)
|
f, err := os.Open(i.filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
csvReader := csv.NewReader(f)
|
csvReader := csv.NewReader(f)
|
||||||
data, err := csvReader.ReadAll()
|
data, err := csvReader.ReadAll()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
fd := core.NewFlightData()
|
fd := core.NewFlightData()
|
||||||
var bar *pb.ProgressBar
|
var bar *pb.ProgressBar
|
||||||
if showProgress {
|
if showProgress {
|
||||||
bar = pb.StartNew(len(data))
|
bar = pb.StartNew(len(data))
|
||||||
}
|
}
|
||||||
for i, row := range data {
|
for i, row := range data {
|
||||||
rawSeg := core.RawDataSegment{
|
rawSeg := core.RawDataSegment{
|
||||||
WriteProgress: 0,
|
WriteProgress: 0,
|
||||||
Timestamp: quietParseFloat(row, core.IndexTimestamp),
|
Timestamp: quietParseFloat(row, core.IndexTimestamp),
|
||||||
Pressure: quietParseFloat(row, core.IndexPressure),
|
Pressure: quietParseFloat(row, core.IndexPressure),
|
||||||
Temperature: quietParseFloat(row, core.IndexTemperature),
|
Temperature: quietParseFloat(row, core.IndexTemperature),
|
||||||
Acceleration: core.XYZ{
|
Acceleration: core.XYZ{
|
||||||
X: quietParseFloat(row, core.IndexAccelerationX),
|
X: quietParseFloat(row, core.IndexAccelerationX),
|
||||||
Y: quietParseFloat(row, core.IndexAccelerationY),
|
Y: quietParseFloat(row, core.IndexAccelerationY),
|
||||||
Z: quietParseFloat(row, core.IndexAccelerationZ),
|
Z: quietParseFloat(row, core.IndexAccelerationZ),
|
||||||
},
|
},
|
||||||
Magnetic: core.XYZ{
|
Magnetic: core.XYZ{
|
||||||
X: quietParseFloat(row, core.IndexMagneticX),
|
X: quietParseFloat(row, core.IndexMagneticX),
|
||||||
Y: quietParseFloat(row, core.IndexMagneticY),
|
Y: quietParseFloat(row, core.IndexMagneticY),
|
||||||
Z: quietParseFloat(row, core.IndexMagneticZ),
|
Z: quietParseFloat(row, core.IndexMagneticZ),
|
||||||
},
|
},
|
||||||
Coordinate: core.Coordinate{
|
Coordinate: core.Coordinate{
|
||||||
Lat: quietParseFloat(row, core.IndexCoordinateLat),
|
Lat: quietParseFloat(row, core.IndexCoordinateLat),
|
||||||
Lon: quietParseFloat(row, core.IndexCoordinateLon),
|
Lon: quietParseFloat(row, core.IndexCoordinateLon),
|
||||||
},
|
},
|
||||||
GPSInfo: core.GPSInfo{
|
GPSInfo: core.GPSInfo{
|
||||||
Quality: quietParseFloat(row, core.IndexGpsQuality),
|
Quality: quietParseFloat(row, core.IndexGpsQuality),
|
||||||
Sats: quietParseFloat(row, core.IndexGpsSats),
|
Sats: quietParseFloat(row, core.IndexGpsSats),
|
||||||
},
|
},
|
||||||
Rssi: 0,
|
Rssi: 0,
|
||||||
}
|
}
|
||||||
computed, basePressure, origin := core.ComputeDataSegment(&fd, rawSeg)
|
computed, basePressure, origin := core.ComputeDataSegment(&fd, rawSeg)
|
||||||
fd.AppendData([]core.DataSegment{{
|
fd.AppendData([]core.DataSegment{{
|
||||||
Raw: rawSeg,
|
Raw: rawSeg,
|
||||||
Computed: computed,
|
Computed: computed,
|
||||||
}})
|
}})
|
||||||
fd.SetBasePressure(basePressure)
|
fd.SetBasePressure(basePressure)
|
||||||
fd.SetOrigin(origin)
|
fd.SetOrigin(origin)
|
||||||
if showProgress {
|
if showProgress {
|
||||||
bar.SetCurrent(int64(i))
|
bar.SetCurrent(int64(i))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if showProgress {
|
if showProgress {
|
||||||
bar.Finish()
|
bar.Finish()
|
||||||
}
|
}
|
||||||
return &fd, nil
|
return &fd, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func quietParseFloat(row []string, i int) float64 {
|
func quietParseFloat(row []string, i int) float64 {
|
||||||
f, _ := strconv.ParseFloat(row[i], 64)
|
f, _ := strconv.ParseFloat(row[i], 64)
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package conversion
|
package conversion
|
||||||
|
|
||||||
import "github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
import "github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
|
|
||||||
type Reader interface {
|
type Reader interface {
|
||||||
Read(showProgress bool) (core.FlightData, error)
|
Read(showProgress bool) (core.FlightData, error)
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
module main
|
module main
|
||||||
|
|
||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
replace github.com/johnjones4/model-rocket-telemetry/dashboard/core => ../core
|
replace github.com/johnjones4/model-rocket-telemetry/dashboard/core => ../core
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/cheggaaa/pb/v3 v3.0.8
|
github.com/cheggaaa/pb/v3 v3.0.8
|
||||||
github.com/johnjones4/model-rocket-telemetry/dashboard/core v0.0.0-00010101000000-000000000000
|
github.com/johnjones4/model-rocket-telemetry/dashboard/core v0.0.0-00010101000000-000000000000
|
||||||
github.com/wcharczuk/go-chart/v2 v2.1.0
|
github.com/wcharczuk/go-chart/v2 v2.1.0
|
||||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect
|
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect
|
||||||
)
|
)
|
||||||
|
@ -1,39 +1,39 @@
|
|||||||
github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM=
|
github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM=
|
||||||
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
|
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
|
||||||
github.com/cheggaaa/pb/v3 v3.0.8 h1:bC8oemdChbke2FHIIGy9mn4DPJ2caZYQnfbRqwmdCoA=
|
github.com/cheggaaa/pb/v3 v3.0.8 h1:bC8oemdChbke2FHIIGy9mn4DPJ2caZYQnfbRqwmdCoA=
|
||||||
github.com/cheggaaa/pb/v3 v3.0.8/go.mod h1:UICbiLec/XO6Hw6k+BHEtHeQFzzBH4i2/qk/ow1EJTA=
|
github.com/cheggaaa/pb/v3 v3.0.8/go.mod h1:UICbiLec/XO6Hw6k+BHEtHeQFzzBH4i2/qk/ow1EJTA=
|
||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
|
github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
|
||||||
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
|
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
|
||||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
||||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||||
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
|
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
|
||||||
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
github.com/mattn/go-runewidth v0.0.12 h1:Y41i/hVW3Pgwr8gV+J23B9YEY0zxjptBuCWEaxmAOow=
|
github.com/mattn/go-runewidth v0.0.12 h1:Y41i/hVW3Pgwr8gV+J23B9YEY0zxjptBuCWEaxmAOow=
|
||||||
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/wcharczuk/go-chart/v2 v2.1.0 h1:tY2slqVQ6bN+yHSnDYwZebLQFkphK4WNrVwnt7CJZ2I=
|
github.com/wcharczuk/go-chart/v2 v2.1.0 h1:tY2slqVQ6bN+yHSnDYwZebLQFkphK4WNrVwnt7CJZ2I=
|
||||||
github.com/wcharczuk/go-chart/v2 v2.1.0/go.mod h1:yx7MvAVNcP/kN9lKXM/NTce4au4DFN99j6i1OwDclNA=
|
github.com/wcharczuk/go-chart/v2 v2.1.0/go.mod h1:yx7MvAVNcP/kN9lKXM/NTce4au4DFN99j6i1OwDclNA=
|
||||||
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
|
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
|
||||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 h1:F5Gozwx4I1xtr/sr/8CFbb57iKi3297KFs0QDbGN60A=
|
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 h1:F5Gozwx4I1xtr/sr/8CFbb57iKi3297KFs0QDbGN60A=
|
||||||
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if len(os.Args) < 2 {
|
if len(os.Args) < 2 {
|
||||||
log.Fatal("not enough arguments")
|
log.Fatal("not enough arguments")
|
||||||
}
|
}
|
||||||
cmds := []task{
|
cmds := []task{
|
||||||
newTaskConvert(),
|
newTaskConvert(),
|
||||||
newTaskSummary(),
|
newTaskSummary(),
|
||||||
newTaskChart(),
|
newTaskChart(),
|
||||||
}
|
}
|
||||||
for _, cmd := range cmds {
|
for _, cmd := range cmds {
|
||||||
if cmd.name() == os.Args[1] {
|
if cmd.name() == os.Args[1] {
|
||||||
cmd.FlagSet().Parse(os.Args[2:])
|
cmd.FlagSet().Parse(os.Args[2:])
|
||||||
err := cmd.run()
|
err := cmd.run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
package summerizers
|
package summerizers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ApogeeSummerizer struct {
|
type ApogeeSummerizer struct {
|
||||||
altitude float64
|
altitude float64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ApogeeSummerizer) Generate(fd []core.DataSegment) error {
|
func (s *ApogeeSummerizer) Generate(fd []core.DataSegment) error {
|
||||||
s.altitude = 0
|
s.altitude = 0
|
||||||
for _, d := range fd {
|
for _, d := range fd {
|
||||||
if d.Computed.SmoothedAltitude > s.altitude && d.Computed.FlightMode == core.ModeAscentUnpowered {
|
if d.Computed.SmoothedAltitude > s.altitude && d.Computed.FlightMode == core.ModeAscentUnpowered {
|
||||||
s.altitude = d.Computed.SmoothedAltitude
|
s.altitude = d.Computed.SmoothedAltitude
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if s.altitude == 0 {
|
if s.altitude == 0 {
|
||||||
return errors.New("cannot determine apogee")
|
return errors.New("cannot determine apogee")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ApogeeSummerizer) Value() string {
|
func (s *ApogeeSummerizer) Value() string {
|
||||||
return fmt.Sprintf("%f m", s.altitude)
|
return fmt.Sprintf("%f m", s.altitude)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ApogeeSummerizer) Name() string {
|
func (s *ApogeeSummerizer) Name() string {
|
||||||
return "Apogee"
|
return "Apogee"
|
||||||
}
|
}
|
||||||
|
@ -1,47 +1,47 @@
|
|||||||
package summerizers
|
package summerizers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ModeTimeSummerizer struct {
|
type ModeTimeSummerizer struct {
|
||||||
time float64
|
time float64
|
||||||
mode core.FlightMode
|
mode core.FlightMode
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewModeTimeSummerizer(m core.FlightMode) Summarizer {
|
func NewModeTimeSummerizer(m core.FlightMode) Summarizer {
|
||||||
return &ModeTimeSummerizer{0, m}
|
return &ModeTimeSummerizer{0, m}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ModeTimeSummerizer) Generate(fd []core.DataSegment) error {
|
func (s *ModeTimeSummerizer) Generate(fd []core.DataSegment) error {
|
||||||
s.time = timeInMode(fd, s.mode)
|
s.time = timeInMode(fd, s.mode)
|
||||||
if s.time == 0 {
|
if s.time == 0 {
|
||||||
return fmt.Errorf("cannot determine time in %s", s.mode)
|
return fmt.Errorf("cannot determine time in %s", s.mode)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ModeTimeSummerizer) Value() string {
|
func (s *ModeTimeSummerizer) Value() string {
|
||||||
return fmt.Sprintf("%f s", s.time)
|
return fmt.Sprintf("%f s", s.time)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ModeTimeSummerizer) Name() string {
|
func (s *ModeTimeSummerizer) Name() string {
|
||||||
switch s.mode {
|
switch s.mode {
|
||||||
case core.ModePrelaunch:
|
case core.ModePrelaunch:
|
||||||
return "Prelaunch"
|
return "Prelaunch"
|
||||||
case core.ModeAscentPowered:
|
case core.ModeAscentPowered:
|
||||||
return "Powered Ascent"
|
return "Powered Ascent"
|
||||||
case core.ModeAscentUnpowered:
|
case core.ModeAscentUnpowered:
|
||||||
return "Unpowered Ascent"
|
return "Unpowered Ascent"
|
||||||
case core.ModeDescentFreefall:
|
case core.ModeDescentFreefall:
|
||||||
return "Freefall Descent"
|
return "Freefall Descent"
|
||||||
case core.ModeDescentParachute:
|
case core.ModeDescentParachute:
|
||||||
return "Controlled Descent"
|
return "Controlled Descent"
|
||||||
case core.ModeRecovery:
|
case core.ModeRecovery:
|
||||||
return "Recovery"
|
return "Recovery"
|
||||||
default:
|
default:
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,36 +1,36 @@
|
|||||||
package summerizers
|
package summerizers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OriginSummerizer struct {
|
type OriginSummerizer struct {
|
||||||
origin core.Coordinate
|
origin core.Coordinate
|
||||||
originSet bool
|
originSet bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *OriginSummerizer) Generate(fd []core.DataSegment) error {
|
func (s *OriginSummerizer) Generate(fd []core.DataSegment) error {
|
||||||
s.origin = core.Coordinate{}
|
s.origin = core.Coordinate{}
|
||||||
s.originSet = false
|
s.originSet = false
|
||||||
for _, d := range fd {
|
for _, d := range fd {
|
||||||
if !s.originSet && d.Computed.FlightMode == core.ModeAscentPowered {
|
if !s.originSet && d.Computed.FlightMode == core.ModeAscentPowered {
|
||||||
s.origin = d.Raw.Coordinate
|
s.origin = d.Raw.Coordinate
|
||||||
s.originSet = true
|
s.originSet = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !s.originSet {
|
if !s.originSet {
|
||||||
return errors.New("cannot determine origin")
|
return errors.New("cannot determine origin")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *OriginSummerizer) Value() string {
|
func (s *OriginSummerizer) Value() string {
|
||||||
return fmt.Sprintf("%f/%f", s.origin.Lat, s.origin.Lon)
|
return fmt.Sprintf("%f/%f", s.origin.Lat, s.origin.Lon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *OriginSummerizer) Name() string {
|
func (s *OriginSummerizer) Name() string {
|
||||||
return "Origin"
|
return "Origin"
|
||||||
}
|
}
|
||||||
|
@ -1,36 +1,36 @@
|
|||||||
package summerizers
|
package summerizers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TouchdownSummerizer struct {
|
type TouchdownSummerizer struct {
|
||||||
touchdown core.Coordinate
|
touchdown core.Coordinate
|
||||||
touchdownSet bool
|
touchdownSet bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TouchdownSummerizer) Generate(fd []core.DataSegment) error {
|
func (s *TouchdownSummerizer) Generate(fd []core.DataSegment) error {
|
||||||
s.touchdown = core.Coordinate{}
|
s.touchdown = core.Coordinate{}
|
||||||
s.touchdownSet = false
|
s.touchdownSet = false
|
||||||
for _, d := range fd {
|
for _, d := range fd {
|
||||||
if !s.touchdownSet && d.Computed.FlightMode == core.ModeRecovery {
|
if !s.touchdownSet && d.Computed.FlightMode == core.ModeRecovery {
|
||||||
s.touchdown = d.Raw.Coordinate
|
s.touchdown = d.Raw.Coordinate
|
||||||
s.touchdownSet = true
|
s.touchdownSet = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !s.touchdownSet {
|
if !s.touchdownSet {
|
||||||
return errors.New("cannot determine touchdown")
|
return errors.New("cannot determine touchdown")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TouchdownSummerizer) Value() string {
|
func (s *TouchdownSummerizer) Value() string {
|
||||||
return fmt.Sprintf("%f/%f", s.touchdown.Lat, s.touchdown.Lon)
|
return fmt.Sprintf("%f/%f", s.touchdown.Lat, s.touchdown.Lon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TouchdownSummerizer) Name() string {
|
func (s *TouchdownSummerizer) Name() string {
|
||||||
return "Touchdown"
|
return "Touchdown"
|
||||||
}
|
}
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
package summerizers
|
package summerizers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TravelSummerizer struct {
|
type TravelSummerizer struct {
|
||||||
distance float64
|
distance float64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TravelSummerizer) Generate(fd []core.DataSegment) error {
|
func (s *TravelSummerizer) Generate(fd []core.DataSegment) error {
|
||||||
s.distance = 0
|
s.distance = 0
|
||||||
for _, d := range fd {
|
for _, d := range fd {
|
||||||
if d.Computed.Distance > s.distance && d.Computed.FlightMode == core.ModeRecovery {
|
if d.Computed.Distance > s.distance && d.Computed.FlightMode == core.ModeRecovery {
|
||||||
s.distance = d.Computed.Distance
|
s.distance = d.Computed.Distance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if s.distance == 0 {
|
if s.distance == 0 {
|
||||||
return errors.New("cannot determine travel distance")
|
return errors.New("cannot determine travel distance")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TravelSummerizer) Value() string {
|
func (s *TravelSummerizer) Value() string {
|
||||||
return fmt.Sprintf("%f m", s.distance)
|
return fmt.Sprintf("%f m", s.distance)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TravelSummerizer) Name() string {
|
func (s *TravelSummerizer) Name() string {
|
||||||
return "Travel Distance"
|
return "Travel Distance"
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package summerizers
|
package summerizers
|
||||||
|
|
||||||
import "github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
import "github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
|
|
||||||
type Summarizer interface {
|
type Summarizer interface {
|
||||||
Generate(fd []core.DataSegment) error
|
Generate(fd []core.DataSegment) error
|
||||||
Name() string
|
Name() string
|
||||||
Value() string
|
Value() string
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package summerizers
|
package summerizers
|
||||||
|
|
||||||
import "github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
import "github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
|
|
||||||
func timeInMode(fd []core.DataSegment, mode core.FlightMode) float64 {
|
func timeInMode(fd []core.DataSegment, mode core.FlightMode) float64 {
|
||||||
startTime := -1.0
|
startTime := -1.0
|
||||||
for _, d := range fd {
|
for _, d := range fd {
|
||||||
if d.Computed.FlightMode == mode && startTime < 0 {
|
if d.Computed.FlightMode == mode && startTime < 0 {
|
||||||
startTime = d.Raw.Timestamp
|
startTime = d.Raw.flightTime
|
||||||
} else if d.Computed.FlightMode != mode && startTime > 0 {
|
} else if d.Computed.FlightMode != mode && startTime > 0 {
|
||||||
return d.Raw.Timestamp - startTime
|
return d.Raw.flightTime - startTime
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
package summerizers
|
package summerizers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
type VelocitySummerizer struct {
|
type VelocitySummerizer struct {
|
||||||
mV float64
|
mV float64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *VelocitySummerizer) Generate(fd []core.DataSegment) error {
|
func (s *VelocitySummerizer) Generate(fd []core.DataSegment) error {
|
||||||
s.mV = 0
|
s.mV = 0
|
||||||
for _, d := range fd {
|
for _, d := range fd {
|
||||||
//TODO fix mode checking
|
//TODO fix mode checking
|
||||||
if d.Computed.SmoothedVelocity > s.mV && d.Computed.FlightMode == core.ModeAscentPowered {
|
if d.Computed.SmoothedVelocity > s.mV && d.Computed.FlightMode == core.ModeAscentPowered {
|
||||||
s.mV = d.Computed.SmoothedVelocity
|
s.mV = d.Computed.SmoothedVelocity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if s.mV == 0 {
|
if s.mV == 0 {
|
||||||
return errors.New("cannot determine max v")
|
return errors.New("cannot determine max v")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *VelocitySummerizer) Value() string {
|
func (s *VelocitySummerizer) Value() string {
|
||||||
return fmt.Sprintf("%f m/s", s.mV)
|
return fmt.Sprintf("%f m/s", s.mV)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *VelocitySummerizer) Name() string {
|
func (s *VelocitySummerizer) Name() string {
|
||||||
return "Max Velocity"
|
return "Max Velocity"
|
||||||
}
|
}
|
||||||
|
@ -1,55 +1,55 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
"main/charts"
|
"main/charts"
|
||||||
"path"
|
"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
type taskChart struct {
|
type taskChart struct {
|
||||||
fs *flag.FlagSet
|
fs *flag.FlagSet
|
||||||
input *string
|
input *string
|
||||||
output *string
|
output *string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTaskChart() taskChart {
|
func newTaskChart() taskChart {
|
||||||
tc := taskChart{
|
tc := taskChart{
|
||||||
fs: flag.NewFlagSet("chart", flag.ContinueOnError),
|
fs: flag.NewFlagSet("chart", flag.ContinueOnError),
|
||||||
}
|
}
|
||||||
tc.input = tc.fs.String("input", "", "Input file path")
|
tc.input = tc.fs.String("input", "", "Input file path")
|
||||||
tc.output = tc.fs.String("output", "", "Output folder")
|
tc.output = tc.fs.String("output", "", "Output folder")
|
||||||
return tc
|
return tc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t taskChart) FlagSet() *flag.FlagSet {
|
func (t taskChart) FlagSet() *flag.FlagSet {
|
||||||
return t.fs
|
return t.fs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t taskChart) name() string {
|
func (t taskChart) name() string {
|
||||||
return t.fs.Name()
|
return t.fs.Name()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t taskChart) run() error {
|
func (t taskChart) run() error {
|
||||||
log.Printf("Reading light data from %s\n", *t.input)
|
log.Printf("Reading light data from %s\n", *t.input)
|
||||||
fd, err := flightDataFromFile(*t.input)
|
fd, err := flightDataFromFile(*t.input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
charts := []charts.ChartTask{
|
charts := []charts.ChartTask{
|
||||||
charts.NewAltitudeChart(path.Join(*t.output, "altitude.png")),
|
charts.NewAltitudeChart(path.Join(*t.output, "altitude.png")),
|
||||||
charts.NewVelocityChart(path.Join(*t.output, "velocity.png")),
|
charts.NewVelocityChart(path.Join(*t.output, "velocity.png")),
|
||||||
}
|
}
|
||||||
|
|
||||||
offset := determineOffsetSeconds(fd)
|
offset := determineOffsetSeconds(fd)
|
||||||
|
|
||||||
for _, c := range charts {
|
for _, c := range charts {
|
||||||
err = c.Generate(offset, fd)
|
err = c.Generate(offset, fd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,72 +1,72 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
"main/conversion"
|
"main/conversion"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DataTypeInboard = "inboard"
|
DataTypeInboard = "inboard"
|
||||||
)
|
)
|
||||||
|
|
||||||
type taskConvert struct {
|
type taskConvert struct {
|
||||||
fs *flag.FlagSet
|
fs *flag.FlagSet
|
||||||
input *string
|
input *string
|
||||||
output *string
|
output *string
|
||||||
dtype *string
|
dtype *string
|
||||||
progress *bool
|
progress *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTaskConvert() taskConvert {
|
func newTaskConvert() taskConvert {
|
||||||
tc := taskConvert{
|
tc := taskConvert{
|
||||||
fs: flag.NewFlagSet("convert", flag.ContinueOnError),
|
fs: flag.NewFlagSet("convert", flag.ContinueOnError),
|
||||||
}
|
}
|
||||||
tc.input = tc.fs.String("input", "", "Input file path")
|
tc.input = tc.fs.String("input", "", "Input file path")
|
||||||
tc.dtype = tc.fs.String("type", DataTypeInboard, "Data type (inboard or ground)")
|
tc.dtype = tc.fs.String("type", DataTypeInboard, "Data type (inboard or ground)")
|
||||||
tc.output = tc.fs.String("output", "converted_flight_data.json", "Output file path")
|
tc.output = tc.fs.String("output", "converted_flight_data.json", "Output file path")
|
||||||
tc.progress = tc.fs.Bool("progress", true, "Show progress")
|
tc.progress = tc.fs.Bool("progress", true, "Show progress")
|
||||||
return tc
|
return tc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t taskConvert) FlagSet() *flag.FlagSet {
|
func (t taskConvert) FlagSet() *flag.FlagSet {
|
||||||
return t.fs
|
return t.fs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t taskConvert) name() string {
|
func (t taskConvert) name() string {
|
||||||
return t.fs.Name()
|
return t.fs.Name()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t taskConvert) run() error {
|
func (t taskConvert) run() error {
|
||||||
var readerInst conversion.Reader
|
var readerInst conversion.Reader
|
||||||
switch *t.dtype {
|
switch *t.dtype {
|
||||||
case DataTypeInboard:
|
case DataTypeInboard:
|
||||||
log.Printf("Will read inboard data from %s\n", *t.input)
|
log.Printf("Will read inboard data from %s\n", *t.input)
|
||||||
readerInst = conversion.NewInboardReader(*t.input)
|
readerInst = conversion.NewInboardReader(*t.input)
|
||||||
}
|
}
|
||||||
if readerInst == nil {
|
if readerInst == nil {
|
||||||
return errors.New("data type not supported")
|
return errors.New("data type not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
fd, err := readerInst.Read(*t.progress)
|
fd, err := readerInst.Read(*t.progress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Converting data")
|
log.Println("Converting data")
|
||||||
fdData, err := json.Marshal(fd.AllSegments())
|
fdData, err := json.Marshal(fd.AllSegments())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Writing data")
|
log.Println("Writing data")
|
||||||
err = os.WriteFile(*t.output, fdData, 0777)
|
err = os.WriteFile(*t.output, fdData, 0777)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,64 +1,64 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"main/summerizers"
|
"main/summerizers"
|
||||||
|
|
||||||
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
type taskSummary struct {
|
type taskSummary struct {
|
||||||
fs *flag.FlagSet
|
fs *flag.FlagSet
|
||||||
input *string
|
input *string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTaskSummary() taskSummary {
|
func newTaskSummary() taskSummary {
|
||||||
tc := taskSummary{
|
tc := taskSummary{
|
||||||
fs: flag.NewFlagSet("summary", flag.ContinueOnError),
|
fs: flag.NewFlagSet("summary", flag.ContinueOnError),
|
||||||
}
|
}
|
||||||
tc.input = tc.fs.String("input", "", "Input file path")
|
tc.input = tc.fs.String("input", "", "Input file path")
|
||||||
return tc
|
return tc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t taskSummary) FlagSet() *flag.FlagSet {
|
func (t taskSummary) FlagSet() *flag.FlagSet {
|
||||||
return t.fs
|
return t.fs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t taskSummary) name() string {
|
func (t taskSummary) name() string {
|
||||||
return t.fs.Name()
|
return t.fs.Name()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t taskSummary) run() error {
|
func (t taskSummary) run() error {
|
||||||
log.Printf("Reading light data from %s\n", *t.input)
|
log.Printf("Reading light data from %s\n", *t.input)
|
||||||
fd, err := flightDataFromFile(*t.input)
|
fd, err := flightDataFromFile(*t.input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
summerizers := []summerizers.Summarizer{
|
summerizers := []summerizers.Summarizer{
|
||||||
&summerizers.ApogeeSummerizer{},
|
&summerizers.ApogeeSummerizer{},
|
||||||
&summerizers.VelocitySummerizer{},
|
&summerizers.VelocitySummerizer{},
|
||||||
&summerizers.TravelSummerizer{},
|
&summerizers.TravelSummerizer{},
|
||||||
&summerizers.OriginSummerizer{},
|
&summerizers.OriginSummerizer{},
|
||||||
&summerizers.TouchdownSummerizer{},
|
&summerizers.TouchdownSummerizer{},
|
||||||
summerizers.NewModeTimeSummerizer(core.ModeAscentPowered),
|
summerizers.NewModeTimeSummerizer(core.ModeAscentPowered),
|
||||||
summerizers.NewModeTimeSummerizer(core.ModeAscentUnpowered),
|
summerizers.NewModeTimeSummerizer(core.ModeAscentUnpowered),
|
||||||
summerizers.NewModeTimeSummerizer(core.ModeDescentFreefall),
|
summerizers.NewModeTimeSummerizer(core.ModeDescentFreefall),
|
||||||
summerizers.NewModeTimeSummerizer(core.ModeDescentParachute),
|
summerizers.NewModeTimeSummerizer(core.ModeDescentParachute),
|
||||||
}
|
}
|
||||||
for _, s := range summerizers {
|
for _, s := range summerizers {
|
||||||
log.Printf("Calculating %s\n", s.Name())
|
log.Printf("Calculating %s\n", s.Name())
|
||||||
err = s.Generate(fd)
|
err = s.Generate(fd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range summerizers {
|
for _, s := range summerizers {
|
||||||
log.Printf("%s: %s\n", s.Name(), s.Value())
|
log.Printf("%s: %s\n", s.Name(), s.Value())
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
)
|
)
|
||||||
|
|
||||||
type task interface {
|
type task interface {
|
||||||
FlagSet() *flag.FlagSet
|
FlagSet() *flag.FlagSet
|
||||||
name() string
|
name() string
|
||||||
run() error
|
run() error
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
"github.com/johnjones4/model-rocket-telemetry/dashboard/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flightDataFromFile(input string) ([]core.DataSegment, error) {
|
func flightDataFromFile(input string) ([]core.DataSegment, error) {
|
||||||
bytes, err := os.ReadFile(input)
|
bytes, err := os.ReadFile(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var segs []core.DataSegment
|
var segs []core.DataSegment
|
||||||
err = json.Unmarshal(bytes, &segs)
|
err = json.Unmarshal(bytes, &segs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return segs, err
|
return segs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func determineOffsetSeconds(ds []core.DataSegment) float64 {
|
func determineOffsetSeconds(ds []core.DataSegment) float64 {
|
||||||
for _, d := range ds {
|
for _, d := range ds {
|
||||||
if d.Computed.FlightMode == core.ModeAscentPowered {
|
if d.Computed.FlightMode == core.ModeLaunch {
|
||||||
return d.Raw.Timestamp
|
return d.Raw.flightTime
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -1,157 +1,327 @@
|
|||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
#define TRIGGER_FLIGHT_TIME '#'
|
#include <stdlib.h>
|
||||||
#define TRIGGER_ALTITUDE_100 '{'
|
#include <base64.hpp>
|
||||||
#define TRIGGER_ALTITUDE '<'
|
|
||||||
#define TRIGGER_VELOCITY '('
|
#define BIT(n) (1 << (n))
|
||||||
#define TRIGGER_ACCELERATION_10 '\\'
|
|
||||||
#define TRIGGER_FLIGHT_PHASE '@'
|
#define BIT_FLIGHT_TIME BIT(0)
|
||||||
#define TRIGGER_CHANNEL '~'
|
#define BIT_ALTITUDE_100 BIT(1)
|
||||||
#define TRIGGER_TEMPERATURE_10 '!'
|
#define BIT_ALTITUDE BIT(2)
|
||||||
#define TRIGGER_NAME '='
|
#define BIT_VELOCITY BIT(3)
|
||||||
#define TRIGGER_BATERY_10 '?'
|
#define BIT_ACCELERATION BIT(4)
|
||||||
#define TRIGGER_APOGEE '%'
|
#define BIT_FLIGHT_PHASE BIT(5)
|
||||||
#define TRIGGER_MAX_VELOCITY '^'
|
#define BIT_CHANNEL BIT(6)
|
||||||
#define TRIGGER_MAX_ACCELERATION '['
|
#define BIT_TEMPERATURE_10 BIT(7)
|
||||||
#define TRIGGER_END_PACKET '>'
|
#define BIT_NAME BIT(8)
|
||||||
|
#define BIT_BATERY_10 BIT(9)
|
||||||
typedef union EggtimerData
|
#define BIT_APOGEE BIT(10)
|
||||||
{
|
#define BIT_MAX_VELOCITY BIT(11)
|
||||||
int fight_time;
|
#define BIT_MAX_ACCELERATION BIT(12)
|
||||||
int altitude_100;
|
#define ALL_ELEMENTS 0b1111111111111
|
||||||
int altitude;
|
|
||||||
int velocity;
|
#define TRIGGER_FLIGHT_TIME '#'
|
||||||
int acceleration_10;
|
#define TRIGGER_ALTITUDE_100 '{'
|
||||||
int fight_phase;
|
#define TRIGGER_ALTITUDE '<'
|
||||||
char channel[6];
|
#define TRIGGER_VELOCITY '('
|
||||||
int temperature_10;
|
#define TRIGGER_ACCELERATION_10 '\\'
|
||||||
char name[9];
|
#define TRIGGER_FLIGHT_PHASE '@'
|
||||||
int battery_voltage_10;
|
#define TRIGGER_CHANNEL '~'
|
||||||
int apogee;
|
#define TRIGGER_TEMPERATURE_10 '!'
|
||||||
int max_velocity;
|
#define TRIGGER_NAME '='
|
||||||
int max_acceleration;
|
#define TRIGGER_BATERY_10 '?'
|
||||||
}EggtimerData;
|
#define TRIGGER_APOGEE '%'
|
||||||
|
#define TRIGGER_MAX_VELOCITY '^'
|
||||||
typedef struct EggtimerElementPacket{
|
#define TRIGGER_MAX_ACCELERATION '['
|
||||||
char type;
|
#define TRIGGER_END_PACKET '>'
|
||||||
EggtimerData data;
|
|
||||||
} EggtimerElementPacket;
|
#define MAX_DATA_SIZE 100
|
||||||
|
|
||||||
static char _last_state = 0;
|
typedef struct WhiteVestsPacket{
|
||||||
static size_t counter = 0;
|
double flight_time;
|
||||||
|
double flight_phase;
|
||||||
/**
|
double altitude;
|
||||||
* @brief this function stores the data in the element packet
|
double velocity;
|
||||||
*/
|
double acceleration;
|
||||||
void _save_data(char byte_received, EggtimerElementPacket *element){
|
double temperature;
|
||||||
switch (_last_state)
|
double latitude;
|
||||||
{
|
double longitude;
|
||||||
case TRIGGER_FLIGHT_TIME:
|
double gpsSignal; // GPS Signal Strength
|
||||||
case TRIGGER_ALTITUDE_100:
|
double gpsstat; // GPS Status
|
||||||
case TRIGGER_ALTITUDE:
|
}WhiteVestsPacket;
|
||||||
case TRIGGER_VELOCITY:
|
|
||||||
case TRIGGER_ACCELERATION_10:
|
typedef struct EggtimerElement{
|
||||||
case TRIGGER_FLIGHT_PHASE:
|
char type;
|
||||||
case TRIGGER_TEMPERATURE_10:
|
char data[MAX_DATA_SIZE];
|
||||||
case TRIGGER_BATERY_10:
|
} EggtimerElement;
|
||||||
case TRIGGER_APOGEE:
|
|
||||||
case TRIGGER_MAX_VELOCITY:
|
/**
|
||||||
case TRIGGER_MAX_ACCELERATION:
|
* @brief This function is used to parse the data received from the Eggtimer
|
||||||
element->data.altitude *= 10;
|
* @param byte_received byte received
|
||||||
element->data.altitude += byte_received - '0';
|
* @param packet package to store the data
|
||||||
break;
|
*
|
||||||
case TRIGGER_CHANNEL:
|
* @return true if receive new data packet, false otherwise
|
||||||
case TRIGGER_NAME:
|
*/
|
||||||
element->data.name[counter++] = byte_received;
|
bool decode_eggtimer_data(char byte_received, EggtimerElement * packet){
|
||||||
break;
|
static size_t counter = 0;
|
||||||
default:
|
static char last_state = 0;
|
||||||
|
|
||||||
break;
|
switch (byte_received)
|
||||||
}
|
{
|
||||||
}
|
case TRIGGER_FLIGHT_TIME:
|
||||||
|
case TRIGGER_ALTITUDE_100:
|
||||||
/**
|
case TRIGGER_ALTITUDE:
|
||||||
* @brief This function is used to parse the data received from the Eggtimer
|
case TRIGGER_VELOCITY:
|
||||||
* @param byte_received byte received
|
case TRIGGER_ACCELERATION_10:
|
||||||
* @param packet package to store the data
|
case TRIGGER_FLIGHT_PHASE:
|
||||||
*
|
case TRIGGER_CHANNEL:
|
||||||
* @return true if receive new data packet, false otherwise
|
case TRIGGER_TEMPERATURE_10:
|
||||||
*/
|
case TRIGGER_NAME:
|
||||||
bool decode_eggtimer_data(char byte_received, EggtimerElementPacket * packet){
|
case TRIGGER_BATERY_10:
|
||||||
|
case TRIGGER_APOGEE:
|
||||||
switch (byte_received)
|
case TRIGGER_MAX_VELOCITY:
|
||||||
{
|
case TRIGGER_MAX_ACCELERATION:
|
||||||
case TRIGGER_FLIGHT_TIME:
|
|
||||||
case TRIGGER_ALTITUDE_100:
|
last_state = byte_received;
|
||||||
case TRIGGER_ALTITUDE:
|
packet->type = byte_received;
|
||||||
case TRIGGER_VELOCITY:
|
|
||||||
case TRIGGER_ACCELERATION_10:
|
memset(&packet->data, 0, sizeof packet->data);
|
||||||
case TRIGGER_FLIGHT_PHASE:
|
counter = 0;
|
||||||
case TRIGGER_CHANNEL:
|
break;
|
||||||
case TRIGGER_TEMPERATURE_10:
|
|
||||||
case TRIGGER_NAME:
|
case TRIGGER_END_PACKET:
|
||||||
case TRIGGER_BATERY_10:
|
if (last_state){
|
||||||
case TRIGGER_APOGEE:
|
packet->type = last_state;
|
||||||
case TRIGGER_MAX_VELOCITY:
|
packet->data[counter] = '\0';
|
||||||
case TRIGGER_MAX_ACCELERATION:
|
last_state = 0;
|
||||||
|
return true;
|
||||||
_last_state = byte_received;
|
}
|
||||||
packet->type = byte_received;
|
last_state = 0;
|
||||||
|
break;
|
||||||
memset(&packet->data, 0, sizeof packet->data);
|
default:
|
||||||
Serial.println( byte_received);
|
// save data
|
||||||
counter = 0;
|
if(last_state)
|
||||||
break;
|
packet->data[counter++] = byte_received;
|
||||||
|
break;
|
||||||
case TRIGGER_END_PACKET:
|
}
|
||||||
if (_last_state){
|
return false;
|
||||||
packet->type = _last_state;
|
}
|
||||||
|
|
||||||
_last_state = 0;
|
|
||||||
return true;
|
bool buildPacket(EggtimerElement *eggt_packet, WhiteVestsPacket *wv_packet){
|
||||||
}
|
static int16_t elements_received = 0;
|
||||||
_last_state = 0;
|
static WhiteVestsPacket nextPacket; // packet used when the packet is sent but it is not complete
|
||||||
break;
|
static bool sentIncomplete = false;
|
||||||
default:
|
|
||||||
_save_data(byte_received, packet);
|
if(sentIncomplete){
|
||||||
break;
|
memcpy(wv_packet, &nextPacket, sizeof(WhiteVestsPacket));
|
||||||
}
|
sentIncomplete = false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
int16_t element_bit = NULL;
|
||||||
|
double *element_pointer = NULL;
|
||||||
bool test(){
|
double *nextElement_pointer = NULL;
|
||||||
char str[] = "{004>@5>#0132>~1B---->(00023>\\000>%04679>^0660>[025>?079>!201>=KM6ZFL>";
|
|
||||||
char *p = str;
|
|
||||||
EggtimerElementPacket packet;
|
// convert data to double
|
||||||
for (; *p; p++)
|
bool converted = true;
|
||||||
{
|
char *endptr;
|
||||||
if(decode_eggtimer_data(*p, &packet)){
|
double element = strtol((char*)&eggt_packet->data, &endptr, 10);
|
||||||
Serial.print("Data packet: ");
|
if(endptr == (char*)&eggt_packet->data|| *endptr != NULL){ // error
|
||||||
if(packet.type == TRIGGER_NAME || packet.type == TRIGGER_CHANNEL){
|
converted = false;
|
||||||
Serial.println(packet.data.name);
|
element = 0;
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
Serial.println(packet.data.altitude);
|
switch (eggt_packet->type){
|
||||||
}
|
case TRIGGER_FLIGHT_TIME:
|
||||||
|
element_bit = BIT_FLIGHT_TIME;
|
||||||
}
|
element_pointer = &wv_packet->flight_time;
|
||||||
}
|
nextElement_pointer = &nextPacket.flight_time;
|
||||||
|
break;
|
||||||
return false;
|
case TRIGGER_ALTITUDE_100:
|
||||||
|
element_bit = BIT_ALTITUDE_100;
|
||||||
}
|
element_pointer = &wv_packet->altitude;
|
||||||
|
nextElement_pointer = &nextPacket.altitude;
|
||||||
void setup() {
|
element *= 100.0;
|
||||||
Serial.begin(9600);
|
break;
|
||||||
while (!Serial);
|
case TRIGGER_ALTITUDE:
|
||||||
|
element_bit = BIT_ALTITUDE;
|
||||||
Serial.println("Ready!");
|
element_pointer = &wv_packet->altitude;
|
||||||
|
nextElement_pointer = &nextPacket.altitude;
|
||||||
test();
|
break;
|
||||||
}
|
case TRIGGER_VELOCITY:
|
||||||
|
element_bit = BIT_VELOCITY;
|
||||||
void loop() {
|
element_pointer = &wv_packet->velocity;
|
||||||
}
|
nextElement_pointer = &nextPacket.velocity;
|
||||||
|
break;
|
||||||
|
case TRIGGER_ACCELERATION_10:
|
||||||
|
element_bit = BIT_ACCELERATION;
|
||||||
|
element_pointer = &wv_packet->acceleration;
|
||||||
|
nextElement_pointer = &nextPacket.acceleration;
|
||||||
|
|
||||||
|
element /= 10;
|
||||||
|
break;
|
||||||
|
case TRIGGER_FLIGHT_PHASE:
|
||||||
|
element_bit = BIT_FLIGHT_PHASE;
|
||||||
|
element_pointer = &wv_packet->flight_phase;
|
||||||
|
nextElement_pointer = &nextPacket.flight_phase;
|
||||||
|
break;
|
||||||
|
case TRIGGER_TEMPERATURE_10:
|
||||||
|
element_bit = BIT_TEMPERATURE_10;
|
||||||
|
element_pointer = &wv_packet->temperature;
|
||||||
|
nextElement_pointer = &nextPacket.temperature;
|
||||||
|
element /= 10;
|
||||||
|
break;
|
||||||
|
case TRIGGER_BATERY_10:
|
||||||
|
element_bit = BIT_BATERY_10;
|
||||||
|
break;
|
||||||
|
case TRIGGER_APOGEE:
|
||||||
|
element_bit = BIT_APOGEE;
|
||||||
|
break;
|
||||||
|
case TRIGGER_MAX_VELOCITY:
|
||||||
|
element_bit = BIT_MAX_VELOCITY;
|
||||||
|
break;
|
||||||
|
case TRIGGER_MAX_ACCELERATION:
|
||||||
|
element_bit = BIT_MAX_ACCELERATION;
|
||||||
|
break;
|
||||||
|
case TRIGGER_CHANNEL:
|
||||||
|
element_bit = BIT_CHANNEL;
|
||||||
|
break;
|
||||||
|
case TRIGGER_NAME:
|
||||||
|
element_bit = BIT_NAME;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if the data received is from current packet, if not, it will be stored in the next packet
|
||||||
|
if((elements_received & element_bit) && element_pointer != NULL && nextElement_pointer != NULL && converted){
|
||||||
|
memcpy(&nextPacket, wv_packet, sizeof(WhiteVestsPacket));
|
||||||
|
*nextElement_pointer = element; // stores element in nextPacket
|
||||||
|
elements_received = element_bit;
|
||||||
|
sentIncomplete = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( element_pointer != NULL){
|
||||||
|
if(converted)
|
||||||
|
*element_pointer = element;
|
||||||
|
else
|
||||||
|
return false; // error converting data
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
elements_received |= element_bit;
|
||||||
|
|
||||||
|
// check if the packet is complete
|
||||||
|
if(elements_received == ALL_ELEMENTS){
|
||||||
|
elements_received = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function send the packet to the server
|
||||||
|
*/
|
||||||
|
void sendPacket(WhiteVestsPacket * packet){
|
||||||
|
unsigned char data_base64[255];
|
||||||
|
encode_base64((unsigned char*)packet, sizeof(WhiteVestsPacket), data_base64);
|
||||||
|
|
||||||
|
char rssi_base64[] = "//8=";
|
||||||
|
|
||||||
|
Serial.print("T,");
|
||||||
|
Serial.print((char *) data_base64);
|
||||||
|
Serial.print(",");
|
||||||
|
Serial.print((char *) rssi_base64);
|
||||||
|
Serial.print("\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool test(){
|
||||||
|
char str[] ="{000>@1>#0000>~AB---->?079>!211>=KM6ZFL>"
|
||||||
|
"{000>@1>#0000>~AB---->?079>!211>=KM6ZFL>"
|
||||||
|
"{040>@2>#0010>~AB---->(0213>\\-001>?079>!212>=KM6ZFL>01>?079>!212>=KM6ZFL>"
|
||||||
|
"{045>@2>#0014>~AB---->(0072>\\-001>?079>!212>=KM6ZFL>"
|
||||||
|
"{046>@4>#0016>~AB---->(0033>\\-001>?079>!212>=KM6ZFL>"
|
||||||
|
"{046>@5>#0018>~1B---->(2787>\\000>%04679>^0660>[025>?079>!210>=KM6ZFL> "
|
||||||
|
"{045>@5>#0020>~1B---->(-0354>\\0=KM6ZFL>"
|
||||||
|
"{043>@5>#0022>~1B---->(-0029>\\004>%04679>^0660>[025>?079>!209>=KM6ZFL>"
|
||||||
|
"{043>@5>#0024>~1B---->(-0023>\\000>%04679>^0660>[025>?079>!209>=KM6ZFL>"
|
||||||
|
"{042>@5>#0026>~1B---->(-0028>\\000>%04679>^0660>[025>?079>!209>=KM6ZFL>"
|
||||||
|
"{042>@5>#0028>~1B---->(-0035>\\000>%04679>^0660>[025>?079>!209>=KM6ZFL>"
|
||||||
|
"{041>@5>#0030>~1B---->(-0029>\\000>%04679>^0660>[025>?079>!209>=KM6ZFL>"
|
||||||
|
"{040>@5>#0032>~1B---->(-0032>\\000>%04679>^0660>[025>?079>!209>=KM6ZFL>"
|
||||||
|
"{040>@5>#0034>~1B---->(-0021>\\000>%04679>^0660>[025>?079>!209>=KM6ZFL>"
|
||||||
|
"{039>@5>#0036>~1B---->(-0028>\\000>%04679>^0660>[025>?079>!209>=KM6ZFL>"
|
||||||
|
"{038>@5>#0038>~1B---->(-0028>\\000>%04679>^0660>[025>?079>!209>=KM6ZFL>"
|
||||||
|
"{038>@5>#0040>~1B---->(-0031>\\000>%04679>^0660>[025>?079>!209>=KM6ZFL>"
|
||||||
|
"{037>@5>#0042>~1B---->(-0043>\\000>%04679>^0660>[025>?079>!208>=KM6ZFL>"
|
||||||
|
"{037>@5>#0044>~1B---->(-0040>\\000>%04679>^0660>[025>?079>!209>=KM6ZFL>"
|
||||||
|
"{036>@5>#0046>~1B---->(-0022>\\000>%04679>^0660>[025>?079>!208>=KM6ZFL>"
|
||||||
|
"{035>@5>#0048>~1B---->(-0038>\\000>%04679>^0660>[025>?079>!208>=KM6ZFL>"
|
||||||
|
"{034>@5>#0050>~1B---->(-0028>\\000>%04679>^0660>[025>?079>!208>=KM6ZFL>"
|
||||||
|
"{034>@5>#0052>~1B---->(-0043>\\0=KM6ZFL>"
|
||||||
|
"{033>@5>#0054>~1B---->(-0033>\\000>%04679>^0660>[025>?079>!208>=KM6ZFL>"
|
||||||
|
"{032>@5>#0056>~1B---->(-0041>\\000>%04679>^0660>[025>?079>!208>=KM6ZFL>"
|
||||||
|
"{032>@5>#0058>~1B---->(-0026>\\000>%04679>^0660>[025>?079>!207>=KM6ZFL>"
|
||||||
|
"{031>@5>#0060>~1B---->(-0035>\\000>%04679>^0660>[025>?079>!208>=KM6ZFL>"
|
||||||
|
"{030>@5>#0062>~1B---->(-0037>\\000>%04679>^0660>[025>?079>!207>=KM6ZFL>"
|
||||||
|
"{029>@5>#0064>~1B---->(-0032>\\000>%04679>^0660>[025>?079>!207>=KM6ZFL>"
|
||||||
|
"{029>@5>#0066>~1B---->(-0035>\\000>%04679>^0660>[025>?079>!207>=KM6ZFL>"
|
||||||
|
"{028>@5>#0068>~1B---->(-0044>\\000>%04679>^0660>[025>?079>!207>=KM6ZFL>"
|
||||||
|
"{027>@5>#0070>~1B---->(-0045>\\000>%04679>^0660>[025>?079>!207>=KM6ZFL>"
|
||||||
|
"{026>@5>#0072>~1B---->(-0035>\\000>%04679>^0660>[025>?079>!206>=KM6ZFL>"
|
||||||
|
"{025>@5>#0074>~1B---->(-0045>\\000>%04679>^0660>[025>?079>!206>=KM6ZFL>"
|
||||||
|
"{025>@5>#0076>~1B---->(-0043>\\000>%04679>^0660>[025>?079>!206>=KM6ZFL>"
|
||||||
|
"{024>@5>#0078>~1B---->(-0046>\\000>%04679>^0660>[025>?079>!206>=KM6ZFL>"
|
||||||
|
"{023>@5>#0080>~1B---->(-0046>\\000>%04679>^0660>[025>?079>!206>=KM6ZFL>"
|
||||||
|
"{022>@5>#0082>~1B---->(-0037>\\000>%04679>^0660>[025>?079>!206>=KM6ZFL>"
|
||||||
|
"{021>@5>#0084>~1B---->(-0039>\\000>%04679>^0660>[025>?079>!205>=KM6ZFL>"
|
||||||
|
"{020>@5>#0086>~1B---->(-0043>\\000>%04679>^0660>[025>?079>!205>=KM6ZFL>"
|
||||||
|
"{020>@5>#0088>~1B---->(-0046>\\000>%04679>^0660>[025>?079>!205>=KM6ZFL>"
|
||||||
|
"{019>@5>#0090>~1B---->(-0037>\\000>%04679>^0660>[025>?079>!205>=KM6ZFL>"
|
||||||
|
"{018>@5>#0092>~1B---->(-0046>\\000>%04679>^0660>[025>?079>!205>=KM6ZFL>"
|
||||||
|
"{017>@5>#0094>~1B---->(-0035>\\000>%04679>^0660>[025>?079>!205>=KM6ZFL>"
|
||||||
|
"{016>@5>#0096>~1B---->(-0046>\\000>%04679>^0660>[025>?079>!205>=KM6ZFL>"
|
||||||
|
"{016>@5>#0098>~1B---->(-0032>\\000>%04679>^0660>[025>?079>!204>=KM6ZFL>"
|
||||||
|
"{015>@5>#0100>~1B---->(-0043>\\000>%04679>^0660>[025>?079>!204>=KM6ZFL>"
|
||||||
|
"{014>@5>#0102>~1B---->(-0037>\\000>%04679>^0660>[025>?079>!204>=KM6ZFL>"
|
||||||
|
"{013>@5>#0104>~1B---->(-0033>\\000>%04679>^0660>[025>?079>!204>=KM6ZFL>"
|
||||||
|
"{012>@5>#0106>~1B---->(-0026>\\000>%04679>^0660>[025>?079>!204>=KM6ZFL>"
|
||||||
|
"{012>@5>#0108>~1B---->(-0029>\\000>%04679>^0660>[025>?079>!204>=KM6ZFL>"
|
||||||
|
"{011>@5>#0110>~1B---->(-0042>\\000>%04679>^0660>[025>?079>!203>=KM6ZFL>"
|
||||||
|
"{010>@5>#0112>~1B---->(-0041>\\000>%04679>^0660>[025>?079>!203>=KM6ZFL>"
|
||||||
|
"{009>@5>#0114>~1B---->(-0037>\\000>%04679>^0660>[025>?079>!203>=KM6ZFL>"
|
||||||
|
"{009>@5>#0116>~1B---->(-0040>\\000>%04679>^0660>[025>?079>!203>=KM6ZFL>"
|
||||||
|
"{008>@5>#0118>~1B---->(-0043>\\000>%04679>^0660>[025>?079>!202>=KM6ZFL>";
|
||||||
|
|
||||||
|
char *p = str;
|
||||||
|
EggtimerElement eggt_packet;
|
||||||
|
WhiteVestsPacket wv_packet;
|
||||||
|
memset(&wv_packet, 0, sizeof(WhiteVestsPacket));
|
||||||
|
for (; *p; p++){
|
||||||
|
if(decode_eggtimer_data(*p, &eggt_packet) && buildPacket(&eggt_packet, &wv_packet)){
|
||||||
|
sendPacket(&wv_packet);
|
||||||
|
delay(2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(9600);
|
||||||
|
Serial.flush();
|
||||||
|
while (!Serial);
|
||||||
|
Serial.println();
|
||||||
|
test();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user