void write(std::string time, ILogger::Level level, std::string message)
{
std::cout << "[APPLogger] " << time << " " << ILogger::getString(level) << " "
- << message;
+ << message;
}
};
std::shared_ptr<AppLogger> gAppLogger(new AppLogger());
{
case 1 : simulateResource(configPath); break;
case 2 : displayResource(); break;
- case 3 : deleteResource(); break;
+ case 3 :
+ try
+ {
+ deleteResource();
+ }
+ catch (InvalidArgsException &e)
+ {
+ std::cout << "InvalidArgsException occured [code : " << e.code() <<
+ " Detail: " << e.what() << "]" << std::endl;
+ }
+ break;
case 4 : updateAttributePower(); break;
case 5 : updateAttributeIntensity(); break;
case 6 : automateResourceUpdate(); break;
const SimulatorResourceModel &resModel)
{
std::cout << "[callback] Resource model is changed URI: " << uri.c_str()
- << " Count : " << resModel.size() << std::endl;
+ << " Count : " << resModel.size() << std::endl;
std::cout << "#### Modified attributes are ####" << std::endl;
for (auto & attribute : resModel.getAttributes())
{
std::cout << attribute.second.getName() << " : "
- << attribute.second.valueToString().c_str() << std::endl;
+ << attribute.second.valueToString().c_str() << std::endl;
}
std::cout << "########################" << std::endl;
}
try
{
SimulatorResourceServerSP resource =
- SimulatorManager::getInstance()->createResource(configPath, callback);
+ SimulatorManager::getInstance()->createResource(configPath, callback);
m_resources.push_back(resource);
std::cout << "Resource created successfully! URI= " << resource->getURI().c_str()
- << std::endl;
+ << std::endl;
}
catch (InvalidArgsException &e)
{
std::cout << "InvalidArgsException occured [code : " << e.code() << " Detail: "
- << e.what() << "]" << std::endl;
+ << e.what() << "]" << std::endl;
}
catch (SimulatorException &e)
{
std::cout << "SimulatorException occured [code : " << e.code() << " Detail: "
- << e.what() << "]" << std::endl;
+ << e.what() << "]" << std::endl;
}
}
{
SimulatorManager::getInstance()->deleteResource(resourceType);
std::cout << "Resources of type \"" << resourceType << "\"" <<
- " deleted successfully! " << std::endl;
+ " deleted successfully! " << std::endl;
std::vector<SimulatorResourceServerSP>::iterator ite = m_resources.begin();
while (ite != m_resources.end())
{
catch (InvalidArgsException &e)
{
std::cout << "InvalidArgsException occured [code : " << e.code()
- << " Detail: " << e.what() << "]" << std::endl;
+ << " Detail: " << e.what() << "]" << std::endl;
}
catch (SimulatorException &e)
{
std::cout << "SimulatorException occured [code : " << e.code()
- << " Detail: " << e.what() << "]" << std::endl;
+ << " Detail: " << e.what() << "]" << std::endl;
}
} break;
}
std::cout << "Setting the new values from allowed values list to power attribute" <<
- std::endl;
+ std::endl;
// Update all possible values from allowed values
for (int index = 0; index < allowedValuesSize; index++)
{
}
std::cout << "Setting the new values from allowed values list to intensity attribute"
- << std::endl;
+ << std::endl;
// Update all possible values from allowed values
for (int index = min; index <= max; index++)
{
// Attributes
SimulatorResourceModel resModel = resource->getModel();
std::map<std::string, SimulatorResourceModel::Attribute> attributes =
- resModel.getAttributes();
+ resModel.getAttributes();
std::cout << "##### Attributes [" << attributes.size() << "]" << std::endl;
for (auto & attribute : attributes)
{
const int id)
{
std::cout << "Update automation is completed [URI: " << uri.c_str()
- << " AutomationID: " << id << "] ###" << std::endl;
+ << " AutomationID: " << id << "] ###" << std::endl;
}
void automateResourceUpdate()
{
int id = m_resources[index - 1]->startUpdateAutomation(type,
std::bind(&SimLightResource::onUpdateAutomationCompleted, this,
- std::placeholders::_1, std::placeholders::_2));
+ std::placeholders::_1, std::placeholders::_2));
std::cout << "startUpdateAutomation() returned succces : " << id << std::endl;
}
catch (SimulatorException &e)
{
std::cout << "SimulatorException occured [code : " << e.code() << " Detail: " <<
- e.what() << "]" << std::endl;
+ e.what() << "]" << std::endl;
}
}
SimulatorResourceServerSP resource = m_resources[index - 1];
SimulatorResourceModel resModel = resource->getModel();
std::map<std::string, SimulatorResourceModel::Attribute> attributes =
- resModel.getAttributes();
+ resModel.getAttributes();
int size = 0;
for (auto & attribute : attributes)
{
int choice = -1;
std::cout << "Select the attribute which you want to automate for updation: " <<
- std::endl;
+ std::endl;
std::cin >> choice;
if (choice < 0 || choice > size)
{
type = AutomationType::RECURRENT;
std::cout << "Requesting attribute automation for " << attributeName.c_str() <<
- std::endl;
+ std::endl;
try
{
int id = resource->startUpdateAutomation(attributeName, type,
std::bind(&SimLightResource::onUpdateAutomationCompleted, this,
- std::placeholders::_1, std::placeholders::_2));
+ std::placeholders::_1, std::placeholders::_2));
std::cout << "startUpdateAutomation() returned succces : " << id << std::endl;
}
catch (SimulatorException &e)
{
std::cout << "SimulatorException occured [Error: " << e.code() << " Details: " <<
- e.what() << "]" << std::endl;
+ e.what() << "]" << std::endl;
}
}
if (!ids.size())
{
std::cout << "No automation operation is going on this resource right now!" <<
- std::endl;
+ std::endl;
return;
}
std::ostringstream out;
out << "ID: " << (int) observerInfo.id << std::endl;
out << " [address: " << observerInfo.address << " port: " << observerInfo.port
- << "]" << std::endl;
+ << "]" << std::endl;
std::cout << out.str();
}
for (auto & observerInfo : observersList)
{
std::cout << " ID : " << (int) observerInfo.id << " [address: " <<
- observerInfo.address << " port: " << observerInfo.port << "]" << std::endl;
+ observerInfo.address << " port: " << observerInfo.port << "]" << std::endl;
}
std::cout << "########################" << std::endl;
}
}
public boolean isDisplayName(String displayName) {
- boolean exist = false;
+ boolean exist;
synchronized (displayNameMap) {
exist = displayNameMap.containsKey(displayName);
}
}
public String getCompleteUriFromDisplayName(String displayName) {
- String completeURI = null;
+ String completeURI;
synchronized (displayNameMap) {
completeURI = displayNameMap.get(displayName);
}
@Override
public void run() {
Map<String, SimulatorResource> resourceTypeMap;
- SimulatorResourceServer[] simulatorResourceServers = null;
+ SimulatorResourceServer[] simulatorResourceServers;
try {
simulatorResourceServers = SimulatorManager.createResource(
configFilePath, noOfInstances,
}
public List<String> getURIList() {
- List<String> list = null;
+ List<String> list;
synchronized (orderedResourceUriMap) {
Set<String> typeSet = orderedResourceUriMap.keySet();
List<String> typeList = Utility.convertSetToList(typeSet);
if (null == typeList || typeList.size() < 1) {
- return list;
+ return null;
}
list = new ArrayList<String>();
int val;
try {
val = Integer.parseInt(value);
+ server.updateAttributeInteger(attributeName, val);
} catch (NumberFormatException nfe) {
return;
}
- server.updateAttributeInteger(attributeName, val);
} else if (baseType == Type.DOUBLE) {
double val;
try {
val = Double.parseDouble(value);
+ server.updateAttributeDouble(attributeName, val);
} catch (NumberFormatException nfe) {
return;
}
- server.updateAttributeDouble(attributeName, val);
} else if (baseType == Type.BOOL) {
boolean val;
val = Boolean.parseBoolean(value);
if (m_getRequestSender)
{
return m_autoRequestGenMngr->startOnGET(m_getRequestSender,
- m_requestModelList[RequestType::RQ_TYPE_GET]->getQueryParams(),
- localCallback);
+ m_requestModelList[RequestType::RQ_TYPE_GET]->getQueryParams(),
+ localCallback);
}
break;
if (m_putRequestSender)
{
return m_autoRequestGenMngr->startOnPUT(m_putRequestSender,
- m_requestModelList[RequestType::RQ_TYPE_PUT]->getQueryParams(),
- m_requestModelList[RequestType::RQ_TYPE_PUT]->getRepSchema(),
- localCallback);
+ m_requestModelList[RequestType::RQ_TYPE_PUT]->getQueryParams(),
+ m_requestModelList[RequestType::RQ_TYPE_PUT]->getRepSchema(),
+ localCallback);
}
break;
if (m_postRequestSender)
{
return m_autoRequestGenMngr->startOnPOST(m_putRequestSender,
- m_requestModelList[RequestType::RQ_TYPE_POST]->getQueryParams(),
- m_requestModelList[RequestType::RQ_TYPE_POST]->getRepSchema(),
- localCallback);
+ m_requestModelList[RequestType::RQ_TYPE_POST]->getQueryParams(),
+ m_requestModelList[RequestType::RQ_TYPE_POST]->getRepSchema(),
+ localCallback);
}
break;
throw InvalidArgsException(SIMULATOR_INVALID_PARAM, "Empty path string!");
}
- RAML::RamlParser *ramlParser = new RAML::RamlParser(path);
+ std::shared_ptr<RAML::RamlParser> ramlParser = std::make_shared<RAML::RamlParser>(path);
RAML::RamlPtr raml = ramlParser->getRamlPtr();
configure(raml);