Command State

@return the state
@throws DevFailed
322399
@Command(name = STATE_NAME, outTypeDesc = "Device state")
    public DevState executeStateCmd() throws DevFailed {
        MDC.setContextMap(contextMap);
        xlogger.entry();
        xlogger.exit();
        return getState();
    }
1312912
public int command_inout_asynch(String cmdname, DeviceData data_in) throws DevFailed {
        return deviceProxyDAO.command_inout_asynch(this, cmdname, data_in);
    }
449384
public String status(final DeviceProxy deviceProxy, final boolean src) throws DevFailed {

        build_connection(deviceProxy);

        if (deviceProxy.url.protocol == TANGO) {
            String status = "Unknown";
            final int retries = deviceProxy.transparent_reconnection ? 2 : 1;
            boolean done = false;
            for (int i = 0; i < retries && !done; i++) {
            try {
                //noinspection PointlessBooleanExpression
                if (src == ApiDefs.FROM_ATTR) {
                    status = deviceProxy.device.status();
                } else {
                    final DeviceData argout = deviceProxy.command_inout("Status");
                    status = argout.extractString();
                }
                done = true;
            } catch (final Exception e) {
                manageExceptionReconnection(deviceProxy, retries, i, e, this.getClass()
                    + ".status");
            }
            }
            return status;
        } else {
            return command_inout(deviceProxy, "DevStatus").extractString();
        }
    }
1029265
@Command(name = "GetLoggingTarget", inTypeDesc = DEVICE_NAME, outTypeDesc = "Logging target list")
    public String[] getLoggingTarget(final String deviceName) throws DevFailed {
        return LoggingManager.getInstance().getLoggingTarget(deviceName);
    }
384350
public DevState updateState() throws DevFailed {
        xlogger.entry();
        Object getState;
        if (getStateMethod != null) {
            try {
                getState = getStateMethod.invoke(businessObject);
                if (getState != null) {
                    if (getState instanceof DeviceState) {
                        state = ((DeviceState) getState).getDevState();
                    } else {
                        state = (DevState) getState;
                    }
                }
            } catch (final IllegalArgumentException e) {
                throw DevFailedUtils.newDevFailed(e);
            } catch (final IllegalAccessException e) {
                throw DevFailedUtils.newDevFailed(e);
            } catch (final InvocationTargetException e) {
                if (e.getCause() instanceof DevFailed) {
                    throw (DevFailed) e.getCause();
                } else {
                    throw DevFailedUtils.newDevFailed(e.getCause());
                }
            }
        }
        //	if (!attributeAlarm.isEmpty()) {
        //	    state = DevState.ALARM;
        //	}
        xlogger.exit();
        return state;
    }
64383
@Override
    public Any command_inout_4(final String commandName, final Any argin, final DevSource source,
                               final ClntIdent clIdent) throws DevFailed {
        MDC.setContextMap(contextMap);
        xlogger.entry(commandName);
        if (!commandName.equalsIgnoreCase(DeviceImpl.STATE_NAME)
                && !commandName.equalsIgnoreCase(DeviceImpl.STATUS_NAME)) {
            checkInitialization();
        }
        final long request = deviceMonitoring.startRequest("Operation command_inout_4 (cmd = " + commandName + ")",
                source, clIdent);
        clientIdentity.set(clIdent);
        Any argout = null;
        if (!name.equalsIgnoreCase(getAdminDeviceName())) {
            clientLocking.checkClientLocking(clIdent, commandName);
        }
        try {
            argout = commandHandler(commandName, argin, source, clIdent);
        } catch (final Exception e) {
            deviceMonitoring.addError();
            if (e instanceof DevFailed) {
                throw (DevFailed) e;
            } else {
                // with CORBA, the stack trace is not visible by the client if
                // not inserted in DevFailed.
                throw DevFailedUtils.newDevFailed(e);
            }
        } finally {
            deviceMonitoring.endRequest(request);
        }
        xlogger.exit();
        return argout;
    }
419611
public int getNbWritten() throws DevFailed {
	manageExceptions("getNbWritten");
	return attrval.w_dim.dim_x * DIM_MINI(attrval.w_dim.dim_y);
    }
574783
public synchronized void statusMachine(final String status, final DeviceState state) throws DevFailed {
        if (status != null) {
            logger.debug("Changing status to: {}", status);
            this.status = status;
            if (setStatusMethod != null) {
                try {
                    setStatusMethod.invoke(businessObject, status);
                } catch (final IllegalArgumentException e) {
                    throw DevFailedUtils.newDevFailed(e);
                } catch (final IllegalAccessException e) {
                    throw DevFailedUtils.newDevFailed(e);
                } catch (final InvocationTargetException e) {
                    if (e.getCause() instanceof DevFailed) {
                        throw (DevFailed) e.getCause();
                    } else {
                        throw DevFailedUtils.newDevFailed(e.getCause());
                    }
                }
            }
        }
    }
515916
public DeviceData[] get_command_specific_argument_list(final boolean fwd) throws DevFailed {
	final int al_size = get_size(fwd);
	final DeviceData[] al = new DeviceData[al_size];
	for (int i = 0; i < al_size; i++) {
	    al[i] = new DeviceData();
	}
	return al;
    }
531662
public boolean isCommandAllowed(String classname, String cmd) throws DevFailed {
		return databaseDAO.isCommandAllowed(this, classname, cmd);
	}
895980
Command get_command(final String cmd_name) throws DevFailed {
	Command ret_cmd = null;
	final Vector cmd_list = device_class.get_command_list();
	for (int i = 0; i < cmd_list.size(); i++) {
	    final Command cmd = (Command) cmd_list.elementAt(i);
	    if (cmd.get_name().toLowerCase().equals(cmd_name.toLowerCase())) {
		ret_cmd = cmd;
	    }
	}

	if (ret_cmd == null) {
	    Except.throw_exception("API_CommandNotFound", "Command " + cmd_name + " not found",
		    "DeviceImpl.get_command");
	}

	return ret_cmd;
    }
569102
public DeviceData command_inout_reply(final DeviceProxy deviceProxy, final int id)
            throws DevFailed {
        return command_inout_reply(deviceProxy, ApiUtil.get_async_object(id));
    }
889963
public DevState[] extractDevStateArray() throws DevFailed {
	manageExceptions("extractDevStateArray()");
	try {
	    if (isArray()) {
		return DevVarStateArrayHelper.extract(attrval.value);
	    } else {
		// It is used for state attribute
		return new DevState[] { DevStateHelper.extract(attrval.value) };
	    }
	} catch (final org.omg.CORBA.BAD_PARAM e) {
	    Except
		    .throw_wrong_data_exception(
			    e.toString(),
			    "Exception catched : "
				    + e.toString()
				    + "\n"
				    + "Maybe the attribute value has not been initialized",
			    "DeviceAttribute.extractDevStateArray()");
	}
	return new DevState[0];// never used
    }
1325816
public CommandInfo commandQuery(TacoTangoDevice tacoDevice, String cmdname) throws DevFailed {
        Except.throw_exception("Api_TacoFailed",
                "Taco protocol not supported",
                "TacoTangoDeviceDAODefaultImpl.command_inout()");
        return null;
    }
279031
@Override
    public void (final int timeout, final boolean fwd) throws DevFailed {
	synchronized (this) {
	    final Iterator it = elements.iterator();
	    while (it.hasNext()) {
		final GroupElement e = (GroupElement) it.next();
		if (e instanceof GroupDeviceElement || fwd) {
		    e.(timeout, fwd);
		}
	    }
	}
    }
793803
public DeviceData command_inout_reply(int id, int timeout) throws DevFailed, AsynReplyNotArrived {
        return deviceProxyDAO.command_inout_reply(this, id, timeout);
    }
849493
synchronized String[] dev_poll_status(final String dev_name) throws DevFailed {
        Util.out4.println("In dev_poll_status command");

        // Find the device
        final DeviceImpl dev = Util.instance().get_device_by_name(dev_name);

        final Vector poll_list = dev.get_poll_obj_list();
        final int nb_poll_obj = poll_list.size();

        // Return an empty sequence if nothing is polled for this device
        if (nb_poll_obj == 0) {
            return new String[0];
        }

        // Compute how many cmds and/or attributes are polled
        int nb_cmd = 0;
        for (int i = 0; i < nb_poll_obj; i++) {
            final PollObj poll_obj = (PollObj) poll_list.elementAt(i);
            if (poll_obj.get_type() == Tango_POLL_CMD) {
                nb_cmd++;
            }
        }

        // Allocate memory for returned strings
        final String[] ret = new String[nb_poll_obj];

        // Populate returned strings
        int cmd_ind = 0;
        int attr_ind = nb_cmd;
        String returned_info;

        for (int i = 0; i < nb_poll_obj; i++) {
            final PollObj poll_obj = (PollObj) poll_list.elementAt(i);
            // First, the name
            final int type = poll_obj.get_type();
            if (type == Tango_POLL_CMD) {
                returned_info = "Polled command name = ";
            } else {
                returned_info = "Polled attribute name = ";
            }
            returned_info += poll_obj.get_name();

            // Add update period
            returned_info += "\nPolling period (mS) = ";
            final int tmp = poll_obj.get_upd();
            returned_info = returned_info + tmp;

            // Add ring buffer depth
            returned_info += "\nPolling ring buffer depth = ";
            final int depth = dev.get_poll_ring_depth();
            if (depth == 0) {
                returned_info += Tango_DefaultPollRingDepth;
            } else {
                returned_info += depth;
            }

            // Add a message if the data ring is empty
            if (poll_obj.is_ring_empty() == true) {
                returned_info += "\nNo data recorded yet";
            } else {
                // Add needed time to execute last command
                returned_info += "\nTime needed for the last ";
                if (type == Tango_POLL_CMD) {
                    returned_info += "command execution (mS) = ";
                } else {
                    returned_info += "attribute reading (mS) = ";
                }
                returned_info += poll_obj.get_needed_time_i();

                // Add not updated since... info
                returned_info += "\nData not updated since ";
                final double since = poll_obj.get_last_insert_date_i();

                final long ctm = System.currentTimeMillis();
                final int tv_sec = (int) (ctm / 1000);
                final int tv_usec = (int) (ctm - 1000 * tv_sec) * 1000;

                final double now_d = tv_sec + (double) tv_usec / 1000000;
                final double diff_t = now_d - since;
                if (diff_t < 1.0) {
                    final int nb_msec = (int) (diff_t * 1000);
                    returned_info = returned_info + nb_msec + " mS";
                } else if (diff_t < 60.0) {
                    final int nb_sec = (int) diff_t;
                    final int nb_msec = (int) ((diff_t - nb_sec) * 1000);
                    returned_info = returned_info + nb_sec + " S and ";
                    returned_info = returned_info + nb_msec + " mS";
                } else {
                    final int nb_min = (int) (diff_t / 60);
                    final int nb_sec = (int) (diff_t - 60 * nb_min);
                    final int nb_msec = (int) ((diff_t - (int) diff_t) * 1000);

                    returned_info = returned_info + nb_min + " MN";

                    if (nb_sec != 0) {
                        returned_info = returned_info + " ," + nb_sec + " S";
                    }

                    if (nb_msec != 0) {
                        returned_info = returned_info + " and " + nb_msec + " mS";
                    }
                }

                // Add delta_t between last record(s)
                try {
                    returned_info += "\nDelta between last records (in mS) = ";
                    final double[] delta = poll_obj.get_delta_t_i(4);
                    for (int j = 0; j < delta.length; j++) {
                        final int nb_msec = (int) (delta[j] * 1000);
                        returned_info = returned_info + nb_msec;
                        if (j != delta.length - 1) {
                            returned_info = returned_info + ", ";
                        }
                    }
                } catch (final DevFailed e) {
                }

                // Add last polling exception fields (if any)
                if (poll_obj.is_last_an_error_i() == true) {
                    if (type == Tango_POLL_CMD) {
                        returned_info += "\nLast command execution FAILED :";
                    } else {
                        returned_info += "\nLast attribute read FAILED :";
                    }
                    final DevFailed ex = poll_obj.get_last_except_i();
                    returned_info += "\n\tReason = " + ex.errors[0].reason;
                    returned_info += "\n\tDesc = " + ex.errors[0].desc;
                    returned_info += "\n\tOrigin = " + ex.errors[0].origin;
                }
            }

            // Init. string in sequence
            if (type == Tango_POLL_CMD) {
                ret[cmd_ind] = returned_info;
                cmd_ind++;
            } else {
                ret[attr_ind] = returned_info;
                attr_ind++;
            }
        }
        return ret;
    }