Changeset 18725 for branches


Ignore:
Timestamp:
01/10/17 13:51:37 (8 years ago)
Author:
(none)
Message:
move structs into header
Location:
branches/FACT++_lidctrl_usb/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/FACT++_lidctrl_usb/src/HeadersLid.h

    r18724 r18725  
    22#define FACT_HeadersLid
    33
    4 namespace LidCtrlUsb
     4namespace Lid
    55{
     6
     7    struct motor_status_t{
     8        float current_mean;
     9        float position_mean;
     10        int32_t speed;
     11    } __attribute__((__packed__));
     12
     13    struct mean_var_samples_t {
     14        uint32_t mean;
     15        uint32_t var;
     16        uint16_t samples;
     17    }__attribute__((packed));
     18
     19    struct message_t {
     20        mean_var_samples_t inner_motor_current;
     21        mean_var_samples_t outer_motor_current;
     22
     23        mean_var_samples_t inner_motor_position;
     24        mean_var_samples_t outer_motor_position;
     25
     26        int16_t inner_motor_speed;
     27        int16_t outer_motor_speed;
     28
     29        char current_cmd;
     30        uint8_t system_state;
     31    }__attribute__((packed));
     32
    633    namespace State
    734    {
  • branches/FACT++_lidctrl_usb/src/lidctrl.cc

    r18724 r18725  
    2424using namespace std;
    2525
    26 using namespace LidCtrlUsb;
     26using namespace Lid;
    2727
    2828#include "DimDescriptionService.h"
     
    3636    State::states_t state;
    3737    State::states_t last_state;
    38     struct mean_std_t {
    39       uint32_t mean;
    40       uint32_t var;
    41       uint16_t samples;
    42     }__attribute__((packed));
    43 
    44    struct motor_status_t{
    45       float current_mean;
    46       float position_mean;
    47       int32_t speed;
    48    } __attribute__((__packed__));
    49 
    50    struct message_t {
    51       mean_std_t inner_motor_current;
    52       mean_std_t outer_motor_current;
    53 
    54       mean_std_t inner_motor_position;
    55       mean_std_t outer_motor_position;
    56 
    57       int16_t inner_motor_speed;
    58       int16_t outer_motor_speed;
    59 
    60       char current_cmd;
    61       uint8_t system_state;
    62   }__attribute__((packed));
    63 
    64   DimDescribedService fDimInnerMotor;
    65   DimDescribedService fDimOuterMotor;
     38
     39    DimDescribedService fDimInnerMotor;
     40    DimDescribedService fDimOuterMotor;
    6641    message_t fLastMessage;
     42
    6743    void PrintMessage(const message_t msg)
    6844    {
     
    8359    {
    8460        int complete_msg_size = 6 /*start:*/ + sizeof(message_t) + sizeof(uint16_t)/*chksum*/;  // 54 bytes
    85  
     61
    8662        std::copy(fRecievedBytes.begin(), fRecievedBytes.begin()+bytes_received, std::back_inserter(fCollectedBytes));
    8763        if (fCollectedBytes.size() > 2*complete_msg_size)
     
    9672            message_t msg;
    9773            memcpy(&msg, part.data(), sizeof(message_t));
    98            
     74
    9975            const uint16_t chk0 = Tools::Fletcher16(part.c_str(), sizeof(message_t));
    10076            uint16_t chk1;
     
    11187                inner_motor_status.position_mean = (float)(msg.inner_motor_position.mean);
    11288                inner_motor_status.speed = (int32_t)msg.inner_motor_speed;
    113                
     89
    11490                motor_status_t outer_motor_status;
    11591                outer_motor_status.current_mean = (float)(msg.outer_motor_current.mean) * 3.4;
     
    12298                }
    12399
    124                 last_state = state;           
     100                last_state = state;
    125101            }
    126102        }
     
    157133        return state;
    158134    }
    159 
    160 
    161 
    162135};
    163136
     
    204177        return T::GetCurrentState();
    205178    }
    206    
     179
    207180    int Close()
    208181    {
Note: See TracChangeset for help on using the changeset viewer.