}//end MIFFileCollection /// <summary> /// Method is used to refresh the collection of MIF's /// </summary> /// <remarks> /// Revision History /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 06/06/07 RDB N/A Created /// 07/27/07 MAH Removed filters based on file extensions - all files will be examined /// </remarks> public void Refresh() { //Local variables MIF objMIF; DirectoryInfo objDir; //clear the current collection InnerList.Clear(); //Create a directory info object based on the directory objDir = new DirectoryInfo(m_strDirectory); //Go through the list of mif files in the directory foreach (FileInfo objFile in objDir.GetFiles()) { if (MIF.IsMeterImageFile(objFile.FullName)) { //Create a new MIF from the File info object objMIF = new MIF(objFile.FullName); //Add the MIF to the collection InnerList.Add(objMIF); } } //Sort list IComparer myComparer = new MIFComparer(); InnerList.Sort(myComparer); }//end Refresh
public void Init() { string apiKey = File.ReadAllText("ApiKey.txt"); MIF.SetConfigForTesting(new TestConfig { LeverApiKey = apiKey }); }
/// <summary> /// This contructor effectively restricts totalization to MIF files only /// </summary> /// <remarks> /// Revision History /// MM/DD/YY Who Version Issue# Description /// -------- --- ------- ------------- ----------------------------------- /// 10/21/08 MAH 9.50 Added logic to use multipliers for /// primary values /// </remarks> public TotalizationDataSource(MIF mif) : base(mif) { // We always totalize energy data not pulses, so make sure that // the load profile data object contains energy values if (LPData != null) { LPData = LPData.EnergyData; } // Energy data by itself is not good enough. Because of the possibility of // differences in transformers, we need to totalize primary values not secondary // values. So we need to get the correct multiplier for each channel if (LPData != null) { double dblTransformerRatio = mif.TransformerRatio; double dblCTRatio = mif.CTRatio; double dblVTRatio = mif.VTRatio; for (int nChannel = 0; nChannel < LPData.Channels.Count; nChannel++) { String strQtyName = LPData.Channels[nChannel].ChannelName; if (strQtyName.Contains("Wh") || strQtyName.Contains("VAh") || strQtyName.Contains("varh") || strQtyName.Contains("Qh")) { LPData.ChangeChannelMultiplier(nChannel, (float)dblTransformerRatio); } else if (strQtyName.Contains("Ah")) { LPData.ChangeChannelMultiplier(nChannel, (float)dblCTRatio); } else if (strQtyName.Contains("A^2h")) { LPData.ChangeChannelMultiplier(nChannel, (float)(dblCTRatio * dblCTRatio)); } else if (strQtyName.Contains("Vh")) { LPData.ChangeChannelMultiplier(nChannel, (float)dblVTRatio); } else if (strQtyName.Contains("V^2h")) { LPData.ChangeChannelMultiplier(nChannel, (float)(dblVTRatio * dblVTRatio)); } else // don't make assumptions - do not try to convert to primary // this could be a PF or input channel { LPData.ChangeChannelMultiplier(nChannel, (float)1.0); } } } }
public void Init() { NamelyApiTestConfig config = new NamelyApiTestConfig(); Dictionary <string, string> apiKeys = JsonConvert.DeserializeObject <Dictionary <string, string> >(File.ReadAllText("NamelyApiKeys.txt")); config.NamelyClientName = apiKeys[nameof(config.NamelyClientName)]; config.NamelyToken = apiKeys[nameof(config.NamelyToken)]; this.ReportGuid = apiKeys["NamelyReportGuid"]; MIF.SetConfigForTesting(config); }
/// <summary> /// This method adds the given file to the list of data sources to be joined /// together. In doing so, the file will be opened and the load profile data /// will be extracted. /// </summary> /// <param name="strFileName" type="string"> /// </param> /// <returns> /// True if the given file was successfully opened, the load profile data was /// extracted, and the file was added to the list of data sources. False is /// returned if the file could not be added to the data source list. /// </returns> /// <remarks> /// Revision History /// MM/DD/YY Who Version Issue# Description /// -------- --- ------- ------------- ----------------------------------- /// 08/26/08 MAH 9.50 Created /// 11/25/09 AF 2.30.22 Changed the catch to quiet a compiler warning /// </remarks> public override Boolean AddContributor(String strFileName) { Boolean boolSuccess = false; HHFFile hhfFile = null; try { if (MIF.IsMeterImageFile(strFileName)) { hhfFile = new MIF(strFileName); } else if (MV90_HHF.IsMV90HHFFile(strFileName)) { hhfFile = new MV90_HHF(strFileName); } if (hhfFile != null) { LoadProfileDataSource newContributor = new LoadProfileDataSource(hhfFile); m_lstDataSources.Add(newContributor); // We are successful only after we have added the file to the list of // contributors boolSuccess = true; // Everytime a new data source is added we need to clear all of the // cached properties so that they can be recalculated when requested FlushCachedValues(); } } // If, for any reason we could not read the load profile data simply throw the // error so that the caller can catch it but also close the HHF file so that we // do not leave open file handles laying around. catch (Exception) { throw; } finally { if (hhfFile != null) { hhfFile.Close(); } } return(boolSuccess); }
/// <summary> /// This method adds the given file to the list of data sources to be /// totalized. In doing so, the file will be opened and the load profile data /// will be extracted. /// </summary> /// <param name="strMIFFileName" type="string"> /// </param> /// <returns> /// True if the given file was successfully opened, the load profile data was /// extracted, and the file was added to the list of data sources. False is /// returned if the file could not be added to the data source list. /// </returns> /// <remarks> /// Revision History /// MM/DD/YY Who Version Issue# Description /// -------- --- ------- ------------- ----------------------------------- /// 08/26/08 MAH 9.50 Created /// 12/22/08 MAH 9.50.28 CQ 124757 Added error handling to prevent /// totaliation of more contributors with more than 16 channels of data /// 11/25/09 AF 2.30.22 Changed the catch block to preserve /// the call stack and quiet compiler warning /// </remarks> public override Boolean AddContributor(String strMIFFileName) { Boolean boolSuccess = false; MIF hhfFile = null; try { if (MIF.IsMeterImageFile(strMIFFileName)) { hhfFile = new MIF(strMIFFileName); TotalizationDataSource newContributor = new TotalizationDataSource(hhfFile); // By default all new contributors will be added to the resulting data newContributor.Calculation = TotalizationDataSource.CalculationType.Addition; m_lstDataSources.Add(newContributor); // We are successful only after we have added the file to the list of // contributors boolSuccess = true; // Clear any previous totalized results. They will need to be recalculated FlushCachedValues(); } } // If, for any reason we could not read the load profile data // simply treat it as if it doesn't exist catch (Exception) { throw; } finally { if (hhfFile != null) { hhfFile.Close(); } } return(boolSuccess); }
/// <summary> /// Makes it possible for MIFFileCollections to be sorted alphabetically /// </summary> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 06/06/07 RDB N/A Created int IComparer.Compare(object x, object y) { MIF xMIF = (MIF)x; MIF yMIF = (MIF)y; if (xMIF == null && yMIF == null) { return(0); } else if (xMIF == null && yMIF != null) { return(-1); } else if (xMIF != null && yMIF == null) { return(1); } else { return(xMIF.FileName.CompareTo(yMIF.FileName)); } } //end Compare
public void Init() { MIF.SetConfigForTesting(new TestConfig()); }
public async Task StopAsync(CancellationToken cancellationToken) { await MIF.Stop(); }
public void Initialize() { TestConfig config = JsonConvert.DeserializeObject <TestConfig>(File.ReadAllText("ApiKey.txt")); MIF.SetConfigForTesting(config); }