public ForceSensorHandlerSingle(WebSocketObjectHolder webSocketObjectHolder, Settings settings) : base(webSocketObjectHolder)
        {
            this.settings = settings;

            if (isEthernet)
            {
                forceSensor = new ForceSensorEthernetManager();
            }
            else
            {
                forceSensor = new ForceSensorSerialManager
                {
                    PortName = settings.SensorCom
                };
            }

            forceSensor.SensorDataUpdated += ForceSensor_SensorDataUpdated;

            try
            {
                forceSensor.Connect();
            }
            catch (System.Exception e)
            {
                Console.Error.WriteLine(e.ToString());
            }
        }
Ejemplo n.º 2
0
        // WebSocket 関連イベント

        public override async Task OnConnected(WebSocket socket)
        {
            await base.OnConnected(socket);

            if (!cfdLogger.IsLogging)
            {
                cfdLogger.Connect(settings.CfdIP, settings.CfdPort);
            }

            if (!forceSensor.IsConnecting)
            {
                forceSensor.Connect();
            }

            StartSendTimer();

            var socketid = WebSocketObjectHolder.GetId(socket);

            Console.WriteLine($"socket created: {socketid}");

            await Task.CompletedTask;
        }