00001 #ifndef Se_Message_Included
00002 #define Se_Message_Included
00003
00004 #include "se_ipc.h"
00005 #include "se_data_vector.h"
00006 #include "se_data.h"
00007 #include "se_sim_data_vector.h"
00008 #include "se_sim_data.h"
00009
00010 namespace Se{
00011
00012
00013
00014 class Message{
00015
00016 public:
00017
00018
00019
00020
00021
00022 enum Task{READ=1,
00023 WRITE=2};
00024
00025 enum Type{UNDEFINED=3,
00026 SIMULATION_INFO=4,
00027 START=5,
00028 STEP=6,
00029 STEPN=7,
00030 STOP=8,
00031 RESET=9,
00032 SHOW=10,
00033 HIDE=11,
00034 EXEC=12,
00035 SIMULATION_DATA=13,
00036 CHANGE_DOUBLE_DATA=14};
00037
00038 protected:
00039
00040
00041
00042
00043
00044 struct Ipc::msg_buf *msgb;
00045 int position;
00046 int size;
00047 Type type;
00048 Task task;
00049 static const int Max_Size=Ipc::Max_Msg_Size;
00050 static const int Size_Incr=1000;
00051
00052
00053
00054
00055
00056
00057 void set_variable(void *var, int size);
00058 void get_variable(void *var,int the_size);
00059
00060
00061
00062
00063
00064 int pop_int();
00065 double pop_double();
00066 char *pop_string(int length);
00067 void pop_doubles(double *table,int table_size);
00068
00069 void push_int(int i);
00070 void push_double(double d);
00071 void push_string(const char *the_string,int the_size);
00072 void push_string(String name);
00073 void push_doubles(double *table,int table_size);
00074 void push_data(Data *data);
00075 void push_data_vector(Data_Vector *data_vector);
00076 void push_data_descr(Data *data);
00077 void push_data_vector_descr(Data_Vector *data_vector);
00078
00079 public:
00080
00081
00082
00083
00084 Message(Task the_task);
00085
00086
00087
00088
00089
00090 protected:
00091 void send(int msq_id);
00092
00093 public:
00094 void receive(int id);
00095
00096 public:
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 void send_order_step_n(int msq_id,int n);
00121 void send_order_simulation_info(int msq_id,int sim_id,int slave_msq_key,
00122 Data_Vector *my_variables);
00123 void send_order_simulation_data(int msq_id,int sim_id,
00124 Data_Vector *my_variables);
00125 void send_order_simple(int msq_id,
00126 Message::Type type);
00127 void send_order_change_double_data(int msq_id,
00128 String name,
00129 double value);
00130
00131
00132
00133 void read_order_step_n(int *n);
00134
00135
00136
00137 void read_order_change_double_data(String *name,
00138 double *value);
00139
00140 void read_order_change_double_data(Sim_Data_Vector *data_vector);
00141
00142
00143
00144
00145 protected:
00146 int get_size();
00147 public:
00148 Type get_type();
00149
00150
00151
00152
00153 void print();
00154 };
00155
00156 }
00157 #endif