Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) SiteWhere, LLC. All rights reserved. http://www.sitewhere.com
  *
  * The software in this package is published under the terms of the CPAL v1.0
  * license, a copy of which has been included with this distribution in the
  * LICENSE.txt file.
  */
 package com.sitewhere.device;
 
Handles underlying logic to make common actions simpler to invoke from scripts.

Author(s):
Derek
public class DeviceActions implements IDeviceActions {

Device management implementation
	public DeviceActions(IDeviceManagement deviceManagement) {
		this. = deviceManagement;
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see com.sitewhere.spi.device.IDeviceActions#sendCommand(java.lang.String,
	 * java.lang.String, java.util.Map)
	 */
	public void sendCommand(String assignmentTokenString commandNameMap<StringStringparameters)
		if (assignment == null) {
			throw new SiteWhereException("Command not executed. Assignment not found: " + assignmentToken);
		}
		List<IDeviceCommandcommands =
		IDeviceCommand match = null;
		for (IDeviceCommand command : commands) {
			if (command.getName().equals(commandName)) {
				match = command;
			}
		}
		if (match == null) {
			throw new SiteWhereException("Command not executed. No command found matching: " + commandName);
		}
		create.setCommandToken(match.getToken());
		create.setParameterValues(parameters);
		create.setTargetId(assignment.getToken());
		create.setEventDate(new Date());
		getDeviceManagement().addDeviceCommandInvocation(assignment.getToken(), matchcreate);
	}
	}
	public void setDeviceManagement(IDeviceManagement deviceManagement) {
		this. = deviceManagement;
	}
New to GrepCode? Check out our FAQ X