コード例 #1
0
        private void StartFunction(IWebSocketConnection socket, string functionType)
        {
            FunctionType type;

            // Stop any running writer
            StopFunction(socket);

            // Get the function type
            switch (functionType.ToUpper())
            {
            case "RANDOM":
                type = FunctionType.Random;
                break;

            case "SAWTOOTH":
                type = FunctionType.Sawtooth;
                break;

            case "SINE":
                type = FunctionType.Sine;
                break;

            case "SQUARE":
                type = FunctionType.Square;
                break;

            case "TRIANGLE":
                type = FunctionType.Triangle;
                break;

            default:
                return;
            }

            // Create the function generator
            var generator = new FunctionGenerator(type);

            // Start a thread to write out the function's value periodically
            var writer = new Writer(socket, generator, 50);

            writer.Start();

            _activeWriters.Add(socket.ConnectionInfo.Id, writer);
        }
コード例 #2
0
 public Writer(IWebSocketConnection socket, FunctionGenerator generator, int updateRate)
 {
     _socket    = socket;
     _generator = generator;
 }