public static UploadConfig GetUploadConfig(string arduinoSoftwareRoorDir, string tempPath, string boardName, CommunicationTypeEnum comType) { var board = getBoards(arduinoSoftwareRoorDir).Where(p => p.Name == boardName).Single(); return new UploadConfig(arduinoSoftwareRoorDir, tempPath, board) { Force = true, VerboseOutput = true, Communication = comType, }; }
/// <summary> /// creates a new CommunicationType /// </summary> /// <param name="type"></param> /// <returns></returns> public static int CreateCommunicationType(CommunicationTypeEnum type) { try { var dc = new ManagementContext(); CommunicationType com = new CommunicationType(); com.Type = type.ToString(); dc.CommunicationType.Add(com); dc.SaveChanges(); return com.CommunicationTypeId; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return 0; }
/// <summary> /// Set the data dictionary defined parameters to their default values. /// </summary> private static void SetToDefault() { // -------------------- // Function Flags // . // . // . // Bit 3 - Not Used. // Bit 2 - Not Used. // Bit 1 - ShowLogName - Flag to specify whether the event log name field is to be shown when saved event logs are displayed. True, if the // log name is to be displayed; otherwise, false. // Bit 0 - Use4DigitYearCode - Flag to specify whether the project VCU uses a 2 or 4 digit year code. True, if the project uses a 4 digit year code; // otherwise, false. // // -------------------- m_FunctionFlags = 0; m_ShowLogName = false; m_Use4DigitYearCode = false; // -------------------- // Recorded Watch Data // -------------------- m_WatchSize = DefaultWatchSize; // -------------------- // Fault Log // -------------------- m_WatchSizeFaultLog = DefaultWatchSizeFaultLog; m_SupportsMultipleDataStreamTypes = false; // -------------------- // Project Information // -------------------- m_ProjectInformation = new DataDictionaryInformation_t(); m_ProjectInformation.DataDictionaryName = Resources.TextNotAvailable; m_ProjectInformation.ProjectIdentifier = string.Empty; m_ProjectInformation.Version = Resources.TextNotAvailable; m_ProjectInformation.DataDictionaryBuilderVersion = Resources.TextNotAvailable; m_ProjectInformation.WatchIdentifierCount = 0; // ---------------------- // WibuBox Parameters // ---------------------- m_WibuBox.FirmCode = 0; m_WibuBox.UserCode = 0; m_WibuBox.SlotId = 0; m_WibuBox.PortId = DefaultWibuBoxPortId; // ---------------------- // Application Data Path // ---------------------- m_PathPTUApplicationData = Resources.PathUseDefault; // -------- // Security // -------- m_SecurityConfiguration = new SecurityConfiguration_t(); m_SecurityConfiguration.DescriptionLevel0 = m_DefaultDescriptionLevel0; m_SecurityConfiguration.DescriptionLevel1 = m_DefaultDescriptionLevel1; m_SecurityConfiguration.DescriptionLevel2 = m_DefaultDescriptionLevel2; m_SecurityConfiguration.DescriptionLevel3 = m_DefaultDescriptionLevel3; m_SecurityConfiguration.SecurityLevelBase = DefaultSecurityLevelBase; m_SecurityConfiguration.SecurityLevelHighest = DefaultSecurityLevelHighest; // ---------------------- // Communication Variables // ---------------------- m_URIList = new List<String>(); m_CommunicationType = CommunicationTypeEnum.TCPIP; }
/// <summary> /// Initializes the class properties to the parameter values contained within the specified configuration file. If any configuration file /// parameters are invalid all properties associated with the table to which the parameter belongs will be left at their default values. /// </summary> /// <param name="dataDictionary">The <c>DataSet</c> corresponding to the current data dictionary.</param> public static void Initialize(DataDictionary dataDictionary) { // Set the data dictionary defined properties to their default values. SetToDefault(); // Now overlay the values defined in the data dictionary. If an exception is thrown the properties will be left in their default state. // -------------------- // Function Flags // -------------------- try { m_FunctionFlags = dataDictionary.CONFIGUREPTU[0].FunctionFlags; m_Use4DigitYearCode = ((m_FunctionFlags & CommonConstants.MaskBit0) == CommonConstants.MaskBit0) ? true : false; m_ShowLogName = ((m_FunctionFlags & CommonConstants.MaskBit1) == CommonConstants.MaskBit1) ? true : false; m_GenerateCSV = ((m_FunctionFlags & CommonConstants.MaskBit2) == CommonConstants.MaskBit2) ? true : false; m_EnableSTCommWatchdog = ((m_FunctionFlags & CommonConstants.MaskBit3) == CommonConstants.MaskBit3) ? true : false; } catch (Exception) { // Use the default values set up by the static constructor instead. } // -------------------- // Recorded Watch Data // -------------------- try { m_WatchSize = dataDictionary.CONFIGUREPTU[0].WatchSize; } catch (System.EntryPointNotFoundException) { MessageBox.Show(Resources.MBTSetWatchSizeNotSupported, Resources.MBCaptionWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (Exception) { // Use the default values set up by the static constructor instead. } // -------------------- // Fault Log WatchSize // -------------------- try { // Scan the number of watch variables that are recorded by each event log and determine the maximum. short watchVariablesMax = 0; short watchVariablesPrev = 0; short watchVariableCurrent; bool firstPass = true; m_SupportsMultipleDataStreamTypes = false; for (short recordIndex = 0; recordIndex < dataDictionary.LOGS.Count; recordIndex++) { watchVariableCurrent = dataDictionary.DataStreamTypes[dataDictionary.LOGS[recordIndex].DataStreamTypeIdentifier].WatchVariablesMax; if (firstPass == true) { watchVariablesMax = watchVariableCurrent; watchVariablesPrev = watchVariableCurrent; firstPass = false; } else { if (watchVariableCurrent > watchVariablesMax) { watchVariablesMax = watchVariableCurrent; } if (watchVariableCurrent != watchVariablesPrev) { m_SupportsMultipleDataStreamTypes = true; } } } m_WatchSizeFaultLog = watchVariablesMax; } catch (Exception) { // Use the default values set up by the static constructor instead. } // -------------------- // Project Information // -------------------- try { m_ProjectInformation.DataDictionaryName = dataDictionary.FILEINFO[0].DDNAME; m_ProjectInformation.ProjectIdentifier = dataDictionary.FILEINFO[0].PROJECTSTRING; m_ProjectInformation.Version = dataDictionary.FILEINFO[0].VERSION; m_ProjectInformation.DataDictionaryBuilderVersion = dataDictionary.FILEINFO[0].DDBVersion; m_ProjectInformation.WatchIdentifierCount = dataDictionary.FILEINFO[0].NUMOFVARS; } catch (Exception) { // Use the default values set up by the static constructor instead. } // ---------------------- // WibuBox Parameters // ---------------------- try { m_WibuBox.FirmCode = dataDictionary.CONFIGUREPTU[0].FIRMCODE; m_WibuBox.UserCode = dataDictionary.CONFIGUREPTU[0].USERCODE; m_WibuBox.SlotId = dataDictionary.CONFIGUREPTU[0].SLOTID; m_WibuBox.PortId = dataDictionary.CONFIGUREPTU[0].PORTID; } catch (Exception) { // Use the default values set up by the static constructor instead. } // ---------------------- // Application Data Path // ---------------------- try { m_PathPTUApplicationData = dataDictionary.CONFIGUREPTU[0].ApplicationDataPath; } catch (Exception) { // Use the default values set up by the static constructor instead. } // -------- // Security // -------- try { m_SecurityConfiguration.DescriptionLevel0 = dataDictionary.Security[0].DescriptionLevel0; m_SecurityConfiguration.DescriptionLevel1 = dataDictionary.Security[0].DescriptionLevel1; m_SecurityConfiguration.DescriptionLevel2 = dataDictionary.Security[0].DescriptionLevel2; m_SecurityConfiguration.DescriptionLevel3 = dataDictionary.Security[0].DescriptionLevel3; m_SecurityConfiguration.SecurityLevelBase = (SecurityLevel)dataDictionary.Security[0].SecurityLevelBase; m_SecurityConfiguration.SecurityLevelHighest = (SecurityLevel)dataDictionary.Security[0].SecurityLevelHighest; } catch (Exception) { // Use the default values set up by the static constructor instead. } // ---------------------- // Communication Variables // ---------------------- try { m_CommunicationType = (CommunicationTypeEnum)dataDictionary.CONFIGUREPTU[0].CommunicationType; } catch (Exception) { // Use the default values set up by the static constructor instead. } try { m_URIList = new List <string>(dataDictionary.URI.Count); foreach (System.Data.DataRow dataRow in dataDictionary.URI.Rows) { string URI = (string)dataRow.ItemArray[1]; if (URI.Length > 0) { m_URIList.Add(URI); } } } catch (Exception) { // Use the default values set up by the static constructor instead. } }
/// <summary> /// Set the data dictionary defined parameters to their default values. /// </summary> private static void SetToDefault() { // -------------------- // Function Flags // . // . // . // Bit 3 - EnableSTCommWatchdog - If set, a Self Test comm watchdog is enabled. // Bit 2 - GenerateCSV - generate CSV event log file when saving logs. // Bit 1 - ShowLogName - Flag to specify whether the event log name field is to be shown when saved event logs are displayed. True, if the // log name is to be displayed; otherwise, false. // Bit 0 - Use4DigitYearCode - Flag to specify whether the project VCU uses a 2 or 4 digit year code. True, if the project uses a 4 digit year code; // otherwise, false. // // -------------------- m_FunctionFlags = 0; m_GenerateCSV = false; m_ShowLogName = false; m_Use4DigitYearCode = false; m_EnableSTCommWatchdog = false; // -------------------- // Recorded Watch Data // -------------------- m_WatchSize = DefaultWatchSize; // -------------------- // Fault Log // -------------------- m_WatchSizeFaultLog = DefaultWatchSizeFaultLog; m_SupportsMultipleDataStreamTypes = false; // -------------------- // Project Information // -------------------- m_ProjectInformation = new DataDictionaryInformation_t(); m_ProjectInformation.DataDictionaryName = Resources.TextNotAvailable; m_ProjectInformation.ProjectIdentifier = string.Empty; m_ProjectInformation.Version = Resources.TextNotAvailable; m_ProjectInformation.DataDictionaryBuilderVersion = Resources.TextNotAvailable; m_ProjectInformation.WatchIdentifierCount = 0; // ---------------------- // WibuBox Parameters // ---------------------- m_WibuBox.FirmCode = 0; m_WibuBox.UserCode = 0; m_WibuBox.SlotId = 0; m_WibuBox.PortId = DefaultWibuBoxPortId; // ---------------------- // Application Data Path // ---------------------- m_PathPTUApplicationData = Resources.PathUseDefault; // -------- // Security // -------- m_SecurityConfiguration = new SecurityConfiguration_t(); m_SecurityConfiguration.DescriptionLevel0 = m_DefaultDescriptionLevel0; m_SecurityConfiguration.DescriptionLevel1 = m_DefaultDescriptionLevel1; m_SecurityConfiguration.DescriptionLevel2 = m_DefaultDescriptionLevel2; m_SecurityConfiguration.DescriptionLevel3 = m_DefaultDescriptionLevel3; m_SecurityConfiguration.SecurityLevelBase = DefaultSecurityLevelBase; m_SecurityConfiguration.SecurityLevelHighest = DefaultSecurityLevelHighest; // ---------------------- // Communication Variables // ---------------------- m_URIList = new List <String>(); m_CommunicationType = CommunicationTypeEnum.RS232; }
/// <summary> /// Initializes the class properties to the parameter values contained within the specified configuration file. If any configuration file /// parameters are invalid all properties associated with the table to which the parameter belongs will be left at their default values. /// </summary> /// <param name="dataDictionary">The <c>DataSet</c> corresponding to the current data dictionary.</param> public static void Initialize(DataDictionary dataDictionary) { // Set the data dictionary defined properties to their default values. SetToDefault(); // Now overlay the values defined in the data dictionary. If an exception is thrown the properties will be left in their default state. // -------------------- // Function Flags // -------------------- try { m_FunctionFlags = dataDictionary.CONFIGUREPTU[0].FunctionFlags; m_Use4DigitYearCode = ((m_FunctionFlags & CommonConstants.MaskBit0) == CommonConstants.MaskBit0) ? true : false; m_ShowLogName = ((m_FunctionFlags & CommonConstants.MaskBit1) == CommonConstants.MaskBit1) ? true : false; } catch (Exception) { // Use the default values set up by the static constructor instead. } // -------------------- // Recorded Watch Data // -------------------- try { m_WatchSize = dataDictionary.CONFIGUREPTU[0].WatchSize; } catch (System.EntryPointNotFoundException) { MessageBox.Show(Resources.MBTSetWatchSizeNotSupported, Resources.MBCaptionWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (Exception) { // Use the default values set up by the static constructor instead. } // -------------------- // Fault Log WatchSize // -------------------- try { // Scan the number of watch variables that are recorded by each event log and determine the maximum. short watchVariablesMax = 0; short watchVariablesPrev = 0; short watchVariableCurrent; bool firstPass = true; m_SupportsMultipleDataStreamTypes = false; for (short recordIndex = 0; recordIndex < dataDictionary.LOGS.Count; recordIndex++) { watchVariableCurrent = dataDictionary.DataStreamTypes[dataDictionary.LOGS[recordIndex].DataStreamTypeIdentifier].WatchVariablesMax; if (firstPass == true) { watchVariablesMax = watchVariableCurrent; watchVariablesPrev = watchVariableCurrent; firstPass = false; } else { if (watchVariableCurrent > watchVariablesMax) { watchVariablesMax = watchVariableCurrent; } if (watchVariableCurrent != watchVariablesPrev) { m_SupportsMultipleDataStreamTypes = true; } } } m_WatchSizeFaultLog = watchVariablesMax; } catch (Exception) { // Use the default values set up by the static constructor instead. } // -------------------- // Project Information // -------------------- try { m_ProjectInformation.DataDictionaryName = dataDictionary.FILEINFO[0].DDNAME; m_ProjectInformation.ProjectIdentifier = dataDictionary.FILEINFO[0].PROJECTSTRING; m_ProjectInformation.Version = dataDictionary.FILEINFO[0].VERSION; m_ProjectInformation.DataDictionaryBuilderVersion = dataDictionary.FILEINFO[0].DDBVersion; m_ProjectInformation.WatchIdentifierCount = dataDictionary.FILEINFO[0].NUMOFVARS; } catch (Exception) { // Use the default values set up by the static constructor instead. } // ---------------------- // WibuBox Parameters // ---------------------- try { m_WibuBox.FirmCode = dataDictionary.CONFIGUREPTU[0].FIRMCODE; m_WibuBox.UserCode = dataDictionary.CONFIGUREPTU[0].USERCODE; m_WibuBox.SlotId = dataDictionary.CONFIGUREPTU[0].SLOTID; m_WibuBox.PortId = dataDictionary.CONFIGUREPTU[0].PORTID; } catch(Exception) { // Use the default values set up by the static constructor instead. } // ---------------------- // Application Data Path // ---------------------- try { m_PathPTUApplicationData = dataDictionary.CONFIGUREPTU[0].ApplicationDataPath; } catch (Exception) { // Use the default values set up by the static constructor instead. } // -------- // Security // -------- try { m_SecurityConfiguration.DescriptionLevel0 = dataDictionary.Security[0].DescriptionLevel0; m_SecurityConfiguration.DescriptionLevel1 = dataDictionary.Security[0].DescriptionLevel1; m_SecurityConfiguration.DescriptionLevel2 = dataDictionary.Security[0].DescriptionLevel2; m_SecurityConfiguration.DescriptionLevel3 = dataDictionary.Security[0].DescriptionLevel3; m_SecurityConfiguration.SecurityLevelBase = (SecurityLevel)dataDictionary.Security[0].SecurityLevelBase; m_SecurityConfiguration.SecurityLevelHighest = (SecurityLevel)dataDictionary.Security[0].SecurityLevelHighest; } catch (Exception) { // Use the default values set up by the static constructor instead. } // ---------------------- // Communication Variables // ---------------------- try { m_CommunicationType = (CommunicationTypeEnum)dataDictionary.CONFIGUREPTU[0].CommunicationType; } catch (Exception) { // Use the default values set up by the static constructor instead. } try { m_URIList = new List<string>(dataDictionary.URI.Count); foreach (System.Data.DataRow dataRow in dataDictionary.URI.Rows) { string URI = (string)dataRow.ItemArray[1]; if (URI.Length > 0) { m_URIList.Add(URI); } } } catch (Exception) { // Use the default values set up by the static constructor instead. } }
public static UploadConfig GetUploadConfig(string arduinoSoftwareRoorDir, string tempPath, string boardName, CommunicationTypeEnum comType) { var board = getBoards(arduinoSoftwareRoorDir).Where(p => p.Name == boardName).Single(); return(new UploadConfig(arduinoSoftwareRoorDir, tempPath, board) { Force = true, VerboseOutput = true, Communication = comType, }); }