Exemple #1
0
    public bool getLine(uint line)
    {
        Task      task        = new Task();
        string    devFullname = string.Format("{0}/port0/line{1}", name, line);
        DIChannel channel     = task.DIChannels.CreateChannel(devFullname, "", ChannelLineGrouping.OneChannelForEachLine);

        task.Start();
        DigitalMultiChannelReader reader = new DigitalMultiChannelReader(task.Stream);
        IAsyncResult result = reader.BeginReadSingleSamplePortUInt32(null, null);
        uint         value  = reader.EndReadSingleSamplePortUInt32(result).ElementAt(0);

        task.Stop();
        int shft = (int)line;

        return((value & (1u << shft)) == (1u << shft));
    }
Exemple #2
0
    public uint getPort()
    {
        Task      task        = new Task();
        string    devFullname = string.Format("{0}/port0/line0:31", name);
        DIChannel channel     = task.DIChannels.CreateChannel(devFullname, "", ChannelLineGrouping.OneChannelForEachLine);

        task.Start();
        DigitalMultiChannelReader reader = new DigitalMultiChannelReader(task.Stream);
        IAsyncResult result = reader.BeginReadSingleSamplePortUInt32(null, null);
        uint         value  = 0;
        var          bits   = reader.EndReadSingleSamplePortUInt32(result);

        foreach (uint bit in bits)
        {
            value += bit;
        }
        task.Stop();
        return(value);
    }