Open Core Interface - MLPI
MLPI-MotionLogicProgrammingInterface(mlpi4Java)  1.26.2
Parameter.java
Go to the documentation of this file.
1 // -----------------------------------------------------------------------
2 // MLPI - <Parameter.java>
3 // -----------------------------------------------------------------------
4 // Copyright (c) 2012 Bosch Rexroth. All rights reserved.
5 // Redistribution and use in source and binary forms of this MLPI software
6 // (SW) provided to you, with or without modification, are permitted
7 // without prior approval provided that the following conditions are met:
8 //
9 // 1. Redistributions of source code of SW must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form of SW must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // 3. User recognizes and acknowledges that it acquires no right,
17 // title or interest in or to any of the names or trademarks used in
18 // connection with the SW ("names") by virtue of this License and waives
19 // any right to or interest in the names. User recognizes and acknowledges
20 // that names of companies or names or products of companies displayed
21 // in the documentation of SW to indicate the interoperability of products
22 // with the SW are the names of their respective owners. The use of such
23 // names in the documentation of SW does not imply any sponsorship,
24 // approval, or endorsement by such companies of this product.
25 //
26 // 4. Modified code versions, i.e. any addition to or deletion from
27 // the substance or structure of the original code of the SW running
28 // the MLPI must be plainly marked as such and must not be misrepresented
29 // as being original SW.
30 //
31 // 5. The SW may only be used in connection with a Bosch Rexroth product.
32 //
33 // THIS INFORMATION IS PROVIDED BY BOSCH REXROTH CORPORATION "AS IS"
34 // AND WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING
35 // (BUT NOTLIMITED TO) ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
36 // FITNESS FOR ANY PARTICULAR PURPOSE, OR NON-INFRINGEMENT. WHILE THE
37 // INFORMATION PROVIDED IS BELIEVED TO BE ACCURATE, IT MAY INCLUDE
38 // ERRORS OR INACCURACIES.
39 // SUBJECT TO COMPULSORY STATUTORY PROVISIONS OF THE GERMAN LAW AS
40 // THE APPLICABLE LAW FOR THIS LICENSE BOSCH REXROTH CORPORATION WILL
41 // NOT BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING FROM THE USE OF
42 // THE SOFTWARE DISTRIBUTED HEREUNDER, INCLUDING BUT NOT LIMITED TO
43 // DIRECT, INDIRECT, INCIDENTAL, PUNITIVE, AND CONSEQUENTIAL DAMAGES.
44 // -----------------------------------------------------------------------
45 //
55 //
56 // -----------------------------------------------------------------------
57 package com.boschrexroth.mlpi;
58 
59 import java.util.Vector;
60 
62 
63 
64 
70 public class Parameter extends MlpiComponent {
71 
72  /*
73  * Constants
74  */
76  public static final long MLPI_ADDRESS_SLAVE_MASK = 0x000000000000FFFFL;
78  public static final long MLPI_ADDRESS_MASTER_MASK = 0x00000000FFFF0000L;
80  public static final long MLPI_ADDRESS_MODE_MASK = 0x000000FF00000000L;
81 
83  public static final long MLPI_READ_EVERYTHING_SINGLE_PARAMETER = 8;
85  public static final long MLPI_READ_EVERYTHING_LIST_PARAMETER = 65536;
87  public static final long MLPI_INFINITE = -1;
88 
89 
90  /*
91  * Enums
92  */
104  public enum AddressMode
105  {
106  ADDRESS_MODE_LOGICAL (0),
107  ADDRESS_MODE_PHYSICAL (1),
108  ADDRESS_MODE_TOPOLOGICAL (2),
109  ADDRESS_MODE_LOGICAL_NATIVE (3);
110 
111  private int _code;
112  int getCode() { return _code; }
113  AddressMode(int code) { this._code = code; }
114  static AddressMode valueOf(int code) {
115  for (AddressMode value : values()) {
116  if (code == value.getCode()) return value;
117  }
118  return null;
119  }
120  }
121 
136  public enum CommandStatus
137  {
138  COMMAND_INACTIVE(0),
139  COMMAND_SET(1),
140  COMMAND_EXECUTED_CORRECTLY(3),
141  COMMAND_INTERRUPTED(5),
142  COMMAND_IN_PROGRESS(7),
143  COMMAND_ERROR(15),
144  COMMAND_STATUS_INVALID(256);
145 
146  private int _code;
147  int getCode() { return _code; }
148  CommandStatus(int code) { this._code = code; }
149  static CommandStatus valueOf(int code) {
150  for (CommandStatus value : values()) {
151  if (code == value.getCode()) return value;
152  }
153  return null;
154  }
155  };
156 
157  /*
158  * Structs
159  */
173  public static class ReadEverythingAddressing
174  {
175  public ReadEverythingAddressing(int axisNo, String idn) {
176  this.address = MLPI_ADDRESS(AddressMode.ADDRESS_MODE_LOGICAL, 0, (long) axisNo);
177  this.idn = idn;
178  }
179  public ReadEverythingAddressing(int controlNo, int axisNo, String idn) {
180  this.address = MLPI_ADDRESS(AddressMode.ADDRESS_MODE_LOGICAL, (long) controlNo, (long) axisNo);
181  this.idn = idn;
182  }
183  public ReadEverythingAddressing(AddressMode mode, int axisNo, String idn) {
184  this.address = MLPI_ADDRESS(mode, 0, (long) axisNo);
185  this.idn = idn;
186  }
187  public ReadEverythingAddressing(AddressMode mode, int controlNo, int axisNo, String idn) {
188  this.address = MLPI_ADDRESS(mode, (long) controlNo, (long) axisNo);
189  this.idn = idn;
190  }
191 
192  public ReadEverythingAddressing(short axisNo, String idn) {
193  this.address = MLPI_ADDRESS(AddressMode.ADDRESS_MODE_LOGICAL, 0, (long) axisNo);
194  this.idn = idn;
195  }
196  public ReadEverythingAddressing(short controlNo, short axisNo, String idn) {
197  this.address = MLPI_ADDRESS(AddressMode.ADDRESS_MODE_LOGICAL, (long) controlNo, (long) axisNo);
198  this.idn = idn;
199  }
200  public ReadEverythingAddressing(AddressMode mode, short axisNo, String idn) {
201  this.address = MLPI_ADDRESS(mode, 0, (long) axisNo);
202  this.idn = idn;
203  }
204  public ReadEverythingAddressing(AddressMode mode, short controlNo, short axisNo, String idn) {
205  this.address = MLPI_ADDRESS(mode, (long) controlNo, (long) axisNo);
206  this.idn = idn;
207  }
208 
209  public ReadEverythingAddressing(long axis, String idn) {
210  this.address = axis;
211  this.idn = idn;
212  }
213 
214  long address;
215  String idn;
216  }
217 
241  public static class ReadEverythingData
242  {
243  public long address;
244  public String idn;
245 
246  public boolean dataStatus;
247  public CommandStatus cmdStatus;
248  public String name;
249  public int attribute;
250  public String unit;
251  public String min;
252  public String max;
253  public String data;
254 
255  public int result;
256  }
257 
271  public static class ParameterAddressing
272  {
273  public ParameterAddressing(int axisNo, String idn) {
274  this.address = MLPI_ADDRESS(AddressMode.ADDRESS_MODE_LOGICAL, 0, (long) axisNo);
275  this.idn = idn;
276  }
277  public ParameterAddressing(int controlNo, int axisNo, String idn) {
278  this.address = MLPI_ADDRESS(AddressMode.ADDRESS_MODE_LOGICAL, (long) controlNo, (long) axisNo);
279  this.idn = idn;
280  }
281  public ParameterAddressing(AddressMode mode, int axisNo, String idn) {
282  this.address = MLPI_ADDRESS(mode, 0, (long) axisNo);
283  this.idn = idn;
284  }
285  public ParameterAddressing(AddressMode mode, int controlNo, int axisNo, String idn) {
286  this.address = MLPI_ADDRESS(mode, (long) controlNo, (long) axisNo);
287  this.idn = idn;
288  }
289 
290  public ParameterAddressing(short axisNo, String idn) {
291  this.address = MLPI_ADDRESS(AddressMode.ADDRESS_MODE_LOGICAL, 0, (long) axisNo);
292  this.idn = idn;
293  }
294  public ParameterAddressing(short controlNo, short axisNo, String idn) {
295  this.address = MLPI_ADDRESS(AddressMode.ADDRESS_MODE_LOGICAL, (long) controlNo, (long) axisNo);
296  this.idn = idn;
297  }
298  public ParameterAddressing(AddressMode mode, short axisNo, String idn) {
299  this.address = MLPI_ADDRESS(mode, 0, (long) axisNo);
300  this.idn = idn;
301  }
302  public ParameterAddressing(AddressMode mode, short controlNo, short axisNo, String idn) {
303  this.address = MLPI_ADDRESS(mode, (long) controlNo, (long) axisNo);
304  this.idn = idn;
305  }
306 
307  public ParameterAddressing(long axis, String idn) {
308  this.address = axis;
309  this.idn = idn;
310  }
311 
312  long address;
313  String idn;
314  }
325  public static class WriteAccessData
326  {
327  public long address;
328  public String idn;
329  }
330 
331  /*
332  * Methods
333  */
334  Parameter(MlpiHandle connection) {
335  super(connection);
336  }
337 
352  public static long MLPI_ADDRESS(AddressMode mode, long master, long slave)
353  {
354  return
355  ( ( ((long) mode.getCode() ) << 32 ) & MLPI_ADDRESS_MODE_MASK ) |
356  ( ( ((long) master ) << 16 ) & MLPI_ADDRESS_MASTER_MASK ) |
357  ( ( ((long) slave ) ) & MLPI_ADDRESS_SLAVE_MASK ) ;
358  }
359 
376  public native String readDataAsString(String idn, long address);
377 
394  public native String readMinimumAsString(String idn, long address);
395 
412  public native String readMaximumAsString(String idn, long address);
413 
430  public native String readDefaultAsString(String idn, long address);
431 
448  public native String readName(String idn, long address);
449 
466  public native String readUnit(String idn, long address);
467 
484  public native int readAttribute(String idn, long address);
485 
500  public native void command(String idn, long address);
501 
520  public native void writeDataAsString(String idn, long address, String data);
521 
540  public native Parameter.CommandStatus getCommandStatus(String idn, long address);
541 
560  public native boolean getDataStatus(String idn, long address);
561 
613  public native Parameter.ReadEverythingData[] readEverything(Parameter.ReadEverythingAddressing[] addressing, int dataLoad);
614 
655  {
656  ReadEverythingAddressing[] request = {new ReadEverythingAddressing(addressing.address, addressing.idn)};
657  ReadEverythingData[] response = readEverything(request, dataLoad);
658  return response[0];
659  }
660 
696  public native int writeAccessSetup(Parameter.ParameterAddressing[] addressing);
697 
744  public native Parameter.WriteAccessData[] writeAccessStatus(int process, boolean waitForWriteAccess, int timeout);
745 
776  public native void writeAccessAbort(int process);
777 }
778 
static final long MLPI_ADDRESS_MODE_MASK
Definition: Parameter.java:80
This class defines the data response of a readEverything request.
Definition: Parameter.java:241
Parameter.ReadEverythingData readEverything(Parameter.ReadEverythingAddressing addressing, int dataLoad)
Definition: Parameter.java:654
native int writeAccessSetup(Parameter.ParameterAddressing[] addressing)
This class defines the axis through the definition of control and axis number.
Definition: Motion.java:417
native String readDefaultAsString(String idn, long address)
native String readName(String idn, long address)
native void writeAccessAbort(int process)
native void writeDataAsString(String idn, long address, String data)
native String readMaximumAsString(String idn, long address)
static long MLPI_ADDRESS(AddressMode mode, long master, long slave)
Definition: Parameter.java:352
This enumeration defines the status of a command execution used by Parameter.getCommandStatus.
Definition: Parameter.java:136
native int readAttribute(String idn, long address)
static final long MLPI_ADDRESS_MASTER_MASK
Definition: Parameter.java:78
native Parameter.CommandStatus getCommandStatus(String idn, long address)
This class defines the addressing of a readEverything request through the definition of the address t...
Definition: Parameter.java:173
This class defines the addressing of a parameter request through the definition of the address type...
Definition: Parameter.java:271
native Parameter.WriteAccessData[] writeAccessStatus(int process, boolean waitForWriteAccess, int timeout)
native String readDataAsString(String idn, long address)
native void command(String idn, long address)
Class definition of the ParameterLib.
Definition: Parameter.java:70
This enumeration defines the address mode. It is used in the MLPI_ADDRESS method. ...
Definition: Parameter.java:104
static final long MLPI_READ_EVERYTHING_SINGLE_PARAMETER
Definition: Parameter.java:83
native String readUnit(String idn, long address)
native Parameter.ReadEverythingData[] readEverything(Parameter.ReadEverythingAddressing[] addressing, int dataLoad)
static final long MLPI_ADDRESS_SLAVE_MASK
Definition: Parameter.java:76
Class definition of the MotionLib.
Definition: Motion.java:66
static final long MLPI_READ_EVERYTHING_LIST_PARAMETER
Definition: Parameter.java:85
native boolean getDataStatus(String idn, long address)
native String readMinimumAsString(String idn, long address)
static final long MLPI_INFINITE
Definition: Parameter.java:87