A thesis Submitted to




Download 2.64 Mb.
bet14/14
Sana09.09.2023
Hajmi2.64 Mb.
#80939
1   ...   6   7   8   9   10   11   12   13   14
Bog'liq
asosiyyy diplom uchun (1)
MTA Majmua(2021), 1, 4-Karno kartadan foydalanib mantiqiy ifodalarni minimallash, Kalendar reja algoritm, Ishchi dastur(Dasturlash I) 24.11.2021, 1 -amaliyot, 4-Lab, Yurtimiz mustaqillikga erishishidan oldin milliy urf odat, 7-8-mavzuDT larni sertifikatlashtirish, Axborotlarni izlash va ajratib olish fanidan mustaqil ish Mavzu, Abdulla Oripov O\'zbekiston (qasida), 2 lab Yarashov Diyorbek, TATU NF Hemis axborot tizimi, Algo 1-299, prezentatsiya

APPENDIX A


PYTHON CODE FOR SMART CAR
from gpio import * from time import * from physical import * from ioeclient import *
from environment import *

state = 0; # 0 stop, 1 up, 2 down, 3 left, 4 right


lastTimeInSeconds = 0 def main():


setup() while True:
loop() def setup():
IoEClient.setup({ "type": "car", "states": [
{
"name": "Status",

"type": "options", "options": {


"0": "stop",

"1": "up",


"2": "down",


"3": "left",


"4": "right"


},


"controllable": True

}


]

})


IoEClient.onInputReceive(onInputReceiveDone) global state
add_event_detect(0, detect)

state = restoreProperty("state", 0) setState(state)


def detect(): processData(customRead(0), False)
def onInputReceiveDone(analogInput): processData(analogInput, True)
def restoreProperty(propertyName, defaultValue):

value = getDeviceProperty(getName(), propertyName) if not (value is "" or value is None):


if type(defaultValue) is int : value = int(value)
setDeviceProperty(getName(), propertyName, value) return value
return defaultValue

def mouseEvent(pressed, x, y, firstPress): global state


if firstPress: setState(state+1)
def loop(): updateEnvironment()
sleep(1)

def processData(data, bIsRemote): if len(data) <= 0 :


return setState(int(data))
def setState(newState): global state
if newState >= 5 : newState = 0
state = newState analogWrite(A1, state) customWrite(0, state) IoEClient.reportStates(state)
setDeviceProperty(getName(), "state", state) def updateEnvironment():
global VOLUME_AT_RATE

global ENVIRONMENT_IMPACT_DIM


volumeRatio = float(VOLUME_AT_RATE) / Environment.getVolume() print("volume ratios is " + str(volumeRatio))


print("lalalala " + str(ENVIRONMENT_IMPACT_DIM*2*volumeRatio)) if state is 0 :
Environment.setContribution("stop...", 0,0, False) elif state is 1 :
Environment.setContribution("up...", 0, -20, True) moveBy(0,-5)
print("up is pushed..") elif state is 2 :
Environment.setContribution("down..", -20,0, True) moveBy(0,5)
print("down is pushed..") elif state is 3 :
Environment.setContribution("left..", 0,20, True) moveBy(-5,0)
print("left is pushed..") elif state is 4 :
Environment.setContribution("right...", 20,0, True) moveBy(5,0)
print("right is pushed..") if name == " main ":
main()


https://github.com/davidthera/iot-simulation-with-cisco-packet-tracer
Download 2.64 Mb.
1   ...   6   7   8   9   10   11   12   13   14




Download 2.64 Mb.