Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: AX-12A Dynamixel mbed iothub_client EthernetInterface NTPClient ConfigFile SDFileSystem iothub_amqp_transport mbed-rtos proton-c-mbed wolfSSL
NodeEmul.cpp
00001 // Copyright (c) Microsoft. All rights reserved. 00002 // Licensed under the MIT license. See LICENSE file in the project root for full license information. 00003 00004 #include "mbed.h" 00005 #include "NodeEmul.h" 00006 #include "threadapi.h" 00007 00008 // emulated device that does nothing 00009 00010 NodeEmul::NodeEmul(int id) 00011 { 00012 _LastPosition= 20.0f + id; 00013 _LastTemperature = 30 + id; 00014 _LastVoltage = 12 + ((float)id * 0.1f); 00015 _LastLoad = 9 + id; 00016 } 00017 00018 00019 bool NodeEmul::HasMeasure(int measureId) 00020 { 00021 switch (measureId) 00022 { 00023 case NM_Temperature: 00024 return true; 00025 00026 case NM_Degrees: 00027 return true; 00028 00029 case NM_Voltage: 00030 return true; 00031 00032 case NM_Load: 00033 return true; 00034 00035 default: 00036 return false; 00037 } 00038 } 00039 00040 void NodeEmul::ClearMeasureCache() 00041 { 00042 00043 } 00044 00045 float NodeEmul::GetMeasure(int measureId) 00046 { 00047 switch (measureId) 00048 { 00049 case NM_Temperature: 00050 return (float)_LastTemperature; 00051 00052 case NM_Degrees: 00053 return _LastPosition; 00054 00055 case NM_Voltage: 00056 return _LastVoltage; 00057 00058 case NM_Load: 00059 return _LastLoad; 00060 00061 default: 00062 return 0.0f; 00063 } 00064 } 00065 00066 bool NodeEmul::HasAction(int actionId) 00067 { 00068 switch (actionId) 00069 { 00070 case NA_Ping: 00071 return true; 00072 00073 case NA_Init: 00074 return true; 00075 00076 case NA_Rotate: 00077 return true; 00078 00079 case NA_ClearError: 00080 return true; 00081 00082 default: 00083 return false; 00084 } 00085 } 00086 00087 00088 bool NodeEmul::DoAction(int actionId, float actionValue) 00089 { 00090 switch (actionId) 00091 { 00092 case NA_Ping: 00093 return true; 00094 00095 case NA_Init: 00096 return true; 00097 00098 case NA_Rotate: 00099 _LastPosition = actionValue; 00100 return true; 00101 00102 case NA_ClearError: 00103 return true; 00104 00105 default: 00106 return false; 00107 } 00108 } 00109 00110 NodePartType NodeEmul::GetNodeType() 00111 { 00112 return NT_Emul; 00113 } 00114 00115 int NodeEmul::GetLastError() 00116 { 00117 return 0; 00118 } 00119 00120 bool NodeEmul::HasError() 00121 { 00122 return false; 00123 }
Generated on Tue Jul 12 2022 16:05:14 by
1.7.2