public ExThread(ZenSensorDesc sensor, int device_No, ZenClientHandle_t device_Handle, ZenSensorHandle_t device_Sensor) { this.mSensor = sensor; this.device_No = device_No; this.device_Handle = device_Handle; this.device_Sensor = device_Sensor; }
static void Main(string[] args) { ZenClientHandle_t zenHandle = new ZenClientHandle_t(); OpenZen.ZenInit(zenHandle); ExThread obj = new ExThread(zenHandle); // Creating thread // Using thread class Thread thr = new Thread(new ThreadStart(obj.sensorEventThread)); thr.Start(); // start sensor listing, new sensors will be reported as Events in our event thread OpenZen.ZenListSensorsAsync(zenHandle); while (!obj.mSearchDone) { Console.WriteLine("Searching for sensors ..."); Thread.Sleep(1000); } if (obj.mFoundSensors.Count == 0) { Console.WriteLine("No sensor found on the system"); OpenZen.ZenShutdown(zenHandle); thr.Abort(); return; } ZenSensorInitError sensorInitError = ZenSensorInitError.ZenSensorInitError_Max; // try three connection attempts for (int i = 0; i < 3; i++) { ZenSensorHandle_t sensorHandle = new ZenSensorHandle_t(); sensorInitError = OpenZen.ZenObtainSensor(zenHandle, obj.mFoundSensors[0], sensorHandle); Console.WriteLine("Connecting to sensor " + obj.mFoundSensors[0].identifier + " on IO interface " + obj.mFoundSensors[0].ioType); if (sensorInitError == ZenSensorInitError.ZenSensorInitError_None) { Console.WriteLine("Succesfully connected to sensor"); break; } } if (sensorInitError != ZenSensorInitError.ZenSensorInitError_None) { Console.WriteLine("Could not connect to sensor"); System.Environment.Exit(1); } // stream some data Thread.Sleep(5000); OpenZen.ZenShutdown(zenHandle); thr.Abort(); }
public static bool ZenSensorIsExecutableProperty(ZenClientHandle_t clientHandle, ZenSensorHandle_t sensorHandle, int property) { bool ret = OpenZenPINVOKE.ZenSensorIsExecutableProperty(ZenClientHandle_t.getCPtr(clientHandle), ZenSensorHandle_t.getCPtr(sensorHandle), property); if (OpenZenPINVOKE.SWIGPendingException.Pending) { throw OpenZenPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static ZenError ZenSensorSetInt32Property(ZenClientHandle_t clientHandle, ZenSensorHandle_t sensorHandle, int property, int value) { ZenError ret = (ZenError)OpenZenPINVOKE.ZenSensorSetInt32Property(ZenClientHandle_t.getCPtr(clientHandle), ZenSensorHandle_t.getCPtr(sensorHandle), property, value); if (OpenZenPINVOKE.SWIGPendingException.Pending) { throw OpenZenPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static ZenError ZenSensorSetArrayProperty(ZenClientHandle_t clientHandle, ZenSensorHandle_t sensorHandle, int property, ZenPropertyType type, SWIGTYPE_p_void buffer, uint bufferSize) { ZenError ret = (ZenError)OpenZenPINVOKE.ZenSensorSetArrayProperty(ZenClientHandle_t.getCPtr(clientHandle), ZenSensorHandle_t.getCPtr(sensorHandle), property, (int)type, SWIGTYPE_p_void.getCPtr(buffer), bufferSize); if (OpenZenPINVOKE.SWIGPendingException.Pending) { throw OpenZenPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static ZenError ZenSensorGetFloatProperty(ZenClientHandle_t clientHandle, ZenSensorHandle_t sensorHandle, int property, SWIGTYPE_p_float outValue) { ZenError ret = (ZenError)OpenZenPINVOKE.ZenSensorGetFloatProperty(ZenClientHandle_t.getCPtr(clientHandle), ZenSensorHandle_t.getCPtr(sensorHandle), property, SWIGTYPE_p_float.getCPtr(outValue)); if (OpenZenPINVOKE.SWIGPendingException.Pending) { throw OpenZenPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static bool ZenSensorEquals(ZenClientHandle_t clientHandle, ZenSensorHandle_t sensorHandle, ZenSensorDesc desc) { bool ret = OpenZenPINVOKE.ZenSensorEquals(ZenClientHandle_t.getCPtr(clientHandle), ZenSensorHandle_t.getCPtr(sensorHandle), ZenSensorDesc.getCPtr(desc)); if (OpenZenPINVOKE.SWIGPendingException.Pending) { throw OpenZenPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static ZenError ZenSensorComponents(ZenClientHandle_t clientHandle, ZenSensorHandle_t sensorHandle, string type, SWIGTYPE_p_p_ZenComponentHandle outComponentHandles, SWIGTYPE_p_size_t outLength) { ZenError ret = (ZenError)OpenZenPINVOKE.ZenSensorComponents(ZenClientHandle_t.getCPtr(clientHandle), ZenSensorHandle_t.getCPtr(sensorHandle), type, SWIGTYPE_p_p_ZenComponentHandle.getCPtr(outComponentHandles), SWIGTYPE_p_size_t.getCPtr(outLength)); if (OpenZenPINVOKE.SWIGPendingException.Pending) { throw OpenZenPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static ZenError ZenPublishEvents(ZenClientHandle_t clientHandle, ZenSensorHandle_t sensorHandle, string endpoint) { ZenError ret = (ZenError)OpenZenPINVOKE.ZenPublishEvents(ZenClientHandle_t.getCPtr(clientHandle), ZenSensorHandle_t.getCPtr(sensorHandle), endpoint); if (OpenZenPINVOKE.SWIGPendingException.Pending) { throw OpenZenPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
private void connect_Device4_Click(object sender, EventArgs e) { device4_Handle = new ZenClientHandle_t(); device4_Sensor = new ZenSensorHandle_t(); connectedDevice[3] = foundSensors[device_List4.SelectedIndex].identifier; ExThread exThread = new ExThread(foundSensors[device_List4.SelectedIndex], 4, device4_Handle, device4_Sensor); device4_Thread = new Thread(new ThreadStart(exThread.sensorEventThread)); device4_Thread.Start(); }
public static void main() { // Start of Code ZenClientHandle_t zenHandle = new ZenClientHandle_t(); OpenZen.ZenInit(zenHandle); ExThread obj = new ExThread(zenHandle); // Creating thread // Using thread class thr = new Thread(new ThreadStart(obj.sensorEventThread)); thr.Start(); // start sensor listing, new sensors will be reported as Events in our event thread OpenZen.ZenListSensorsAsync(zenHandle); while (!obj.mSearchDone) { Console.WriteLine("Searching for sensors ..."); Thread.Sleep(1000); } ZenSensorInitError sensorInitError = ZenSensorInitError.ZenSensorInitError_Max; // try three connection attempts for (int i = 0; i < 10; i++) { ZenSensorHandle_t sensorHandle = new ZenSensorHandle_t(); sensorInitError = OpenZen.ZenObtainSensor(zenHandle, obj.mFoundSensors[0], sensorHandle); if (sensorInitError == ZenSensorInitError.ZenSensorInitError_None) { Console.WriteLine("Succesfully connected to sensor"); break; } } if (sensorInitError != ZenSensorInitError.ZenSensorInitError_None) { Console.WriteLine("Could not connect to sensor"); System.Environment.Exit(1); } }
public static ZenAsyncStatus ZenSensorUpdateIAPAsync(ZenClientHandle_t clientHandle, ZenSensorHandle_t sensorHandle, SWIGTYPE_p_unsigned_char buffer, uint bufferSize) { ZenAsyncStatus ret = (ZenAsyncStatus)OpenZenPINVOKE.ZenSensorUpdateIAPAsync(ZenClientHandle_t.getCPtr(clientHandle), ZenSensorHandle_t.getCPtr(sensorHandle), SWIGTYPE_p_unsigned_char.getCPtr(buffer), bufferSize); if (OpenZenPINVOKE.SWIGPendingException.Pending) { throw OpenZenPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static ZenError ZenSensorComponentsByNumber(ZenClientHandle_t clientHandle, ZenSensorHandle_t sensorHandle, string type, uint number, ZenComponentHandle_t outComponentHandle) { ZenError ret = (ZenError)OpenZenPINVOKE.ZenSensorComponentsByNumber(ZenClientHandle_t.getCPtr(clientHandle), ZenSensorHandle_t.getCPtr(sensorHandle), type, number, ZenComponentHandle_t.getCPtr(outComponentHandle)); if (OpenZenPINVOKE.SWIGPendingException.Pending) { throw OpenZenPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ZenSensorHandle_t obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }