示例#1
0
    public void PlayOrderly(List <string> orderedTags)
    {
        if (m_isProcessing ||
            m_effects.Count == 0)
        {
            return;
        }

        foreach (var tag in orderedTags)
        {
            if (!m_effects.ContainsKey(tag))
            {
                return;
            }
        }

        m_isProcessing = true;

        var process = new SerialProcess();

        foreach (var tag in orderedTags)
        {
            process.Add(m_effects[tag]);
        }

        process.Add((System.Action finish) =>
        {
            m_isProcessing = false;
            Clear();
        });

        process.Flush();
    }
示例#2
0
        public void SerialExceptionOnReadTest()
        {
            var ss = new SerialSettings("COM0");

            using (var sp = new SerialProcess(ss))
            {
                Assert.Throws <SerialException>(() =>
                {
                    sp.Read(-1, -1, 200);
                });
            }
        }
示例#3
0
        public void EofExceptionOnWriteTest()
        {
            var ss = new SerialSettings("COM99");

            using (var sp = new SerialProcess(ss))
            {
                Process.GetProcessById(sp.Pid).Kill();
                Assert.Throws <EndOfStreamException>(() =>
                {
                    sp.Write(new byte[0]);
                });
            }
        }
示例#4
0
        public void EofExceptionOnReadTest()
        {
            var ss = new SerialSettings("COM98");

            using (var sp = new SerialProcess(ss))
            {
                Process.GetProcessById(sp.Pid).Kill();
                Assert.Throws <EndOfStreamException>(() =>
                {
                    sp.Read(-1, -1, 200);
                });
            }
        }
示例#5
0
        private static void Main(string[] args)
        {
            socketProcess = new SocketProcess(port, maxThreads, dataTimeReadout, storageSize);
            Console.WriteLine("<Server>Stallus Server is on. Currently listening on " + "145.93.73.21" + ":" + port + "\n And waiting for Serial communication"); //GetIPAddress() //"145.93.73.139"
            Thread ipThread = new Thread(socketProcess.InitializeSocketProcessing);

            ipThread.Start();
            serialProcess = new SerialProcess('#', '%');
            Thread serialThread = new Thread(serialProcess.InitializeSerialProcessing);

            serialThread.Start();
            Thread commandThread = new Thread(CommandCentre);

            commandThread.Start();
        }
示例#6
0
        public void SerialExceptionOnWriteTest()
        {
            var ss = new SerialSettings("COM0");

            using (var sp = new SerialProcess(ss))
            {
                //stdout pipe remains open even after process exited
                //exception wont happend in stdout.writeline but
                //in detection of ! in beggining of stdin.readline
                Assert.Throws <SerialException>(() =>
                {
                    //write zero bytes is a good ping
                    sp.Write(new byte[0]);
                });
            }
        }
 public ModbusIsolatedStream(object settings, int timeout, Action <char, byte[], int> monitor = null)
 {
     serialProcess = new SerialProcess(settings);
     this.timeout  = timeout;
     this.monitor  = monitor;
 }
示例#8
0
    public void Test()
    {
        var testCases = new List <TestCase>
        {
            new TestCase
            {
                title = "ordered test 1",
                raw   = new List <int>
                {
                    1, 2, 3, 4
                },
                expected = new List <int>
                {
                    1, 2, 3, 4
                }
            },
            new TestCase
            {
                title = "reverse ordered test 1",
                raw   = new List <int>
                {
                    5, 4, 3, 2, 1
                },
                expected = new List <int>
                {
                    5, 4, 3, 2, 1
                }
            }
        };

        foreach (var testCase in testCases)
        {
            int size     = testCase.raw.Count;
            var procaess = new SerialProcess();

            var result = new List <int>();

            for (int i = 0; i < size; i++)
            {
                int index = i;
                procaess.Add((System.Action finish) =>
                {
                    result.Add(testCase.raw[index]);
                    finish();
                });
            }

            procaess.Add((System.Action finish) =>
            {
                if (!IsSameList(result, testCase.expected))
                {
                    Assert.Fail("Test : " + testCase.title + " failed.");
                }

                finish();
            });

            procaess.Flush();
        }

        Assert.Pass();
    }