Upload from CMSource

This commit is contained in:
2025-09-15 18:26:49 -04:00
parent 933c55a3fa
commit 5df1e43bd6
105 changed files with 25450 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,56 @@
<#
.SYNOPSIS
This script is a template that allows you to extend the toolkit with your own custom functions.
# LICENSE #
PowerShell App Deployment Toolkit - Provides a set of functions to perform common application deployment tasks on Windows.
Copyright (C) 2017 - Sean Lillis, Dan Cunningham, Muhammad Mashwani, Aman Motazedian.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
.DESCRIPTION
The script is automatically dot-sourced by the AppDeployToolkitMain.ps1 script.
.NOTES
Toolkit Exit Code Ranges:
60000 - 68999: Reserved for built-in exit codes in Deploy-Application.ps1, Deploy-Application.exe, and AppDeployToolkitMain.ps1
69000 - 69999: Recommended for user customized exit codes in Deploy-Application.ps1
70000 - 79999: Recommended for user customized exit codes in AppDeployToolkitExtensions.ps1
.LINK
http://psappdeploytoolkit.com
#>
[CmdletBinding()]
Param (
)
##*===============================================
##* VARIABLE DECLARATION
##*===============================================
# Variables: Script
[string]$appDeployToolkitExtName = 'PSAppDeployToolkitExt'
[string]$appDeployExtScriptFriendlyName = 'App Deploy Toolkit Extensions'
[version]$appDeployExtScriptVersion = [version]'3.8.3'
[string]$appDeployExtScriptDate = '30/09/2020'
[hashtable]$appDeployExtScriptParameters = $PSBoundParameters
##*===============================================
##* FUNCTION LISTINGS
##*===============================================
# <Your custom functions go here>
##*===============================================
##* END FUNCTION LISTINGS
##*===============================================
##*===============================================
##* SCRIPT BODY
##*===============================================
If ($scriptParentPath) {
Write-Log -Message "Script [$($MyInvocation.MyCommand.Definition)] dot-source invoked by [$(((Get-Variable -Name MyInvocation).Value).ScriptName)]" -Source $appDeployToolkitExtName
} Else {
Write-Log -Message "Script [$($MyInvocation.MyCommand.Definition)] invoked directly" -Source $appDeployToolkitExtName
}
##*===============================================
##* END SCRIPT BODY
##*===============================================

View File

@@ -0,0 +1,130 @@
<#
.SYNOPSIS
Displays a graphical console to browse the help for the App Deployment Toolkit functions
# LICENSE #
PowerShell App Deployment Toolkit - Provides a set of functions to perform common application deployment tasks on Windows.
Copyright (C) 2017 - Sean Lillis, Dan Cunningham, Muhammad Mashwani, Aman Motazedian.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
.DESCRIPTION
Displays a graphical console to browse the help for the App Deployment Toolkit functions
.EXAMPLE
AppDeployToolkitHelp.ps1
.NOTES
.LINK
http://psappdeploytoolkit.com
#>
##*===============================================
##* VARIABLE DECLARATION
##*===============================================
## Variables: Script
[string]$appDeployToolkitHelpName = 'PSAppDeployToolkitHelp'
[string]$appDeployHelpScriptFriendlyName = 'App Deploy Toolkit Help'
[version]$appDeployHelpScriptVersion = [version]'3.8.3'
[string]$appDeployHelpScriptDate = '30/09/2020'
## Variables: Environment
[string]$scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
# Dot source the App Deploy Toolkit Functions
. "$scriptDirectory\AppDeployToolkitMain.ps1" -DisableLogging
. "$scriptDirectory\AppDeployToolkitExtensions.ps1"
##*===============================================
##* END VARIABLE DECLARATION
##*===============================================
##*===============================================
##* FUNCTION LISTINGS
##*===============================================
Function Show-HelpConsole {
## Import the Assemblies
Add-Type -AssemblyName 'System.Windows.Forms' -ErrorAction 'Stop'
Add-Type -AssemblyName System.Drawing -ErrorAction 'Stop'
## Form Objects
$HelpForm = New-Object -TypeName 'System.Windows.Forms.Form'
$HelpListBox = New-Object -TypeName 'System.Windows.Forms.ListBox'
$HelpTextBox = New-Object -TypeName 'System.Windows.Forms.RichTextBox'
$InitialFormWindowState = New-Object -TypeName 'System.Windows.Forms.FormWindowState'
## Form Code
$System_Drawing_Size = New-Object -TypeName 'System.Drawing.Size'
$System_Drawing_Size.Height = 665
$System_Drawing_Size.Width = 957
$HelpForm.ClientSize = $System_Drawing_Size
$HelpForm.DataBindings.DefaultDataSourceUpdateMode = 0
$HelpForm.Name = 'HelpForm'
$HelpForm.Text = 'PowerShell App Deployment Toolkit Help Console'
$HelpForm.WindowState = 'Normal'
$HelpForm.ShowInTaskbar = $true
$HelpForm.FormBorderStyle = 'Fixed3D'
$HelpForm.MaximizeBox = $false
$HelpForm.Icon = New-Object -TypeName 'System.Drawing.Icon' -ArgumentList $AppDeployLogoIcon
$HelpListBox.Anchor = 7
$HelpListBox.BorderStyle = 1
$HelpListBox.DataBindings.DefaultDataSourceUpdateMode = 0
$HelpListBox.Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList ('Microsoft Sans Serif', 9.75, 1, 3, 1)
$HelpListBox.FormattingEnabled = $true
$HelpListBox.ItemHeight = 16
$System_Drawing_Point = New-Object -TypeName 'System.Drawing.Point'
$System_Drawing_Point.X = 0
$System_Drawing_Point.Y = 0
$HelpListBox.Location = $System_Drawing_Point
$HelpListBox.Name = 'HelpListBox'
$System_Drawing_Size = New-Object -TypeName 'System.Drawing.Size'
$System_Drawing_Size.Height = 658
$System_Drawing_Size.Width = 271
$HelpListBox.Size = $System_Drawing_Size
$HelpListBox.Sorted = $true
$HelpListBox.TabIndex = 2
$HelpListBox.add_SelectedIndexChanged({ $HelpTextBox.Text = Get-Help -Name $HelpListBox.SelectedItem -Full | Out-String })
$helpFunctions = Get-Command -CommandType 'Function' | Where-Object { ($_.HelpUri -match 'psappdeploytoolkit') -and ($_.Definition -notmatch 'internal script function') } | Select-Object -ExpandProperty Name
$null = $HelpListBox.Items.AddRange($helpFunctions)
$HelpForm.Controls.Add($HelpListBox)
$HelpTextBox.Anchor = 11
$HelpTextBox.BorderStyle = 1
$HelpTextBox.DataBindings.DefaultDataSourceUpdateMode = 0
$HelpTextBox.Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList ('Microsoft Sans Serif', 8.5, 0, 3, 1)
$HelpTextBox.ForeColor = [System.Drawing.Color]::FromArgb(255, 0, 0, 0)
$System_Drawing_Point = New-Object -TypeName System.Drawing.Point
$System_Drawing_Point.X = 277
$System_Drawing_Point.Y = 0
$HelpTextBox.Location = $System_Drawing_Point
$HelpTextBox.Name = 'HelpTextBox'
$HelpTextBox.ReadOnly = $True
$System_Drawing_Size = New-Object -TypeName 'System.Drawing.Size'
$System_Drawing_Size.Height = 658
$System_Drawing_Size.Width = 680
$HelpTextBox.Size = $System_Drawing_Size
$HelpTextBox.TabIndex = 1
$HelpTextBox.Text = ''
$HelpForm.Controls.Add($HelpTextBox)
## Save the initial state of the form
$InitialFormWindowState = $HelpForm.WindowState
## Init the OnLoad event to correct the initial state of the form
$HelpForm.add_Load($OnLoadForm_StateCorrection)
## Show the Form
$null = $HelpForm.ShowDialog()
}
##*===============================================
##* END FUNCTION LISTINGS
##*===============================================
##*===============================================
##* SCRIPT BODY
##*===============================================
Write-Log -Message "Load [$appDeployHelpScriptFriendlyName] console..." -Source $appDeployToolkitHelpName
## Show the help console
Show-HelpConsole
Write-Log -Message "[$appDeployHelpScriptFriendlyName] console closed." -Source $appDeployToolkitHelpName
##*===============================================
##* END SCRIPT BODY
##*===============================================

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@@ -0,0 +1,792 @@
// Date Modified: 30/09/2020
// Version Number: 3.8.3
using System;
using System.Text;
using System.Collections;
using System.ComponentModel;
using System.DirectoryServices;
using System.Security.Principal;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
namespace PSADT
{
public class Msi
{
enum LoadLibraryFlags : int
{
DONT_RESOLVE_DLL_REFERENCES = 0x00000001,
LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010,
LOAD_LIBRARY_AS_DATAFILE = 0x00000002,
LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040,
LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020,
LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008
}
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hFile, LoadLibraryFlags dwFlags);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern int LoadString(IntPtr hInstance, int uID, StringBuilder lpBuffer, int nBufferMax);
// Get MSI exit code message from msimsg.dll resource dll
public static string GetMessageFromMsiExitCode(int errCode)
{
IntPtr hModuleInstance = LoadLibraryEx("msimsg.dll", IntPtr.Zero, LoadLibraryFlags.LOAD_LIBRARY_AS_DATAFILE);
StringBuilder sb = new StringBuilder(255);
LoadString(hModuleInstance, errCode, sb, sb.Capacity + 1);
return sb.ToString();
}
}
public class Explorer
{
private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
private const int WM_SETTINGCHANGE = 0x1a;
private const int SMTO_ABORTIFHUNG = 0x0002;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern bool SendNotifyMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, int fuFlags, int uTimeout, IntPtr lpdwResult);
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
public static void RefreshDesktopAndEnvironmentVariables()
{
// Update desktop icons
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, null, SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
// Update environment variables
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, "Environment", SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
}
}
public sealed class FileVerb
{
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern int LoadString(IntPtr h, int id, StringBuilder sb, int maxBuffer);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern IntPtr LoadLibrary(string s);
public static string GetPinVerb(int VerbId)
{
IntPtr hShell32 = LoadLibrary("shell32.dll");
const int nChars = 255;
StringBuilder Buff = new StringBuilder("", nChars);
LoadString(hShell32, VerbId, Buff, Buff.Capacity);
return Buff.ToString();
}
}
public sealed class IniFile
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern int GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, int nSize, string lpFileName);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool WritePrivateProfileString(string lpAppName, string lpKeyName, StringBuilder lpString, string lpFileName);
public static string GetIniValue(string section, string key, string filepath)
{
string sDefault = "";
const int nChars = 1024;
StringBuilder Buff = new StringBuilder(nChars);
GetPrivateProfileString(section, key, sDefault, Buff, Buff.Capacity, filepath);
return Buff.ToString();
}
public static void SetIniValue(string section, string key, StringBuilder value, string filepath)
{
WritePrivateProfileString(section, key, value, filepath);
}
}
public class UiAutomation
{
public enum GetWindow_Cmd : int
{
GW_HWNDFIRST = 0,
GW_HWNDLAST = 1,
GW_HWNDNEXT = 2,
GW_HWNDPREV = 3,
GW_OWNER = 4,
GW_CHILD = 5,
GW_ENABLEDPOPUP = 6
}
public enum ShowWindowEnum
{
Hide = 0,
ShowNormal = 1,
ShowMinimized = 2,
ShowMaximized = 3,
Maximize = 3,
ShowNormalNoActivate = 4,
Show = 5,
Minimize = 6,
ShowMinNoActivate = 7,
ShowNoActivate = 8,
Restore = 9,
ShowDefault = 10,
ForceMinimized = 11
}
public enum UserNotificationState
{
// http://msdn.microsoft.com/en-us/library/bb762533(v=vs.85).aspx
ScreenSaverOrLockedOrFastUserSwitching =1, // A screen saver is displayed, the machine is locked, or a nonactive Fast User Switching session is in progress.
FullScreenOrPresentationModeOrLoginScreen =2, // A full-screen application is running or Presentation Settings are applied. Presentation Settings allow a user to put their machine into a state fit for an uninterrupted presentation, such as a set of PowerPoint slides, with a single click. Also returns this state if machine is at the login screen.
RunningDirect3DFullScreen =3, // A full-screen, exclusive mode, Direct3D application is running.
PresentationMode =4, // The user has activated Windows presentation settings to block notifications and pop-up messages.
AcceptsNotifications =5, // None of the other states are found, notifications can be freely sent.
QuietTime =6, // Introduced in Windows 7. The current user is in "quiet time", which is the first hour after a new user logs into his or her account for the first time.
WindowsStoreAppRunning =7 // Introduced in Windows 8. A Windows Store app is running.
}
// Only for Vista or above
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern int SHQueryUserNotificationState(out UserNotificationState pquns);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumWindows(EnumWindowsProcD lpEnumFunc, ref IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern int GetWindowTextLength(IntPtr hWnd);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern IntPtr GetShellWindow();
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsWindowEnabled(IntPtr hWnd);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern bool IsWindowVisible(IntPtr hWnd);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsIconic(IntPtr hWnd);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ShowWindow(IntPtr hWnd, ShowWindowEnum flags);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern IntPtr SetActiveWindow(IntPtr hwnd);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern IntPtr SetFocus(IntPtr hWnd);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern bool BringWindowToTop(IntPtr hWnd);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern int GetCurrentThreadId();
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern bool AttachThreadInput(int idAttach, int idAttachTo, bool fAttach);
[DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto, SetLastError = false)]
public static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex);
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr", CharSet = CharSet.Auto, SetLastError = false)]
public static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern bool EnableMenuItem(IntPtr hMenu, uint uIDEnableItem, uint uEnable);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern IntPtr DestroyMenu(IntPtr hWnd);
public delegate bool EnumWindowsProcD(IntPtr hWnd, ref IntPtr lItems);
public static bool EnumWindowsProc(IntPtr hWnd, ref IntPtr lItems)
{
if (hWnd != IntPtr.Zero)
{
GCHandle hItems = GCHandle.FromIntPtr(lItems);
List<IntPtr> items = hItems.Target as List<IntPtr>;
items.Add(hWnd);
return true;
}
else
{
return false;
}
}
public static List<IntPtr> EnumWindows()
{
try
{
List<IntPtr> items = new List<IntPtr>();
EnumWindowsProcD CallBackPtr = new EnumWindowsProcD(EnumWindowsProc);
GCHandle hItems = GCHandle.Alloc(items);
IntPtr lItems = GCHandle.ToIntPtr(hItems);
EnumWindows(CallBackPtr, ref lItems);
return items;
}
catch (Exception ex)
{
throw new Exception("An error occured during window enumeration: " + ex.Message);
}
}
public static string GetWindowText(IntPtr hWnd)
{
int iTextLength = GetWindowTextLength(hWnd);
if (iTextLength > 0)
{
StringBuilder sb = new StringBuilder(iTextLength);
GetWindowText(hWnd, sb, iTextLength + 1);
return sb.ToString();
}
else
{
return String.Empty;
}
}
public static bool BringWindowToFront(IntPtr windowHandle)
{
bool breturn = false;
if (IsIconic(windowHandle))
{
// Show minimized window because SetForegroundWindow does not work for minimized windows
ShowWindow(windowHandle, ShowWindowEnum.ShowMaximized);
}
int lpdwProcessId;
int windowThreadProcessId = GetWindowThreadProcessId(GetForegroundWindow(), out lpdwProcessId);
int currentThreadId = GetCurrentThreadId();
AttachThreadInput(windowThreadProcessId, currentThreadId, true);
BringWindowToTop(windowHandle);
breturn = SetForegroundWindow(windowHandle);
SetActiveWindow(windowHandle);
SetFocus(windowHandle);
AttachThreadInput(windowThreadProcessId, currentThreadId, false);
return breturn;
}
public static int GetWindowThreadProcessId(IntPtr windowHandle)
{
int processID = 0;
GetWindowThreadProcessId(windowHandle, out processID);
return processID;
}
public static IntPtr GetWindowLong(IntPtr hWnd, int nIndex)
{
if (IntPtr.Size == 4)
{
return GetWindowLong32(hWnd, nIndex);
}
return GetWindowLongPtr64(hWnd, nIndex);
}
public static string GetUserNotificationState()
{
// Only works for Windows Vista or higher
UserNotificationState state;
int returnVal = SHQueryUserNotificationState(out state);
return state.ToString();
}
}
public class QueryUser
{
[DllImport("wtsapi32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern IntPtr WTSOpenServer(string pServerName);
[DllImport("wtsapi32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern void WTSCloseServer(IntPtr hServer);
[DllImport("wtsapi32.dll", CharSet = CharSet.Ansi, SetLastError = false)]
public static extern bool WTSQuerySessionInformation(IntPtr hServer, int sessionId, WTS_INFO_CLASS wtsInfoClass, out IntPtr pBuffer, out int pBytesReturned);
[DllImport("wtsapi32.dll", CharSet = CharSet.Ansi, SetLastError = false)]
public static extern int WTSEnumerateSessions(IntPtr hServer, int Reserved, int Version, out IntPtr pSessionInfo, out int pCount);
[DllImport("wtsapi32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern void WTSFreeMemory(IntPtr pMemory);
[DllImport("winsta.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern int WinStationQueryInformation(IntPtr hServer, int sessionId, int information, ref WINSTATIONINFORMATIONW pBuffer, int bufferLength, ref int returnedLength);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern int GetCurrentProcessId();
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern bool ProcessIdToSessionId(int processId, ref int pSessionId);
public class TerminalSessionData
{
public int SessionId;
public string ConnectionState;
public string SessionName;
public bool IsUserSession;
public TerminalSessionData(int sessionId, string connState, string sessionName, bool isUserSession)
{
SessionId = sessionId;
ConnectionState = connState;
SessionName = sessionName;
IsUserSession = isUserSession;
}
}
public class TerminalSessionInfo
{
public string NTAccount;
public string SID;
public string UserName;
public string DomainName;
public int SessionId;
public string SessionName;
public string ConnectState;
public bool IsCurrentSession;
public bool IsConsoleSession;
public bool IsActiveUserSession;
public bool IsUserSession;
public bool IsRdpSession;
public bool IsLocalAdmin;
public DateTime? LogonTime;
public TimeSpan? IdleTime;
public DateTime? DisconnectTime;
public string ClientName;
public string ClientProtocolType;
public string ClientDirectory;
public int ClientBuildNumber;
}
[StructLayout(LayoutKind.Sequential)]
private struct WTS_SESSION_INFO
{
public Int32 SessionId;
[MarshalAs(UnmanagedType.LPStr)]
public string SessionName;
public WTS_CONNECTSTATE_CLASS State;
}
[StructLayout(LayoutKind.Sequential)]
public struct WINSTATIONINFORMATIONW
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 70)]
private byte[] Reserved1;
public int SessionId;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
private byte[] Reserved2;
public FILETIME ConnectTime;
public FILETIME DisconnectTime;
public FILETIME LastInputTime;
public FILETIME LoginTime;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1096)]
private byte[] Reserved3;
public FILETIME CurrentTime;
}
public enum WINSTATIONINFOCLASS
{
WinStationInformation = 8
}
public enum WTS_CONNECTSTATE_CLASS
{
Active,
Connected,
ConnectQuery,
Shadow,
Disconnected,
Idle,
Listen,
Reset,
Down,
Init
}
public enum WTS_INFO_CLASS
{
SessionId=4,
UserName,
SessionName,
DomainName,
ConnectState,
ClientBuildNumber,
ClientName,
ClientDirectory,
ClientProtocolType=16
}
private static IntPtr OpenServer(string Name)
{
IntPtr server = WTSOpenServer(Name);
return server;
}
private static void CloseServer(IntPtr ServerHandle)
{
WTSCloseServer(ServerHandle);
}
private static IList<T> PtrToStructureList<T>(IntPtr ppList, int count) where T : struct
{
List<T> result = new List<T>();
long pointer = ppList.ToInt64();
int sizeOf = Marshal.SizeOf(typeof(T));
for (int index = 0; index < count; index++)
{
T item = (T) Marshal.PtrToStructure(new IntPtr(pointer), typeof(T));
result.Add(item);
pointer += sizeOf;
}
return result;
}
public static DateTime? FileTimeToDateTime(FILETIME ft)
{
if (ft.dwHighDateTime == 0 && ft.dwLowDateTime == 0)
{
return null;
}
long hFT = (((long) ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
return DateTime.FromFileTime(hFT);
}
public static WINSTATIONINFORMATIONW GetWinStationInformation(IntPtr server, int sessionId)
{
int retLen = 0;
WINSTATIONINFORMATIONW wsInfo = new WINSTATIONINFORMATIONW();
WinStationQueryInformation(server, sessionId, (int) WINSTATIONINFOCLASS.WinStationInformation, ref wsInfo, Marshal.SizeOf(typeof(WINSTATIONINFORMATIONW)), ref retLen);
return wsInfo;
}
public static TerminalSessionData[] ListSessions(string ServerName)
{
IntPtr server = IntPtr.Zero;
if (ServerName == "localhost" || ServerName == String.Empty)
{
ServerName = Environment.MachineName;
}
List<TerminalSessionData> results = new List<TerminalSessionData>();
try
{
server = OpenServer(ServerName);
IntPtr ppSessionInfo = IntPtr.Zero;
int count;
bool _isUserSession = false;
IList<WTS_SESSION_INFO> sessionsInfo;
if (WTSEnumerateSessions(server, 0, 1, out ppSessionInfo, out count) == 0)
{
throw new Win32Exception();
}
try
{
sessionsInfo = PtrToStructureList<WTS_SESSION_INFO>(ppSessionInfo, count);
}
finally
{
WTSFreeMemory(ppSessionInfo);
}
foreach (WTS_SESSION_INFO sessionInfo in sessionsInfo)
{
if (sessionInfo.SessionName != "Services" && sessionInfo.SessionName != "RDP-Tcp")
{
_isUserSession = true;
}
results.Add(new TerminalSessionData(sessionInfo.SessionId, sessionInfo.State.ToString(), sessionInfo.SessionName, _isUserSession));
_isUserSession = false;
}
}
finally
{
CloseServer(server);
}
TerminalSessionData[] returnData = results.ToArray();
return returnData;
}
public static TerminalSessionInfo GetSessionInfo(string ServerName, int SessionId)
{
IntPtr server = IntPtr.Zero;
IntPtr buffer = IntPtr.Zero;
int bytesReturned;
TerminalSessionInfo data = new TerminalSessionInfo();
bool _IsCurrentSessionId = false;
bool _IsConsoleSession = false;
bool _IsUserSession = false;
int currentSessionID = 0;
string _NTAccount = String.Empty;
if (ServerName == "localhost" || ServerName == String.Empty)
{
ServerName = Environment.MachineName;
}
if (ProcessIdToSessionId(GetCurrentProcessId(), ref currentSessionID) == false)
{
currentSessionID = -1;
}
// Get all members of the local administrators group
bool _IsLocalAdminCheckSuccess = false;
List<string> localAdminGroupSidsList = new List<string>();
try
{
DirectoryEntry localMachine = new DirectoryEntry("WinNT://" + ServerName + ",Computer");
string localAdminGroupName = new SecurityIdentifier("S-1-5-32-544").Translate(typeof(NTAccount)).Value.Split('\\')[1];
DirectoryEntry admGroup = localMachine.Children.Find(localAdminGroupName, "group");
object members = admGroup.Invoke("members", null);
string validSidPattern = @"^S-\d-\d+-(\d+-){1,14}\d+$";
foreach (object groupMember in (IEnumerable)members)
{
DirectoryEntry member = new DirectoryEntry(groupMember);
if (member.Name != String.Empty)
{
if (Regex.IsMatch(member.Name, validSidPattern))
{
localAdminGroupSidsList.Add(member.Name);
}
else
{
localAdminGroupSidsList.Add((new NTAccount(member.Name)).Translate(typeof(SecurityIdentifier)).Value);
}
}
}
_IsLocalAdminCheckSuccess = true;
}
catch { }
try
{
server = OpenServer(ServerName);
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ClientBuildNumber, out buffer, out bytesReturned) == false)
{
return data;
}
int lData = Marshal.ReadInt32(buffer);
data.ClientBuildNumber = lData;
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ClientDirectory, out buffer, out bytesReturned) == false)
{
return data;
}
string strData = Marshal.PtrToStringAnsi(buffer);
data.ClientDirectory = strData;
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ClientName, out buffer, out bytesReturned) == false)
{
return data;
}
strData = Marshal.PtrToStringAnsi(buffer);
data.ClientName = strData;
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ClientProtocolType, out buffer, out bytesReturned) == false)
{
return data;
}
Int16 intData = Marshal.ReadInt16(buffer);
if (intData == 2)
{
strData = "RDP";
data.IsRdpSession = true;
}
else
{
strData = "";
data.IsRdpSession = false;
}
data.ClientProtocolType = strData;
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ConnectState, out buffer, out bytesReturned) == false)
{
return data;
}
lData = Marshal.ReadInt32(buffer);
data.ConnectState = ((WTS_CONNECTSTATE_CLASS) lData).ToString();
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.SessionId, out buffer, out bytesReturned) == false)
{
return data;
}
lData = Marshal.ReadInt32(buffer);
data.SessionId = lData;
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.DomainName, out buffer, out bytesReturned) == false)
{
return data;
}
strData = Marshal.PtrToStringAnsi(buffer).ToUpper();
data.DomainName = strData;
if (strData != String.Empty)
{
_NTAccount = strData;
}
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.UserName, out buffer, out bytesReturned) == false)
{
return data;
}
strData = Marshal.PtrToStringAnsi(buffer);
data.UserName = strData;
if (strData != String.Empty)
{
data.NTAccount = _NTAccount + "\\" + strData;
string _Sid = (new NTAccount(_NTAccount + "\\" + strData)).Translate(typeof(SecurityIdentifier)).Value;
data.SID = _Sid;
if (_IsLocalAdminCheckSuccess == true)
{
foreach (string localAdminGroupSid in localAdminGroupSidsList)
{
if (localAdminGroupSid == _Sid)
{
data.IsLocalAdmin = true;
break;
}
else
{
data.IsLocalAdmin = false;
}
}
}
}
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.SessionName, out buffer, out bytesReturned) == false)
{
return data;
}
strData = Marshal.PtrToStringAnsi(buffer);
data.SessionName = strData;
if (strData != "Services" && strData != "RDP-Tcp" && data.UserName != String.Empty)
{
_IsUserSession = true;
}
data.IsUserSession = _IsUserSession;
if (strData == "Console")
{
_IsConsoleSession = true;
}
data.IsConsoleSession = _IsConsoleSession;
WINSTATIONINFORMATIONW wsInfo = GetWinStationInformation(server, SessionId);
DateTime? _loginTime = FileTimeToDateTime(wsInfo.LoginTime);
DateTime? _lastInputTime = FileTimeToDateTime(wsInfo.LastInputTime);
DateTime? _disconnectTime = FileTimeToDateTime(wsInfo.DisconnectTime);
DateTime? _currentTime = FileTimeToDateTime(wsInfo.CurrentTime);
TimeSpan? _idleTime = (_currentTime != null && _lastInputTime != null) ? _currentTime.Value - _lastInputTime.Value : TimeSpan.Zero;
data.LogonTime = _loginTime;
data.IdleTime = _idleTime;
data.DisconnectTime = _disconnectTime;
if (currentSessionID == SessionId)
{
_IsCurrentSessionId = true;
}
data.IsCurrentSession = _IsCurrentSessionId;
}
finally
{
WTSFreeMemory(buffer);
buffer = IntPtr.Zero;
CloseServer(server);
}
return data;
}
public static TerminalSessionInfo[] GetUserSessionInfo(string ServerName)
{
if (ServerName == "localhost" || ServerName == String.Empty)
{
ServerName = Environment.MachineName;
}
// Find and get detailed information for all user sessions
// Also determine the active user session. If a console user exists, then that will be the active user session.
// If no console user exists but users are logged in, such as on terminal servers, then select the first logged-in non-console user that is either 'Active' or 'Connected' as the active user.
TerminalSessionData[] sessions = ListSessions(ServerName);
TerminalSessionInfo sessionInfo = new TerminalSessionInfo();
List<TerminalSessionInfo> userSessionsInfo = new List<TerminalSessionInfo>();
string firstActiveUserNTAccount = String.Empty;
bool IsActiveUserSessionSet = false;
foreach (TerminalSessionData session in sessions)
{
if (session.IsUserSession == true)
{
sessionInfo = GetSessionInfo(ServerName, session.SessionId);
if (sessionInfo.IsUserSession == true)
{
if ((firstActiveUserNTAccount == String.Empty) && (sessionInfo.ConnectState == "Active" || sessionInfo.ConnectState == "Connected"))
{
firstActiveUserNTAccount = sessionInfo.NTAccount;
}
if (sessionInfo.IsConsoleSession == true)
{
sessionInfo.IsActiveUserSession = true;
IsActiveUserSessionSet = true;
}
else
{
sessionInfo.IsActiveUserSession = false;
}
userSessionsInfo.Add(sessionInfo);
}
}
}
TerminalSessionInfo[] userSessions = userSessionsInfo.ToArray();
if (IsActiveUserSessionSet == false)
{
foreach (TerminalSessionInfo userSession in userSessions)
{
if (userSession.NTAccount == firstActiveUserNTAccount)
{
userSession.IsActiveUserSession = true;
break;
}
}
}
return userSessions;
}
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0"/>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>

View File

@@ -0,0 +1,255 @@
<#
.SYNOPSIS
This script performs the installation or uninstallation of an application(s).
# LICENSE #
PowerShell App Deployment Toolkit - Provides a set of functions to perform common application deployment tasks on Windows.
Copyright (C) 2017 - Sean Lillis, Dan Cunningham, Muhammad Mashwani, Aman Motazedian.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
.DESCRIPTION
The script is provided as a template to perform an install or uninstall of an application(s).
The script either performs an "Install" deployment type or an "Uninstall" deployment type.
The install deployment type is broken down into 3 main sections/phases: Pre-Install, Install, and Post-Install.
The script dot-sources the AppDeployToolkitMain.ps1 script which contains the logic and functions required to install or uninstall an application.
.PARAMETER DeploymentType
The type of deployment to perform. Default is: Install.
.PARAMETER DeployMode
Specifies whether the installation should be run in Interactive, Silent, or NonInteractive mode. Default is: Interactive. Options: Interactive = Shows dialogs, Silent = No dialogs, NonInteractive = Very silent, i.e. no blocking apps. NonInteractive mode is automatically set if it is detected that the process is not user interactive.
.PARAMETER AllowRebootPassThru
Allows the 3010 return code (requires restart) to be passed back to the parent process (e.g. SCCM) if detected from an installation. If 3010 is passed back to SCCM, a reboot prompt will be triggered.
.PARAMETER TerminalServerMode
Changes to "user install mode" and back to "user execute mode" for installing/uninstalling applications for Remote Destkop Session Hosts/Citrix servers.
.PARAMETER DisableLogging
Disables logging to file for the script. Default is: $false.
.EXAMPLE
powershell.exe -Command "& { & '.\Deploy-Application.ps1' -DeployMode 'Silent'; Exit $LastExitCode }"
.EXAMPLE
powershell.exe -Command "& { & '.\Deploy-Application.ps1' -AllowRebootPassThru; Exit $LastExitCode }"
.EXAMPLE
powershell.exe -Command "& { & '.\Deploy-Application.ps1' -DeploymentType 'Uninstall'; Exit $LastExitCode }"
.EXAMPLE
Deploy-Application.exe -DeploymentType "Install" -DeployMode "Silent"
.NOTES
Toolkit Exit Code Ranges:
60000 - 68999: Reserved for built-in exit codes in Deploy-Application.ps1, Deploy-Application.exe, and AppDeployToolkitMain.ps1
69000 - 69999: Recommended for user customized exit codes in Deploy-Application.ps1
70000 - 79999: Recommended for user customized exit codes in AppDeployToolkitExtensions.ps1
.LINK
http://psappdeploytoolkit.com
#>
[CmdletBinding()]
Param (
[Parameter(Mandatory=$false)]
[ValidateSet('Install','Uninstall','Repair')]
[string]$DeploymentType = 'Install',
[Parameter(Mandatory=$false)]
[ValidateSet('Interactive','Silent','NonInteractive')]
[string]$DeployMode = 'Interactive',
[Parameter(Mandatory=$false)]
[switch]$AllowRebootPassThru = $false,
[Parameter(Mandatory=$false)]
[switch]$TerminalServerMode = $false,
[Parameter(Mandatory=$false)]
[switch]$DisableLogging = $false
)
Try {
## Set the script execution policy for this process
Try { Set-ExecutionPolicy -ExecutionPolicy 'ByPass' -Scope 'Process' -Force -ErrorAction 'Stop' } Catch {}
##*===============================================
##* VARIABLE DECLARATION
##*===============================================
## Variables: Application
[string]$appVendor = 'Metler Toledo'
[string]$appName = 'Calibry'
[string]$appVersion = '5.0'
[string]$appArch = 'x86'
[string]$appLang = 'EN'
[string]$appRevision = '01'
[string]$appScriptVersion = '1.0.0'
[string]$appScriptDate = '03/26/2021'
[string]$appScriptAuthor = 'John Palmer'
##*===============================================
## Variables: Install Titles (Only set here to override defaults set by the toolkit)
[string]$installName = ''
[string]$installTitle = ''
##* Do not modify section below
#region DoNotModify
## Variables: Exit Code
[int32]$mainExitCode = 0
## Variables: Script
[string]$deployAppScriptFriendlyName = 'Deploy Application'
[version]$deployAppScriptVersion = [version]'3.8.3'
[string]$deployAppScriptDate = '30/09/2020'
[hashtable]$deployAppScriptParameters = $psBoundParameters
## Variables: Environment
If (Test-Path -LiteralPath 'variable:HostInvocation') { $InvocationInfo = $HostInvocation } Else { $InvocationInfo = $MyInvocation }
[string]$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent
## Dot source the required App Deploy Toolkit Functions
Try {
[string]$moduleAppDeployToolkitMain = "$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
If (-not (Test-Path -LiteralPath $moduleAppDeployToolkitMain -PathType 'Leaf')) { Throw "Module does not exist at the specified location [$moduleAppDeployToolkitMain]." }
If ($DisableLogging) { . $moduleAppDeployToolkitMain -DisableLogging } Else { . $moduleAppDeployToolkitMain }
}
Catch {
If ($mainExitCode -eq 0){ [int32]$mainExitCode = 60008 }
Write-Error -Message "Module [$moduleAppDeployToolkitMain] failed to load: `n$($_.Exception.Message)`n `n$($_.InvocationInfo.PositionMessage)" -ErrorAction 'Continue'
## Exit the script, returning the exit code to SCCM
If (Test-Path -LiteralPath 'variable:HostInvocation') { $script:ExitCode = $mainExitCode; Exit } Else { Exit $mainExitCode }
}
#endregion
##* Do not modify section above
##*===============================================
##* END VARIABLE DECLARATION
##*===============================================
If ($deploymentType -ine 'Uninstall' -and $deploymentType -ine 'Repair') {
##*===============================================
##* PRE-INSTALLATION
##*===============================================
[string]$installPhase = 'Pre-Installation'
## Show Welcome Message, close Internet Explorer if required, allow up to 3 deferrals, verify there is enough disk space to complete the install, and persist the prompt
#Show-InstallationWelcome -CloseApps 'iexplore' -AllowDefer -DeferTimes 3 -CheckDiskSpace -PersistPrompt
## Show Progress Message (with the default message)
#Show-InstallationProgress
## <Perform Pre-Installation tasks here>
##*===============================================
##* INSTALLATION
##*===============================================
[string]$installPhase = 'Installation'
## Handle Zero-Config MSI Installations
If ($useDefaultMsi) {
[hashtable]$ExecuteDefaultMSISplat = @{ Action = 'Install'; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add('Transform', $defaultMstFile) }
Execute-MSI @ExecuteDefaultMSISplat; If ($defaultMspFiles) { $defaultMspFiles | ForEach-Object { Execute-MSI -Action 'Patch' -Path $_ } }
}
## <Perform Installation tasks here>
#Execute-Process -Path 'Install.exe' -Parameters '/S /v/qn'
#Execute-Process -Path "$dirFiles\Calibry\Calibry\InstallationUI.exe" -Parameters '/S /v/qn'
Execute-Process -Path "$dirFiles\Calibry\Calibry\InstallationUI.exe"
#Execute-Process -Path "$dirFiles\Calibry\setup.exe" -Wait
#Execute-MSI -Action Install -Path 'CalibryInstaller.msi'# -Parameters #'/q'
##*===============================================
##* POST-INSTALLATION
##*===============================================
[string]$installPhase = 'Post-Installation'
## <Perform Post-Installation tasks here>
Execute-Process -Path "$dirFiles\Patch for calibry.exe"
Copy-Item -Path "$dirFiles\Configuration.xml" -Destination "C:\ProgramData\METTLER TOLEDO\Calibry" -Recurse
#Execute-MSI -Action Install -Path $dirFiles\3f8a8cf7.msi -Parameters '/q'
## Display a message at the end of the install
If (-not $useDefaultMsi) { #Show-InstallationPrompt -Message 'You can customize text to appear at the end of an install or remove it completely for unattended installations.' -ButtonRightText 'OK' -Icon Information -NoWait }
}
}
ElseIf ($deploymentType -ieq 'Uninstall')
{
##*===============================================
##* PRE-UNINSTALLATION
##*===============================================
[string]$installPhase = 'Pre-Uninstallation'
## Show Welcome Message, close Internet Explorer with a 60 second countdown before automatically closing
Show-InstallationWelcome -CloseApps 'iexplore' -CloseAppsCountdown 60
## Show Progress Message (with the default message)
Show-InstallationProgress
## <Perform Pre-Uninstallation tasks here>
##*===============================================
##* UNINSTALLATION
##*===============================================
[string]$installPhase = 'Uninstallation'
## Handle Zero-Config MSI Uninstallations
If ($useDefaultMsi) {
[hashtable]$ExecuteDefaultMSISplat = @{ Action = 'Uninstall'; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add('Transform', $defaultMstFile) }
Execute-MSI @ExecuteDefaultMSISplat
}
# <Perform Uninstallation tasks here>
Execute-MSI -Action Uninstall -Path '{F357E98D-6AE9-4FE4-86BE-A2254DEC7F18}' -Parameters '/q /norestart'
##*===============================================
##* POST-UNINSTALLATION
##*===============================================
[string]$installPhase = 'Post-Uninstallation'
## <Perform Post-Uninstallation tasks here>
}
ElseIf ($deploymentType -ieq 'Repair')
{
##*===============================================
##* PRE-REPAIR
##*===============================================
[string]$installPhase = 'Pre-Repair'
## Show Progress Message (with the default message)
Show-InstallationProgress
## <Perform Pre-Repair tasks here>
##*===============================================
##* REPAIR
##*===============================================
[string]$installPhase = 'Repair'
## Handle Zero-Config MSI Repairs
If ($useDefaultMsi) {
[hashtable]$ExecuteDefaultMSISplat = @{ Action = 'Repair'; Path = $defaultMsiFile; }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add('Transform', $defaultMstFile) }
Execute-MSI @ExecuteDefaultMSISplat
}
# <Perform Repair tasks here>
##*===============================================
##* POST-REPAIR
##*===============================================
[string]$installPhase = 'Post-Repair'
## <Perform Post-Repair tasks here>
}
##*===============================================
##* END SCRIPT BODY
##*===============================================
## Call the Exit-Script function to perform final cleanup operations
Exit-Script -ExitCode $mainExitCode
}
Catch {
[int32]$mainExitCode = 60001
[string]$mainErrorMessage = "$(Resolve-Error)"
Write-Log -Message $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
Show-DialogBox -Text $mainErrorMessage -Icon 'Stop'
Exit-Script -ExitCode $mainExitCode
}

View File

@@ -0,0 +1,38 @@
Hot Fix for Microsoft Knowledge Base article number(s) 981145
Knowledge Base Article
======================
To view the contents of the knowledge base article for this update, visit
http://support.microsoft.com/?kbid=981145 directly, or
visit http://support.microsoft.com and query the Knowledge base
for the product and the KB number of this update.
Installation Instructions
=========================
1. If this hotfix was delivered with hfx.exe then it can be installed by running
hfx.exe from the appropriate platform directory.
2. Install and run
Disclaimer of Liability
======================
The software which may include "online" or electronic documentation (together the "Software"),
are provided to you at no additional charge. The Software is protected by United States copyright
laws and international copyright treaties, as well as other intellectual property laws and treaties.
Microsoft Corporation owns all right, title and interest to the Software. The Software is licensed,
not sold.
DISCLAIMER OF WARRANTIES. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND ITS
SUPPLIERS EXPRESSLY DISCLAIM ALL WARRANTIES FOR THE SOFTWARE. THE SOFTWARE IS PROVIDED "AS IS"
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
THE ENTIRE RISK ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE REMAINS WITH YOU.
The Software is provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the Government
is subject to restrictions set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and
Computer Software clause at DFARS 252.227-7013 or subparagraphs (c)(1) and (2) of the Commercial
Computer Software--Restricted Rights at 48 CFR 52.227-19, as applicable. Manufacturer is Microsoft
Corporation, One Microsoft Way, Redmond, WA 98052-6399. Any transfer of this Software must be
accompanied by this statement and may only be transferred if first approved by Microsoft.
(c) 2002 Microsoft Corporation, All Rights Reserved.

View File

@@ -0,0 +1,27 @@
Option
Description
/q
Suppresses all UI. An .ini file cannot be specified with this option.
/uninstall
Uninstalls product.
/remove
Same as /uninstall.
/f
Repairs all .NET Framework components that are installed.
/nopatch
Specifies that patches are not applied and bypasses patch checking.
/norollback
Specifies that setup is not rolled back if a setup component fails.
/norestart
Specifies that the installer does not restart the computer after installation completes. The redistributable installer returns ERROR_SUCCESS_REBOOT_REQUIRED (3010) if a reboot is required.
/?
Displays this list of options.

View File

@@ -0,0 +1,40 @@
Error code
Value
Description
ERROR_SUCCESS
0
The action completed successfully.
ERROR_INSTALL_USEREXIT
1602
User canceled installation.
ERROR_INSTALL_FAILURE
1603
A fatal error occurred during installation.
ERROR_UNKNOWN_PRODUCT
1605
This action is valid only for products that are currently installed.
ERROR_PATCH_PACKAGE_INVALID
1636
The patch package could not be opened, or the patch was not applicable to the .NET Framework.
ERROR_INVALID_COMMAND_LINE
1639
Invalid command-line argument.
ERROR_SUCCESS_REBOOT_INITIATED
1641
The installer has initiated a restart. This indicates success, and setup will continue after restart. (The reboot is not performed if the /norestart option was specified.)
ERROR_PATCH_PACKAGE_REJECTED
1643
The patch package is not permitted by system policy.
ERROR_SUCCESS_REBOOT_REQUIRED
3010
A restart is required to complete the installation. This message indicates success.

View File

@@ -0,0 +1,13 @@
Command-Line Options
The Windows Installer redistributable software update packages use the following case-insensitive command-line options.
Option Description
/norestart Prevents the redistributable package from asking the user to reboot even if it had to replace files that were in use during the installation.
If the update package is invoked with this option, it returns ERROR_SUCCESS_REBOOT_REQUIRED if it had to replace files that were in use.
If it did not have to replace files that were in use, it returns ERROR_SUCCESS. See the remarks section for additional information on delayed reboots.
/quiet For use by applications that redistribute the Windows Installer as part of a bootstrapping application.
A user interface (UI) is not presented to the user. The bootstrapping application should check the return code to determine whether a reboot is needed to complete the installation of the Windows Installer.
/help Displays help on all the available options.

View File

@@ -0,0 +1,17 @@
Instructions
Download the file that is appropriate for your operating system version and platform.
For Windows Vista, Windows Vista Service Pack 1 and Windows Server 2008:
x86 Platform: Windows6.0-KB942288-v2-x86.msu
x64 Platform: Windows6.0-KB942288-v2-x64.msu
IA64 Platform: Windows6.0-KB942288-v2-ia64.msu
For Windows XP Service Pack 2 and Windows XP Service Pack 3 (32-bit platforms):
x86 Platform: WindowsXP-KB942288-v3-x86.exe
For Windows Server 2003 Service Pack 1, Windows Server 2003 Service Pack 2 and Windows XP 64-bit Editions:
x86 Platform: WindowsServer2003-KB942288-v4-x86.exe
x64 Platform: WindowsServer2003-KB942288-v4-x64.exe
IA64 Platform: WindowsServer2003-KB942288-v4-ia64.exe
For complete information on installing or upgrading Windows installer, including command line options, please see the Windows Installer Start Page on MSDN.

View File

@@ -0,0 +1,65 @@
Error code Value Description
-------------------------------------
ERROR_SUCCESS 0 The action completed successfully.
ERROR_INVALID_DATA 13 The data is invalid.
ERROR_INVALID_PARAMETER 87 One of the parameters was invalid.
ERROR_CALL_NOT_IMPLEMENTED 120 This value is returned when a custom action attempts to call a function that cannot be called from custom actions. The function returns the value ERROR_CALL_NOT_IMPLEMENTED. Available beginning with Windows Installer version 3.0.
ERROR_APPHELP_BLOCK 1259 If Windows Installer determines a product may be incompatible with the current operating system, it displays a dialog box informing the user and asking whether to try to install anyway. This error code is returned if the user chooses not to try the installation.
ERROR_INSTALL_SERVICE_FAILURE 1601 The Windows Installer service could not be accessed. Contact your support personnel to verify that the Windows Installer service is properly registered.
ERROR_INSTALL_USEREXIT 1602 The user cancels installation.
ERROR_INSTALL_FAILURE 1603 A fatal error occurred during installation.
ERROR_INSTALL_SUSPEND 1604 Installation suspended, incomplete.
ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed.
ERROR_UNKNOWN_FEATURE 1606 The feature identifier is not registered.
ERROR_UNKNOWN_COMPONENT 1607 The component identifier is not registered.
ERROR_UNKNOWN_PROPERTY 1608 This is an unknown property.
ERROR_INVALID_HANDLE_STATE 1609 The handle is in an invalid state.
ERROR_BAD_CONFIGURATION 1610 The configuration data for this product is corrupt. Contact your support personnel.
ERROR_INDEX_ABSENT 1611 The component qualifier not present.
ERROR_INSTALL_SOURCE_ABSENT 1612 The installation source for this product is not available. Verify that the source exists and that you can access it.
ERROR_INSTALL_PACKAGE_VERSION 1613 This installation package cannot be installed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service.
ERROR_PRODUCT_UNINSTALLED 1614 The product is uninstalled.
ERROR_BAD_QUERY_SYNTAX 1615 The SQL query syntax is invalid or unsupported.
ERROR_INVALID_FIELD 1616 The record field does not exist.
ERROR_INSTALL_ALREADY_RUNNING 1618 Another installation is already in progress. Complete that installation before proceeding with this install.
For information about the mutex, see _MSIExecute Mutex.
ERROR_INSTALL_PACKAGE_OPEN_FAILED 1619 This installation package could not be opened. Verify that the package exists and is accessible, or contact the application vendor to verify that this is a valid Windows Installer package.
ERROR_INSTALL_PACKAGE_INVALID 1620 This installation package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer package.
ERROR_INSTALL_UI_FAILURE 1621 There was an error starting the Windows Installer service user interface. Contact your support personnel.
ERROR_INSTALL_LOG_FAILURE 1622 There was an error opening installation log file. Verify that the specified log file location exists and is writable.
ERROR_INSTALL_LANGUAGE_UNSUPPORTED 1623 This language of this installation package is not supported by your system.
ERROR_INSTALL_TRANSFORM_FAILURE 1624 There was an error applying transforms. Verify that the specified transform paths are valid.
ERROR_INSTALL_PACKAGE_REJECTED 1625 This installation is forbidden by system policy. Contact your system administrator.
ERROR_FUNCTION_NOT_CALLED 1626 The function could not be executed.
ERROR_FUNCTION_FAILED 1627 The function failed during execution.
ERROR_INVALID_TABLE 1628 An invalid or unknown table was specified.
ERROR_DATATYPE_MISMATCH 1629 The data supplied is the wrong type.
ERROR_UNSUPPORTED_TYPE 1630 Data of this type is not supported.
ERROR_CREATE_FAILED 1631 The Windows Installer service failed to start. Contact your support personnel.
ERROR_INSTALL_TEMP_UNWRITABLE 1632 The Temp folder is either full or inaccessible. Verify that the Temp folder exists and that you can write to it.
ERROR_INSTALL_PLATFORM_UNSUPPORTED 1633 This installation package is not supported on this platform. Contact your application vendor.
ERROR_INSTALL_NOTUSED 1634 Component is not used on this machine.
ERROR_PATCH_PACKAGE_OPEN_FAILED 1635 This patch package could not be opened. Verify that the patch package exists and is accessible, or contact the application vendor to verify that this is a valid Windows Installer patch package.
ERROR_PATCH_PACKAGE_INVALID 1636 This patch package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer patch package.
ERROR_PATCH_PACKAGE_UNSUPPORTED 1637 This patch package cannot be processed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service.
ERROR_PRODUCT_VERSION 1638 Another version of this product is already installed. Installation of this version cannot continue. To configure or remove the existing version of this product, use Add/Remove Programs in Control Panel.
ERROR_INVALID_COMMAND_LINE 1639 Invalid command line argument. Consult the Windows Installer SDK for detailed command-line help.
ERROR_INSTALL_REMOTE_DISALLOWED 1640 The current user is not permitted to perform installations from a client session of a server running the Terminal Server role service.
ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success.
ERROR_PATCH_TARGET_NOT_FOUND 1642 The installer cannot install the upgrade patch because the program being upgraded may be missing or the upgrade patch updates a different version of the program. Verify that the program to be upgraded exists on your computer and that you have the correct upgrade patch.
ERROR_PATCH_PACKAGE_REJECTED 1643 The patch package is not permitted by system policy.
ERROR_INSTALL_TRANSFORM_REJECTED 1644 One or more customizations are not permitted by system policy.
ERROR_INSTALL_REMOTE_PROHIBITED 1645 Windows Installer does not permit installation from a Remote Desktop Connection.
ERROR_PATCH_REMOVAL_UNSUPPORTED 1646 The patch package is not a removable patch package. Available beginning with Windows Installer version 3.0.
ERROR_UNKNOWN_PATCH 1647 The patch is not applied to this product. Available beginning with Windows Installer version 3.0.
ERROR_PATCH_NO_SEQUENCE 1648 No valid sequence could be found for the set of patches. Available beginning with Windows Installer version 3.0.
ERROR_PATCH_REMOVAL_DISALLOWED 1649 Patch removal was disallowed by policy. Available beginning with Windows Installer version 3.0.
ERROR_INVALID_PATCH_XML 1650 The XML patch data is invalid. Available beginning with Windows Installer version 3.0.
ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT 1651 Administrative user failed to apply patch for a per-user managed or a per-machine application that is in advertise state. Available beginning with Windows Installer version 3.0.
ERROR_INSTALL_SERVICE_SAFEBOOT 1652 Windows Installer is not accessible when the computer is in Safe Mode. Exit Safe Mode and try again or try using System Restore to return your computer to a previous state. Available beginning with Windows Installer version 4.0.
ERROR_ROLLBACK_DISABLED 1653 Could not perform a multiple-package transaction because rollback has been disabled. Multiple-Package Installations cannot run if rollback is disabled. Available beginning with Windows Installer version 4.5.
ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success. This does not include installs where the ForceReboot action is run.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="InstallationUI.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<InstallationUI.Properties.Settings>
<setting name="thirdPartyFolder" serializeAs="String">
<value>..\3rdParty</value>
</setting>
<setting name="Installer" serializeAs="String">
<value>CalibryInstaller.msi</value>
</setting>
<setting name="ProductCode" serializeAs="String">
<value>{f357e98d-6ae9-4fe4-86be-a2254dec7f18}</value>
</setting>
</InstallationUI.Properties.Settings>
</applicationSettings>
</configuration>

Binary file not shown.

View File

@@ -0,0 +1,119 @@
[CPPBootstrapper_Products]
Product1 = Product_WI
Product2 = Product_NET
[EnternalUI]
Path = Calibry\InstallationUI.exe
[OS]
Path = Calibry\SEQ_OS.dll
[Product_WI]
ID = 1
Name=Windows Installer 4.5
Description= Windows Installer 4.5
LibPath = Calibry\SEQ_WI45.dll
logfilePath = <WINDOWS>\WindowsUpdate.log
ALL_OS_BS = <OS>
VISTA_X86 = 3rdParty\WI45\Windows6.0-KB942288-v2-x86.msu
VISTA_X86_SP1 = 3rdParty\WI45\Windows6.0-KB942288-v2-x86.msu
VISTA_X86_SP2 = 3rdParty\WI45\Windows6.0-KB942288-v2-x86.msu
VISTA_X64 = 3rdParty\WI45\Windows6.0-KB942288-v2-x64.msu
VISTA_X64_SP1 = 3rdParty\WI45\Windows6.0-KB942288-v2-x64.msu
VISTA_X64_SP2 = 3rdParty\WI45\Windows6.0-KB942288-v2-x64.msu
VISTA_IA64 = 3rdParty\WI45\Windows6.0-KB942288-v2-ia64.msu
VISTA_IA64_SP1 = 3rdParty\WI45\Windows6.0-KB942288-v2-ia64.msu
VISTA_IA64_SP2 = 3rdParty\WI45\Windows6.0-KB942288-v2-ia64.msu
WINXP_X86_SP2 = 3rdParty\WI45\WindowsXP-KB942288-v3-x86.exe
WINXP_X86_SP3 = 3rdParty\WI45\WindowsXP-KB942288-v3-x86.exe
WINXP_X64_SP2 = 3rdParty\WI45\WindowsServer2003-KB942288-v4-x64.exe
WINXP_X64_SP3 = 3rdParty\WI45\WindowsServer2003-KB942288-v4-x64.exe
WIN2003_X86_SP1 = 3rdParty\WI45\WindowsServer2003-KB942288-v4-x86.exe
WIN2003_X86_SP2 = 3rdParty\WI45\WindowsServer2003-KB942288-v4-x86.exe
WIN2003_X64_SP1 = 3rdParty\WI45\WindowsServer2003-KB942288-v4-x64.exe
WIN2003_X64_SP2 = 3rdParty\WI45\WindowsServer2003-KB942288-v4-x64.exe
WIN2003_IA64_SP1 = 3rdParty\WI45\WindowsServer2003-KB942288-v4-ia64.exe
WIN2003_IA64_SP2 = 3rdParty\WI45\WindowsServer2003-KB942288-v4-ia64.exe
WIN2008_X86 = 3rdParty\WI45\Windows6.0-KB942288-v2-x86.msu
WIN2008_X86_SP1 = 3rdParty\WI45\Windows6.0-KB942288-v2-x86.msu
WIN2008_X86_SP2 = 3rdParty\WI45\Windows6.0-KB942288-v2-x86.msu
WIN2008_X64 = 3rdParty\WI45\Windows6.0-KB942288-v2-x64.msu
WIN2008_X64_SP1 = 3rdParty\WI45\Windows6.0-KB942288-v2-x64.msu
WIN2008_X64_SP2 = 3rdParty\WI45\Windows6.0-KB942288-v2-x64.msu
WIN2008_IA64 = 3rdParty\WI45\Windows6.0-KB942288-v2-ia64.msu
WIN2008_IA64_SP1 = 3rdParty\WI45\Windows6.0-KB942288-v2-ia64.msu
WIN2008_IA64_SP2 = 3rdParty\WI45\Windows6.0-KB942288-v2-ia64.msu
WIN7_X86 = na
WIN7_X64 = na
WIN2008R2_X64 = na
CmdLine = /norestart /quiet
StatusEntryPoint = IsPackageInstalled
InstallEntryPoint = InstallPackage
MetaInfoEntryPoint = SetMetaInfo
ShowParameterEntryPoint = ShowParameterUI
FilterEntryPoint = IsSequoiaPrerequisite
LogFileEntryPoint = SetLogFileHandle
ForcedRestart = 2
;0=none 1=immediate 2=postponed 3=Immediate_result_dependent 4 = Postponed_result_dependent
Optional = 0
;Product installation optional status if this set to false check box for the corresponding product will not be displayed
[Product_NET]
ID=2
Name=Microsoft .NET 3.5
Description= .NET 3.5
LibPath = Calibry\SEQ_NET35.dll
logfilePath = <USERTEMP>\dd_dotnetfx35install.log
ALL_OS_BS = 3rdParty\NET35\dotnetfx35_SP1.exe
CmdLine = /q /norestart
StatusEntryPoint = IsPackageInstalled
InstallEntryPoint = InstallPackage
MetaInfoEntryPoint = SetMetaInfo
ShowParameterEntryPoint = ShowParameterUI
FilterEntryPoint = IsSequoiaPrerequisite
LogFileEntryPoint = SetLogFileHandle
ForcedRestart = 2
Optional = 0
[Product_KB981145]
ID=3
Name=Microsoft KB981145
Description= KB981145
LibPath = Calibry\SEQ_KB.dll
logfilePath = <WINDOWS>\WindowsUpdate.log
ALL_OS_BS = <OS>
VISTA_X86 = 3rdParty\MSKB\Windows6.0-KB981145-x86.msu
VISTA_X86_SP1 = 3rdParty\MSKB\Windows6.0-KB981145-x86.msu
VISTA_X86_SP2 = 3rdParty\MSKB\Windows6.0-KB981145-x86.msu
VISTA_X64 = 3rdParty\MSKB\Windows6.0-KB981145-x64.msu
VISTA_X64_SP1 = 3rdParty\MSKB\Windows6.0-KB981145-x64.msu
VISTA_X64_SP2 = 3rdParty\MSKB\Windows6.0-KB981145-x64.msu
WINXP_X86_SP2 = 3rdParty\MSKB\NDP20SP2-KB981145-x86.exe
WINXP_X86_SP3 = 3rdParty\MSKB\NDP20SP2-KB981145-x86.exe
WINXP_X64_SP2 = 3rdParty\MSKB\NDP20SP2-KB981145-x64.exe
WINXP_X64_SP3 = 3rdParty\MSKB\NDP20SP2-KB981145-x64.exe
WIN2003_X86_SP1 = 3rdParty\MSKB\NDP20SP2-KB981145-x86.exe
WIN2003_X86_SP2 = 3rdParty\MSKB\NDP20SP2-KB981145-x86.exe
WIN2003_X64_SP1 = 3rdParty\MSKB\NDP20SP2-KB981145-x64.exe
WIN2003_X64_SP2 = 3rdParty\MSKB\NDP20SP2-KB981145-x64.exe
WIN2008_X86 = 3rdParty\MSKB\Windows6.0-KB981145-x86.msu
WIN2008_X86_SP1 = 3rdParty\MSKB\Windows6.0-KB981145-x86.msu
WIN2008_X86_SP2 = 3rdParty\MSKB\Windows6.0-KB981145-x86.msu
WIN2008_X64 = 3rdParty\MSKB\Windows6.0-KB981145-x64.msu
WIN2008_X64_SP1 = 3rdParty\MSKB\Windows6.0-KB981145-x64.msu
WIN2008_X64_SP2 = 3rdParty\MSKB\Windows6.0-KB981145-x64.msu
WIN7_X86 = 3rdParty\MSKB\Windows6.1-KB981145-v2-x86.msu
WIN7_X64 = 3rdParty\MSKB\Windows6.1-KB981145-v2-x64.msu
WIN2008R2_X64 = 3rdParty\MSKB\Windows6.1-KB981145-v2-x64.msu
CmdLine = /norestart /quiet
StatusEntryPoint = IsPackageInstalled
InstallEntryPoint = InstallPackage
MetaInfoEntryPoint = SetMetaInfo
ShowParameterEntryPoint = ShowParameterUI
FilterEntryPoint = IsSequoiaPrerequisite
LogFileEntryPoint = SetLogFileHandle
ForcedRestart = 1
;0=none 1=immediate 2=postponed 3=Immediate_result_dependent 4 = Postponed_result_dependent
Optional = 0
;Product installation optional status if this set to false check box for the corresponding product will not be displayed

View File

@@ -0,0 +1,162 @@
<?xml version="1.0" encoding="utf-8"?>
<clsUserSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<AdvancedSettings>
<UseAdvancedUEvaporation>false</UseAdvancedUEvaporation>
<EnableCubicExpansionForPipette>false</EnableCubicExpansionForPipette>
<EnableCubicExpansionForTips>false</EnableCubicExpansionForTips>
<BalanceCalibrationMode>None</BalanceCalibrationMode>
<DeviceCalibrationMode>None</DeviceCalibrationMode>
</AdvancedSettings>
<AuditSettings>
<Title />
<Subtitle />
</AuditSettings>
<BalanceSettings>
<AutoResolution4Decimal>100</AutoResolution4Decimal>
<AutoResolution5Decimal>10</AutoResolution5Decimal>
<DefaultBalance />
<WarningLimits>0.03</WarningLimits>
<OutOfOrderLimits>0.1</OutOfOrderLimits>
<McpSettings>
<ReferenceMeasurementTime>30</ReferenceMeasurementTime>
<VibrationAdapter>Unstable</VibrationAdapter>
<ProcessAdapter>Off</ProcessAdapter>
<Repeatability>VeryQuickRelease</Repeatability>
<RecallSettings>
<RecallForInternal>0</RecallForInternal>
<RecallForInternalExternal>0</RecallForInternalExternal>
<RecallForExternalInternalExternal>0</RecallForExternalInternalExternal>
</RecallSettings>
</McpSettings>
<XpSettings>
<RecallSettings>
<RecallForInternal>0</RecallForInternal>
<RecallForInternalExternal>0</RecallForInternalExternal>
<RecallForExternalInternalExternal>0</RecallForExternalInternalExternal>
</RecallSettings>
</XpSettings>
<AxSettings>
<RecallSettings>
<RecallForInternal>0</RecallForInternal>
<RecallForInternalExternal>0</RecallForInternalExternal>
<RecallForExternalInternalExternal>0</RecallForExternalInternalExternal>
</RecallSettings>
</AxSettings>
<SagSettings>
<RecallSettings>
<RecallForInternal>0</RecallForInternal>
<RecallForInternalExternal>0</RecallForInternalExternal>
<RecallForExternalInternalExternal>0</RecallForExternalInternalExternal>
</RecallSettings>
</SagSettings>
<AgSettings>
<RecallSettings>
<RecallForInternal>0</RecallForInternal>
<RecallForInternalExternal>0</RecallForInternalExternal>
<RecallForExternalInternalExternal>0</RecallForExternalInternalExternal>
</RecallSettings>
</AgSettings>
<GenericsSettings>
<RecallSettings>
<RecallForInternal>0</RecallForInternal>
<RecallForInternalExternal>0</RecallForInternalExternal>
<RecallForExternalInternalExternal>0</RecallForExternalInternalExternal>
</RecallSettings>
</GenericsSettings>
</BalanceSettings>
<CalibrationSettings>
<MaxUndoAllowed>10</MaxUndoAllowed>
<UnitType>Weight</UnitType>
<DisplayUnit>true</DisplayUnit>
<MinimumAsFoundMeasurements>2</MinimumAsFoundMeasurements>
<MinimumAsReturnedMeasurements>2</MinimumAsReturnedMeasurements>
<DefaultAsReturnedMeasurements>4</DefaultAsReturnedMeasurements>
<DefaultAsFoundMeasurement>4</DefaultAsFoundMeasurement>
<CalibrationUpDown>Ascending</CalibrationUpDown>
<TareBetweenReadings>false</TareBetweenReadings>
<CompensateEvaporation>false</CompensateEvaporation>
<LockCompensateEvaporation>false</LockCompensateEvaporation>
<IsOrderNumberRequired>false</IsOrderNumberRequired>
<OpenTime>4</OpenTime>
<ReadTime>7</ReadTime>
</CalibrationSettings>
<DatabaseSettings>
<SqlServerName>RAP-Calibary-DB.crii.org</SqlServerName>
<DatabaseName>CalibryBiomed</DatabaseName>
</DatabaseSettings>
<EnvironmentalsSettings>
<ExternalCaptureToolAddress />
<ExternalCaptureToolPort>0</ExternalCaptureToolPort>
<UseTableOnly>false</UseTableOnly>
<UseOneTemperature>true</UseOneTemperature>
<IsHumidityFixed>false</IsHumidityFixed>
<IsWaterTemperatureFixed>false</IsWaterTemperatureFixed>
<IsPressureFixed>false</IsPressureFixed>
<UseExternalCaptureTool>false</UseExternalCaptureTool>
<MinAirTemperature>0</MinAirTemperature>
<MaxAirTemperature>0</MaxAirTemperature>
<MinWaterTemperature>0</MinWaterTemperature>
<MaxWaterTemperature>0</MaxWaterTemperature>
<MinPressure>0</MinPressure>
<MaxPressure>0</MaxPressure>
<MinHumidity>0</MinHumidity>
<MaxHumidity>0</MaxHumidity>
<MinZFactor>0</MinZFactor>
<MaxZFactor>0</MaxZFactor>
<PromptSecondRead>false</PromptSecondRead>
</EnvironmentalsSettings>
<ReportSettings>
<DefaultSummaryView>false</DefaultSummaryView>
<NoPromptForExportFileName>false</NoPromptForExportFileName>
<AutoShowReport>false</AutoShowReport>
<AutoPrintReport>false</AutoPrintReport>
<FontName>Arial</FontName>
<TitelFontSize>16</TitelFontSize>
<SubtitelFontSize>10</SubtitelFontSize>
<TextFontSize>6</TextFontSize>
<NoticeFontSize>8</NoticeFontSize>
<TopTitle>50</TopTitle>
<AlignTitel>MiddleCenter</AlignTitel>
<Top>100</Top>
<ShowHumidity>true</ShowHumidity>
<ShowInspectionStatus>true</ShowInspectionStatus>
<ShowMeanStatistics>true</ShowMeanStatistics>
<ShowAbsoluteSystematicErrorStatistics>true</ShowAbsoluteSystematicErrorStatistics>
<ShowAbsoluteRandomErrorStatistics>true</ShowAbsoluteRandomErrorStatistics>
<ShowRelativeSystematicErrorStatistics>true</ShowRelativeSystematicErrorStatistics>
<showRelativeRandomErrorStatistics>true</showRelativeRandomErrorStatistics>
<ShowUncertaintyStatistics>true</ShowUncertaintyStatistics>
<ShowNotice>true</ShowNotice>
<ShowNoticeTitle>true</ShowNoticeTitle>
<ShowUndos>true</ShowUndos>
<ShowNextDueDate>true</ShowNextDueDate>
<ShowGraph>true</ShowGraph>
<ShowTime>false</ShowTime>
<SignReport>false</SignReport>
<Logo1>
<PosX>100</PosX>
<PosY>100</PosY>
<Displays>PageHeader</Displays>
</Logo1>
<Logo2>
<PosX>100</PosX>
<PosY>100</PosY>
<Displays>PageHeader</Displays>
</Logo2>
<Logo3>
<PosX>100</PosX>
<PosY>100</PosY>
<Displays>PageHeader</Displays>
</Logo3>
</ReportSettings>
<SoundSettings>
<EnableNextVolume>false</EnableNextVolume>
<EnableError>false</EnableError>
<EnableFinish>false</EnableFinish>
<EnableOutOfTolerance>false</EnableOutOfTolerance>
</SoundSettings>
<RfidSettings>
<ShouldFilterLists>false</ShouldFilterLists>
<ShouldShowQuickAccess>true</ShouldShowQuickAccess>
</RfidSettings>
</clsUserSettings>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,3 @@
[autorun]
open=install.exe
icon=Xtras\Icon.ico

View File

@@ -0,0 +1,111 @@
[0x0409]
TITLE=Choose Setup Language
DESCRIPTION=Select the language for this installation from the choices below.
REBOOTMESSAGE=The installer must restart your system to complete configuring the Windows Installer service. Click Yes to restart now or No if you plan to restart later.
ONUPGRADE=This setup will perform an upgrade of '%s'. Do you want to continue?
LATERVERSIONINSTALLED=A later version of '%s' is already installed on this machine. The setup cannot continue.
OK=OK
Cancel=Cancel
Password=Password:
Install=Install
1100=Setup Initialization Error
1101=%s
1102=%s Setup is preparing the %s, which will guide you through the program setup process. Please wait.
1103=Checking Operating System Version
1104=Checking Windows(R) Installer Version
1105=Configuring Windows Installer
1106=Configuring %s
1107=Setup has completed configuring the Windows Installer on your system. The system needs to be restarted in order to continue with the installation. Please click Restart to reboot the system.
1108=%s
1150=Setup has detected an incompatible version of Windows. Please click OK and verify that the target system is running either Windows 95 (or later version), or Windows NT 4.0 Service Pack 6 (or later version), before relaunching the installation
1151=Error writing to the temporary location
1152=Error extracting %s to the temporary location
1153=Error reading setup initialization file
1154=Installer not found in %s
1155=File %s not found
1156=Internal error in Windows Installer
1158=Error populating strings. Verify that all strings in Setup.ini are valid.
1200=Restart
1603=Error installing Windows Installer engine. A file which needs to be replaced may be held in use. Close all applications and try again.
1201=Setup needs %lu KB free disk space in %s. Please free up some space and try again
1202=You do not have sufficient privileges to complete this installation for all users of the machine. Log on as administrator and then retry this installation
1203=Command line parameters:
1204=/L language ID
1205=/S Hide intialization dialog. For silent mode use: /S /v/qn.
1206=/V parameters to MsiExec.exe
1207=Windows(R) Installer %s found. This is an older version of the Windows(R) Installer. Click OK to continue.
1208=ANSI code page for %s is not installed on the system and therefore setup cannot run in the selected language. Run the setup and select another language.
1210=Setup requires Windows Installer version %s or higher to install the Microsoft .NET Framework version 2.0. Please install the Windows Installer version %s or higher and try again.
1604=This setup does not contain the Windows Installer engine (%s) required to run the installation on this operating system.
1607=Unable to install %s Scripting Runtime.
1608=Unable to create InstallDriver instance, Return code: %d
1609=Please specify a location to save the installation package.
1611=Unable to extract the file %s.
1612=Extracting files.
1613=Downloading file %s.
1614=An error occurred while downloading the file %s. What would you like to do?
1615=hr
1616=min
1617=sec
1618=MB
1619=KB
1620=/sec
1621=Failed to verify signature of file %s.
1622=Estimated time remaining:
1623=%d KB of %d KB downloaded at
1624=Preparing to Install...
1625=Get help for this installation.
1626=Help
1627=Unable to save file: %s
1628=Failed to complete installation.
1629=Invalid command line.
1630=/UA<url to InstMsiA.exe>
1631=/UW<url to InstMsiW.exe>
1632=/UM<url to msi package>
1633=/US<url to IsScript.msi>
1634=Setup Initialization Error, failed to clone the process.
1635=The file %s already exists. Would you like to replace it?
1636=/P password mode
1637=/A administrative installation
1638=/J advertise mode
1639=/X uninstall mode
1640=/F repair mode
1641=/B cache installation locally
1642=Could not verify signature. You need Internet Explorer 3.02 or later with Authenticode update.
1643=Setup requires a newer version of WinInet.dll. You may need to install Internet Explorer 3.02 or later.
1644=You do not have sufficient privileges to complete this installation. Log on as administrator and then retry this installation
1645=Error installing Microsoft(R) .NET Framework, Return Code: %d
1646=%s optionally uses the Microsoft (R) .NET %s Framework. Would you like to install it now?
1648=Setup has detected an incompatible version of Windows. Please click OK and verify that the target system is running either Windows 95 (or later version), or Windows NT 4.0 Service Pack 3 (or later version), before relaunching the installation
1649=%s optionally uses the Visual J# Redistributable Package. Would you like to install it now?
1650= (This will also install the .NET Framework.)
1651=Setup has detected an incompatible version of Windows. Please click OK and verify that the target system is running Windows 2000 Service Pack 3 (or later version), before relaunching the installation
1652=%s requires that the following requirements be installed on your computer prior to installing this application. Click Install to begin installing these requirements:
1653=Installing %s
1654=Would you like to cancel the setup after %s has finished installing?
1655=The files for installation requirement %s could not be found. The installation will now stop. This is probably due to a failed, or canceled download.
1656=The installation of %s appears to have failed. Do you want to continue the installation?
1657=Succeeded
1658=Installing
1659=Pending
1660=Installed
1661=Status
1662=Requirement
1663=Failed
1664=Extracting
1665=Downloading
1666=Skipped
1667=The installation of %s has failed. Setup will now exit.
1668=The installation of %s requires a reboot. Click Yes to restart now or No if you plan to restart later.
1669=%1 optionally uses %2. Would you like to install it now?
1670=Unable to load module %s, Error Code: %d
1671=Downloading file %2 of %3: %1
1700=An error occurred initializing the InstallScript engine
1701=Unable to extract InstallScript engine support files to temp location
[Languages]
0x0404=Chinese (Traditional)
0x0804=Chinese (Simplified)

View File

@@ -0,0 +1,2 @@
[autorun]
OPEN=setup.exe

View File

@@ -0,0 +1,182 @@
[Info]
Name=INTL
Version=1.00.000
DiskSpace=8000 ;DiskSpace requirement in KB
[Startup]
CmdLine=
SuppressWrongOS=Y
ScriptDriven=0
ScriptVer=1.0.0.1
DotNetOptionalInstallIfSilent=N
OnUpgrade=1
RequireExactLangMatch=0404,0804
Product=Calibry capture tool
PackageName=Calibry capture tool.msi
EnableLangDlg=N
LogResults=N
DoMaintenance=N
ProductCode={1E246158-8BA8-4729-AA70-FB0CD1002D41}
ProductVersion=1.00.0000
SuppressReboot=Y
LauncherName=setup.exe
AdvertiseWhileElevated=Y
DotNetVersion=v2.0.50727
DotNetSPRequired=
UseDotNetUI=N
DotNetCoreSetupUILang=1033
DotNetLangPacks=
DotNetFxCmd=
DotNetLangPackCmd=
DotNetOptional=Y
DotNetDelayReboot=Y
PackageCode={7110E558-4E83-4C5C-AD2E-D81DE89A7A95}
[MsiVersion]
3.1.4000.2435=SupportOSMsi30
[SupportOSMsi11] ;Supported platforms for MSI 1.1
Win95=1
Win98=1
WinNT4SP3=1
[SupportOSMsi12] ;Supported platforms for MSI 1.2
Win95=1
Win98=1
WinME=1
WinNT4SP3=1
[SupportOS] ;Supported platforms for MSI 2.0
Win95=1
Win98=1
WinME=1
WinNT4SP6=1
Win2K=1
[SupportOSMsi30] ;Supported platforms for MSI 3.0
Win2KSP3=1
WinXP=1
Win2003Server=1
[Win95]
MajorVer=4
MinorVer=0
MinorVerMax=1
BuildNo=950
PlatformId=1
[Win98]
MajorVer=4
MinorVer=10
MinorVerMax=11
BuildNo=1998
PlatformId=1
[WinME]
MajorVer=4
MinorVer=90
MinorVerMax=91
BuildNo=3000
PlatformId=1
[WinNT4SP3]
MajorVer=4
MinorVer=0
MinorVerMax=1
BuildNo=1381
PlatformId=2
ServicePack=768
[WinNT4SP6]
MajorVer=4
MinorVer=0
MinorVerMax=1
BuildNo=1381
PlatformId=2
ServicePack=1536
[Win2K]
MajorVer=5
MinorVer=0
MinorVerMax=1
BuildNo=2195
PlatformId=2
[Win2KSP3]
MajorVer=5
MinorVer=0
MinorVerMax=1
BuildNo=2195
PlatformId=2
ServicePack=768
[WinXP]
MajorVer=5
MinorVer=1
MinorVerMax=2
BuildNo=2600
PlatformId=2
[Win2003Server]
MajorVer=5
MinorVer=2
MinorVerMax=3
BuildNo=2600
PlatformId=2
[0x0409]
TITLE=Choose Setup Language
DESCRIPTION=Select the language for this installation from the choices below.
OK=OK
Cancel=Cancel
0x0409=English (United States)
0x0411=Japanese
0x0401=Arabic (Saudi Arabia)
0x042d=Basque
0x0402=Bulgarian
0x0403=Catalan
0x0804=Chinese (PRC)
0x0404=Chinese (Taiwan)
0x041a=Croatian
0x0405=Czech
0x0406=Danish
0x0413=Dutch (Netherlands)
0x040b=Finnish
0x0c0c=French (Canada)
0x040c=French (France)
0x0407=German (Germany)
0x0408=Greek
0x040d=Hebrew
0x040e=Hungarian
0x0421=Indonesian
0x0410=Italian (Italy)
0x0412=Korean
0x0414=Norwegian (Bokmal)
0x0415=Polish
0x0416=Portuguese (Brazil)
0x0816=Portuguese (Portugal)
0x0418=Romanian
0x0419=Russian
0x0c1a=Serbian (Cyrillic)
0x041b=Slovak
0x0424=Slovenian
0x040a=Spanish (Traditional Sort)
0x041d=Swedish
0x041e=Thai
0x041f=Turkish
[Languages]
count=1
default=409
key0=409
[Calibry capture tool.msi]
Type=0
Location=Calibry capture tool.msi
[Setup.bmp]
Type=0
[dotnetfx.exe]
Type=0
Location=isnetfx.exe
[WindowsInstaller-KB893803-x86.exe]
Type=0
Location=WindowsInstaller-KB893803-x86.exe

View File

@@ -0,0 +1,245 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
namespace TestoCaptureTool
{
/// <summary>
/// State object for reading client data asynchronously
/// </summary>
public class StateObject
{
public Socket workSocket; // Client socket.
public const int BufferSize = 1024; // Size of receive buffer.
public byte[] buffer = new byte[BufferSize]; // Receive buffer.
public StringBuilder sb = new StringBuilder(); // Received data string.
}
/// <summary>
/// Class which listen to incoming request from calibry and reply to the query
/// </summary>
class Communication
{
Socket listenSocket;
bool _listening;
bool _closing = false;
public static System.Threading.ManualResetEvent allDone = new System.Threading.ManualResetEvent(false);
public void StopListening()
{
_closing = true;
allDone.Set();
listenSocket.Close();
_listening = false;
}
/// <summary>
/// Function which open the connection and start listening for incoming
/// requests.
/// </summary>
public void OpenCommunication()
{
try
{
// create the socket
listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
// bind the listening socket to the port (specified in the settings.settings file
IPEndPoint ep = new IPEndPoint(IPAddress.Any, Properties.Settings.Default.NetworkPort);
listenSocket.Bind(ep);
}
catch (SocketException e)
{
listenSocket.Close();
System.Diagnostics.Trace.TraceError(String.Format("{0}: {1}", e.ErrorCode, e.Message));
return;
}
// start listening
_listening = true;
}
public void StartListening()
{
listenSocket.Listen(100);
//Listen to incoming request until the application ends.
while (!_closing)
{
try
{
// Set the event to nonsignaled state.
allDone.Reset();
// Start an asynchronous socket to listen for connections.
listenSocket.BeginAccept(new AsyncCallback(AcceptCallback), listenSocket);
// Wait until a connection is made before continuing.
allDone.WaitOne();
}
catch (System.Threading.ThreadInterruptedException)
{
_closing=true;
}
}
}
public bool IsListening
{
get { return _listening; }
}
/// <summary>
/// Function which handle an incoming request.
/// </summary>
/// <param name="ar"></param>
private static void AcceptCallback(IAsyncResult ar)
{
// Signal the main thread to continue.
allDone.Set();
// Get the socket that handles the client request.
Socket listener = (Socket)ar.AsyncState;
try
{
Socket handler = listener.EndAccept(ar);
// Create the state object.
StateObject state = new StateObject();
state.workSocket = handler;
handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(ReadCallback), state);
}
catch (ObjectDisposedException)
{
System.Diagnostics.Trace.TraceInformation("Socket closed");
}
}
/// <summary>
/// Function which interpret the receiving string
/// </summary>
/// <param name="ar"></param>
private static void ReadCallback(IAsyncResult ar)
{
// Retrieve the state object and the handler socket
// from the asynchronous state object.
StateObject state = (StateObject)ar.AsyncState;
Socket handler = state.workSocket;
int bytesRead = handler.EndReceive(ar);;
// There might be more data, so store the data received so far.
state.sb.Append(Encoding.ASCII.GetString(state.buffer, 0, bytesRead));
string receivedString = state.sb.ToString();
//If format is not Calibry format, closing the communication
if (!receivedString.StartsWith("<bal m=\"r\">"))
{
handler.Shutdown(SocketShutdown.Both);
handler.Close();
return;
}
//Retrieving the different value for the different parameter received
//from calibry. Could be used to request the data from a specific device
//depending on these parameters
int dvnStart=receivedString.IndexOf("<dvn>");
int dsnStart = receivedString.IndexOf("<dsn>");
int locStart = receivedString.IndexOf("<loc>");
string deviceNumber = receivedString.Substring(dvnStart + 5, dsnStart - (dvnStart + 5));
string serialNumber = receivedString.Substring(dsnStart + 5, locStart - (dsnStart + 5));
string location = receivedString.Substring(locStart+5);
//Proceeding with the reply
Send(handler, deviceNumber, serialNumber, location);
}
/// <summary>
/// Building the answer to the request
/// Sending the answer
/// Terminating the communication
/// </summary>
/// <param name="handler"></param>
/// <param name="deviceNumber"></param>
/// <param name="serialNumber"></param>
/// <param name="location"></param>
private static void Send(Socket handler, string deviceNumber, string serialNumber, string location)
{
//Sending only the parameter for which a channel is configured.
StringBuilder sentDate = new StringBuilder();
sentDate.Append("<bal m=\"r\"><dvn>");
sentDate.Append(deviceNumber);
if (Program._device.IsConnected)
{
if (Program._device.AirTemperatureChannel > -1)
{
sentDate.Append("<tea>");
sentDate.Append(Program._device.AirTemperature.ToString("0.00",System.Globalization.CultureInfo.CurrentUICulture));
sentDate.Append(";");
sentDate.Append(Program._device.DeviceSN);
}
if (Program._device.WaterTemperatureChannel > -1)
{
sentDate.Append("<tew>");
sentDate.Append(Program._device.WaterTemperature.ToString("0.00",System.Globalization.CultureInfo.CurrentUICulture));
sentDate.Append(";");
sentDate.Append(Program._device.DeviceSN);
}
if (Program._device.HumidityChannel > -1)
{
sentDate.Append("<hgr>");
sentDate.Append(Program._device.Humidity.ToString("0.00",System.Globalization.CultureInfo.CurrentUICulture));
sentDate.Append(";");
sentDate.Append(Program._device.DeviceSN);
}
if (Program._device.PressureChannel > -1)
{
sentDate.Append("<prs>");
sentDate.Append(Program._device.Pressure.ToString("0.00",System.Globalization.CultureInfo.CurrentUICulture));
sentDate.Append(";");
sentDate.Append(Program._device.DeviceSN);
}
}
// Convert the string data to byte data using ASCII encoding.
byte[] byteData = Encoding.ASCII.GetBytes(sentDate.ToString());
// Begin sending the data to the remote device.
handler.BeginSend(byteData, 0, byteData.Length, 0, new AsyncCallback(SendCallback), handler);
}
/// <summary>
/// When all data have been send, terminating the communication
/// </summary>
/// <param name="ar"></param>
private static void SendCallback(IAsyncResult ar)
{
try
{
// Retrieve the socket from the state object.
Socket handler = (Socket)ar.AsyncState;
// Complete sending the data to the remote device.
handler.EndSend(ar);
handler.Shutdown(SocketShutdown.Both);
handler.Close();
}
catch (Exception e)
{
System.Diagnostics.Trace.WriteLine(e.ToString());
}
}
}
}

View File

@@ -0,0 +1,458 @@
namespace TestoCaptureTool
{
partial class ConfigurationForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ConfigurationForm));
this.lblAirTemperature = new System.Windows.Forms.Label();
this.lblWaterTemperature = new System.Windows.Forms.Label();
this.lblHumidity = new System.Windows.Forms.Label();
this.lblPressure = new System.Windows.Forms.Label();
this.txtAirTemperature = new System.Windows.Forms.TextBox();
this.txtPressure = new System.Windows.Forms.TextBox();
this.txtHumidity = new System.Windows.Forms.TextBox();
this.txtWaterTemperature = new System.Windows.Forms.TextBox();
this.lblDeviceSN = new System.Windows.Forms.Label();
this.lblCaptureTime = new System.Windows.Forms.Label();
this.txtDeviceSN = new System.Windows.Forms.TextBox();
this.txtCaptureTime = new System.Windows.Forms.TextBox();
this.lblDeviceModel = new System.Windows.Forms.Label();
this.txtDeviceModel = new System.Windows.Forms.TextBox();
this.lblConnectionStatus = new System.Windows.Forms.Label();
this.txtConnectionStatus = new System.Windows.Forms.TextBox();
this.grbCapture = new System.Windows.Forms.GroupBox();
this.lblAutoReadingNameHeader = new System.Windows.Forms.Label();
this.lblAutoReadingPortHeader = new System.Windows.Forms.Label();
this.lblCalibrySetup = new System.Windows.Forms.Label();
this.lblAutoReadingHeader = new System.Windows.Forms.Label();
this.lblAutoReadingValue = new System.Windows.Forms.Label();
this.lblAutoReadingNameValue = new System.Windows.Forms.Label();
this.lblAutoReadingPortValue = new System.Windows.Forms.Label();
this.grbConfigureCalibry = new System.Windows.Forms.GroupBox();
this.cmbDeviceModel = new System.Windows.Forms.ComboBox();
this.lblDevice = new System.Windows.Forms.Label();
this.btnConnect = new System.Windows.Forms.Button();
this.lblComPort = new System.Windows.Forms.Label();
this.cmbCOMPort = new System.Windows.Forms.ComboBox();
this.grbConnect = new System.Windows.Forms.GroupBox();
this.cmbAirTempChannel = new System.Windows.Forms.ComboBox();
this.cmbWaterTempChannel = new System.Windows.Forms.ComboBox();
this.cmbHumdityChannel = new System.Windows.Forms.ComboBox();
this.cmbPressureChannel = new System.Windows.Forms.ComboBox();
this.lblAirTemperatureChannel = new System.Windows.Forms.Label();
this.lblWaterTemperatureChannel = new System.Windows.Forms.Label();
this.lblHumidityChannel = new System.Windows.Forms.Label();
this.lblPressureChannel = new System.Windows.Forms.Label();
this.grpConfiguration = new System.Windows.Forms.GroupBox();
this.lblInformation = new System.Windows.Forms.Label();
this.grbInformation = new System.Windows.Forms.GroupBox();
this.timRefresh = new System.Windows.Forms.Timer(this.components);
this.btnClose = new System.Windows.Forms.Button();
this.grbCapture.SuspendLayout();
this.grbConfigureCalibry.SuspendLayout();
this.grbConnect.SuspendLayout();
this.grpConfiguration.SuspendLayout();
this.grbInformation.SuspendLayout();
this.SuspendLayout();
//
// lblAirTemperature
//
resources.ApplyResources(this.lblAirTemperature, "lblAirTemperature");
this.lblAirTemperature.Name = "lblAirTemperature";
//
// lblWaterTemperature
//
resources.ApplyResources(this.lblWaterTemperature, "lblWaterTemperature");
this.lblWaterTemperature.Name = "lblWaterTemperature";
//
// lblHumidity
//
resources.ApplyResources(this.lblHumidity, "lblHumidity");
this.lblHumidity.Name = "lblHumidity";
//
// lblPressure
//
resources.ApplyResources(this.lblPressure, "lblPressure");
this.lblPressure.Name = "lblPressure";
//
// txtAirTemperature
//
this.txtAirTemperature.BackColor = System.Drawing.SystemColors.Control;
resources.ApplyResources(this.txtAirTemperature, "txtAirTemperature");
this.txtAirTemperature.Name = "txtAirTemperature";
this.txtAirTemperature.ReadOnly = true;
//
// txtPressure
//
this.txtPressure.BackColor = System.Drawing.SystemColors.Control;
resources.ApplyResources(this.txtPressure, "txtPressure");
this.txtPressure.Name = "txtPressure";
this.txtPressure.ReadOnly = true;
//
// txtHumidity
//
this.txtHumidity.BackColor = System.Drawing.SystemColors.Control;
resources.ApplyResources(this.txtHumidity, "txtHumidity");
this.txtHumidity.Name = "txtHumidity";
this.txtHumidity.ReadOnly = true;
//
// txtWaterTemperature
//
this.txtWaterTemperature.BackColor = System.Drawing.SystemColors.Control;
resources.ApplyResources(this.txtWaterTemperature, "txtWaterTemperature");
this.txtWaterTemperature.Name = "txtWaterTemperature";
this.txtWaterTemperature.ReadOnly = true;
//
// lblDeviceSN
//
resources.ApplyResources(this.lblDeviceSN, "lblDeviceSN");
this.lblDeviceSN.Name = "lblDeviceSN";
//
// lblCaptureTime
//
resources.ApplyResources(this.lblCaptureTime, "lblCaptureTime");
this.lblCaptureTime.Name = "lblCaptureTime";
//
// txtDeviceSN
//
this.txtDeviceSN.BackColor = System.Drawing.SystemColors.Control;
resources.ApplyResources(this.txtDeviceSN, "txtDeviceSN");
this.txtDeviceSN.Name = "txtDeviceSN";
this.txtDeviceSN.ReadOnly = true;
//
// txtCaptureTime
//
this.txtCaptureTime.BackColor = System.Drawing.SystemColors.Control;
resources.ApplyResources(this.txtCaptureTime, "txtCaptureTime");
this.txtCaptureTime.Name = "txtCaptureTime";
this.txtCaptureTime.ReadOnly = true;
//
// lblDeviceModel
//
resources.ApplyResources(this.lblDeviceModel, "lblDeviceModel");
this.lblDeviceModel.Name = "lblDeviceModel";
//
// txtDeviceModel
//
this.txtDeviceModel.BackColor = System.Drawing.SystemColors.Control;
resources.ApplyResources(this.txtDeviceModel, "txtDeviceModel");
this.txtDeviceModel.Name = "txtDeviceModel";
this.txtDeviceModel.ReadOnly = true;
//
// lblConnectionStatus
//
resources.ApplyResources(this.lblConnectionStatus, "lblConnectionStatus");
this.lblConnectionStatus.Name = "lblConnectionStatus";
//
// txtConnectionStatus
//
this.txtConnectionStatus.BackColor = System.Drawing.SystemColors.Control;
resources.ApplyResources(this.txtConnectionStatus, "txtConnectionStatus");
this.txtConnectionStatus.Name = "txtConnectionStatus";
this.txtConnectionStatus.ReadOnly = true;
//
// grbCapture
//
this.grbCapture.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.grbCapture.Controls.Add(this.txtConnectionStatus);
this.grbCapture.Controls.Add(this.lblConnectionStatus);
this.grbCapture.Controls.Add(this.txtDeviceModel);
this.grbCapture.Controls.Add(this.lblDeviceModel);
this.grbCapture.Controls.Add(this.txtCaptureTime);
this.grbCapture.Controls.Add(this.txtDeviceSN);
this.grbCapture.Controls.Add(this.lblCaptureTime);
this.grbCapture.Controls.Add(this.lblDeviceSN);
this.grbCapture.Controls.Add(this.txtWaterTemperature);
this.grbCapture.Controls.Add(this.txtHumidity);
this.grbCapture.Controls.Add(this.txtPressure);
this.grbCapture.Controls.Add(this.txtAirTemperature);
this.grbCapture.Controls.Add(this.lblPressure);
this.grbCapture.Controls.Add(this.lblHumidity);
this.grbCapture.Controls.Add(this.lblWaterTemperature);
this.grbCapture.Controls.Add(this.lblAirTemperature);
resources.ApplyResources(this.grbCapture, "grbCapture");
this.grbCapture.Name = "grbCapture";
this.grbCapture.TabStop = false;
//
// lblAutoReadingNameHeader
//
resources.ApplyResources(this.lblAutoReadingNameHeader, "lblAutoReadingNameHeader");
this.lblAutoReadingNameHeader.Name = "lblAutoReadingNameHeader";
//
// lblAutoReadingPortHeader
//
resources.ApplyResources(this.lblAutoReadingPortHeader, "lblAutoReadingPortHeader");
this.lblAutoReadingPortHeader.Name = "lblAutoReadingPortHeader";
//
// lblCalibrySetup
//
resources.ApplyResources(this.lblCalibrySetup, "lblCalibrySetup");
this.lblCalibrySetup.Name = "lblCalibrySetup";
//
// lblAutoReadingHeader
//
resources.ApplyResources(this.lblAutoReadingHeader, "lblAutoReadingHeader");
this.lblAutoReadingHeader.Name = "lblAutoReadingHeader";
//
// lblAutoReadingValue
//
resources.ApplyResources(this.lblAutoReadingValue, "lblAutoReadingValue");
this.lblAutoReadingValue.Name = "lblAutoReadingValue";
//
// lblAutoReadingNameValue
//
resources.ApplyResources(this.lblAutoReadingNameValue, "lblAutoReadingNameValue");
this.lblAutoReadingNameValue.Name = "lblAutoReadingNameValue";
//
// lblAutoReadingPortValue
//
resources.ApplyResources(this.lblAutoReadingPortValue, "lblAutoReadingPortValue");
this.lblAutoReadingPortValue.Name = "lblAutoReadingPortValue";
//
// grbConfigureCalibry
//
this.grbConfigureCalibry.Controls.Add(this.lblAutoReadingPortValue);
this.grbConfigureCalibry.Controls.Add(this.lblAutoReadingNameValue);
this.grbConfigureCalibry.Controls.Add(this.lblAutoReadingValue);
this.grbConfigureCalibry.Controls.Add(this.lblAutoReadingHeader);
this.grbConfigureCalibry.Controls.Add(this.lblCalibrySetup);
this.grbConfigureCalibry.Controls.Add(this.lblAutoReadingPortHeader);
this.grbConfigureCalibry.Controls.Add(this.lblAutoReadingNameHeader);
resources.ApplyResources(this.grbConfigureCalibry, "grbConfigureCalibry");
this.grbConfigureCalibry.Name = "grbConfigureCalibry";
this.grbConfigureCalibry.TabStop = false;
//
// cmbDeviceModel
//
this.cmbDeviceModel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbDeviceModel.FormattingEnabled = true;
resources.ApplyResources(this.cmbDeviceModel, "cmbDeviceModel");
this.cmbDeviceModel.Name = "cmbDeviceModel";
this.cmbDeviceModel.SelectedIndexChanged += new System.EventHandler(this.cmbDeviceModel_SelectedIndexChanged);
this.cmbDeviceModel.Click += new System.EventHandler(this.cmbDeviceModel_SelectedIndexChanged);
//
// lblDevice
//
resources.ApplyResources(this.lblDevice, "lblDevice");
this.lblDevice.Name = "lblDevice";
//
// btnConnect
//
resources.ApplyResources(this.btnConnect, "btnConnect");
this.btnConnect.Name = "btnConnect";
this.btnConnect.UseVisualStyleBackColor = true;
this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click);
//
// lblComPort
//
resources.ApplyResources(this.lblComPort, "lblComPort");
this.lblComPort.Name = "lblComPort";
//
// cmbCOMPort
//
this.cmbCOMPort.FormattingEnabled = true;
resources.ApplyResources(this.cmbCOMPort, "cmbCOMPort");
this.cmbCOMPort.Name = "cmbCOMPort";
//
// grbConnect
//
this.grbConnect.Controls.Add(this.cmbCOMPort);
this.grbConnect.Controls.Add(this.lblComPort);
this.grbConnect.Controls.Add(this.btnConnect);
this.grbConnect.Controls.Add(this.lblDevice);
this.grbConnect.Controls.Add(this.cmbDeviceModel);
resources.ApplyResources(this.grbConnect, "grbConnect");
this.grbConnect.Name = "grbConnect";
this.grbConnect.TabStop = false;
//
// cmbAirTempChannel
//
this.cmbAirTempChannel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbAirTempChannel.FormattingEnabled = true;
resources.ApplyResources(this.cmbAirTempChannel, "cmbAirTempChannel");
this.cmbAirTempChannel.Name = "cmbAirTempChannel";
this.cmbAirTempChannel.SelectedIndexChanged += new System.EventHandler(this.cmbChannel_SelectedIndexChanged);
//
// cmbWaterTempChannel
//
this.cmbWaterTempChannel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbWaterTempChannel.FormattingEnabled = true;
resources.ApplyResources(this.cmbWaterTempChannel, "cmbWaterTempChannel");
this.cmbWaterTempChannel.Name = "cmbWaterTempChannel";
this.cmbWaterTempChannel.SelectedIndexChanged += new System.EventHandler(this.cmbChannel_SelectedIndexChanged);
//
// cmbHumdityChannel
//
this.cmbHumdityChannel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbHumdityChannel.FormattingEnabled = true;
resources.ApplyResources(this.cmbHumdityChannel, "cmbHumdityChannel");
this.cmbHumdityChannel.Name = "cmbHumdityChannel";
this.cmbHumdityChannel.SelectedIndexChanged += new System.EventHandler(this.cmbChannel_SelectedIndexChanged);
//
// cmbPressureChannel
//
this.cmbPressureChannel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbPressureChannel.FormattingEnabled = true;
resources.ApplyResources(this.cmbPressureChannel, "cmbPressureChannel");
this.cmbPressureChannel.Name = "cmbPressureChannel";
this.cmbPressureChannel.SelectedIndexChanged += new System.EventHandler(this.cmbChannel_SelectedIndexChanged);
//
// lblAirTemperatureChannel
//
resources.ApplyResources(this.lblAirTemperatureChannel, "lblAirTemperatureChannel");
this.lblAirTemperatureChannel.Name = "lblAirTemperatureChannel";
//
// lblWaterTemperatureChannel
//
resources.ApplyResources(this.lblWaterTemperatureChannel, "lblWaterTemperatureChannel");
this.lblWaterTemperatureChannel.Name = "lblWaterTemperatureChannel";
//
// lblHumidityChannel
//
resources.ApplyResources(this.lblHumidityChannel, "lblHumidityChannel");
this.lblHumidityChannel.Name = "lblHumidityChannel";
//
// lblPressureChannel
//
resources.ApplyResources(this.lblPressureChannel, "lblPressureChannel");
this.lblPressureChannel.Name = "lblPressureChannel";
//
// grpConfiguration
//
this.grpConfiguration.Controls.Add(this.lblPressureChannel);
this.grpConfiguration.Controls.Add(this.lblHumidityChannel);
this.grpConfiguration.Controls.Add(this.lblWaterTemperatureChannel);
this.grpConfiguration.Controls.Add(this.lblAirTemperatureChannel);
this.grpConfiguration.Controls.Add(this.cmbPressureChannel);
this.grpConfiguration.Controls.Add(this.cmbHumdityChannel);
this.grpConfiguration.Controls.Add(this.cmbWaterTempChannel);
this.grpConfiguration.Controls.Add(this.cmbAirTempChannel);
resources.ApplyResources(this.grpConfiguration, "grpConfiguration");
this.grpConfiguration.Name = "grpConfiguration";
this.grpConfiguration.TabStop = false;
//
// lblInformation
//
resources.ApplyResources(this.lblInformation, "lblInformation");
this.lblInformation.Name = "lblInformation";
//
// grbInformation
//
this.grbInformation.Controls.Add(this.lblInformation);
resources.ApplyResources(this.grbInformation, "grbInformation");
this.grbInformation.Name = "grbInformation";
this.grbInformation.TabStop = false;
//
// timRefresh
//
this.timRefresh.Interval = 5000;
this.timRefresh.Tick += new System.EventHandler(this.timRefresh_Tick);
//
// btnClose
//
resources.ApplyResources(this.btnClose, "btnClose");
this.btnClose.Name = "btnClose";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// ConfigurationForm
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.Controls.Add(this.grbConfigureCalibry);
this.Controls.Add(this.grbCapture);
this.Controls.Add(this.grbInformation);
this.Controls.Add(this.grbConnect);
this.Controls.Add(this.grpConfiguration);
this.Controls.Add(this.btnClose);
this.Name = "ConfigurationForm";
this.Load += new System.EventHandler(this.ConfigurationForm_Load);
this.grbCapture.ResumeLayout(false);
this.grbCapture.PerformLayout();
this.grbConfigureCalibry.ResumeLayout(false);
this.grbConfigureCalibry.PerformLayout();
this.grbConnect.ResumeLayout(false);
this.grpConfiguration.ResumeLayout(false);
this.grbInformation.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Label lblAirTemperature;
private System.Windows.Forms.Label lblWaterTemperature;
private System.Windows.Forms.Label lblHumidity;
private System.Windows.Forms.Label lblPressure;
private System.Windows.Forms.TextBox txtAirTemperature;
private System.Windows.Forms.TextBox txtPressure;
private System.Windows.Forms.TextBox txtHumidity;
private System.Windows.Forms.TextBox txtWaterTemperature;
private System.Windows.Forms.Label lblDeviceSN;
private System.Windows.Forms.Label lblCaptureTime;
private System.Windows.Forms.TextBox txtDeviceSN;
private System.Windows.Forms.TextBox txtCaptureTime;
private System.Windows.Forms.Label lblDeviceModel;
private System.Windows.Forms.TextBox txtDeviceModel;
private System.Windows.Forms.Label lblConnectionStatus;
private System.Windows.Forms.TextBox txtConnectionStatus;
private System.Windows.Forms.GroupBox grbCapture;
private System.Windows.Forms.Label lblAutoReadingNameHeader;
private System.Windows.Forms.Label lblAutoReadingPortHeader;
private System.Windows.Forms.Label lblCalibrySetup;
private System.Windows.Forms.Label lblAutoReadingHeader;
private System.Windows.Forms.Label lblAutoReadingValue;
private System.Windows.Forms.Label lblAutoReadingNameValue;
private System.Windows.Forms.Label lblAutoReadingPortValue;
private System.Windows.Forms.GroupBox grbConfigureCalibry;
private System.Windows.Forms.ComboBox cmbDeviceModel;
private System.Windows.Forms.Label lblDevice;
private System.Windows.Forms.Button btnConnect;
private System.Windows.Forms.Label lblComPort;
private System.Windows.Forms.ComboBox cmbCOMPort;
private System.Windows.Forms.GroupBox grbConnect;
private System.Windows.Forms.ComboBox cmbAirTempChannel;
private System.Windows.Forms.ComboBox cmbWaterTempChannel;
private System.Windows.Forms.ComboBox cmbHumdityChannel;
private System.Windows.Forms.ComboBox cmbPressureChannel;
private System.Windows.Forms.Label lblAirTemperatureChannel;
private System.Windows.Forms.Label lblWaterTemperatureChannel;
private System.Windows.Forms.Label lblHumidityChannel;
private System.Windows.Forms.Label lblPressureChannel;
private System.Windows.Forms.GroupBox grpConfiguration;
private System.Windows.Forms.Label lblInformation;
private System.Windows.Forms.GroupBox grbInformation;
private System.Windows.Forms.Timer timRefresh;
private System.Windows.Forms.Button btnClose;
}
}

View File

@@ -0,0 +1,251 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace TestoCaptureTool
{
public partial class ConfigurationForm : Form
{
public ConfigurationForm()
{
InitializeComponent();
Program._device.ConnectionStatusChanged += new EventHandler(Device_ConnectionStatusChanged);
}
/// <summary>
/// Update the information according to the status of the device
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void Device_ConnectionStatusChanged(object sender, EventArgs e)
{
UpdateDeviceStatus();
}
/// <summary>
/// Get the environmental conditions from the device and display it to the user.
/// </summary>
private void GetValue()
{
txtAirTemperature.Text = Program._device.AirTemperature.ToString("0.00",System.Globalization.CultureInfo.CurrentUICulture);
txtWaterTemperature.Text = Program._device.WaterTemperature.ToString("0.00", System.Globalization.CultureInfo.CurrentUICulture);
txtPressure.Text = Program._device.Pressure.ToString("0.00", System.Globalization.CultureInfo.CurrentUICulture);
txtHumidity.Text = Program._device.Humidity.ToString("0.00", System.Globalization.CultureInfo.CurrentUICulture);
txtDeviceSN.Text = Program._device.DeviceSN.ToString(System.Globalization.CultureInfo.CurrentUICulture);
txtCaptureTime.Text = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString();
txtDeviceModel.Text = cmbDeviceModel.Text;
}
/// <summary>
/// Refresh the environmental conditions (automatic)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void timRefresh_Tick(object sender, EventArgs e)
{
GetValue();
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
/// <summary>
/// Fill the list of the supported devices model displayed to the user
/// Selects the current device from the list (if defined)
/// Display the device status to the user
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ConfigurationForm_Load(object sender, EventArgs e)
{
cmbCOMPort.Items.Clear();
cmbCOMPort.Items.AddRange(System.IO.Ports.SerialPort.GetPortNames());
cmbDeviceModel.Items.Add(new CaptionObject("testo 435-635-735", "testo435-635-735"));
cmbDeviceModel.DisplayMember = "Caption";
cmbDeviceModel.ValueMember = "Name";
foreach (CaptionObject item in cmbDeviceModel.Items)
{
if (item.Name == Program._device.DeviceType)
{
cmbDeviceModel.SelectedItem = item;
break;
}
}
foreach (string port in cmbCOMPort.Items)
{
if(String.Compare(port.Remove(0,3),Program._device.ComPort.ToString())==0)
{
cmbCOMPort.SelectedItem=port;
break;
}
}
UpdateDeviceStatus();
lblAutoReadingNameValue.Text = System.Net.Dns.GetHostName();
lblAutoReadingPortValue.Text = Properties.Settings.Default.NetworkPort.ToString();
}
/// <summary>
/// When the user select an other device in the list,
/// defining the selection as current model.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cmbDeviceModel_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbDeviceModel.SelectedItem != null)
{
CaptionObject selectedDevice = (CaptionObject)cmbDeviceModel.SelectedItem;
if (Program._device != null)
{
if (TestoDevice.IsUsbDevice(selectedDevice.Name))
{
cmbCOMPort.Enabled = false;
cmbCOMPort.DropDownStyle = ComboBoxStyle.DropDown;
cmbCOMPort.Text = "USB";
}
else
{
cmbCOMPort.DropDownStyle = ComboBoxStyle.DropDownList;
cmbCOMPort.Enabled = true;
cmbCOMPort.SelectedIndex = 0;
}
}
}
}
/// <summary>
/// Updating the information related to the status of the device to the user
/// </summary>
private void UpdateDeviceStatus()
{
timRefresh.Enabled = Program._device.IsConnected;
//The list of available channel is cleared and filled with the new settings.
cmbAirTempChannel.Items.Clear();
cmbWaterTempChannel.Items.Clear();
cmbPressureChannel.Items.Clear();
cmbHumdityChannel.Items.Clear();
if (Program._device.IsConnected)
{
CaptionObject channelItem = new CaptionObject(Properties.Resources.NotAvailable, "-1");
cmbAirTempChannel.Items.Add(channelItem);
cmbWaterTempChannel.Items.Add(channelItem);
cmbPressureChannel.Items.Add(channelItem);
cmbHumdityChannel.Items.Add(channelItem);
for (int channel = 0; channel < Program._device.AvailableChannelCount; channel++)
{
channelItem = new CaptionObject(String.Format(System.Globalization.CultureInfo.CurrentUICulture, Properties.Resources.channelNumber, channel + 1), channel.ToString(System.Globalization.CultureInfo.InvariantCulture));
cmbAirTempChannel.Items.Add(channelItem);
cmbWaterTempChannel.Items.Add(channelItem);
cmbPressureChannel.Items.Add(channelItem);
cmbHumdityChannel.Items.Add(channelItem);
}
//Selecting the value for each channel if already defined
cmbAirTempChannel.SelectedIndex = Program._device.AirTemperatureChannel+1;
cmbWaterTempChannel.SelectedIndex = Program._device.WaterTemperatureChannel+1;
cmbHumdityChannel.SelectedIndex = Program._device.HumidityChannel+1;
cmbPressureChannel.SelectedIndex = Program._device.PressureChannel+1;
//Displaying the current value retrieved on the device
GetValue();
txtConnectionStatus.ForeColor = Color.Green;
txtConnectionStatus.Text = Properties.Resources.deviceConnected;
}
cmbAirTempChannel.DisplayMember = "Caption";
cmbWaterTempChannel.DisplayMember = "Caption";
cmbPressureChannel.DisplayMember = "Caption";
cmbHumdityChannel.DisplayMember = "Caption";
cmbAirTempChannel.ValueMember = "Name";
cmbWaterTempChannel.ValueMember = "Name";
cmbPressureChannel.ValueMember = "Name";
cmbHumdityChannel.ValueMember = "Name";
}
/// <summary>
/// Connecting to the device with the specified model type and
/// specified COM Port (if not USB device)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnConnect_Click(object sender, EventArgs e)
{
CaptionObject selectedDevice = (CaptionObject)cmbDeviceModel.SelectedItem;
if (selectedDevice == null)
{
MessageBox.Show(Properties.Resources.selectDevice, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
Program._device.Disconnect();
Program._device.DeviceType = selectedDevice.Name;
if (!TestoDevice.IsUsbDevice(selectedDevice.Name))
{
short comPortOut;
string comPort = cmbCOMPort.Text.Remove(0, 3);
if (!short.TryParse(comPort, out comPortOut))
{
MessageBox.Show(Properties.Resources.specifyCOMPort, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
Program._device.ComPort = comPortOut;
}
TestoDevice.OperationResult result = Program._device.Connect();
if (result != TestoDevice.OperationResult.Ok)
{
txtConnectionStatus.ForeColor = Color.Red;
txtConnectionStatus.Text = TestoDevice.ErrorMessage(result);
txtAirTemperature.Text = "";
txtWaterTemperature.Text = "";
txtPressure.Text = "";
txtHumidity.Text = "";
txtDeviceSN.Text = "";
txtCaptureTime.Text = "";
MessageBox.Show(TestoDevice.ErrorMessage(result), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
}
return;
}
private void cmbChannel_SelectedIndexChanged(object sender, EventArgs e)
{
ComboBox cmbSender = (ComboBox)sender;
if (cmbSender == cmbAirTempChannel)
Program._device.AirTemperatureChannel = System.Convert.ToInt16(((CaptionObject)cmbSender.SelectedItem).Name);
if(cmbSender==cmbWaterTempChannel)
Program._device.WaterTemperatureChannel = System.Convert.ToInt16(((CaptionObject)cmbSender.SelectedItem).Name);
if(cmbSender==cmbHumdityChannel)
Program._device.HumidityChannel = System.Convert.ToInt16(((CaptionObject)cmbSender.SelectedItem).Name);
if(cmbSender==cmbPressureChannel)
Program._device.PressureChannel = System.Convert.ToInt16(((CaptionObject)cmbSender.SelectedItem).Name);
GetValue();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,137 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
[assembly: CLSCompliant(true)]
namespace TestoCaptureTool
{
class Program
{
static Communication CalibryListener;
static public TestoDevice _device;
static private string deviceConfigurationFile = System.IO.Path.Combine(Application.CommonAppDataPath, "DeviceSetting.xml");
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
//If the file exist, deserializing the configuration saved at the last shutdown.
System.Xml.Serialization.XmlSerializer serializer;
if (System.IO.File.Exists(deviceConfigurationFile))
{
serializer = new System.Xml.Serialization.XmlSerializer(typeof(TestoDevice));
System.IO.StreamReader streamReader = new System.IO.StreamReader(deviceConfigurationFile);
try
{
_device = (TestoDevice)serializer.Deserialize(streamReader);
}
catch
{
System.IO.File.Delete(deviceConfigurationFile);
}
finally
{
streamReader.Close();
streamReader.Dispose();
}
if (_device != null)
{
_device.Connect();
}
}
//If no configuration was saved or if the deserialization failed, instantiating a new object
if (_device == null)
_device = new TestoDevice();
//Starting the process to listen to calibry request
CalibryListener = new Communication();
//CalibryListener.StartListening();
CalibryListener.OpenCommunication();
System.Threading.Thread listener = new System.Threading.Thread(new System.Threading.ThreadStart(CalibryListener.StartListening));
listener.Start();
//Displaying the UI to the user
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new ConfigurationForm());
CalibryListener.StopListening();
//On shut down, aborting the listening operation and saving the configuration
listener.Interrupt();
serializer = new System.Xml.Serialization.XmlSerializer(typeof(TestoDevice));
System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(deviceConfigurationFile);
serializer.Serialize(streamWriter, _device);
streamWriter.Close();
streamWriter.Dispose();
}
internal static string AssemblyVersion
{
get
{
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}
internal static string AssemblyDescription
{
get
{
// Get all Description attributes on this assembly
object[] attributes = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(System.Reflection.AssemblyDescriptionAttribute), false);
// If there aren't any Description attributes, return an empty string
if (attributes.Length == 0)
return "";
// If there is a Description attribute, return its value
return ((System.Reflection.AssemblyDescriptionAttribute)attributes[0]).Description;
}
}
internal static string AssemblyCopyright
{
get
{
// Get all Copyright attributes on this assembly
object[] attributes = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(System.Reflection.AssemblyCopyrightAttribute), false);
// If there aren't any Copyright attributes, return an empty string
if (attributes.Length == 0)
return "";
// If there is a Copyright attribute, return its value
return ((System.Reflection.AssemblyCopyrightAttribute)attributes[0]).Copyright;
}
}
}
/// <summary>
/// Class which contains a displayed value and a value used internally
/// </summary>
class CaptionObject
{
private string _caption;
private string _name;
public CaptionObject(string Caption, string Name)
{
_caption = Caption;
_name = Name;
}
public string Caption
{
get { return _caption; }
}
public string Name
{
get { return _name; }
}
}
}

View File

@@ -0,0 +1,32 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d5c7c598-fe09-4ee1-bcc2-d046cbb55f89")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,108 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.832
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TestoCaptureTool.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TestoCaptureTool.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to Channel {0}.
/// </summary>
internal static string channelNumber {
get {
return ResourceManager.GetString("channelNumber", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Device is connected.
/// </summary>
internal static string deviceConnected {
get {
return ResourceManager.GetString("deviceConnected", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Not available on the device.
/// </summary>
internal static string NotAvailable {
get {
return ResourceManager.GetString("NotAvailable", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Select a device in the list.
/// </summary>
internal static string selectDevice {
get {
return ResourceManager.GetString("selectDevice", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to COM Port is invalid. Please provide a valid COM Port number..
/// </summary>
internal static string specifyCOMPort {
get {
return ResourceManager.GetString("specifyCOMPort", resourceCulture);
}
}
}
}

View File

@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="channelNumber" xml:space="preserve">
<value>Channel {0}</value>
</data>
<data name="deviceConnected" xml:space="preserve">
<value>Device is connected</value>
</data>
<data name="NotAvailable" xml:space="preserve">
<value>Not available on the device</value>
</data>
<data name="selectDevice" xml:space="preserve">
<value>Select a device in the list</value>
</data>
<data name="specifyCOMPort" xml:space="preserve">
<value>COM Port is invalid. Please provide a valid COM Port number.</value>
</data>
</root>

View File

@@ -0,0 +1,35 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.832
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TestoCaptureTool.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("50907")]
public int NetworkPort {
get {
return ((int)(this["NetworkPort"]));
}
}
}
}

View File

@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TestoCaptureTool.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="NetworkPort" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">50907</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -0,0 +1,28 @@
namespace TestoCaptureTool.Properties {
// This class allows you to handle specific events on the settings class:
// The SettingChanging event is raised before a setting's value is changed.
// The PropertyChanged event is raised after a setting's value is changed.
// The SettingsLoaded event is raised after the setting values are loaded.
// The SettingsSaving event is raised before the setting values are saved.
internal sealed partial class Settings {
public Settings() {
// // To add event handlers for saving and changing settings, uncomment the lines below:
//
// this.SettingChanging += this.SettingChangingEventHandler;
//
// this.SettingsSaving += this.SettingsSavingEventHandler;
//
}
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
// Add code to handle the SettingChangingEvent event here.
}
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
// Add code to handle the SettingsSaving event here.
}
}
}

View File

@@ -0,0 +1,488 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.Xml;
namespace TestoCaptureTool
{
/// <summary>
/// This class provide the communication functionality with a testo device.
/// </summary>
public class TestoDevice : IDisposable
{
public event EventHandler ConnectionStatusChanged;
public enum OperationResult
{
Ok = 0,
DeviceTypeNotSpecified,
DeviceTypeNotSupported,
ComPortNotSpecified,
DeviceNotFound,
DeviceNotResponding,
DriverNotInstalled
}
Tcddka.tcddk _testoDevice;
short _airTemperatureChannel = -1;
short _waterTemperatureChannel = -1;
short _pressureChannel = -1;
short _humidityChannel = -1;
short _availableChannelCount = -1;
int _deviceSN;
int _timeOut;
string _deviceType;
short _comPort;
bool _deviceConnected;
~TestoDevice()
{
Dispose(false);
}
public static string ErrorMessage(OperationResult result)
{
switch(result)
{
case OperationResult.ComPortNotSpecified: return "COM Port not specified";
case OperationResult.DeviceNotFound: return "Device not found";
case OperationResult.DeviceNotResponding: return "Device is not responding";
case OperationResult.DeviceTypeNotSpecified: return "Device type is not specified";
case OperationResult.DeviceTypeNotSupported: return "Device type is not supported";
case OperationResult.DriverNotInstalled: return "Driver is not installed";
default: return result.ToString();
}
}
/// <summary>
/// Open a connection with a testo device using a serial port.
/// If the device is an USB device, the correct function will be called.
/// </summary>
/// <param name="COMPort">Port number where the device is connected</param>
/// <returns>Operation result</returns>
public OperationResult Connect(short COMPort)
{
if (_deviceConnected)
return OperationResult.Ok;
if (TestoDevice.IsUsbDevice(_deviceType))
return this.Connect();
_comPort = COMPort;
if (_comPort == 0)
throw new InvalidOperationException("Specified COM Port is invalid");
try
{
_testoDevice = new Tcddka.tcddk();
if (_testoDevice.Init(_comPort, _deviceType, _timeOut))
{
_deviceConnected = true;
if (ConnectionStatusChanged != null)
ConnectionStatusChanged(this, new EventArgs());
}
}
catch (System.Runtime.InteropServices.COMException)
{
return OperationResult.DeviceNotResponding;
}
return OperationResult.Ok;
}
/// <summary>
/// Open a connection with a testo device using an USB connection.
/// If the device uses a serial port, the correct function will be called.
/// </summary>
/// <returns>Operation result</returns>
public OperationResult Connect()
{
if (String.IsNullOrEmpty(_deviceType))
return OperationResult.DeviceTypeNotSpecified;
if (!TestoDevice.IsUsbDevice(_deviceType))
return this.Connect(_comPort);
//get a reference to the interface for USB devices
Tcddka.tcusbserials connectedDevices=null;
try
{
connectedDevices = new Tcddka.tcusbserials();
}
catch
{
if (connectedDevices == null)
return OperationResult.DriverNotInstalled;
}
//Get a reference to a specific device type (e.g Testo 435)
try
{
connectedDevices.Init(_deviceType);
}
catch (System.Runtime.InteropServices.COMException)
{
_deviceConnected = false;
return OperationResult.DeviceNotFound;
}
//If a device was found, configure it.
//This version supports only 1 device. The first device found will be used.
if (connectedDevices.Count > 0)
{
System.Collections.IEnumerator testoEnum = (System.Collections.IEnumerator)connectedDevices._NewEnum;
while (testoEnum.MoveNext())
{
//Getting the device Serial number
int deviceSN = 0;
if (Int32.TryParse(testoEnum.Current.ToString(), out deviceSN))
{
//Get a reference to the device.
_testoDevice = new Tcddka.tcddk();
try
{
//Initialize the communication between the computer and the device.
_testoDevice.InitSerial(deviceSN, _deviceType, _timeOut);
_availableChannelCount = _testoDevice.NumCols;
int.TryParse(_testoDevice.Ident, out _deviceSN);
_deviceConnected = true;
//trying to configure the channel.
//The channel configuration is based on the unit returned by each channel.
//It is assumed that the water temperature is colder than the air temperature.
for (short channelNumber = 0; channelNumber < _availableChannelCount; channelNumber++)
{
string channelUnit = _testoDevice.get_Unit(channelNumber);
if (string.Compare(channelUnit, "<22>C") == 0 || string.Compare(channelUnit, "<22>F") == 0)
{
if (this.AirTemperatureChannel == -1)
{
this.AirTemperatureChannel = channelNumber;
if (this.WaterTemperatureChannel == -1)
{
this.WaterTemperatureChannel = channelNumber;
}
else
{
double temperature1 = _testoDevice.get_RecentVal(this.AirTemperatureChannel);
double temperature2 = _testoDevice.get_RecentVal(this.WaterTemperatureChannel);
if (temperature1 < temperature2)
{
this.AirTemperatureChannel = this.WaterTemperatureChannel;
this.WaterTemperatureChannel = channelNumber;
}
}
}
else
{
if (this.WaterTemperatureChannel == -1)
{
this.WaterTemperatureChannel = channelNumber;
}
double temperature1 = _testoDevice.get_RecentVal(this.AirTemperatureChannel);
double temperature2 = _testoDevice.get_RecentVal(channelNumber);
if (temperature1 < temperature2)
{
this.WaterTemperatureChannel = this.AirTemperatureChannel;
this.AirTemperatureChannel = channelNumber;
}
else
{
this.WaterTemperatureChannel = channelNumber;
}
}
}
else if (string.Compare(channelUnit, "hPa") == 0 || string.Compare(channelUnit, "kPa") == 0 || string.Compare(channelUnit, "inW") == 0 || string.Compare(channelUnit, "mbar") == 0 || string.Compare(channelUnit, "Pa") == 0)
{
if (this.PressureChannel == -1)
this.PressureChannel = channelNumber;
}
else if (string.Compare(channelUnit, "%rH") == 0)
{
if (this.HumidityChannel == -1)
this.HumidityChannel = channelNumber;
}
}
if (ConnectionStatusChanged != null)
ConnectionStatusChanged(this, new EventArgs());
break;
}
catch (System.Runtime.InteropServices.COMException)
{
return OperationResult.DeviceNotResponding;
}
}
}
}
else
{
return OperationResult.DeviceNotFound;
}
return OperationResult.Ok;
}
/// <summary>
/// Close the connection with the device.
/// </summary>
public void Disconnect()
{
if (!_deviceConnected)
return;
Dispose(true);
_deviceConnected = false;
if (ConnectionStatusChanged != null)
ConnectionStatusChanged(this, new EventArgs());
}
public bool IsConnected
{
get { return _deviceConnected; }
}
static public bool IsUsbDevice (string deviceType)
{
if (string.Compare(deviceType, "testo435-635-735", true, System.Globalization.CultureInfo.InvariantCulture) == 0)
return true;
return false;
}
public short ComPort
{
get { return _comPort; }
set { _comPort = value; }
}
public string DeviceType
{
get { return _deviceType; }
set
{
if (_deviceConnected)
Disconnect();
_deviceType = value;
switch (_deviceType)
{
case "testostor175":
_timeOut = 7000;
_deviceType = DeviceType;
break;
case "testostor171":
_timeOut = 7000;
_deviceType = DeviceType;
break;
case "testo400-650-950":
_timeOut = 30000;
_deviceType = DeviceType;
break;
case "testo445-645-945-946-545":
_timeOut = 7000;
_deviceType = DeviceType;
break;
case "testo454-2000":
_timeOut = 38000;
_deviceType = DeviceType;
break;
case "testo175-177":
_timeOut = 7000;
_deviceType = DeviceType;
break;
case "testo174":
_timeOut = 12000;
_deviceType = DeviceType;
break;
case "testo300-M-XL":
_timeOut = 7000;
_deviceType = DeviceType;
break;
case "testo435-635-735":
_deviceType = DeviceType;
_timeOut = 7000;
break;
default:
_deviceType = "";
break;
}
}
}
public int AvailableChannelCount
{
get { return _availableChannelCount; }
}
/// <summary>
/// Retrieve the Air temperature. The value is in <20>C.
/// If the device provides the temperature in <20>F, it will be converted to <20>C
/// </summary>
public double AirTemperature
{
get
{
if (!_deviceConnected)
return 0;
_testoDevice.Get();
if (_availableChannelCount > _airTemperatureChannel && _airTemperatureChannel > -1)
{
double temperature = _testoDevice.get_RecentVal(_airTemperatureChannel);
string unit = _testoDevice.get_Unit(_airTemperatureChannel);
if (string.Compare(unit, "<22>C") == 0)
return temperature;
else if (string.Compare(unit, "<22>F") == 0)
return (temperature-32)/1.8;
else
return temperature;
}
return 0;
}
}
/// <summary>
/// Retrieve the Water temperature. The value is in <20>C.
/// If the device provides the temperature in <20>F, it will be converted to <20>C
/// </summary>
public double WaterTemperature
{
get
{
if (!_deviceConnected)
return 0;
if (_availableChannelCount > _waterTemperatureChannel && _waterTemperatureChannel > -1)
{
double temperature = _testoDevice.get_RecentVal(_waterTemperatureChannel);
string unit = _testoDevice.get_Unit(_waterTemperatureChannel);
if (string.Compare(unit, "<22>C") == 0)
return temperature;
else if (string.Compare(unit, "<22>F") == 0)
return (temperature - 32) / 1.8;
else
return temperature;
}
return 0;
}
}
/// <summary>
/// Retrieve the Pressure. The value is in kPa.
/// If the device provides the temperature in hPa, mbar or Pa, it will be converted to kPa
/// </summary>
public double Pressure
{
get
{
if (!_deviceConnected)
return 0;
if (_availableChannelCount > _pressureChannel & _pressureChannel > -1)
{
double pressure = _testoDevice.get_RecentVal(_pressureChannel);
string unit = _testoDevice.get_Unit(_pressureChannel);
if (string.Compare(unit, "hPa") == 0)
return pressure / 10;
else if (string.Compare(unit, "kPa") == 0)
return pressure;
else if (string.Compare(unit, "inW") == 0)
return pressure / (10 / 1013);
else if (string.Compare(unit, "mbar") == 0)
return pressure / 10;
else if (string.Compare(unit, "Pa") == 0)
return pressure / 1000;
else
return pressure;
}
return 0;
}
}
/// <summary>
/// Retrieve the Humidity. The value is in %rH.
/// </summary>
public double Humidity
{
get
{
if (!_deviceConnected)
return 0;
if (_availableChannelCount > _humidityChannel && _humidityChannel > -1)
return _testoDevice.get_RecentVal(_humidityChannel);
return 0;
}
}
public int DeviceSN
{
get { return _deviceSN; }
}
public short AirTemperatureChannel
{
get { return _airTemperatureChannel; }
set { _airTemperatureChannel = value; }
}
public short WaterTemperatureChannel
{
get { return _waterTemperatureChannel; }
set { _waterTemperatureChannel = value; }
}
public short PressureChannel
{
get { return _pressureChannel; }
set { _pressureChannel = value; }
}
public short HumidityChannel
{
get { return _humidityChannel; }
set { _humidityChannel = value; }
}
#region IDisposable Members
public void Dispose()
{
Dispose(true);
}
private void Dispose(bool disposing)
{
if (disposing)
{
}
if (_testoDevice != null)
System.Runtime.InteropServices.Marshal.ReleaseComObject(_testoDevice);
_testoDevice = null;
GC.SuppressFinalize(this);
}
#endregion
}
}

View File

@@ -0,0 +1,140 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AA47E4A9-0625-49FB-ABC2-2E90FB34B471}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TestoCaptureTool</RootNamespace>
<AssemblyName>TestoCapture</AssemblyName>
<StartupObject>TestoCaptureTool.Program</StartupObject>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<ManifestCertificateThumbprint>5B4B94893678DB9BDE24EC0F0BD2AFC06B3DE386</ManifestCertificateThumbprint>
<ManifestKeyFile>TestoCapture_TemporaryKey.pfx</ManifestKeyFile>
<GenerateManifests>false</GenerateManifests>
<TargetZone>LocalIntranet</TargetZone>
<SignManifests>false</SignManifests>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationVersion>1.0.0.1</ApplicationVersion>
<BootstrapperEnabled>true</BootstrapperEnabled>
<ApplicationIcon>
</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Communication.cs" />
<Compile Include="ConfigurationForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ConfigurationForm.Designer.cs">
<DependentUpon>ConfigurationForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="Settings.cs" />
<Compile Include="Testo435.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ConfigurationForm.resx">
<SubType>Designer</SubType>
<DependentUpon>ConfigurationForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<SubType>Designer</SubType>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<COMReference Include="Tcddka">
<Guid>{933CB583-B37E-11D2-B9E5-0000C0A215C3}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>2</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
</ItemGroup>
<ItemGroup>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Resources\capture_header_image.png" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
<Visible>False</Visible>
<ProductName>.NET Framework 2.0</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\DataSources\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="TestoCaptureTool.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<TestoCaptureTool.Properties.Settings>
<setting name="NetworkPort" serializeAs="String">
<value>50907</value>
</setting>
</TestoCaptureTool.Properties.Settings>
</applicationSettings>
</configuration>

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="TestoCaptureTool.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<TestoCaptureTool.Properties.Settings>
<setting name="NetworkPort" serializeAs="String">
<value>50907</value>
</setting>
</TestoCaptureTool.Properties.Settings>
</applicationSettings>
</configuration>

Some files were not shown because too many files have changed in this diff Show More