예제 #1
0
 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;
 }
예제 #2
0
    public static ZenSensorInitError ZenObtainSensor(ZenClientHandle_t clientHandle, ZenSensorDesc desc, ZenSensorHandle_t outSensorHandle)
    {
        ZenSensorInitError ret = (ZenSensorInitError)OpenZenPINVOKE.ZenObtainSensor(ZenClientHandle_t.getCPtr(clientHandle), ZenSensorDesc.getCPtr(desc), ZenSensorHandle_t.getCPtr(outSensorHandle));

        if (OpenZenPINVOKE.SWIGPendingException.Pending)
        {
            throw OpenZenPINVOKE.SWIGPendingException.Retrieve();
        }
        return(ret);
    }
예제 #3
0
    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);
    }
예제 #4
0
        private void retrieve_Port_Click(object sender, EventArgs e)
        {
            foundSensors.Clear();
            device_List1.Items.Clear();
            device_List2.Items.Clear();
            device_List3.Items.Clear();
            device_List4.Items.Clear();

            OpenZen.ZenInit(zenHandle);

            ZenEvent zenEvent   = new ZenEvent();
            Boolean  searchDone = false;

            // start sensor listing, new sensors will be reported as Events in our event thread
            OpenZen.ZenListSensorsAsync(zenHandle);

            // Searching for device
            while (searchDone == false)
            {
                if (OpenZen.ZenWaitForNextEvent(zenHandle, zenEvent) && zenEvent.component.handle == 0)
                {
                    // Handle Event
                    switch (zenEvent.eventType)
                    {
                    case (int)ZenSensorEvent.ZenSensorEvent_SensorFound:
                        //MessageBox.Show("Device : " + zenEvent.data.sensorFound.name);
                        ZenSensorDesc sensor = new ZenSensorDesc();
                        sensor.identifier   = zenEvent.data.sensorFound.identifier;
                        sensor.baudRate     = zenEvent.data.sensorFound.baudRate;
                        sensor.ioType       = zenEvent.data.sensorFound.ioType;
                        sensor.name         = zenEvent.data.sensorFound.name;
                        sensor.serialNumber = zenEvent.data.sensorFound.serialNumber;
                        foundSensors.Add(sensor);
                        break;

                    case (int)ZenSensorEvent.ZenSensorEvent_SensorListingProgress:
                        if (zenEvent.data.sensorListingProgress.progress == 1.0)
                        {
                            searchDone = true;
                        }
                        break;
                    }
                }
            }

            // Listing Connected Device
            if (foundSensors.Count > 0)
            {
                for (int i = 0; i < foundSensors.Count; i++)
                {
                    device_List1.Items.Add(foundSensors[i].name);
                    device_List2.Items.Add(foundSensors[i].name);
                    device_List3.Items.Add(foundSensors[i].name);
                    device_List4.Items.Add(foundSensors[i].name);
                }
                device_List1.SelectedIndex = 0;
                device_List2.SelectedIndex = 0;
                device_List3.SelectedIndex = 0;
                device_List4.SelectedIndex = 0;
            }
            else
            {
                MessageBox.Show("No Sensor Device is found");
            }
        }
예제 #5
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ZenSensorDesc obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }