/// <summary>
        /// Stop bracer task.
        /// When you override this method in derived class, remember to call basic class method first.
        /// </summary>
        protected virtual void StopBracerTask()
        {
            BracerNode = new NodeHandle();

            if (_bracerCotask != null)
            {
                _bracerCotask.Dispose();
                _bracerCotask = null;

                BracerStateChanged.Invoke(BracerState.Disconnected);
            }
        }
    /*private void Init()
     * {
     *  if (Network == null)
     *  {
     *      Debug.LogError("Network is null");
     *      return;
     *  }
     *
     *
     *
     *
     *  if (_library == null)
     *  {
     *      Debug.LogError("Failed to create hardware extension interface library");
     *      return;
     *  }
     * }*/

    public Example()
    {
        Console.WriteLine("Example hi");
        _adnLibrary = Antilatency.DeviceNetwork.Library.load();
        _library    = Antilatency.HardwareExtensionInterface.Library.load();

        _nodeHandle        = WaitForNode();
        _cotaskConstructor = _library.getCotaskConstructor();
        _deviceNetwork     = _adnLibrary.createNetwork(new[] { new UsbDeviceType {
                                                                   vid = UsbVendorId.Antilatency, pid = 0x0000
                                                               } });
        _cotask = _cotaskConstructor.startTask(_deviceNetwork, _nodeHandle);



        outputPin1 = _cotask.createOutputPin(Pins.IO1, PinState.Low);
        outputPin2 = _cotask.createOutputPin(Pins.IO2, PinState.Low);
        outputPin5 = _cotask.createOutputPin(Pins.IO5, PinState.Low);
        outputPin6 = _cotask.createOutputPin(Pins.IO6, PinState.Low);


        _cotask.run();

        Update();

        void Update()
        {
            if (Input.GetKey(KeyCode.UpArrow))
            {
                outputPin2.setState(PinState.High);
                outputPin6.setState(PinState.High);
            }
            if (Input.GetKey(KeyCode.DownArrow))
            {
                outputPin1.setState(PinState.High);
                outputPin5.setState(PinState.High);
            }
            if (Input.GetKey(KeyCode.LeftArrow))
            {
                outputPin2.setState(PinState.High);
                outputPin5.setState(PinState.High);
            }
            if (Input.GetKey(KeyCode.RightArrow))
            {
                outputPin6.setState(PinState.High);
                outputPin1.setState(PinState.High);
            }
        }
    }
        /// <summary>
        /// Start bracer task on node.
        /// </summary>
        /// <param name="node">Node to start task on.</param>
        protected virtual void StartBracerTask(NodeHandle node)
        {
            var network = GetNativeNetwork();

            if (network == null)
            {
                return;
            }

            if (_bracerCotask != null)
            {
                Debug.LogWarningFormat("Bracer task already running on node {0}", BracerNode.value);
                return;
            }

            if (_bracerLibrary == null)
            {
                Debug.LogError("Bracer library is null");
                return;
            }

            if (network.nodeGetStatus(node) != NodeStatus.Idle)
            {
                Debug.LogError("Wrong node status");
                return;
            }

            using (var cotaskConstructor = _bracerLibrary.getCotaskConstructor()) {
                if (cotaskConstructor == null)
                {
                    Debug.LogError("Failed to get bracer cotask constructor");
                    return;
                }

                _bracerCotask = cotaskConstructor.startTask(network, node);
                if (_bracerCotask == null)
                {
                    StopBracerTask();
                    Debug.LogWarning("Failed to start bracer task on node " + node.value);
                    return;
                }

                BracerNode = node;
                BracerStateChanged.Invoke(BracerState.Connected);
            }
        }
        private void init()
        {
            //node = new NodeHandle();

            if (Network == null)
            {
                Debug.LogError("Network is null, from Init");
                return;
            }
            dLibrary = Antilatency.DeviceNetwork.Library.load();
            library  = Antilatency.HardwareExtensionInterface.Library.load();

            if (library == null)
            {
                Debug.LogError("HW Lib is null");
            }
            if (dLibrary == null)
            {
                Debug.LogError("DN Lib is null");
            }
            dLibrary.setLogLevel(LogLevel.Info);

            cotaskConstructor = library.getCotaskConstructor();


            var nw = GetNativeNetwork();

            node   = GetFirstIdleHardwareExtensionInterfaceNode();
            cotask = cotaskConstructor.startTask(nw, node);
            if (cotask != null)
            {
                outputPin1 = cotask.createOutputPin(Antilatency.HardwareExtensionInterface.Interop.Pins.IO1, Antilatency.HardwareExtensionInterface.Interop.PinState.High);
                outputPin2 = cotask.createOutputPin(Antilatency.HardwareExtensionInterface.Interop.Pins.IO2, Antilatency.HardwareExtensionInterface.Interop.PinState.High);
                outputPin5 = cotask.createOutputPin(Antilatency.HardwareExtensionInterface.Interop.Pins.IO5, Antilatency.HardwareExtensionInterface.Interop.PinState.High);
                outputPin6 = cotask.createOutputPin(Antilatency.HardwareExtensionInterface.Interop.Pins.IO6, Antilatency.HardwareExtensionInterface.Interop.PinState.High);
                outputPin3 = cotask.createOutputPin(Antilatency.HardwareExtensionInterface.Interop.Pins.IOA3, Antilatency.HardwareExtensionInterface.Interop.PinState.High);
                outputPin4 = cotask.createOutputPin(Antilatency.HardwareExtensionInterface.Interop.Pins.IOA4, Antilatency.HardwareExtensionInterface.Interop.PinState.High);
                outputPin7 = cotask.createOutputPin(Antilatency.HardwareExtensionInterface.Interop.Pins.IO7, Antilatency.HardwareExtensionInterface.Interop.PinState.High);
                outputPin8 = cotask.createOutputPin(Antilatency.HardwareExtensionInterface.Interop.Pins.IO8, Antilatency.HardwareExtensionInterface.Interop.PinState.High);

                cotask.run();
            }
        }