Note: Goby version 1 (shown here) is now considered obsolete. Please use version 2 for new projects, and consider upgrading old projects.

Goby Underwater Autonomy Project  Series: 1.1, revision: 163, released on 2013-02-06 14:23:27 -0500
acomms/acomms_constants.h
00001 // copyright 2009-2011 t. schneider tes@mit.edu
00002 // 
00003 // this file is part of goby-acomms, a collection of libraries for acoustic underwater networking
00004 //
00005 // This program is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // This software is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this software.  If not, see <http://www.gnu.org/licenses/>.
00017 
00018 #ifndef AcommsConstants20091122H
00019 #define AcommsConstants20091122H
00020 
00021 #include <string>
00022 #include <limits>
00023 #include <bitset>
00024 
00025 #include "goby/core/core_constants.h"
00026 
00027 namespace goby
00028 {
00029 
00030     namespace acomms
00031     {
00032         const unsigned BITS_IN_BYTE = 8;
00033         // one hex char is a nibble (4 bits), two nibbles per byte
00034         const unsigned NIBS_IN_BYTE = 2;
00035 
00037         const int BROADCAST_ID = 0;
00039         const int QUERY_DESTINATION_ID = -1;
00040         
00041         const unsigned char DCCL_CCL_HEADER = 32;
00042     
00043         const double NaN = std::numeric_limits<double>::quiet_NaN();
00044         
00045         const unsigned DCCL_NUM_HEADER_BYTES = 6;
00046 
00047         const unsigned DCCL_NUM_HEADER_PARTS = 8;
00048 
00049         enum DCCLHeaderPart { HEAD_CCL_ID = 0,
00050                               HEAD_DCCL_ID = 1,
00051                               HEAD_TIME = 2,
00052                               HEAD_SRC_ID = 3,
00053                               HEAD_DEST_ID = 4,
00054                               HEAD_MULTIMESSAGE_FLAG = 5,
00055                               HEAD_BROADCAST_FLAG = 6,
00056                               HEAD_UNUSED = 7
00057         };
00058     
00059         const std::string DCCL_HEADER_NAMES [] = { "_ccl_id",
00060                                                    "_id",
00061                                                    "_time",
00062                                                    "_src_id",
00063                                                    "_dest_id",
00064                                                    "_multimessage_flag",
00065                                                    "_broadcast_flag",
00066                                                    "_unused",
00067         };
00068         inline std::string to_str(DCCLHeaderPart p)
00069         {
00070             return DCCL_HEADER_NAMES[p];
00071         }
00072 
00073         
00074         enum DCCLHeaderBits { HEAD_CCL_ID_SIZE = 8,
00075                               HEAD_DCCL_ID_SIZE = 9,
00076                               HEAD_TIME_SIZE = 17,
00077                               HEAD_SRC_ID_SIZE = 5,
00078                               HEAD_DEST_ID_SIZE = 5,
00079                               HEAD_FLAG_SIZE = 1,
00080                               HEAD_UNUSED_SIZE = 2
00081         };
00082 
00083 
00084         
00085                 
00086         
00087     }
00088 }
00089 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends