Ejemplo n.º 1
0
        public void Add(ThreePhaseMeasure measure)
        {
            using (var context = new PowerUnitContext())
            {
                context.ThreePhaseMeasures.Add(measure);

                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        ThreePhaseMeasure IThreePhaseInputService.Get()
        {
            using (var client = new TcpClient(hostname, port))
                using (var master = ModbusIpMaster.CreateIp(client))
                {
                    ushort[] inputs = master.ReadHoldingRegisters(slaveId, startAddress, numRegisters);

                    var measure = new ThreePhaseMeasure
                    {
                        Frequency = Converter.ConvertToFloat(inputs, 56),
                        L1        = GetPhase(inputs, 1),
                        L2        = GetPhase(inputs, 2),
                        L3        = GetPhase(inputs, 3),
                    };

                    return(measure);
                }
        }