Пример #1
0
        private void InitLibrary()
        {
            String Working = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            hModule = LoadLibrary(Path.Combine(Working, "gcdapi.dll"));

            Load = GetFunction <GCDAPI_Load>(hModule, "gcdapi_Load");
            //Console.WriteLine((Load == null ? "Failed to obtain function '" : "Obtained function '") + "GCDAPI_Load" + "'");

            Unload = GetFunction <GCDAPI_Unload>(hModule, "gcdapi_Unload");
            //Console.WriteLine((Unload == null ? "Failed to obtain function '" : "Obtained function '") + "GCDAPI_Unload" + "'");

            IsConnected = GetFunction <GCAPI_IsConnected>(hModule, "gcapi_IsConnected");
            //Console.WriteLine((IsConnected == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_IsConnected" + "'");

            GetFWVer = GetFunction <GCAPI_GetFWVer>(hModule, "gcapi_GetFWVer");
            //Console.WriteLine((GetFWVer == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_GetFWVer" + "'");

            Read = GetFunction <GCAPI_Read>(hModule, "gcapi_Read");
            //Console.WriteLine((Read == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_Read" + "'");

            Write = GetFunction <GCAPI_Write>(hModule, "gcapi_Write");
            //Console.WriteLine((Write == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_Write" + "'");

            GetTimeVal = GetFunction <GCAPI_GetTimeVal>(hModule, "gcapi_GetTimeVal");
            //Console.WriteLine((GetTimeVal == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_GetTimeVal" + "'");

            CalcPressTime = GetFunction <GCAPI_CalcPressTime>(hModule, "gcapi_CalcPressTime");
            //Console.WriteLine((CalcPressTime == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_CalcPressTime" + "'");

            isLive = Load();
        }
Пример #2
0
        public bool Init()
        {
            if (!functionsLoaded)
            {
                try
                {
                    String Working = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                    hModule = LoadLibrary(Path.Combine(Working, "gcdapi.dll"));

                    if (hModule == IntPtr.Zero)
                    {
                        return(false);
                    }
                    Console.WriteLine("Loaded DLL");

                    _Load = GetFunction <GCDAPI_Load>(hModule, "gcdapi_Load");
                    Console.WriteLine((_Load == null ? "Failed to obtain function '" : "Obtained function '") + "GCDAPI_Load" + "'");

                    _Unload = GetFunction <GCDAPI_Unload>(hModule, "gcdapi_Unload");
                    Console.WriteLine((_Unload == null ? "Failed to obtain function '" : "Obtained function '") + "GCDAPI_Unload" + "'");

                    _IsConnected = GetFunction <GCAPI_IsConnected>(hModule, "gcapi_IsConnected");
                    Console.WriteLine((_IsConnected == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_IsConnected" + "'");

                    _GetFWVer = GetFunction <GCAPI_GetFWVer>(hModule, "gcapi_GetFWVer");
                    Console.WriteLine((_GetFWVer == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_GetFWVer" + "'");

                    _Read = GetFunction <GCAPI_Read>(hModule, "gcapi_Read");
                    Console.WriteLine((_Read == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_Read" + "'");

                    _Write = GetFunction <GCAPI_Write>(hModule, "gcapi_Write");
                    Console.WriteLine((_Write == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_Write" + "'");

                    _GetTimeVal = GetFunction <GCAPI_GetTimeVal>(hModule, "gcapi_GetTimeVal");
                    Console.WriteLine((_GetTimeVal == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_GetTimeVal" + "'");

                    _CalcPressTime = GetFunction <GCAPI_CalcPressTime>(hModule, "gcapi_CalcPressTime");
                    Console.WriteLine((_CalcPressTime == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_CalcPressTime" + "'");

                    functionsLoaded = _Load();
                }
                catch
                {
                    functionsLoaded = false;
                    threadRunning   = false;
                }
            }

            if (functionsLoaded && !threadRunning)
            {
                threadRunning = true;
                titanWatcher.Start();
            }

            RefreshControllerTypes();

            return(functionsLoaded);
        }
Пример #3
0
        private void InitLibrary()
        {
            String Working = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            hModule = LoadLibrary(Path.Combine(Working, "gcdapi.dll"));

            Load = GetFunction <GCDAPI_Load>(hModule, "gcdapi_Load");
            //Console.WriteLine((Load == null ? "Failed to obtain function '" : "Obtained function '") + "GCDAPI_Load" + "'");

            Unload = GetFunction <GCDAPI_Unload>(hModule, "gcdapi_Unload");
            //Console.WriteLine((Unload == null ? "Failed to obtain function '" : "Obtained function '") + "GCDAPI_Unload" + "'");

            IsConnected = GetFunction <GCAPI_IsConnected>(hModule, "gcapi_IsConnected");
            //Console.WriteLine((IsConnected == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_IsConnected" + "'");

            GetFWVer = GetFunction <GCAPI_GetFWVer>(hModule, "gcapi_GetFWVer");
            //Console.WriteLine((GetFWVer == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_GetFWVer" + "'");

            Read = GetFunction <GCAPI_Read>(hModule, "gcapi_Read");
            //Console.WriteLine((Read == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_Read" + "'");

            Write = GetFunction <GCAPI_Write>(hModule, "gcapi_Write");
            //Console.WriteLine((Write == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_Write" + "'");

            GetTimeVal = GetFunction <GCAPI_GetTimeVal>(hModule, "gcapi_GetTimeVal");
            //Console.WriteLine((GetTimeVal == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_GetTimeVal" + "'");

            CalcPressTime = GetFunction <GCAPI_CalcPressTime>(hModule, "gcapi_CalcPressTime");
            //Console.WriteLine((CalcPressTime == null ? "Failed to obtain function '" : "Obtained function '") + "GCAPI_CalcPressTime" + "'");

            Load();
            var fwVer = GetFWVer();

            if (fwVer != 0)
            {
                _isLive       = true;
                _errorMessage = string.Empty;
            }
            else
            {
                _isLive       = false;
                _errorMessage = "Titan One device not present or PC Link cable not connected";
            }
        }