private static void GenerateWinDllConfig(string rootFolder, string dataPath) { var backupFolder = GetWinBackupDllFolder(rootFolder); var dllVersion = new DllVersion(); foreach (var file in Directory.GetFiles(backupFolder, "*.dll")) { var name = Path.GetFileNameWithoutExtension(file); var md5 = MD5Hashing.HashFile(file); var size = (new FileInfo(file)).Length; var dllInfo = new DllInfo() { dllName = name, MD5 = md5, size = size, }; dllVersion.Manifest.Add(name, dllInfo); FileUtil.MoveFileOrDirectory(file, backupFolder + "/" + dllInfo.ToFileName()); } dllVersion.Version = AssetManager.GetVisualDateTimeNow(); FileHelper.SaveJsonObj(dllVersion, backupFolder + "/" + dllVersion.ToFileName()); FileHelper.SaveJsonObj(dllVersion, dataPath + "/StreamingAssets/" + GameResPath.DLLVERSION_FILE); }
//生成dll版本配置 public static void CreateDllConfig(string dllOutPath = "") { //读取 string dllRoot = Application.dataPath + "/../Library/ScriptAssemblies/"; string hotfixdll = Path.Combine(dllRoot, hotfixDllName + ".dll"); string hotfixPdb = Path.Combine(dllRoot, hotfixDllName + ".pdb"); if (string.IsNullOrEmpty(dllOutPath)) { dllOutPath = Application.dataPath + "/../Dll/"; } if (Directory.Exists(dllOutPath)) { Directory.Delete(dllOutPath, true); } Directory.CreateDirectory(dllOutPath); File.Copy(hotfixdll, Path.Combine(dllOutPath, hotfixDllName + ".dll")); File.Copy(hotfixPdb, Path.Combine(dllOutPath, hotfixDllName + ".pdb")); DllVersion dllVersion = new DllVersion(); ReadDllInfo(dllVersion, Path.Combine(dllOutPath, hotfixDllName + ".dll")); ReadDllInfo(dllVersion, Path.Combine(dllOutPath, hotfixDllName + ".pdb")); string json = LitJson.JsonMapper.ToJson(dllVersion); Debug.Log(json); File.WriteAllText(Path.Combine(dllOutPath, "dllVersion.txt"), json); }
/// <summary> 获取远端dll的版本 </summary> public IEnumerator GetServerDllVersion() { while (serverDllVersion == null) { using (UnityWebRequest webRequest = UnityWebRequest.Get(Path.Combine(server, versionName))) { yield return(webRequest.SendWebRequest()); if (webRequest.result != UnityWebRequest.Result.Success) { Debug.LogError("请求失败"); //可以弹窗之类的提示 然后通过以下语法阻塞界面 //bool reGet = false; //yield return new WaitUntil((() => reGet)); yield return(new WaitForSeconds(1)); } else { Debug.Log($"Get Content:{webRequest.downloadHandler.text}"); serverDllVersion = LitJson.JsonMapper.ToObject <DllVersion>(webRequest.downloadHandler.text); } } } }
private static void GenerateAndroidDllConfig(string pathToBuildProject) { var backupFolder = GetAndroidBackupDllFolder(pathToBuildProject); var dllVersion = new DllVersion(); foreach (var file in Directory.GetFiles(backupFolder, "*.dll")) { var name = Path.GetFileNameWithoutExtension(file); var md5 = MD5Hashing.HashFile(file); var size = (new FileInfo(file)).Length; var dllInfo = new DllInfo() { dllName = name, MD5 = md5, size = size, }; dllVersion.Manifest.Add(name, dllInfo); FileUtil.MoveFileOrDirectory(file, backupFolder + "/" + dllInfo.ToFileName()); } dllVersion.Version = AssetManager.GetVisualDateTimeNow(); if (dllVersion.Version > DllHelper.Max_Versoin) { throw new Exception("dll版本号居然比限定的最大版本号还要大!"); } FileHelper.SaveJsonObj(dllVersion, backupFolder + "/" + dllVersion.ToFileName()); FileHelper.SaveJsonObj(dllVersion, GetDecodeApkFolder(pathToBuildProject) + "/assets/dllVersion.json"); ChangeAndroidManifestDllVersion(pathToBuildProject, dllVersion.Version); }
private static void GenerateAndroidDllConfig(string pathToBuildProject) { var backupFolder = GetAndroidBackupDllFolder(pathToBuildProject); var dllVersion = new DllVersion(); foreach (var file in Directory.GetFiles(backupFolder, "*.dll")) { var name = Path.GetFileNameWithoutExtension(file); var md5 = MD5Hashing.HashFile(file); var size = (new FileInfo(file)).Length; var dllInfo = new DllInfo() { dllName = name, MD5 = md5, size = size, }; dllVersion.Manifest.Add(name, dllInfo); FileUtil.MoveFileOrDirectory(file, backupFolder + "/" + dllInfo.ToFileName()); } dllVersion.Version = DateTime.UtcNow.ToFileTimeUtc(); FileHelper.SaveJsonObj(dllVersion, backupFolder + "/" + dllVersion.ToFileName()); FileHelper.SaveJsonObj(dllVersion, GetDecodeApkFolder(pathToBuildProject) + "/assets/dllVersion.json"); }
private static IVBERuntime DetermineVersion() { IVBERuntime runtime; try { runtime = new VBERuntime7(); runtime.Timer(); _version = DllVersion.Vbe7; } catch { try { runtime = new VBERuntime6(); runtime.Timer(); _version = DllVersion.Vbe6; } catch { // we shouldn't be here.... Rubberduck is a VBA add-in, so how the heck could it have loaded without a VBE dll?!? throw new InvalidOperationException("Cannot execute DoEvents; the VBE dll could not be located."); } } return(_version != DllVersion.Unknown ? runtime : null); }
public static void ReadDllInfo(DllVersion dllVersion, string path) { string md5 = MD5Helper.FileMD5(path); FileInfo fileInfo = new FileInfo(path); long size = fileInfo.Length; dllVersion.dllFile.Add(Path.GetFileName(path), new DllConfig() { md5 = md5, size = size }); }
public VbeNativeApiAccessor(IVBE vbe) { if (_version == DllVersion.Unknown) { try { _version = VbeDllVersion.GetCurrentVersion(vbe); } catch { _version = DllVersion.Unknown; } } _runtime = InitializeRuntime(); }
/// <summary> 初始化 </summary> public void Init() { local = Path.Combine(Application.persistentDataPath, "Dll"); server = local;//测试 //未包含保存dll的目录 则创建一个 if (!Directory.Exists(local)) { Directory.CreateDirectory(local); } localVersion = Path.Combine(local, versionName); //已经包含本地文件了 if (File.Exists(localVersion)) { this.localDllVersion = LitJson.JsonMapper.ToObject <DllVersion>(File.ReadAllText(localVersion)); } }
void InitGame() { nowUtc = DateTime.UtcNow.ToFileTimeUtc(); string url = FileTools.GetDllNetPath(jsonName + "?v=" + nowUtc); // string url = FileTools.GetDllNetPath(jsonName); local = FileTools.ReadText <DllVersionList>(localPath + jsonName); if (local == null) { local = new DllVersionList(); DllVersion dv = new DllVersion(); dv.dllName = Main.Instance.runtimeConfig.runTimeName + ".zip"; dv.version = 0; local.item.Add(dv); FileTools.CreateFile(localPath, jsonName, local); } for (int i = 0; i < local.item.Count; i++) { localDL.Add(local.item[i].dllName, local.item[i]); } StartCoroutine(DownSetting(url)); }
static VbeNativeApiAccessor() { _version = DllVersion.Unknown; }
/// <summary> /// Called after pressing the button responsible for creating anaglyph. Runs the method from the object instance responsible for creating anaglyph. /// </summary> /// <param name="sender"> object sender </param> /// <param name="e"> RoutedEventArgs </param> private void OnClickButtonGenerateAnaglyph(object sender, RoutedEventArgs e) { if (radioAsm.IsChecked.Value) // assembler dll selected { this.dllVersion = DllVersion.ASM_DLL; } else if (radioC.IsChecked.Value) // C++ dll selected { this.dllVersion = DllVersion.CPP_DLL; } else // no dll selected { this.dllVersion = DllVersion.VOID; } if (radioTrue.IsChecked.Value) // true anaglyph filter selected { this.anaglyphVersion = AnaglyphVersion.TRUE_ANAGLYPH; } else if (radioGray.IsChecked.Value) // gray anaglyph filter selected { this.anaglyphVersion = AnaglyphVersion.GRAY_ANAGLYPH; } else if (radioColor.IsChecked.Value) // color anaglyph filter selected { this.anaglyphVersion = AnaglyphVersion.COLOR_ANAGLYPH; } else if (radioHalfColor.IsChecked.Value) // half color anaglyph filter selected { this.anaglyphVersion = AnaglyphVersion.HALF_COLOR_ANAGLYPH; } else if (radioOptimized.IsChecked.Value) // optimized anaglyph filter selected { this.anaglyphVersion = AnaglyphVersion.OPTIMIZED_ANAGLYPH; } else // no anaglyph filter selected { this.anaglyphVersion = AnaglyphVersion.VOID; } if (this.anaglyphVersion == AnaglyphVersion.VOID || this.dllVersion == DllVersion.VOID) // if anaglyph filter is no selected or dll is no selected display message to user { MessageBox.Show("You must select the DLL and anaglyph type choice!", "Anaglyph Creator Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } // checking if the images are the same size if (this.leftImage.GetImageInformation().imageSizeX != this.rightImage.GetImageInformation().imageSizeX || this.leftImage.GetImageInformation().imageSizeY != this.rightImage.GetImageInformation().imageSizeY) { MessageBox.Show("Left and right images must be the same size!", "Wrong image sizes", MessageBoxButton.OK, MessageBoxImage.Error); return; } // checking if there are dll files if (this.dllVersion == DllVersion.CPP_DLL && !File.Exists("DLL_C.dll")) { MessageBox.Show("No DLL found for the C++ algorithm!", "C++ DLL missing", MessageBoxButton.OK, MessageBoxImage.Error); return; } else if (this.dllVersion == DllVersion.ASM_DLL && !File.Exists("DLL_ASM.dll")) { MessageBox.Show("No DLL found for the assembler algorithm!", "Asm DLL missing", MessageBoxButton.OK, MessageBoxImage.Error); return; } TimerClock.ResetTimer(); // reset timer that measures algorithm time int threadsAmount = (int)this.threadsBar.Value; // getting the number of threads this.buttonGenerateAnaglyph.IsEnabled = false; // turning off the generate button while creating anaglyph new Thread(() => { Thread.CurrentThread.IsBackground = true; anaglyph.CreateAnaglyph(this.dllVersion, this.anaglyphVersion, rightImage.GetImageInformation(), leftImage.GetImageInformation(), threadsAmount); }).Start(); // invoke method that creates anaglyph }
public void DllVersion() { var v1 = new DllVersion(); Assert.AreEqual("autodetected dll", v1.ToString()); }
private void OKbutton_Click(object sender, EventArgs e) { uint ftStatus = FTC_SUCCESS; uint numHiSpeedDevices = 0; // 32-bit unsigned integer uint hiSpeedDeviceIndex = 0; uint locationID = 0; byte[] byteHiSpeedDeviceName = new byte[MAX_NUM_DEVICE_NAME_CHARS]; byte[] byteHiSpeedDeviceChannel = new byte[MAX_NUM_CHANNEL_CHARS]; uint hiSpeedDeviceType = 0; string hiSpeedDeviceName = null; string hiSpeedChannel = null; IntPtr ftHandle = IntPtr.Zero; byte timerValue = 0; uint clockFrequencyHz = 0; bool bLoopBackState = false; FTC_INPUT_OUTPUT_PINS LowInputOutputPinsData; FTH_INPUT_OUTPUT_PINS HighInputOutputPinsData; FTC_LOW_HIGH_PINS LowPinsInputData; FTH_LOW_HIGH_PINS HighPinsInputData; FTC_CLOSE_FINAL_STATE_PINS CloseFinalStatePinsData; Nullable <bool> bPerformCommandSequence = false; int iLoopCntr = 0; uint numBytesReturned = 0; byte[] WriteDataBuffer = new byte[WRITE_DATA_BUFFER_SIZE]; byte[] ReadDataBuffer = new byte[READ_DATA_BUFFER_SIZE]; byte[] ReadCmdSequenceDataBuffer = new byte[READ_CMDS_DATA_BUFFER_SIZE]; byte[] byteDllVersion = new byte[MAX_NUM_DLL_VERSION_CHARS]; string DllVersion; //"1.9"; byte[] byteErrorMessage = new byte[MAX_NUM_ERROR_MESSAGE_CHARS]; String ErrorMessage = null; string mismatchMsg = null; MessageBoxButtons MsgBoxButtons = MessageBoxButtons.OKCancel; DialogResult response = DialogResult.OK; // This function returns a ULONG value ie 32-bit unsigned integer //ftStatus = JTAG_GetDllVersion(byteDllVersion, MAX_NUM_DLL_VERSION_CHARS); ftStatus = GetDllVersion(byteDllVersion, MAX_NUM_DLL_VERSION_CHARS); DllVersion = Encoding.ASCII.GetString(byteDllVersion); // Trim strings to first occurrence of a null terminator character DllVersion = DllVersion.Substring(0, DllVersion.IndexOf("\0")); this.DLLVersionLabel.Text = Dll_Version_Label + DllVersion; this.DLLVersionLabel.Refresh(); this.DeviceNameLabel.Text = Device_Name_Label; this.DeviceNameLabel.Refresh(); this.FT2232HRadioButton.Checked = false; this.FT4232HRadioButton.Checked = false; this.PassFailResultsStatusLabel.Text = ""; this.PassFailureStatusStrip.Refresh(); Thread.Sleep(1000); // The parameter of this function is a pointer to a variable of type DWORD ie 32-bit unsigned integer ftStatus = JTAG_GetNumHiSpeedDevices(ref numHiSpeedDevices); if ((ftStatus == FTC_SUCCESS) && (numHiSpeedDevices > 0)) { do { ftStatus = JTAG_GetHiSpeedDeviceNameLocIDChannel(hiSpeedDeviceIndex, byteHiSpeedDeviceName, MAX_NUM_DEVICE_NAME_CHARS, ref locationID, byteHiSpeedDeviceChannel, MAX_NUM_CHANNEL_CHARS, ref hiSpeedDeviceType); if (ftStatus == FTC_SUCCESS) { hiSpeedChannel = Encoding.ASCII.GetString(byteHiSpeedDeviceChannel); // Trim strings to first occurrence of a null terminator character hiSpeedChannel = hiSpeedChannel.Substring(0, hiSpeedChannel.IndexOf("\0")); } hiSpeedDeviceIndex = hiSpeedDeviceIndex + 1; }while ((ftStatus == FTC_SUCCESS) && (hiSpeedDeviceIndex < numHiSpeedDevices) && ((hiSpeedChannel != null) && (hiSpeedChannel != this.ChannelComboBox.Text))); if (ftStatus == FTC_SUCCESS) { if ((hiSpeedChannel != null) && (hiSpeedChannel != this.ChannelComboBox.Text)) { ftStatus = FTC_DEVICE_IN_USE; } } if (ftStatus == FTC_SUCCESS) { hiSpeedDeviceName = Encoding.ASCII.GetString(byteHiSpeedDeviceName); // Trim strings to first occurrence of a null terminator character hiSpeedDeviceName = hiSpeedDeviceName.Substring(0, hiSpeedDeviceName.IndexOf("\0")); // The ftHandle parameter is a pointer to a variable of type DWORD ie 32-bit unsigned integer ftStatus = JTAG_OpenHiSpeedDevice(hiSpeedDeviceName, locationID, hiSpeedChannel, ref ftHandle); if (ftStatus == FTC_SUCCESS) { this.DeviceNameLabel.Text = Device_Name_Label + hiSpeedDeviceName; this.DeviceNameLabel.Refresh(); ftStatus = JTAG_GetHiSpeedDeviceType(ftHandle, ref hiSpeedDeviceType); if (ftStatus == FTC_SUCCESS) { if (hiSpeedDeviceType == (uint)HI_SPEED_DEVICE_TYPES.FT4232H_DEVICE_TYPE) { this.FT4232HRadioButton.Checked = true; } else if (hiSpeedDeviceType == (uint)HI_SPEED_DEVICE_TYPES.FT2232H_DEVICE_TYPE) { this.FT2232HRadioButton.Checked = true; } } } } if ((ftHandle != IntPtr.Zero) && (ftStatus == FTC_SUCCESS)) { ftStatus = JTAG_InitDevice(ftHandle, 0); if (ftStatus == FTC_SUCCESS) { //ftStatus = JTAG_TurnOnAdaptiveClockingHiSpeedDevice(ftHandle); //ftStatus = JTAG_TurnOffAdaptiveClockingHiSpeedDevice(ftHandle); } if (ftStatus == FTC_SUCCESS) { if ((ftStatus = JTAG_GetDeviceLatencyTimer(ftHandle, ref timerValue)) == FTC_SUCCESS) { if ((ftStatus = JTAG_SetDeviceLatencyTimer(ftHandle, 50)) == FTC_SUCCESS) { ftStatus = JTAG_GetDeviceLatencyTimer(ftHandle, ref timerValue); ftStatus = JTAG_SetDeviceLatencyTimer(ftHandle, 16); ftStatus = JTAG_GetDeviceLatencyTimer(ftHandle, ref timerValue); } } } if (ftStatus == FTC_SUCCESS) { ftStatus = TestHiSpeedDeviceClock(ftHandle); } if (ftStatus == FTC_SUCCESS) { ftStatus = JTAG_SetLoopback(ftHandle, bLoopBackState); } if (ftStatus == FTC_SUCCESS) { LowInputOutputPinsData.bPin1InputOutputState = true; LowInputOutputPinsData.bPin2InputOutputState = true; LowInputOutputPinsData.bPin3InputOutputState = true; LowInputOutputPinsData.bPin4InputOutputState = true; LowInputOutputPinsData.bPin1LowHighState = true; LowInputOutputPinsData.bPin2LowHighState = true; LowInputOutputPinsData.bPin3LowHighState = true; LowInputOutputPinsData.bPin4LowHighState = true; HighInputOutputPinsData.bPin1InputOutputState = true; HighInputOutputPinsData.bPin2InputOutputState = true; HighInputOutputPinsData.bPin3InputOutputState = true; HighInputOutputPinsData.bPin4InputOutputState = true; HighInputOutputPinsData.bPin5InputOutputState = true; HighInputOutputPinsData.bPin6InputOutputState = true; HighInputOutputPinsData.bPin7InputOutputState = true; HighInputOutputPinsData.bPin8InputOutputState = true; HighInputOutputPinsData.bPin1LowHighState = false; HighInputOutputPinsData.bPin2LowHighState = true; HighInputOutputPinsData.bPin3LowHighState = true; HighInputOutputPinsData.bPin4LowHighState = false; HighInputOutputPinsData.bPin5LowHighState = false; HighInputOutputPinsData.bPin6LowHighState = true; HighInputOutputPinsData.bPin7LowHighState = true; HighInputOutputPinsData.bPin8LowHighState = false; if (hiSpeedDeviceType == (uint)HI_SPEED_DEVICE_TYPES.FT2232H_DEVICE_TYPE) { ftStatus = JTAG_SetHiSpeedDeviceGPIOs(ftHandle, true, ref LowInputOutputPinsData, true, ref HighInputOutputPinsData); } else { ftStatus = JTAG_SetHiSpeedDeviceGPIOs(ftHandle, true, ref LowInputOutputPinsData, false, ref HighInputOutputPinsData); } // Sleep for 1 second Thread.Sleep(1000); if (ftStatus == FTC_SUCCESS) { if (hiSpeedDeviceType == (uint)HI_SPEED_DEVICE_TYPES.FT2232H_DEVICE_TYPE) { ftStatus = JTAG_GetHiSpeedDeviceGPIOs(ftHandle, true, out LowPinsInputData, true, out HighPinsInputData); } else { ftStatus = JTAG_GetHiSpeedDeviceGPIOs(ftHandle, true, out LowPinsInputData, false, out HighPinsInputData); } } if (ftStatus == FTC_SUCCESS) { WriteDataBuffer[0] = 0x01; WriteDataBuffer[1] = 0x01; WriteDataBuffer[2] = 0x01; WriteDataBuffer[3] = 0x01; if (this.CommandSequenceMenuItem.CheckState == CheckState.Unchecked) { do { if ((ftStatus = JTAG_Write(ftHandle, true, 32, WriteDataBuffer, 4, RUN_TEST_IDLE_STATE)) == FTC_SUCCESS) { ftStatus = JTAG_GenerateClockPulses(ftHandle, 100); } if (ftStatus == FTC_SUCCESS) { // Sleep for 10 milliseconds Thread.Sleep(10); if ((ftStatus = JTAG_Read(ftHandle, true, 32, ReadDataBuffer, ref numBytesReturned, RUN_TEST_IDLE_STATE)) == FTC_SUCCESS) { if ((ftStatus = JTAG_WriteRead(ftHandle, true, 32, WriteDataBuffer, 4, ReadDataBuffer, ref numBytesReturned, RUN_TEST_IDLE_STATE)) == FTC_SUCCESS) { if ((WriteDataBuffer[0] != ReadDataBuffer[0]) || (WriteDataBuffer[1] != ReadDataBuffer[1]) || (WriteDataBuffer[2] != ReadDataBuffer[2]) || (WriteDataBuffer[3] != ReadDataBuffer[3])) { byte mismatchValue = 0; if (WriteDataBuffer[0] != ReadDataBuffer[0]) { mismatchValue = ReadDataBuffer[0]; } else if (WriteDataBuffer[1] != ReadDataBuffer[1]) { mismatchValue = ReadDataBuffer[1]; } else if (WriteDataBuffer[2] != ReadDataBuffer[2]) { mismatchValue = ReadDataBuffer[2]; } else if (WriteDataBuffer[3] != ReadDataBuffer[3]) { mismatchValue = ReadDataBuffer[3]; } mismatchMsg = String.Format("JTAG Write/Read mismatch, Loop = {0}, Write Value = {1}, Read Value = {2}", iLoopCntr, 1, mismatchValue); response = MessageBox.Show(mismatchMsg, "JTAG Read Error Message", MsgBoxButtons); } } } } iLoopCntr++; // Sleep for 50 milliseconds Thread.Sleep(50); }while ((iLoopCntr < 20) && (ftStatus == FTC_SUCCESS) && (response == DialogResult.OK)); } else { if (numHiSpeedDevices == 1) { ftStatus = JTAG_ClearCmdSequence(); while ((iLoopCntr < 10) && (ftStatus == FTC_SUCCESS)) { if ((ftStatus = JTAG_AddWriteCmd(true, 32, WriteDataBuffer, 4, RUN_TEST_IDLE_STATE)) == FTC_SUCCESS) { ftStatus = JTAG_AddReadCmd(true, 32, RUN_TEST_IDLE_STATE); } if (ftStatus == FTC_SUCCESS) { ftStatus = JTAG_AddWriteReadCmd(true, 32, WriteDataBuffer, 4, RUN_TEST_IDLE_STATE); } iLoopCntr++; } } else { ftStatus = JTAG_ClearDeviceCmdSequence(ftHandle); while ((iLoopCntr < 10) && (ftStatus == FTC_SUCCESS)) { if ((ftStatus = JTAG_AddDeviceWriteCmd(ftHandle, true, 32, WriteDataBuffer, 4, RUN_TEST_IDLE_STATE)) == FTC_SUCCESS) { ftStatus = JTAG_AddDeviceReadCmd(ftHandle, true, 32, RUN_TEST_IDLE_STATE); } if (ftStatus == FTC_SUCCESS) { ftStatus = JTAG_AddDeviceWriteReadCmd(ftHandle, true, 32, WriteDataBuffer, 4, RUN_TEST_IDLE_STATE); } iLoopCntr = iLoopCntr + 1; } } if (ftStatus == FTC_SUCCESS) { ftStatus = JTAG_ExecuteCmdSequence(ftHandle, ReadCmdSequenceDataBuffer, ref numBytesReturned); } } } } } } if (ftHandle != IntPtr.Zero) { //CloseFinalStatePinsData.bTCKPinState = true; //CloseFinalStatePinsData.bTCKPinActiveState = true; //CloseFinalStatePinsData.bTDIPinState = true; //CloseFinalStatePinsData.bTDIPinActiveState = false; //CloseFinalStatePinsData.bTMSPinState = true; //CloseFinalStatePinsData.bTMSPinActiveState = true; //ftStatus = JTAG_CloseDevice(ftHandle, ref CloseFinalStatePinsData); JTAG_Close(ftHandle); ftHandle = IntPtr.Zero; } if ((ftStatus != FTC_SUCCESS) || (numHiSpeedDevices == 0) || (mismatchMsg != null)) { if (ftStatus != FTC_SUCCESS) { ErrorMessage = "Status Code(" + ftStatus.ToString() + ") - "; ftStatus = JTAG_GetErrorCodeString("EN", ftStatus, byteErrorMessage, MAX_NUM_ERROR_MESSAGE_CHARS); ErrorMessage = ErrorMessage + Encoding.ASCII.GetString(byteErrorMessage); // Trim strings to first occurrence of a null terminator character ErrorMessage = ErrorMessage.Substring(0, ErrorMessage.IndexOf("\0")); MessageBox.Show(ErrorMessage); } else { if (numHiSpeedDevices == 0) { ErrorMessage = "There are no devices connected."; MessageBox.Show(ErrorMessage); } else { ErrorMessage = mismatchMsg; } } this.PassFailResultsStatusLabel.Text = "Fail - " + ErrorMessage; this.PassFailureStatusStrip.Refresh(); //Console.WriteLine(ErrorMessage); Console.WriteLine("Fail - {0}", ErrorMessage); } else { this.PassFailResultsStatusLabel.Text = "Pass"; this.PassFailureStatusStrip.Refresh(); } }
/// <summary> /// A method that creates anaglyph from the left and right image. /// </summary> /// <param name="dllVersion"> The dll version selected by the user. </param> /// <param name="anaglyphVersion"> User selection of anaglyph version. </param> /// <param name="leftImageInformation"> An instance of the class that stores information about the left image. </param> /// <param name="rightImageInformation"> An instance of the class that stores information about the right image. </param> /// <param name="threadAmount"> Number of threads selected by the user. </param> public void CreateAnaglyph(DllVersion dllVersion, AnaglyphVersion anaglyphVersion, ImageInformation leftImageInformation, ImageInformation rightImageInformation, int threadAmount) { int amountOfPixels = leftImageInformation.imagePixelArray.Length / 4; // the number of pixels that will be modified pixelsForThread = amountOfPixels / threadAmount; // the number of pixels to modify per thread if (pixelsForThread * threadAmount != leftImageInformation.imagePixelArray.Length / 4) // condition checking if the same number of pixels can be processed in each thread (different number of pixels) { int delta = amountOfPixels - (pixelsForThread * threadAmount); // number of pixels remaining PrepareThreads(threadAmount - 1); // prepare tables for the number of threads selected by the user minus one int start = pixelsForThread * (threadAmount - 1); // start index for a thread that modifies the rest of the pixels this.coords.Add(start); // start index for the last thread this.coords.Add(leftImageInformation.imagePixelArray.Length / 4); // end index for the last thread } else // the same number of pixels in each thread { PrepareThreads(threadAmount); // prepare a table of coordinates } anaglyphFilters = new float[12]; // creating an array that stores an anaglyph filter switch (anaglyphVersion) // choosing the right anaglyph filter depending on the user's choice { case AnaglyphVersion.TRUE_ANAGLYPH: anaglyphFilters = AnaglyphOptions._true; break; case AnaglyphVersion.GRAY_ANAGLYPH: anaglyphFilters = AnaglyphOptions._gray; break; case AnaglyphVersion.COLOR_ANAGLYPH: anaglyphFilters = AnaglyphOptions._color; break; case AnaglyphVersion.HALF_COLOR_ANAGLYPH: anaglyphFilters = AnaglyphOptions._halfColor; break; case AnaglyphVersion.OPTIMIZED_ANAGLYPH: anaglyphFilters = AnaglyphOptions._optimized; break; } tmpLeftImagePixelArray = new float[leftImageInformation.imagePixelArray.Length]; // creating a temporary array storing the pixels of the left image for (int i = 0; i < tmpLeftImagePixelArray.Length; i++) // loop that copies the pixel values of the left image into a temporary table { tmpLeftImagePixelArray[i] = leftImageInformation.imagePixelArray[i]; // copy the pixel color value from the left image to a temporary table } switch (dllVersion) // choice of dll depending on the user's choice { case DllVersion.ASM_DLL: // assembler dll choice for (int i = 0; i < this.coords.Count; i += 2) // loop calling as many times as there are coordinates (start and end) for each thread { int[] imageCoords = { this.coords[i] * 4, this.coords[i + 1] * 4 }; // get start and start index for the current thread var th = new Thread(() => // thread creation { AnaglyphAlgorithmAsm(leftImageInformation.imagePixelArray, imageCoords, anaglyphFilters, rightImageInformation.imagePixelArray); }); this.threads.Add(th); // adding a newly created thread to the list of threads } break; case DllVersion.CPP_DLL: // C++ dll choice for (int i = 0; i < this.coords.Count; i += 2) // loop calling as many times as there are coordinates(start and end) for each thread { int[] imageCoords = { this.coords[i] * 4, this.coords[i + 1] * 4 }; // get start and start index for the current thread var th = new Thread(() => // thread creation { AnaglyphAlgorithm(leftImageInformation.imagePixelArray, imageCoords, anaglyphFilters, rightImageInformation.imagePixelArray); }); this.threads.Add(th); // adding a newly created thread to the list of threads } break; } TimerClock.StartTimer(); // counting the time it takes for threads to finish foreach (Thread th in threads) // start all threads { th.Start(); } foreach (Thread th in threads) // waiting for the end of each thread { th.Join(); } TimerClock.StopTimer(); // stop counting time threads.Clear(); // clear the list of threads coords.Clear(); // clearing the list of start and end indexes leftImageInformation.finishConversion(); // creating an image based on returned pixels for (int i = 0; i < tmpLeftImagePixelArray.Length; i++) // copying the pixel color values from the previously created table to the table storing the pixel values of the left image { leftImageInformation.imagePixelArray[i] = tmpLeftImagePixelArray[i]; } EventImageFinished(leftImageInformation.imageBitmap); // reporting an event about the end of anaglyph creation }
static VBERuntimeAccessor() { _version = DllVersion.Unknown; }