private unsafe int GetUnitFloat(PIActionList list, uint index, uint *unit, double *data) { if (data == null) { return(PSError.kSPBadParameterError); } ActionListItemCollection items = actionLists[list]; if (index < items.Count) { UnitFloat unitFloat = (UnitFloat)items[(int)index].Value; if (unit != null) { *unit = unitFloat.Unit; } *data = unitFloat.Value; return(PSError.kSPNoError); } return(PSError.kSPBadParameterError); }
public override void OnCreate() { base.OnCreate(); UnitFloat.Clear(); UnitString.Clear(); String.Clear(); }
private int GetUnitFloat(IntPtr descriptor, uint key, ref uint unit, ref double data) { #if DEBUG DebugUtils.Ping(DebugFlags.DescriptorParameters, string.Format("key: 0x{0:X4}({1})", key, DebugUtils.PropToString(key))); #endif AETEValue item; if (actionDescriptors[descriptor].TryGetValue(key, out item)) { UnitFloat unitFloat = (UnitFloat)item.Value; try { unit = unitFloat.Unit; } catch (NullReferenceException) { } data = unitFloat.Value; return(PSError.kSPNoError); } return(PSError.errMissingParameter); }
public void AddUnitFloat(string key, Func <BaseUnit, float> data) { if (UnitFloat.ContainsKey(key)) { return; } UnitFloat.Add(key, data); }
private static UnitFloat ParseUnitFloat(BinaryReverseReader reader) { UnitFloat value = new UnitFloat() { type = (UnitTypes)reader.ReadUInt32(), value = reader.ReadDouble() }; return(value); }
public float GetUnitFloat(string key, BaseUnit unit) { if (unit == null) { CLog.Error("BaseRefMgr:GetUnitFloat:Unit为Null"); return(0); } if (!UnitFloat.ContainsKey(key)) { CLog.Error("BaseRefMgr:GetUnitFloat:没有RefKey:{0}", key); return(0); } return(UnitFloat[key].Invoke(unit)); }
private int PutUnitFloat(PIActionList list, uint unit, double data) { try { UnitFloat item = new UnitFloat(unit, data); actionLists[list].Add(new ActionListItem(DescriptorTypes.UintFloat, item)); } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); }
private int PutUnitFloat(IntPtr descriptor, uint key, uint unit, double data) { #if DEBUG DebugUtils.Ping(DebugFlags.DescriptorParameters, string.Format("key: 0x{0:X4}({1})", key, DebugUtils.PropToString(key))); #endif try { UnitFloat item = new UnitFloat(unit, data); actionDescriptors[descriptor].Add(key, new AETEValue(DescriptorTypes.UintFloat, GetAETEParamFlags(key), 0, item)); } catch (OutOfMemoryException) { return(PSError.memFullErr); } return(PSError.kSPNoError); }
private short PutUnitFloatProc(IntPtr descriptor, uint key, uint unit, ref double data) { #if DEBUG DebugUtils.Ping(DebugFlags.DescriptorParameters, string.Format("key: {0:X4}", key)); #endif try { UnitFloat item = new UnitFloat(unit, data); writeDescriptors[descriptor].AddOrUpdate(key, new AETEValue(DescriptorTypes.UintFloat, GetAETEParamFlags(key), 0, item)); } catch (OutOfMemoryException) { return(PSError.memFullErr); } return(PSError.noErr); }
private short GetUnitFloatProc(IntPtr descriptor, ref uint unit, ref double data) { ReadDescriptorState state = readDescriptors[descriptor]; #if DEBUG DebugUtils.Ping(DebugFlags.DescriptorParameters, string.Format("key: 0x{0:X4}", state.currentKey)); #endif AETEValue item = state.items[state.currentKey]; UnitFloat unitFloat = (UnitFloat)item.Value; try { unit = unitFloat.Unit; } catch (NullReferenceException) { } data = unitFloat.Value; return(PSError.noErr); }
private int GetUnitFloat(IntPtr list, uint index, ref uint unit, ref double data) { ActionListItemCollection items = actionLists[list]; if (index < items.Count) { UnitFloat unitFloat = (UnitFloat)items[(int)index].Value; try { unit = unitFloat.Unit; } catch (NullReferenceException) { } data = unitFloat.Value; return(PSError.kSPNoError); } return(PSError.kSPBadParameterError); }
private short GetPinnedUnitFloatProc(IntPtr descriptor, ref double min, ref double max, ref uint units, ref double floatNumber) { ReadDescriptorState state = readDescriptors[descriptor]; #if DEBUG DebugUtils.Ping(DebugFlags.DescriptorParameters, string.Format("key: 0x{0:X4}", state.currentKey)); #endif short descErr = PSError.noErr; AETEValue item = state.items[state.currentKey]; UnitFloat unitFloat = (UnitFloat)item.Value; if (unitFloat.Unit != units) { descErr = PSError.paramErr; state.lastReadError = descErr; } double amount = unitFloat.Value; if (amount < min) { amount = min; descErr = PSError.coercedParamErr; state.lastReadError = descErr; } else if (amount > max) { amount = max; descErr = PSError.coercedParamErr; state.lastReadError = descErr; } floatNumber = amount; return(descErr); }