コード例 #1
0
        private void MonitorThread()
        {
            do
            {
                var outputs = Convert.ToString(SM_ReadDigitalOutputs(0, DigitalOutput.Count).Sum(b => b), 2)
                              .PadLeft(DigitalOutput.Count, '0')
                              .Select(c => c.ToString()).ToList().Select(c => Convert.ToBoolean(Convert.ToInt32(c))).ToList();
                DigitalOutput.ForEach(n => outputs.ForEach(m => n.Value = m));
                //for (var j = 0; j < DigitalOutput.Count; j++)
                //{
                //    DigitalOutput[j].Value = outputs[j];
                //}
                HandlerCpu.Delay(100);

                var inputs = Convert.ToString(SM_ReadDigitalInputs(0, DigitalInput.Count).Sum(b => b), 2)
                             .PadLeft(DigitalInput.Count, '0')
                             .Select(c => c.ToString()).ToList().Select(c => Convert.ToBoolean(Convert.ToInt32(c))).ToList();
                DigitalInput.ForEach(n => inputs.ForEach(m => n.Value = m));
                //for (var j = 0; j < DigitalInput.Count; j++)
                //{
                //    DigitalInput[j].Value = inputs[j];
                //}
            } while (Monitor);
        }