00001
00002
00003
00004
00005
00006
00007 #include "rcs.hh"
00008
00009
00010 #include "simmot_n.h"
00011 #include "amplifier.h"
00012 #include "dcmotor2.h"
00013 #include "encoder.h"
00014
00015
00016 void simmot_status_struct_update(CMS *cms, simmot_status_struct *x);
00017 void AMPLIFIER_STRUCT_update(CMS *cms, AMPLIFIER_STRUCT *x);
00018 void DC_MOTOR_STRUCT_update(CMS *cms, DC_MOTOR_STRUCT *x);
00019 void ENCODER_STRUCT_update(CMS *cms, ENCODER_STRUCT *x);
00020 void simmot_command_struct_update(CMS *cms, simmot_command_struct *x);
00021
00022
00023
00024
00025
00026
00027 int simmot_format(NMLTYPE type, void *buffer, CMS *cms)
00028 {
00029 switch(type)
00030 {
00031 case SIMMOT_COMMAND_TYPE:
00032 ((SIMMOT_COMMAND *) buffer)->update(cms);
00033 break;
00034 case SIMMOT_STATUS_TYPE:
00035 ((SIMMOT_STATUS *) buffer)->update(cms);
00036 break;
00037
00038 default:
00039 return(0);
00040 }
00041 return 1;
00042 }
00043
00044
00045
00046 const char *simmot_symbol_lookup(int type)
00047 {
00048 switch(type)
00049 {
00050 case SIMMOT_COMMAND_TYPE:
00051 return "SIMMOT_COMMAND";
00052 case SIMMOT_STATUS_TYPE:
00053 return "SIMMOT_STATUS";
00054 default:
00055 return"UNKNOWN";
00056 break;
00057 }
00058 return(NULL);
00059 }
00060
00061
00062
00063
00064
00065
00066 void simmot_status_struct_update(CMS *cms,simmot_status_struct *x)
00067 {
00068 cms->update(x->initialized);
00069 cms->update(x->cmd_count);
00070 cms->update(x->ampOutput,8);
00071 for(int i_amplifier = 0;i_amplifier < 8 ;i_amplifier++)
00072 AMPLIFIER_STRUCT_update(cms,&(x->amplifier[i_amplifier]));
00073 for(int i_dcmotor = 0;i_dcmotor < 8 ;i_dcmotor++)
00074 DC_MOTOR_STRUCT_update(cms,&(x->dcmotor[i_dcmotor]));
00075 for(int i_encoder = 0;i_encoder < 8 ;i_encoder++)
00076 ENCODER_STRUCT_update(cms,&(x->encoder[i_encoder]));
00077
00078 }
00079
00080
00081
00082
00083
00084
00085
00086 void DC_MOTOR_STRUCT_update(CMS *cms,DC_MOTOR_STRUCT *x)
00087 {
00088 cms->update(x->Ra);
00089 cms->update(x->La);
00090 cms->update(x->Kb);
00091 cms->update(x->Jm);
00092 cms->update(x->Bm);
00093 cms->update(x->a);
00094 cms->update(x->b);
00095 cms->update(x->c);
00096 cms->update(x->fourac_minus_b_squared);
00097 cms->update(x->sa_real);
00098 cms->update(x->sb_real);
00099 cms->update(x->sa_img);
00100 cms->update(x->sb_img);
00101 cms->update(x->sa_time_factor);
00102 cms->update(x->sb_time_factor);
00103 cms->update(x->order);
00104 cms->update(x->wo);
00105 cms->update(x->dwo);
00106 cms->update(x->last_ea);
00107 cms->update(x->A);
00108 cms->update(x->B);
00109 cms->update(x->delta_thm);
00110 cms->update(x->ia);
00111 cms->update(x->dia);
00112 cms->update(x->wm);
00113 cms->update(x->dwm);
00114 cms->update(x->thm);
00115 cms->update(x->dthm);
00116 cms->update(x->lastTime);
00117 cms->update(x->configured);
00118 cms->update(x->cycleTime);
00119 cms->update(x->offset);
00120 cms->update(x->revsPerUnit);
00121
00122 }
00123
00124
00125
00126
00127
00128
00129
00130 void SIMMOT_STATUS::update(CMS *cms)
00131 {
00132 simmot_status_struct_update(cms,&data);
00133
00134 }
00135
00136
00137
00138
00139
00140
00141
00142 void AMPLIFIER_STRUCT_update(CMS *cms,AMPLIFIER_STRUCT *x)
00143 {
00144 cms->update(x->gain);
00145 cms->update(x->maxOutputCurrent);
00146 cms->update(x->loadResistance);
00147 cms->update(x->configured);
00148 cms->update(x->enabled);
00149 cms->update(x->tripped);
00150
00151 }
00152
00153
00154
00155
00156
00157
00158
00159 void ENCODER_STRUCT_update(CMS *cms,ENCODER_STRUCT *x)
00160 {
00161 cms->update(x->countsPerRev);
00162 cms->update(x->configured);
00163 cms->update(x->counts);
00164 cms->update(x->calibrating);
00165 cms->update(x->offset);
00166 cms->update(x->lastPosition);
00167 cms->update(x->index);
00168
00169 }
00170
00171
00172
00173
00174
00175
00176
00177 void simmot_command_struct_update(CMS *cms,simmot_command_struct *x)
00178 {
00179 for(int i_amplifier = 0;i_amplifier < 8 ;i_amplifier++)
00180 AMPLIFIER_STRUCT_update(cms,&(x->amplifier[i_amplifier]));
00181 for(int i_dcmotor = 0;i_dcmotor < 8 ;i_dcmotor++)
00182 DC_MOTOR_STRUCT_update(cms,&(x->dcmotor[i_dcmotor]));
00183 for(int i_encoder = 0;i_encoder < 8 ;i_encoder++)
00184 ENCODER_STRUCT_update(cms,&(x->encoder[i_encoder]));
00185
00186 }
00187
00188
00189
00190
00191
00192
00193
00194 void SIMMOT_COMMAND::update(CMS *cms)
00195 {
00196 simmot_command_struct_update(cms,&data);
00197
00198 }
00199
00200
00201
00202
00203
00204
00205 SIMMOT_STATUS::SIMMOT_STATUS()
00206 : NMLmsg(SIMMOT_STATUS_TYPE,sizeof(SIMMOT_STATUS))
00207 {
00208
00209
00210
00211
00212
00213
00214 }
00215
00216
00217
00218
00219
00220
00221 SIMMOT_COMMAND::SIMMOT_COMMAND()
00222 : NMLmsg(SIMMOT_COMMAND_TYPE,sizeof(SIMMOT_COMMAND))
00223 {
00224
00225
00226
00227
00228
00229
00230 }