コード例 #1
0
        static void TestAnalogChannelInformation()
        {
            Console.WriteLine("TestAnalogChannelInformation-TestStart");
            string testStr = "1,Popular Va-g,,,kV,0.123345,0.00000000,0,-2048,2047,2000,1,p";
            var    row     = new AnalogChannelInformation(testStr);

            Console.Write(row.RowToString());
            testStr = "3,Popular Ia-g,,,kV,0.123345,1.00000000,0,-88888,2047,2000,1,p";

            row.StringToRow(testStr);

            Console.Write(row.RowToString());
            Console.WriteLine("TestAnalogChannelInformation-TestEnd");

            while (true)
            {
                try
                {
                    Console.WriteLine();
                    Console.Write("Input:");
                    var instr = Console.ReadLine();
                    if (instr == "q")
                    {
                        return;
                    }
                    else
                    {
                        row.StringToRow(instr);

                        Console.WriteLine("ChannelIndex:" + row.ChannelIndex);
                        Console.WriteLine("ChannelID:" + row.ChannelID);
                        Console.WriteLine("MonitorComponent:" + row.MonitorComponent);
                        Console.WriteLine("ChannelPhaseID:" + row.ChannelPhaseID);
                        Console.WriteLine("ChannelUnit:" + row.ChannelUnit);
                        Console.WriteLine("ChannelGain:" + row.ChannelGain);
                        Console.WriteLine("ChannelOffset:" + row.ChannelOffset);
                        Console.WriteLine("Skewing:" + row.Skewing);
                        Console.WriteLine("Min:" + row.Min);
                        Console.WriteLine("Max:" + row.Max);
                        Console.WriteLine("Primary:" + row.Primary);
                        Console.WriteLine("Primary:" + row.Secondary);
                        Console.WriteLine("PS:" + row.PS);


                        Console.WriteLine("TestEnd");
                        Console.WriteLine();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception:");
                    Console.WriteLine(ex.Message);
                }
            }
        }
コード例 #2
0
        public void ParserTest()
        {
            const string str         = @"  8,F8-VN               ,N,,V     ,     0.012207,1,2,-32767,32767, 330000.0,100.0,S";
            var          channelInfo = new AnalogChannelInformation(str);

            Assert.That(channelInfo.Index, Is.EqualTo(8));
            Assert.That(channelInfo.Name, Is.EqualTo("F8-VN"));
            Assert.That(channelInfo.Phase, Is.EqualTo("N"));
            Assert.That(channelInfo.CircuitComponent, Is.EqualTo(""));
            Assert.That(channelInfo.Units, Is.EqualTo("V"));
            Assert.That(channelInfo.MultiplierA, Is.EqualTo(0.012207).Within(0.001));
            Assert.That(channelInfo.MultiplierB, Is.EqualTo(1).Within(0.001));
            Assert.That(channelInfo.Skew, Is.EqualTo(2).Within(0.001));
            Assert.That(channelInfo.Min, Is.EqualTo(-32767).Within(0.001));
            Assert.That(channelInfo.Max, Is.EqualTo(32767).Within(0.001));
            Assert.That(channelInfo.Primary, Is.EqualTo(330000.0).Within(0.001));
            Assert.That(channelInfo.Secondary, Is.EqualTo(100.0).Within(0.001));
            Assert.That(channelInfo.IsPrimary, Is.EqualTo(false));
        }