Exemplo n.º 1
0
        static public void Add(Coupler coupler, ushort register, IList <ISignal> signals)
        {
            if (signals == null)
            {
                return;
            }

            if (signals.Count == 0)
            {
                return;
            }

            var data = new ushort[(byte)((signals.Count / 16) + 1)];

            for (ushort i = 0; i < data.Length; i++)
            {
                var count = (i != (data.Length - 1)) ? 16 : signals.Count % 16;
                for (byte j = 0; j < count; j++)
                {
                    if (signals[i * 16 + j] != null)
                    {
                        coupler.AddDiscreet(signals[i * 16 + j], (ushort)(register + i), j);
                    }
                }
            }
        }
Exemplo n.º 2
0
        static public void Add(Coupler coupler, ushort register, IList <ISignal> signals)
        {
            if (signals == null)
            {
                return;
            }

            if (signals.Count == 0)
            {
                return;
            }

            // add inputs
            for (ushort i = 0; i < signals.Count; i++)
            {
                coupler.AddUshort(signals[i], (ushort)(register + 2 * i + 1));

                //if (!string.IsNullOrEmpty(ids[i]))
                //        mInputs.Add(new AnalogInput((i % 2 == 0) ? SensorType.Logical : SensorType.Voltage, ids[i], (ushort)(address + i)));
            }

            // add configure outputs
            var output = new List <Signal>
            {
                new Signal(string.Format("w750493.internal.1.{0}", register)),
                new Signal(string.Format("w750493.internal.2.{0}", register)),
                new Signal(string.Format("w750493.internal.3.{0}", register))
            };

            //return new ushort[] { 0x01, 0, 0x01, 0, 0x01, 0 }; - for voltage
            coupler.AddInternalUshort(output[0], (ushort)(register + 512), false);
            coupler.AddInternalUshort(output[1], (ushort)(register + 512 + 2), false);
            coupler.AddInternalUshort(output[2], (ushort)(register + 512 + 4), false);

            foreach (var signal in output)
            {
                signal.Update(1);
            }
        }