public int GetPhraseCount(string phrase) { PhraseCount pc; if (MPhrases.TryGetValue(phrase, out pc)) { return(pc.Count); } else { return(0); } }
void Scoreboard_Kill(int _iSlotID) { ScoreboardVarStruct player; if (mPlayers.TryGetValue(_iSlotID, out player)) { ++player.iKills; } else { Debug.LogError("Attempted to add kill to player " + _iSlotID + ", but they do not exist!"); } }
public static LineCapExtension FromName(string name) { if (_registeredStyles.TryGetValue(name, out var currentStyle)) { return(currentStyle); } else if (_deprecatedGdiStyles.TryGetValue(name, out currentStyle)) { return(currentStyle); } else { throw new ArgumentException(string.Format("Unknown LineCapEx style: {0}", name), "name"); } }
/// <summary> /// /// </summary> /// <param name="type"></param> /// <returns></returns> internal static FastCreateInstanceHandler TryGetValue(Type type) { if (type == null) { return(null); } DTOType dtoType; if (!Cache.TryGetValue(type.GUID, out dtoType)) { return(null); } return(dtoType.Handler); }
private static bool ReapplyDefaults(string filepath, ref System.Collections.Generic.SortedDictionary <string, string> annotationDefaults) { System.Xml.XmlDocument AnnotationsDoc = new XmlDocument(); AnnotationsDoc.Load(filepath); // get list of DAM element sections, iterate through their child nodes, adding each to a new node that will be added to TDConfigDoc XmlNodeList annotationSets = AnnotationsDoc.DocumentElement.SelectNodes("/ArrayOfAnnotationSet/AnnotationSet"); foreach (XmlElement confignode in annotationSets) { var Names = confignode.GetElementsByTagName("Name"); var name = Names.Item(0); var Defaults = confignode.GetElementsByTagName("IsDefault"); var Default = Defaults.Item(0); var theOriginalDefault = ""; if (annotationDefaults.TryGetValue(name.InnerText, out theOriginalDefault)) { Default.InnerText = theOriginalDefault; } } AnnotationsDoc.Save(filepath); return(true); }
private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info) { //InvokeOnMainThread(() => { bool found = false; int cnt; lock (TagInfoList) { string epcstr = info.epc.ToString(); try { TagInfoListSpeedup.Add(epcstr, TagInfoList.Count); TagInfoViewModel item = new TagInfoViewModel(); item.timeOfRead = DateTime.Now; item.EPC = info.epc.ToString(); item.Bank1Data = CSLibrary.Tools.Hex.ToString(info.Bank1Data); item.Bank2Data = CSLibrary.Tools.Hex.ToString(info.Bank2Data); item.RSSI = info.rssi; //item.Phase = info.phase; //item.Channel = (byte)info.freqChannel; item.PC = info.pc.ToUshorts()[0]; //TagInfoList.Add(item); TagInfoList.Insert(0, item); _newtagCount4BeepSound++; _newtagCount4Vibration++; Trace.Message("EPC Data = {0}", item.EPC); //_newTag = true; } catch (Exception ex) { int index; if (TagInfoListSpeedup.TryGetValue(epcstr, out index)) { index = TagInfoList.Count - index; index--; TagInfoList[index].Bank1Data = CSLibrary.Tools.Hex.ToString(info.Bank1Data); TagInfoList[index].Bank2Data = CSLibrary.Tools.Hex.ToString(info.Bank2Data); TagInfoList[index].RSSI = info.rssi; } else { // error found epc } } } }//); }
public void ChangeState(string name, object param = null) { IState <T> state; if (stateDict_.TryGetValue(name, out state)) { ChangeState(state, param); } }
private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info) { InvokeOnMainThread(() => { bool found = false; int cnt; if (BleMvxApplication._rfMicro_Power == 4 && BleMvxApplication._config.RFID_PowerSequencing_NumberofPower != 0) { currentPower = (BleMvxApplication._config.RFID_PowerSequencing_Level[info.antennaPort] / 10).ToString("0.0") + "dB"; RaisePropertyChanged(() => currentPower); } lock (TagInfoList) { string epcstr = info.epc.ToString(); try { TagInfoListSpeedup.Add(epcstr, TagInfoList.Count); RFMicroTagInfoViewModel item = new RFMicroTagInfoViewModel(); item.EPC = info.epc.ToString(); item.NickName = GetNickName(item.EPC); if (item.NickName != "") { item.DisplayName = item.NickName; } else { item.DisplayName = item.EPC; } item.RSSIColor = "Black"; item.valueColor = "Black"; item.ScanValue = info.Bank2Data[2].ToString(); switch (BleMvxApplication._rfMicro_SensorUnit) { case 0: item.TemperatureValue = info.Bank2Data[4].ToString(); break; case 2: item.TemperatureValue = tempF(info.Bank2Data[4], info.Bank1Data[0], info.Bank1Data[1], info.Bank1Data[2], info.Bank1Data[3]).ToString("#0.0"); break; case 3: item.TemperatureValue = temp(info.Bank2Data[4], info.Bank1Data[0], info.Bank1Data[1], info.Bank1Data[2], info.Bank1Data[3]).ToString("#0.0"); break; } item.OCRSSI = info.Bank2Data[3]; if (item.OCRSSI >= BleMvxApplication._rfMicro_minOCRSSI && item.OCRSSI <= BleMvxApplication._rfMicro_maxOCRSSI) { item.RSSIColor = "Black"; item.SucessCount = 1; } else { item.RSSIColor = "Red"; item.SucessCount = 0; } item.EPC = ""; item.GOODOCRSSI = ""; item.NickName = ""; TagInfoList.Insert(0, item); _newtagCount4BeepSound++; _newtagCount4Vibration++; _newTagPerSecond++; Trace.Message("EPC Data = {0}", item.EPC); } catch (Exception ex) { int index; if (TagInfoListSpeedup.TryGetValue(epcstr, out index)) { index = TagInfoList.Count - index; index--; TagInfoList[index].ScanValue = info.Bank2Data[2].ToString(); switch (BleMvxApplication._rfMicro_SensorUnit) { case 0: TagInfoList[index].TemperatureValue = info.Bank2Data[4].ToString(); break; case 2: TagInfoList[index].TemperatureValue = tempF(info.Bank2Data[4], info.Bank1Data[0], info.Bank1Data[1], info.Bank1Data[2], info.Bank1Data[3]).ToString("#0.0"); break; case 3: TagInfoList[index].TemperatureValue = temp(info.Bank2Data[4], info.Bank1Data[0], info.Bank1Data[1], info.Bank1Data[2], info.Bank1Data[3]).ToString("#0.0"); break; } TagInfoList[index].OCRSSI = info.Bank2Data[3]; if (TagInfoList[index].OCRSSI >= BleMvxApplication._rfMicro_minOCRSSI && TagInfoList[index].OCRSSI <= BleMvxApplication._rfMicro_maxOCRSSI) { TagInfoList[index].RSSIColor = "Black"; TagInfoList[index].SucessCount++; } else { TagInfoList[index].RSSIColor = "Red"; } } else { // error found epc } } } }); }
private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info) { InvokeOnMainThread(() => { bool found = false; int cnt; lock (TagInfoList) { #if not_binarysearch for (cnt = 0; cnt < TagInfoList.Count; cnt++) { if (TagInfoList[cnt].EPC == info.epc.ToString()) { TagInfoList[cnt].Bank1Data = CSLibrary.Tools.Hex.ToString(info.Bank1Data); TagInfoList[cnt].Bank2Data = CSLibrary.Tools.Hex.ToString(info.Bank2Data); TagInfoList[cnt].RSSI = info.rssi; //TagInfoList[cnt].Phase = info.phase; //TagInfoList[cnt].Channel = (byte)info.freqChannel; found = true; break; } } if (!found) { TagInfoViewModel item = new TagInfoViewModel(); item.timeOfRead = DateTime.Now; item.EPC = info.epc.ToString(); item.Bank1Data = CSLibrary.Tools.Hex.ToString(info.Bank1Data); item.Bank2Data = CSLibrary.Tools.Hex.ToString(info.Bank2Data); item.RSSI = info.rssi; //item.Phase = info.phase; //item.Channel = (byte)info.freqChannel; item.PC = info.pc.ToUshorts()[0]; //TagInfoList.Add(item); TagInfoList.Insert(0, item); _newTagFound = true; Trace.Message("EPC Data = {0}", item.EPC); _newTag = true; } #else string epcstr = info.epc.ToString(); try { TagInfoListSpeedup.Add(epcstr, TagInfoList.Count); RFMicroTagInfoViewModel item = new RFMicroTagInfoViewModel(); item.RSSIColor = "Black"; item.valueColor = "Black"; item.DisplayName = info.epc.ToString(); item.SensorAvgValue = temp(info.Bank2Data[4], info.Bank1Data[0], info.Bank1Data[1], info.Bank1Data[2], info.Bank1Data[3]).ToString("#0.0"); item.OCRSSI = info.Bank2Data[3]; item.SucessCount = 1; item.EPC = ""; item.GOODOCRSSI = ""; item.NickName = ""; TagInfoList.Insert(0, item); _newtagCount4BeepSound++; _newtagCount4Vibration++; _newTagPerSecond++; Trace.Message("EPC Data = {0}", item.EPC); } catch (Exception ex) { int index; if (TagInfoListSpeedup.TryGetValue(epcstr, out index)) { index = TagInfoList.Count - index; index--; TagInfoList[index].SensorAvgValue = temp(info.Bank2Data[4], info.Bank1Data[0], info.Bank1Data[1], info.Bank1Data[2], info.Bank1Data[3]).ToString("#0.0"); TagInfoList[index].OCRSSI = info.Bank2Data[3]; TagInfoList[index].SucessCount++; } else { // error found epc } } #endif } }); }
private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info) { InvokeOnMainThread(() => { bool found = false; int cnt; lock (TagInfoList) { string epcstr = info.epc.ToString(); try { TagInfoListSpeedup.Add(epcstr, TagInfoList.Count); TagInfoViewModel item = new TagInfoViewModel(); item.timeOfRead = DateTime.Now; item.EPC = info.epc.ToString(); item.Bank1Data = CSLibrary.Tools.Hex.ToString(info.Bank1Data); item.Bank2Data = CSLibrary.Tools.Hex.ToString(info.Bank2Data); item.RSSI = info.rssi; //item.Phase = info.phase; //item.Channel = (byte)info.freqChannel; item.PC = info.pc.ToUshorts()[0]; //TagInfoList.Add(item); TagInfoList.Insert(0, item); var dto = this.fromServer.Where(e => e.RfId.Equals(item.EPC, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault(); if (dto != null) { this.Items.Add(dto); } _newtagCount4BeepSound++; _newtagCount4Vibration++; _newTagPerSecond++; //_newTag = true; } catch (Exception ex) { int index; if (TagInfoListSpeedup.TryGetValue(epcstr, out index)) { index = TagInfoList.Count - index; index--; TagInfoList[index].Bank1Data = CSLibrary.Tools.Hex.ToString(info.Bank1Data); TagInfoList[index].Bank2Data = CSLibrary.Tools.Hex.ToString(info.Bank2Data); TagInfoList[index].RSSI = info.rssi; } else { // error found epc } } } }); }