Im making a project and i need a c# code that does the following: 1. I need that
ID: 3649095 • Letter: I
Question
Im making a project and i need a c# code that does the following:1. I need that the code can receive a signal from a motion sensor that is with a xbee.
2. Then that the code can send a command to a ip camera to take a snapshot when motion is sense in the motion sensor.
thanks
Explanation / Answer
1)import traceback import time from devices.device_base import DeviceBase from devices.xbee.xbee_devices.xbee_base import XBeeBase from settings.settings_base import SettingsBase, Setting from devices.xbee.xbee_devices.xbee_dio import * class XBeeMotion(XBeeDIO): OFF_DELAY = 30 def __init__(self, name, core_services): ## Initialize the base class XBeeDIO.__init__(self, name, core_services) # zero means off, else holds time.time turned on self.__light_on = 0 return ## Locally defined functions: def sample_indication(self, buf, addr, force=False): ## allow base class to process data message XBeeDIO.sample_indication(self, buf, addr, force) # then do our reaction to the status now = time.time() motion = self.property_get( 'channel1_input').value if motion: if self.__light_on == 0: print 'Motion Seen, turning light on' self.set_output(Sample(now, True, "On"), 3) # else: print 'Motion Seen, light already on' # in all cases, bump light_on time to now self.__light_on = now else: # else no motion if self.__light_on != 0: # then light is on if (now - self.__light_on) > self.OFF_DELAY: print 'No Motion, turning light off' self.set_output(Sample(now, False, "Off"), 3) self.__light_on = 0 # else: print 'No Motion Seen, light is on, should stay on' return 2)-- Command to upload the image on the server. local putImgCmd = "curl -T "..fileName.." "..SERVER_URL -- Command to delete the temporary file. local delImgCmd = "rm "..fileName function uploadImage() os.execute(putImgCmd) end function deleteImage() os.execute(delImgCmd) end os.execute(getImgCmd) luup.call_delay("uploadImage", 3) luup.call_delay("deleteImage", 6)