/home/runner/work/kynema/kynema/kynema/src/utilities/controllers/controller_io.hpp Source File

Kynema API: /home/runner/work/kynema/kynema/kynema/src/utilities/controllers/controller_io.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
controller_io.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4
5namespace kynema::util {
6
7static constexpr int kSwapArraySize = 128;
8
12 int status = 0; // Input: Status flag [0=first call, 1=intermediate, -1=final] (-)
13 double time = 0.; // Input: Current time (sec)
14 double dt = 0.; // Input: Communication interval (sec)
15 double pitch_blade1_actual = 0.; // Input: Blade 1 pitch angle (rad)
16 double pitch_actuator_type_req = 0.; // Input: Pitch actuator type [0=position, 1=rate] (-)
17 double generator_power_actual = 0.; // Input: Measured electrical power output (W)
18 double generator_speed_actual = 0.; // Input: Measured generator speed (rad/s)
19 double rotor_speed_actual = 0.; // Input: Measured rotor speed (rad/s)
20 double generator_torque_actual = 0.; // Input: Measured generator torque (Nm)
21 double yaw_error_actual = 0.; // Input: Measured yaw error (rad)
22 double horizontal_wind_speed = 0.; // Input: Horizontal hub-heigh wind speed (m/s)
23 double pitch_control_type = 0.; // Input: Pitch control type [0=collective, 1=individual]
24 double pitch_blade2_actual = 0.; // Input: Blade 2 pitch
25 double pitch_blade3_actual = 0.; // Input: Blade 3 pitch
26 int generator_contactor_status = 0; // Output: Generator contactor status
27 int shaft_brake_status = 0; // Input: Shaft brake status [0=off, 1=on]
28 double yaw_angle_actual = 0; // Input: Nacelle yaw angle from North (rad)
29 double yaw_actuator_torque_command = 0.; // Output: Demanded yaw actuator torque
30 double pitch_blade1_command = 0.; // Output: pitch command (rad)
31 double pitch_blade2_command = 0.; // Output: pitch command (rad)
32 double pitch_blade3_command = 0.; // Output: pitch command (rad)
33 double pitch_collective_command = 0.; // Output: pitch collective command (rad)
34 double pitch_rate_command = 0.; // Output: Demanded pitch rate (Collective pitch)
35 double generator_torque_command = 0.; // Output: Demanded generator torque
36 double nacelle_yaw_rate_command = 0.; // Output: Demanded nacelle yaw rate
37 size_t message_array_size = 0U; // Input: avcMSG array size
38 size_t infile_array_size = 0U; // Input: avcINFILE array size
39 size_t outname_array_size = 0U; // Input: avcOUTNAME array size
40 double tower_top_fore_aft_accel = 0.; // Input: Tower top fore-aft acceleration (m/s^2)
41 int pitch_override = 0; // Input: Pitch override: 0=yes
42 int torque_override = 0; // Input: Torque override: 0=yes
43 double azimuth_angle = 0.; // Input: Azimuth angle (rad)
44 size_t n_blades = 0U; // Input: Number of blades
45 size_t n_log_variables = 0U; // Input: Number of variables returned for logging
46 double generator_startup_resistance = 0.; // Input: Generator start-up resistance
47 int loads_request = 0; // Input: Request for loads: 0=none
48 int variable_slip_status = 0; // Input: Variable slip current status
49 int variable_slip_demand = 0; // Input: Variable slip current demand
50 double nacelle_nodding_accel = 0.; // Input: Nacelle nodding acceleration (rad/s^2)
51
52 void CopyToSwapArray(std::array<float, kSwapArraySize>& swap_array) const {
53 swap_array[0] = static_cast<float>(status);
54 swap_array[1] = static_cast<float>(time);
55 swap_array[2] = static_cast<float>(dt);
56 swap_array[3] = static_cast<float>(pitch_blade1_actual);
57 swap_array[9] = static_cast<float>(pitch_actuator_type_req);
58 swap_array[14] = static_cast<float>(generator_power_actual);
59 swap_array[19] = static_cast<float>(generator_speed_actual);
60 swap_array[20] = static_cast<float>(rotor_speed_actual);
61 swap_array[22] = static_cast<float>(generator_torque_actual);
62 swap_array[23] = static_cast<float>(yaw_error_actual);
63 swap_array[26] = static_cast<float>(horizontal_wind_speed);
64 swap_array[27] = static_cast<float>(pitch_control_type);
65 swap_array[32] = static_cast<float>(pitch_blade2_actual);
66 swap_array[33] = static_cast<float>(pitch_blade3_actual);
67 swap_array[34] = static_cast<float>(generator_contactor_status);
68 swap_array[35] = static_cast<float>(shaft_brake_status);
69 swap_array[36] = static_cast<float>(yaw_angle_actual);
70 swap_array[40] = static_cast<float>(yaw_actuator_torque_command);
71 swap_array[41] = static_cast<float>(pitch_blade1_command);
72 swap_array[42] = static_cast<float>(pitch_blade2_command);
73 swap_array[43] = static_cast<float>(pitch_blade3_command);
74 swap_array[44] = static_cast<float>(pitch_collective_command);
75 swap_array[45] = static_cast<float>(pitch_rate_command);
76 swap_array[46] = static_cast<float>(generator_torque_command);
77 swap_array[47] = static_cast<float>(nacelle_yaw_rate_command);
78 swap_array[48] = static_cast<float>(message_array_size);
79 swap_array[49] = static_cast<float>(infile_array_size);
80 swap_array[50] = static_cast<float>(outname_array_size);
81 swap_array[52] = static_cast<float>(tower_top_fore_aft_accel);
82 swap_array[54] = static_cast<float>(pitch_override);
83 swap_array[55] = static_cast<float>(torque_override);
84 swap_array[59] = static_cast<float>(azimuth_angle);
85 swap_array[60] = static_cast<float>(n_blades);
86 swap_array[64] = static_cast<float>(n_log_variables);
87 swap_array[71] = static_cast<float>(generator_startup_resistance);
88 swap_array[78] = static_cast<float>(loads_request);
89 swap_array[79] = static_cast<float>(variable_slip_status);
90 swap_array[80] = static_cast<float>(variable_slip_demand);
91 swap_array[82] = static_cast<float>(nacelle_nodding_accel);
92 }
93
94 void CopyFromSwapArray(const std::array<float, kSwapArraySize>& swap_array) {
95 status = static_cast<int>(swap_array[0]);
96 time = static_cast<double>(swap_array[1]);
97 dt = static_cast<double>(swap_array[2]);
98 pitch_blade1_actual = static_cast<double>(swap_array[3]);
99 pitch_actuator_type_req = static_cast<double>(swap_array[9]);
100 generator_power_actual = static_cast<double>(swap_array[14]);
101 generator_speed_actual = static_cast<double>(swap_array[19]);
102 rotor_speed_actual = static_cast<double>(swap_array[20]);
103 generator_torque_actual = static_cast<double>(swap_array[22]);
104 yaw_error_actual = static_cast<double>(swap_array[23]);
105 horizontal_wind_speed = static_cast<double>(swap_array[26]);
106 pitch_control_type = static_cast<int>(swap_array[27]);
107 pitch_blade2_actual = static_cast<double>(swap_array[32]);
108 pitch_blade3_actual = static_cast<double>(swap_array[33]);
109 generator_contactor_status = static_cast<int>(swap_array[34]);
110 shaft_brake_status = static_cast<int>(swap_array[35]);
111 yaw_angle_actual = static_cast<double>(swap_array[36]);
112 yaw_actuator_torque_command = static_cast<double>(swap_array[40]);
113 pitch_blade1_command = static_cast<double>(swap_array[41]);
114 pitch_blade2_command = static_cast<double>(swap_array[42]);
115 pitch_blade3_command = static_cast<double>(swap_array[43]);
116 pitch_collective_command = static_cast<double>(swap_array[44]);
117 pitch_rate_command = static_cast<double>(swap_array[45]);
118 generator_torque_command = static_cast<double>(swap_array[46]);
119 nacelle_yaw_rate_command = static_cast<double>(swap_array[47]);
120 message_array_size = static_cast<size_t>(swap_array[48]);
121 infile_array_size = static_cast<size_t>(swap_array[49]);
122 outname_array_size = static_cast<size_t>(swap_array[50]);
123 tower_top_fore_aft_accel = static_cast<double>(swap_array[52]);
124 pitch_override = static_cast<int>(swap_array[54]);
125 torque_override = static_cast<int>(swap_array[55]);
126 azimuth_angle = static_cast<double>(swap_array[59]);
127 n_blades = static_cast<size_t>(swap_array[60]);
128 n_log_variables = static_cast<size_t>(swap_array[64]);
129 generator_startup_resistance = static_cast<double>(swap_array[71]);
130 loads_request = static_cast<int>(swap_array[78]);
131 variable_slip_status = static_cast<int>(swap_array[79]);
132 variable_slip_demand = static_cast<int>(swap_array[80]);
133 nacelle_nodding_accel = static_cast<double>(swap_array[82]);
134 }
135};
136
137} // namespace kynema::util
Definition aerodyn_inflow.hpp:15
static constexpr int kSwapArraySize
Definition controller_io.hpp:7
Definition controller_io.hpp:11
double pitch_blade2_actual
Definition controller_io.hpp:24
double pitch_collective_command
Definition controller_io.hpp:33
int variable_slip_demand
Definition controller_io.hpp:49
int shaft_brake_status
Definition controller_io.hpp:27
double yaw_actuator_torque_command
Definition controller_io.hpp:29
int status
Definition controller_io.hpp:12
double pitch_blade1_actual
Definition controller_io.hpp:15
size_t n_blades
Definition controller_io.hpp:44
double pitch_actuator_type_req
Definition controller_io.hpp:16
double pitch_rate_command
Definition controller_io.hpp:34
int pitch_override
Definition controller_io.hpp:41
size_t infile_array_size
Definition controller_io.hpp:38
double pitch_blade2_command
Definition controller_io.hpp:31
double pitch_control_type
Definition controller_io.hpp:23
double time
Definition controller_io.hpp:13
int variable_slip_status
Definition controller_io.hpp:48
double generator_speed_actual
Definition controller_io.hpp:18
double azimuth_angle
Definition controller_io.hpp:43
void CopyToSwapArray(std::array< float, kSwapArraySize > &swap_array) const
Definition controller_io.hpp:52
double pitch_blade3_actual
Definition controller_io.hpp:25
double tower_top_fore_aft_accel
Definition controller_io.hpp:40
double nacelle_nodding_accel
Definition controller_io.hpp:50
double rotor_speed_actual
Definition controller_io.hpp:19
double generator_startup_resistance
Definition controller_io.hpp:46
int loads_request
Definition controller_io.hpp:47
int generator_contactor_status
Definition controller_io.hpp:26
double nacelle_yaw_rate_command
Definition controller_io.hpp:36
void CopyFromSwapArray(const std::array< float, kSwapArraySize > &swap_array)
Definition controller_io.hpp:94
double dt
Definition controller_io.hpp:14
int torque_override
Definition controller_io.hpp:42
size_t n_log_variables
Definition controller_io.hpp:45
double pitch_blade1_command
Definition controller_io.hpp:30
double yaw_angle_actual
Definition controller_io.hpp:28
double horizontal_wind_speed
Definition controller_io.hpp:22
double yaw_error_actual
Definition controller_io.hpp:21
size_t message_array_size
Definition controller_io.hpp:37
double generator_torque_command
Definition controller_io.hpp:35
double generator_power_actual
Definition controller_io.hpp:17
double generator_torque_actual
Definition controller_io.hpp:20
double pitch_blade3_command
Definition controller_io.hpp:32
size_t outname_array_size
Definition controller_io.hpp:39