UnitsType m_Units = UnitsType.Celsius; // this defines the units of the new input temperatures, but our calculations will be in Celcius #endregion Fields #region Constructors // constructor public Thermometer(UnitsType units, DirectionType direction, double threshold, double hysterisis) { Units = units; Direction = direction; Threshold = threshold; HysterisisThreshold = hysterisis; }
/// <summary> /// Getting measure units short name /// </summary> /// <param name="unitsType">Unit type</param> /// <returns>Units shortName</returns> internal static string GetShortName(this UnitsType unitsType) { switch (unitsType) { case UnitsType.Centimeters: return("cm"); case UnitsType.Millimeters: return("mm"); case UnitsType.Inches: return("in"); default: return(""); } }
//Now 3 types are supported: Length, Angularity and Unitless public static string GetInventorInternalUnitString(UnitsType unitType) { switch (unitType) { case UnitsType.Length: return /*MSG0*/ ("cm"); case UnitsType.Angularity: return /*MSG0*/ ("rad"); case UnitsType.Unitless: return(String.Empty); default: { Debug.Assert(false); return(String.Empty); } } }
//Now 3 types are supported: Length, Angularity and Unitless public static string GetInventorInternalFullUnitString(UnitsType unitType) { switch (unitType) { case UnitsType.Length: return(Resources.Units_Centimeters_Long); case UnitsType.Angularity: return(Resources.Units_Radians_Long); case UnitsType.Unitless: return(String.Empty); default: { Debug.Assert(false); return(String.Empty); } } }
public static UnitsType getUnitsElement(int unitsID, VariablesDataset ds) { DataRow[] dr = ds.Tables["units"].Select("unitsID = " + unitsID); if (dr.Length > 0) { VariablesDataset.UnitsRow row = (VariablesDataset.UnitsRow)dr[0]; string uID = row.UnitsID.ToString(); string unitType = row.UnitsType; string unitAbbrev = row.UnitsAbbreviation; string unitName = row.UnitsName; UnitsType u = CuahsiBuilder.CreateUnitsElement(unitType, uID, unitAbbrev, unitName); return(u); } else { return(null); } }
public void SetNuMaxVolume(UnitsType type, double value) { Vmax = NUConvert.ConvertVolume(type, value); }
public static VariableInfoType CreateVariableInfoType(int varibleId, string vocab, string vCode, string vName, string vDescription, UnitsType aUnit) { VariableInfoType vdt = CreateVariableDescriptionType(); vdt.variableCode[0].Value = vCode; vdt.variableCode[0].vocabulary = vocab; vdt.variableCode[0].variableID = varibleId; vdt.variableCode[0].variableIDSpecified = true; vdt.variableCode[0].defaultSpecified = true; vdt.variableCode[0].@default = true; vdt.variableDescription = vDescription; vdt.variableName = vName; vdt.unit = aUnit; return vdt; }
/// <summary> /// Builds a VariableInfoType from a dataset row /// the dataSet is stored in the NWISService variableDataSet. /// Find the rwo you want with the command: /// /// and convert. /// </summary> /// <param name="row"></param> /// <returns></returns> public static VariableInfoType rowToVariableInfoType(VariablesDataset.VariablesRow row, VariablesDataset ds) { UnitsType aUnit = null; aUnit = getUnitsElement(row.VariableUnitsID, ds); String vCode = row.VariableCode; int vid = row.VariableID; String vocab = System.Configuration.ConfigurationManager.AppSettings["vocabulary"]; String varName = row.VariableName; VariableInfoType vt = CuahsiBuilder.CreateVariableInfoType( vid, vocab, vCode, varName, null, //variable description aUnit ); // add time support vt.timeScale = new VariableInfoTypeTimeScale(); vt.timeScale.isRegular = row.IsRegular; vt.timeScale.timeSupport = Convert.ToInt32(row.TimeSupport); vt.timeScale.timeSupportSpecified = true; // future, when ODM reports spacing //if (row.["timeSpacing"] != null) //{ // vt.timeScale.timeSpacing = Convert.ToInt32(row["timeSpacing"]); // vt.timeScale.timeSpacingSpecified = true; //} UnitsType tUnit = getUnitsElement(row.TimeUnitsID, ds); if (tUnit != null) { vt.timeScale.unit = tUnit; } vt.valueType = String.IsNullOrEmpty(row.ValueType) ? null : row.ValueType; vt.sampleMedium = String.IsNullOrEmpty(row.SampleMedium) ? null : row.SampleMedium; vt.dataType = String.IsNullOrEmpty(row.DataType) ? null : row.DataType; if (vt.dataType.Equals("Categorical", StringComparison.InvariantCultureIgnoreCase)) { IEnumerable <VariableInfoTypeCategory> categories = getCategoryElement(vid, ds); vt.categories = new List <VariableInfoTypeCategory>(categories).ToArray(); } vt.generalCategory = String.IsNullOrEmpty(row.GeneralCategory) ? null : row.GeneralCategory; // zero is default value for datatype... so don't add it if it is the default value if (!row.NoDataValue.Equals(0)) { vt.noDataValue = row.NoDataValue; vt.noDataValueSpecified = true; } vt.speciation = String.IsNullOrEmpty(row.Speciation) ? null : row.Speciation; return(vt); }
public static UnitsType CreateUnitsElement(string ut, string ucode, string unitAbbreivation, string unitName) { UnitsType u = new UnitsType(); u.unitType = ut; u.unitCode = ucode; u.unitAbbreviation = unitAbbreivation; u.unitName = unitName; return u; }
public void SetNuElevation(UnitsType units, double elev) { Elevation = NUConvert.ConvertDistance(units, elev); }
public double GetNuDiameter(UnitsType utype) { return(NUConvert.RevertDiameter(utype, Diameter)); }
public void SetNuDiameter(UnitsType utype, double value) { Diameter = NUConvert.ConvertDistance(utype, value); }
public double GetNuShutoffHead(UnitsType utype) { return(NUConvert.RevertDistance(utype, Hmax)); }
public void SetNuMaxHead(UnitsType utype, double value) { Hmax = NUConvert.ConvertDistance(utype, value); }
protected abstract CarrierRequest GetCarrierRequest(Document doc, UnitsType unit, List <string> methods, List <CarrierBoxEx> boxes);
public void SetNuMaximumHead(UnitsType type, double value) { Hmax = NUConvert.RevertDistance(type, value); }
public void SetNuInitVolume(UnitsType type, double value) { V0 = NUConvert.ConvertVolume(type, value); }
public void SetNuInitHead(UnitsType type, double value) { H0 = NUConvert.RevertDistance(type, value); }
public void SetNuArea(UnitsType type, double value) { Area = NUConvert.ConvertArea(type, value); }
public double GetNuFlowCoefficient(UnitsType utype) { return(NUConvert.RevertPower(utype, FlowCoefficient)); }
public void SetNuMinimumHead(UnitsType type, double value) { Hmin = NUConvert.ConvertArea(type, value); }
public void SetNuFlowCoefficient(UnitsType utype, double value) { FlowCoefficient = NUConvert.ConvertPower(utype, value); }
public void SetNuMixCompartimentSize(UnitsType type, double value) { V1Max = NUConvert.ConvertVolume(type, value); }
public void SetNuShutoffHead(UnitsType utype, double value) { H0 = NUConvert.ConvertDistance(utype, value); }
public static VariableInfoType CreateVariableInfoType(int varibleId, string vocab, string vCode, string vName, string vDescription, UnitsType aUnit) { VariableInfoType vdt = CreateVariableDescriptionType(); vdt.variableCode[0].Value = vCode; vdt.variableCode[0].vocabulary = vocab; vdt.variableCode[0].variableID = varibleId; vdt.variableCode[0].variableIDSpecified = true; vdt.variableCode[0].defaultSpecified = true; vdt.variableCode[0].@default = true; vdt.variableDescription = vDescription; vdt.variableName = vName; vdt.unit = aUnit; return(vdt); }
public double GetNuLength(UnitsType utype) { return(NUConvert.RevertDistance(utype, Lenght)); }
/// <summary> /// Builds a VariableInfoType which is part of the VariablesResponse; /// Columns: /// VariableID /// VariableCode (R) /// VariableVocabulary /// VariableName (r) - will display 'not specified' /// </summary> /// <param name="aRow"></param> /// <returns></returns> public static VariableInfoType CreateVariableRecord(DataRow aRow) { CoreTables.VariablesDataTable vDs = new CoreTables.VariablesDataTable(); vDs.ImportRow(aRow); vDs.AcceptChanges(); VariableInfoType vit = new VariableInfoType(); if (vDs.Rows.Count > 0) { CoreTables.VariablesRow row = (CoreTables.VariablesRow)vDs.Rows[0]; { // set attributes if (!row.IsVariableIDNull()) { vit.oid = row.VariableID.ToString(); } // add a vCode vit.variableCode = new VariableInfoTypeVariableCode[1]; VariableInfoTypeVariableCode vCode = new VariableInfoTypeVariableCode(); if (!row.IsVariableVocabularyNull()) { vCode.vocabulary = row.VariableVocabulary; vCode.@default = true; vCode.defaultSpecified = true; } vCode.Value = row.VariableCode; vit.variableCode[0] = vCode; // add name if (!row.IsVariableNameNull()) { vit.variableName = row.VariableName; } else { vit.variableName = "Not Specified."; } // value type if (!row.IsValueTypeNull()) { // SetEnumFromText(vit, row, "valueType", typeof(valueTypeEnum)); vit.valueType = row.ValueType; } //add DataType if (!row.IsDataTypeNull()) { //SetEnumFromText(vit, row, "dataType", typeof(dataTypeEnum)); vit.dataType = row.DataType; } //add General Categoy // if (!row.IsGeneralCategoryNull()) { // SetEnumFromText(vit, row, "generalCategory", typeof(generalCategoryEnum)); vit.generalCategory = row.GeneralCategory; } // Units // if just the ID exists... then it's not useful if (!row.IsVariableUnitsNameNull() || !row.IsVariableUnitsAbbreviationNull()) { UnitsType unit = new UnitsType(); if (!row.IsVariableUnitsNameNull()) { unit.unitName = row.VariableUnitsName; } if (!row.IsVariableUnitsAbbreviationNull()) { unit.unitAbbreviation = row.VariableUnitsAbbreviation; } if (!row.IsVariableUnitsIDNull()) { unit.unitCode = row.VariableUnitsID.ToString(); } vit.unit = unit; } } // add time support if (!row.IsIsRegularNull() && row.IsRegular) { vit.timeScale = new VariableInfoTypeTimeScale(); vit.timeScale.isRegular = row.IsRegular; //vit.timeScale.isRegularSpecified = true; // add time support // check to be sure we've got some vaild stuff if (!row.IsTimeSupportNull()) { vit.timeScale.timeSupport = row.TimeSupport; } if (!row.IsTimeUnitsNameNull() || !row.IsTimeUnitsAbbreviationNull() ) { vit.timeScale.unit = new UnitsType(); if (!row.IsTimeUnitsNameNull()) { vit.timeScale.unit.unitName = row.TimeUnitsName; } if (!row.IsTimeUnitsAbbreviationNull()) { vit.timeScale.unit.unitAbbreviation = row.TimeUnitsAbbreviation; } // vit.timeSupport.unit.UnitType = (UnitsTypeEnum)CoreBuilder.GetTextAsEnum("Time", typeof(UnitsTypeEnum)); vit.timeScale.unit.unitType = "Time"; } else { // try to get info from time unitsID ///@TODO fix this //if (!row.IsTimeUnitsIDNull()) //{ // vit.timeSupport.unit = new UnitsType(); // vit.timeSupport.unit.UnitID = 104; // vit.timeSupport.unit.UnitIDSpecified = true; // vit.timeSupport.unit.UnitDescription = "day"; // vit.timeSupport.unit.UnitAbbreviation = "d"; // vit.timeSupport.unit.UnitType = (UnitsTypeEnum)CoreBuilder.GetTextAsEnum("Time", typeof(UnitsTypeEnum)); ; //} } } } return(vit); }
public void SetNuLenght(UnitsType utype, double value) { Lenght = NUConvert.ConvertDistance(utype, value); }
///<summary>Update fields and units, after loading the INP.</summary> public void Prepare( UnitsType targetUnits, FlowUnitsType flowFlag, PressUnitsType pressFlag, QualType qualFlag, string chemUnits, double spGrav, long hstep) { double dcf, ccf, qcf, hcf, pcf, wcf; if (targetUnits == UnitsType.SI) { GetField(FieldType.DEMAND).Units = flowFlag.ToString(); GetField(FieldType.ELEV).Units = Keywords.u_METERS; GetField(FieldType.HEAD).Units = Keywords.u_METERS; GetField(FieldType.PRESSURE).Units = pressFlag == PressUnitsType.METERS ? Keywords.u_METERS : Keywords.u_KPA; GetField(FieldType.LENGTH).Units = Keywords.u_METERS; GetField(FieldType.DIAM).Units = Keywords.u_MMETERS; GetField(FieldType.FLOW).Units = flowFlag.ToString(); GetField(FieldType.VELOCITY).Units = Keywords.u_MperSEC; GetField(FieldType.HEADLOSS).Units = "m" + Keywords.u_per1000M; GetField(FieldType.FRICTION).Units = ""; GetField(FieldType.POWER).Units = Keywords.u_KW; dcf = 1000.0 * Constants.MperFT; qcf = Constants.LPSperCFS; if (flowFlag == FlowUnitsType.LPM) { qcf = Constants.LPMperCFS; } if (flowFlag == FlowUnitsType.MLD) { qcf = Constants.MLDperCFS; } if (flowFlag == FlowUnitsType.CMH) { qcf = Constants.CMHperCFS; } if (flowFlag == FlowUnitsType.CMD) { qcf = Constants.CMDperCFS; } hcf = Constants.MperFT; if (pressFlag == PressUnitsType.METERS) { pcf = Constants.MperFT * spGrav; } else { pcf = Constants.KPAperPSI * Constants.PSIperFT * spGrav; } wcf = Constants.KWperHP; } else { GetField(FieldType.DEMAND).Units = flowFlag.ToString(); GetField(FieldType.ELEV).Units = Keywords.u_FEET; GetField(FieldType.HEAD).Units = Keywords.u_FEET; GetField(FieldType.PRESSURE).Units = Keywords.u_PSI; GetField(FieldType.LENGTH).Units = Keywords.u_FEET; GetField(FieldType.DIAM).Units = Keywords.u_INCHES; GetField(FieldType.FLOW).Units = flowFlag.ToString(); GetField(FieldType.VELOCITY).Units = Keywords.u_FTperSEC; GetField(FieldType.HEADLOSS).Units = "ft" + Keywords.u_per1000FT; GetField(FieldType.FRICTION).Units = ""; GetField(FieldType.POWER).Units = Keywords.u_HP; dcf = 12.0; qcf = 1.0; if (flowFlag == FlowUnitsType.GPM) { qcf = Constants.GPMperCFS; } if (flowFlag == FlowUnitsType.MGD) { qcf = Constants.MGDperCFS; } if (flowFlag == FlowUnitsType.IMGD) { qcf = Constants.IMGDperCFS; } if (flowFlag == FlowUnitsType.AFD) { qcf = Constants.AFDperCFS; } hcf = 1.0; pcf = Constants.PSIperFT * spGrav; wcf = 1.0; } GetField(FieldType.QUALITY).Units = ""; ccf = 1.0; switch (qualFlag) { case QualType.CHEM: ccf = 1.0 / Constants.LperFT3; GetField(FieldType.QUALITY).Units = chemUnits; GetField(FieldType.REACTRATE).Units = chemUnits + Keywords.t_PERDAY; break; case QualType.AGE: GetField(FieldType.QUALITY).Units = Keywords.u_HOURS; break; case QualType.TRACE: GetField(FieldType.QUALITY).Units = Keywords.u_PERCENT; break; } SetUnits(FieldType.DEMAND, qcf); SetUnits(FieldType.ELEV, hcf); SetUnits(FieldType.HEAD, hcf); SetUnits(FieldType.PRESSURE, pcf); SetUnits(FieldType.QUALITY, ccf); SetUnits(FieldType.LENGTH, hcf); SetUnits(FieldType.DIAM, dcf); SetUnits(FieldType.FLOW, qcf); SetUnits(FieldType.VELOCITY, hcf); SetUnits(FieldType.HEADLOSS, hcf); SetUnits(FieldType.LINKQUAL, ccf); SetUnits(FieldType.REACTRATE, ccf); SetUnits(FieldType.FRICTION, 1.0); SetUnits(FieldType.POWER, wcf); SetUnits(FieldType.VOLUME, hcf * hcf * hcf); if (hstep < 1800) { SetUnits(FieldType.TIME, 1.0 / 60.0); GetField(FieldType.TIME).Units = Keywords.u_MINUTES; } else { SetUnits(FieldType.TIME, 1.0 / 3600.0); GetField(FieldType.TIME).Units = Keywords.u_HOURS; } }
public double GetNuElevation(UnitsType units) { return(NUConvert.RevertDistance(units, Elevation)); }
public async Task <WeatherApiResponseModel> GetWeatherForCity(string cityName, string apiKey, UnitsType units) { return(await GetAsync <WeatherApiResponseModel>($"data/2.5/weather?q={cityName}&appid={apiKey}&units={units}")); }
public Weather GetByIPGeoLocation(UnitsType unitsType = UnitsType.Metric, Language language = Language.English) { dynamic cityIP = JsonConvert.DeserializeObject(GetRequest("http://ip-api.com/json/")); return(GetByCityName((string)cityIP.city, unitsType, language)); }
public override void Get() { UnitsTypeSearch custSearch = new UnitsTypeSearch(); UnitsTypeSearchBasic custSearchBasic = new UnitsTypeSearchBasic(); custSearch.basic = custSearchBasic; Preferences prefs = new Preferences(); Service(true).preferences = prefs; prefs.warningAsErrorSpecified = true; prefs.warningAsError = false; SearchPreferences _srch_pref = new SearchPreferences(); Service().searchPreferences = _srch_pref; Service().searchPreferences.bodyFieldsOnly = false; bool bodyonly = Service().searchPreferences.bodyFieldsOnly; SearchResult response = Service().search(custSearch); if (response.totalRecords > 0) { List <UnitsOfMeasure> list = new List <UnitsOfMeasure>(); for (int i = 0; i < response.totalRecords; i++) { UnitsType cr = (UnitsType)response.recordList[i]; try { UnitsTypeUomList uomList = cr.uomList; for (int j = 0; j < uomList.uom.Length; j++) { UnitsOfMeasure entity = new UnitsOfMeasure(); entity.unit_id = Convert.ToInt32(cr.internalId); entity.details_id = Convert.ToInt32(uomList.uom[j].internalId); entity.Netsuite_Id = Convert.ToInt32(cr.internalId + uomList.uom[j].internalId); entity.InActive = cr.isInactive; entity.Name = cr.name; entity.baseUnit = uomList.uom[j].baseUnit; entity.unitName = uomList.uom[j].unitName; entity.pluralName = uomList.uom[j].pluralName; entity.abbreviation = uomList.uom[j].abbreviation; entity.pluralAbbreviation = uomList.uom[j].pluralAbbreviation; entity.conversionRate = (float)uomList.uom[j].conversionRate; list.Add(entity); } } catch (Exception ex) { throw ex; } } if (list.Count > 0) { new GenericeDAO <UnitsOfMeasure>().UnitmeasureNetSuiteIntegration(list); } } }