Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            IntPtr           handle      = new IntPtr(0);
            SenselFrame      frame       = new SenselFrame();
            SenselDeviceList list        = new SenselDeviceList();
            SenselSensorInfo sensor_info = new SenselSensorInfo();

            list.num_devices = 0;
            Sensel.senselGetDeviceList(ref list);
            Console.WriteLine("Num Devices: " + list.num_devices);
            if (list.num_devices != 0)
            {
                Sensel.senselOpenDeviceByID(ref handle, list.devices[0].idx);
            }
            if (handle.ToInt64() != 0)
            {
                Sensel.senselGetSensorInfo(handle, ref sensor_info);
                Console.WriteLine("Sensel Device: " + System.Text.Encoding.Default.GetString(list.devices[0].serial_num));
                Console.WriteLine("Width: " + sensor_info.width + "mm");
                Console.WriteLine("Height: " + sensor_info.height + "mm");
                Console.WriteLine("Cols: " + sensor_info.num_cols);
                Console.WriteLine("Rows: " + sensor_info.num_rows);
            }
            Thread.Sleep(4000);
        }
Ejemplo n.º 2
0
 public SenselDevice()
 {
     handle      = new IntPtr(0);
     frame       = new SenselFrame();
     frame_data  = new SenselFrameData();
     sensor_info = new SenselSensorInfo();
     fw_info     = new SenselFirmwareInfo();
 }
Ejemplo n.º 3
0
        public static int senselAllocateFrameData(IntPtr handle, SenselFrame frame)
        {
            SenselSensorInfo info = new SenselSensorInfo();

            Sensel.senselGetSensorInfo(handle, ref info);
            frame.force_array  = new float[info.num_rows * info.num_cols];
            frame.labels_array = new byte[info.num_rows * info.num_cols];
            frame.accel_data   = new SenselAccelData();
            frame.frame_data   = new SenselFrameData();

            Sensel.senselAllocateFrameData(handle, ref frame.frame_data);
            return(0);
        }
Ejemplo n.º 4
0
        public static int senselGetFrame(IntPtr handle, SenselFrame frame)
        {
            Sensel.senselGetFrame(handle, frame.frame_data);
            frame.n_contacts = frame.frame_data.n_contacts;
            frame.contacts   = new SenselContact[frame.n_contacts];
            long ptrIndex = (frame.frame_data.contacts).ToInt64();

            for (int i = 0; i < frame.n_contacts; i++)
            {
                IntPtr cPtr = new IntPtr(ptrIndex);
                frame.contacts[i] = (SenselContact)Marshal.PtrToStructure(cPtr, typeof(SenselContact));
                ptrIndex         += Marshal.SizeOf(typeof(SenselContact));
            }
            Marshal.Copy(frame.frame_data.force_array, frame.force_array, 0, frame.force_array.Length);
            Marshal.Copy(frame.frame_data.labels_array, frame.labels_array, 0, frame.labels_array.Length);
            frame.accel_data = (SenselAccelData)Marshal.PtrToStructure(frame.frame_data.accel_data, typeof(SenselAccelData));
            return(0);
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            IntPtr           handle      = new IntPtr(0);
            SenselFrame      frame       = new SenselFrame();
            SenselDeviceList list        = new SenselDeviceList();
            SenselSensorInfo sensor_info = new SenselSensorInfo();
            float            total_force = 0;

            list.num_devices = 0;
            Sensel.senselGetDeviceList(ref list);
            Console.WriteLine("Num Devices: " + list.num_devices);
            if (list.num_devices != 0)
            {
                Sensel.senselOpenDeviceByID(ref handle, list.devices[0].idx);
                Sensel.senselSetFrameContent(handle, 1);
                Sensel.senselAllocateFrameData(handle, frame);
                Sensel.senselStartScanning(handle);
            }
            if (handle.ToInt64() != 0)
            {
                Sensel.senselGetSensorInfo(handle, ref sensor_info);
                for (int c = 0; c < 500; c++)
                {
                    Int32 num_frames = 0;
                    Sensel.senselReadSensor(handle);
                    Sensel.senselGetNumAvailableFrames(handle, ref num_frames);
                    for (int f = 0; f < num_frames; f++)
                    {
                        Sensel.senselGetFrame(handle, frame);
                        total_force = 0;
                        for (int i = 0; i < sensor_info.num_cols * sensor_info.num_rows; i++)
                        {
                            total_force = total_force + frame.force_array[i];
                        }
                        Console.WriteLine("Total Force: " + total_force);
                    }
                }

                Sensel.senselStopScanning(handle);
                Sensel.senselClose(handle);
            }
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            IntPtr           handle = new IntPtr(0);
            SenselFrame      frame  = new SenselFrame();
            SenselDeviceList list   = new SenselDeviceList();

            list.num_devices = 0;
            Sensel.senselGetDeviceList(ref list);
            Console.WriteLine("Num Devices: " + list.num_devices);
            if (list.num_devices != 0)
            {
                Sensel.senselOpenDeviceByID(ref handle, list.devices[0].idx);
                Sensel.senselSetFrameContent(handle, 4);
                Sensel.senselAllocateFrameData(handle, frame);
                Sensel.senselStartScanning(handle);
            }
            if (handle.ToInt64() != 0)
            {
                for (int c = 0; c < 500; c++)
                {
                    Int32 num_frames = 0;
                    Sensel.senselReadSensor(handle);
                    Sensel.senselGetNumAvailableFrames(handle, ref num_frames);
                    for (int f = 0; f < num_frames; f++)
                    {
                        Sensel.senselGetFrame(handle, frame);
                        Console.WriteLine("\nNum Contacts: " + frame.n_contacts);
                        for (int i = 0; i < frame.n_contacts; i++)
                        {
                            Console.WriteLine("Contact ID: " + frame.contacts[i].id);
                        }
                    }
                }

                Sensel.senselStopScanning(handle);
                Sensel.senselClose(handle);
            }
        }