Project

General

Profile

Bug #4184 » axmo_mccl_3axis.adb

Peyré Jean, 03/29/2013 10:32 AM

 
1
--  Thu Feb 21 11:35:31 CET 2013 : Stubs Generator 0.1.0. Generate for ENX 2.5.
2
--  You just have to fill the stub.
3

    
4
with Common; use Common;
5
with Common.Exceptions;
6
with Interfaces;
7
--  with Interfaces.C;
8
with Ada.Strings.Unbounded;
9
--  with Ada.Characters.Handling;
10

    
11
with Line_To_XML;
12
--  with PDM;
13
--  with Datas;
14
with Motor_Library;
15

    
16
package body Axmo_Mccl_3axis is
17

    
18
   ----------
19
   -- Init --
20
   ----------
21
   procedure Init (Obj : access T_Axmo_Mccl_3axis) is
22
   begin
23
      null;
24
   end Init;
25

    
26
   -----------
27
   -- Close --
28
   -----------
29
   procedure Close (Obj : access T_Axmo_Mccl_3axis) is
30
   begin
31
      null;
32
   end Close;
33

    
34
   ------------------------------------------------------------------------
35
   -- Write_32 : This function is called when ENX receives a MM command. --
36
   ------------------------------------------------------------------------
37
   procedure Write_32
38
     (Obj     : access T_Axmo_Mccl_3axis;
39
      Command : T_Command_Access)
40
   is
41
   begin
42
      raise Common.Exceptions.NOT_AVAILABLE;
43
   end Write_32;
44

    
45
   -------------------------------------------------------------------------
46
   -- Write_16 : This function is called when ENX receives a MMH command. --
47
   -------------------------------------------------------------------------
48
   procedure Write_16
49
     (Obj     : access T_Axmo_Mccl_3axis;
50
      Command : T_Command_Access)
51
   is
52
   begin
53
      raise Common.Exceptions.NOT_AVAILABLE;
54
   end Write_16;
55

    
56
   ------------------------------------------------------------------------
57
   -- Write_8 : This function is called when ENX receives a MMB command. --
58
   ------------------------------------------------------------------------
59
   procedure Write_8
60
     (Obj     : access T_Axmo_Mccl_3axis;
61
      Command : T_Command_Access)
62
   is
63
   begin
64
      raise Common.Exceptions.NOT_AVAILABLE;
65
   end Write_8;
66

    
67
   -----------------------------------------------------------------------
68
   -- Read_32 : This function is called when ENX receives a MD command. --
69
   -----------------------------------------------------------------------
70
   function Read_32
71
     (Obj     : access T_Axmo_Mccl_3axis;
72
      Command : T_Command_Access)
73
      return    T_Result_Access
74
   is
75
   begin
76
      raise Common.Exceptions.NOT_AVAILABLE;
77
      return new T_Result (NO_RESULT);
78
   end Read_32;
79

    
80
   ------------------------------------------------------------------------
81
   -- Read_16 : This function is called when ENX receives a MDH command. --
82
   ------------------------------------------------------------------------
83
   function Read_16
84
     (Obj     : access T_Axmo_Mccl_3axis;
85
      Command : T_Command_Access)
86
      return    T_Result_Access
87
   is
88
   begin
89
      raise Common.Exceptions.NOT_AVAILABLE;
90
      return new T_Result (NO_RESULT);
91
   end Read_16;
92

    
93
   -----------------------------------------------------------------------
94
   -- Read_8 : This function is called when ENX receives a MDB command. --
95
   -----------------------------------------------------------------------
96
   function Read_8
97
     (Obj     : access T_Axmo_Mccl_3axis;
98
      Command : T_Command_Access)
99
      return    T_Result_Access
100
   is
101
   begin
102
      raise Common.Exceptions.NOT_AVAILABLE;
103
      return new T_Result (NO_RESULT);
104
   end Read_8;
105

    
106
   ----------------------------------------------------------------------------
107
   -- Special : This function is called when ENX receives a SPECIAL command. --
108
   ----------------------------------------------------------------------------
109
   function Special
110
     (Obj     : access T_Axmo_Mccl_3axis;
111
      Command : T_Command_Access)
112
      return    T_Result_Access
113
   is
114
      use Line_To_XML;
115
      --  Command_And_Arguments contient une matrice avec
116
      --  la "commande" & les "arguments" sans les blancs
117
      --  definition de
118
      --  "commande" : premiere chaine passee
119
      --  "arguments": chacune des chain es suivantes; il peut y en avoir plusieurs
120
      Command_And_Arguments : constant Line_To_XML.T_Param :=
121
         Line_To_XML.Cut_String
122
            (Ada.Strings.Unbounded.To_String (Command.Command),
123
            Ada.Strings.Unbounded.To_String (Command.Command)'Length);
124

    
125
      Res : constant T_Result_Access := new T_Result (SPECIAL);
126

    
127
   begin
128

    
129
      --  verification si il y a bien une fonction passee
130
      if Command_And_Arguments.Size = 0 then
131
         Res.Text := Ada.Strings.Unbounded.To_Unbounded_String
132
                              ("function not passed");
133
      else
134
         declare
135
            --  "commande"
136
            Command_To_Use : T_Special_Command;
137
         begin
138
            --  Si la commande ne fait pas partie de la liste
139
            --  on traite l erreur
140
            begin
141
               Command_To_Use := T_Special_Command'Value
142
                  (Ada.Strings.Unbounded.To_String
143
                     (Command_And_Arguments.List (0)));
144
            exception
145
               when Constraint_Error =>  --  others
146
                  Command_To_Use := NO_FUNCTION_OR_PROCEDURE;
147
            end;
148

    
149
            --  traite les differentes fonctions & procedures  --
150
            -----------------------------------------------------
151
            case Command_To_Use is
152

    
153
            --  procedure de test  --
154
            -------------------------
155
            when TEST =>
156
               declare
157
                  Local_Value : Interfaces.IEEE_Float_32;
158
               begin
159
                  Local_Value := 22.0;
160
                  Res.Text :=
161
                     Ada.Strings.Unbounded.To_Unbounded_String
162
                        (Interfaces.IEEE_Float_32'Image (Local_Value));
163
               end;
164

    
165
            --  procedure home  --
166
            ----------------------
167
            when HOME =>
168
               --  verification du nombre de parametres
169
               if Command_And_Arguments.Size /= 2 then
170
                  Res.Text := Ada.Strings.Unbounded.To_Unbounded_String
171
                              ("number of parameters is incorrect");
172
               else
173
                  declare
174
                     --  Axis_1, Axis_2, Axis_3
175
                     Argument_1 : constant Motor_Library.Motor_Axis_Enum :=
176
                        Motor_Library.Motor_Axis_Enum'Value
177
                           (Ada.Strings.Unbounded.To_String
178
                              (Command_And_Arguments.List (1)));
179

    
180
                  begin
181
                     Motor_Library.Home
182
                        (Axis =>  Argument_1);
183
                     Res.Text := Ada.Strings.Unbounded.To_Unbounded_String ("ok");
184
                  end;
185
               end if;
186

    
187
            --  procedure tell position  --
188
            -------------------------------
189
            when TELL_POSITION =>
190
               --  verification du nombre de parametres
191
               if Command_And_Arguments.Size /= 2 then
192
                  Res.Text := Ada.Strings.Unbounded.To_Unbounded_String
193
                              ("number of parameters is incorrect");
194
               else
195
                  declare
196
                     --  Axis_1, Axis_2, Axis_3
197
                     Argument_1 : constant Motor_Library.Motor_Axis_Enum :=
198
                        Motor_Library.Motor_Axis_Enum'Value
199
                           (Ada.Strings.Unbounded.To_String
200
                              (Command_And_Arguments.List (1)));
201

    
202
                     --  Position_lue
203
                     Position_Value : Motor_Library.Abs_Position_Int;
204

    
205
                  begin
206
                     --  lit la position
207
                     Motor_Library.Tell_Position
208
                        (Axis =>  Argument_1,
209
                        Position => Position_Value);
210
                     --  renvoie la position
211
                     Res.Text :=
212
                        Ada.Strings.Unbounded.To_Unbounded_String
213
                           (Motor_Library.Abs_Position_Int'Image (Position_Value));
214
                  end;
215
               end if;
216

    
217
            --  procedure move  --
218
            ----------------------
219
            when MOVE =>
220
               --  verification du nombre de parametres
221
               if Command_And_Arguments.Size /= 4 then
222
                  Res.Text := Ada.Strings.Unbounded.To_Unbounded_String
223
                              ("number of parameters is incorrect");
224
               else
225
                  declare
226
                     --  Axis_1, Axis_2, Axis_3
227
                     Argument_1 : constant Motor_Library.Motor_Axis_Enum :=
228
                        Motor_Library.Motor_Axis_Enum'Value
229
                           (Ada.Strings.Unbounded.To_String
230
                              (Command_And_Arguments.List (1)));
231

    
232
                     --  Absolute, Relative
233
                     Argument_2 : constant Motor_Library.Movement_Enum :=
234
                        Motor_Library.Movement_Enum'Value
235
                           (Ada.Strings.Unbounded.To_String
236
                              (Command_And_Arguments.List (2)));
237

    
238
                     --  Position_In
239
                     Argument_3 : constant Motor_Library.Abs_Position_Int :=
240
                        Motor_Library.Abs_Position_Int'Value
241
                           (Ada.Strings.Unbounded.To_String
242
                              (Command_And_Arguments.List (3)));
243

    
244
                     --  Position_lue
245
                     Position_Value : Motor_Library.Abs_Position_Int;
246

    
247
                  begin
248
                     --  deplacement
249
                     Motor_Library.Move
250
                        (Axis =>  Argument_1,
251
                        Movement =>  Argument_2,
252
                        Position_In =>  Argument_3,
253
                        Position_Out => Position_Value);
254
                     --  renvoie la position
255
                     Res.Text :=
256
                        Ada.Strings.Unbounded.To_Unbounded_String
257
                           (Motor_Library.Abs_Position_Int'Image (Position_Value));
258
                  end;
259
               end if;
260

    
261

    
262
            --  When others  --
263
            -------------------
264
            when others =>  --  NO_FUNCTION_OR_PROCEDURE
265
               Res.Text := Ada.Strings.Unbounded.To_Unbounded_String
266
                              ("Found no special function");
267
            end case;
268

    
269
         end;
270
      end if;
271

    
272
      return Res;
273
   end Special;
274

    
275
   ---------------------------------------------------------------------
276
   -- Special_Help : This function is called when ENX receives a HELP --
277
   --                command on special command.                      --
278
   ---------------------------------------------------------------------
279
   function Special_Help
280
     (Obj     : access T_Axmo_Mccl_3axis;
281
      Command : T_Command_Access)
282
      return    T_Result_Access
283
   is
284
      Res : constant T_Result_Access := new T_Result (HELP);
285
   begin
286
      Res.Text :=  Ada.Strings.Unbounded.To_Unbounded_String
287
        (ASCII.LF & ASCII.LF &
288
         "Function Name    : Parameters                        : return value " & ASCII.LF &
289
         "HOME             : Axis                            " & ASCII.LF &
290
         "TELL_POSITION    : Axis                              : Position" & ASCII.LF &
291
         "MOVE             : Axis, Rel-Abs, Position           : Position" & ASCII.LF & ASCII.LF &
292
         "Note : Axis is Axis_1, Axis_2 or Axis_3" & ASCII.LF &
293
         "     : Rel-Abs is Absolute or Relative" & ASCII.LF &
294

    
295
        ASCII.LF);
296

    
297
      return Res;
298
   end Special_Help;
299
   ---------------------------------------------------------------------
300
   -- Dump : This function is called when ENX receives a DUMP command --
301
   ---------------------------------------------------------------------
302
   function Dump
303
     (Obj     : access T_Axmo_Mccl_3axis;
304
      Command : T_Command_Access)
305
      return    T_Result_Access
306
   is
307
   begin
308
      raise Common.Exceptions.DUMP_NOT_AVAILABLE;
309
      return new T_Result (NO_RESULT);
310
   end Dump;
311

    
312
   ----------------------------------------------------------------------
313
   -- Load : This procedure is called when ENX receives a LOAD command --
314
   ----------------------------------------------------------------------
315
   procedure Load
316
     (Obj     : access T_Axmo_Mccl_3axis;
317
      Command : T_Command_Access)
318
   is
319
   begin
320
      raise Common.Exceptions.LOAD_NOT_AVAILABLE;
321
   end Load;
322
end Axmo_Mccl_3axis;
(1-1/2)