public static void PowerConnect(PowerUnit source, DataUnit target) { Builder.PowerConnect(source, target, String.Empty); }
private static OracleDataType BuildPrimitiveDataType(string typeName, int? length = null, int? precision = null, int? scale = null, DataUnit dataUnit = DataUnit.NotApplicable) { return new OracleDataType { FullyQualifiedName = OracleObjectIdentifier.Create(null, typeName), Length = length, Precision = precision, Scale = scale, Unit = dataUnit }; }
public Notification Validate(DataUnit dataUnit, Notification notification) { return(notification); }
public static UIDropItem GetUIDropItemByPrizeItem(SlgPB.PrizeItem prizeItem) { UIDropItem drop = new UIDropItem(prizeItem); switch (drop.type) { case (int)DataConfig.DATA_TYPE.Unit: { DataUnit dataUnit = DataManager.instance.dataUnitsGroup.GetUnit(drop.id); drop.name = dataUnit.name; drop.icon = UICommon.UNIT_SMALL_PATH_PREFIX + drop.id; } break; case (int)DataConfig.DATA_TYPE.UnitPart: { DataUnitPart dataUnitPart = DataManager.instance.dataUnitPartGroup.GetPart(drop.id, 1); drop.name = dataUnitPart.name; } break; case (int)DataConfig.DATA_TYPE.Item: { DataItem dataItem = DataManager.instance.dataItemGroup.GetItem(drop.id); drop.name = dataItem.name; drop.icon = UICommon.ITEM_PATH_PREFIX + drop.id; } break; case (int)DataConfig.DATA_TYPE.Hero: { DataHero dataHero = DataManager.instance.dataHeroGroup.GetHeroPrimitive(drop.id); drop.name = dataHero.name; drop.icon = UICommon.HERO_SMALL_PATH_PREFIX + drop.id; } break; case (int)DataConfig.DATA_TYPE.Combat: { drop.name = DataConfig.GetDataTypeName(DataConfig.DATA_TYPE.Combat); drop.icon = UICommon.DROP_ITEM_PATH_PREFIX + (int)drop.type; } break; case (int)DataConfig.DATA_TYPE.Honor: { drop.name = DataConfig.GetDataTypeName(DataConfig.DATA_TYPE.Honor); drop.icon = UICommon.DROP_ITEM_PATH_PREFIX + (int)drop.type; } break; case (int)DataConfig.DATA_TYPE.Food: { drop.name = DataConfig.GetDataTypeName(DataConfig.DATA_TYPE.Food); drop.icon = UICommon.DROP_ITEM_PATH_PREFIX + (int)drop.type; } break; case (int)DataConfig.DATA_TYPE.Oil: { drop.name = DataConfig.GetDataTypeName(DataConfig.DATA_TYPE.Oil); drop.icon = UICommon.DROP_ITEM_PATH_PREFIX + (int)drop.type; } break; case (int)DataConfig.DATA_TYPE.Metal: { drop.name = DataConfig.GetDataTypeName(DataConfig.DATA_TYPE.Metal); drop.icon = UICommon.DROP_ITEM_PATH_PREFIX + (int)drop.type; } break; case (int)DataConfig.DATA_TYPE.Rare: { drop.name = DataConfig.GetDataTypeName(DataConfig.DATA_TYPE.Rare); drop.icon = UICommon.DROP_ITEM_PATH_PREFIX + (int)drop.type; } break; case (int)DataConfig.DATA_TYPE.Cash: { drop.name = DataConfig.GetDataTypeName(DataConfig.DATA_TYPE.Cash); drop.icon = UICommon.DROP_ITEM_PATH_PREFIX + (int)drop.type; } break; case (int)DataConfig.DATA_TYPE.Exp: { drop.name = DataConfig.GetDataTypeName(DataConfig.DATA_TYPE.Exp); drop.icon = UICommon.DROP_ITEM_PATH_PREFIX + (int)drop.type; } break; case (int)DataConfig.DATA_TYPE.Energy: { drop.name = DataConfig.GetDataTypeName(DataConfig.DATA_TYPE.Energy); drop.icon = UICommon.DROP_ITEM_PATH_PREFIX + (int)drop.type; } break; case (int)DataConfig.DATA_TYPE.Building: break; case (int)DataConfig.DATA_TYPE.Mission: break; case (int)DataConfig.DATA_TYPE.Battle: break; case (int)DataConfig.DATA_TYPE.DropGroup: break; case (int)DataConfig.DATA_TYPE.Equipment: break; } return(drop); }
/// <inheritdoc /> public override string DataUnitHumanize(DataUnit dataUnit, double count, bool toSymbol = true) { return(base.DataUnitHumanize(dataUnit, count, toSymbol)?.TrimEnd('s')); }
/// <summary> /// Выполнить запрос в режиме TCP /// </summary> public bool TcpRequest(DataUnit dataUnit) { if (!CheckConnection()) return false; bool result = false; string logText; // отправка запроса WriteToLog(dataUnit.ReqDescr); Connection.Write(dataUnit.ReqADU, 0, dataUnit.ReqADU.Length, CommUtils.ProtocolLogFormats.Hex, out logText); ExecWriteToLog(logText); // приём ответа // считывание MBAP Header int readCnt = Connection.Read(InBuf, 0, 7, Timeout, CommUtils.ProtocolLogFormats.Hex, out logText); ExecWriteToLog(logText); if (readCnt == 7) { int pduLen = InBuf[4] * 256 + InBuf[5] - 1; if (InBuf[0] == 0 && InBuf[1] == 0 && InBuf[2] == 0 && InBuf[3] == 0 && pduLen > 0 && InBuf[6] == dataUnit.ReqADU[6]) { // считывание PDU readCnt = Connection.Read(InBuf, 7, pduLen, Timeout, CommUtils.ProtocolLogFormats.Hex, out logText); ExecWriteToLog(logText); if (readCnt == pduLen) { // расшифровка ответа string errMsg; if (dataUnit.DecodeRespPDU(InBuf, 7, pduLen, out errMsg)) { ExecWriteToLog(Phrases.OK); result = true; } else { ExecWriteToLog(errMsg + "!"); } } else { WriteToLog(Phrases.CommErrorWithExclamation); } } else { WriteToLog(Phrases.IncorrectMbap); } } else { WriteToLog(Phrases.CommErrorWithExclamation); } return result; }
public void UpdateUI(int unitId) { DataUnit dataUnit = DataManager.instance.dataUnitsGroup.GetUnit(unitId); name_Label.text = dataUnit.name; }
public static void Start(string[] args) { if (args.Length < 2) { TestMain.ErrorExit("perf command requires functionality to test."); } switch (args[1].ToLower()) { case "dataunit": { if (args.Length < 3) { TestMain.ErrorExit("perf dataunit command requires # of elements to test."); } int TestLength = int.Parse(args[2]); Log.Output(Log.Severity.INFO, Log.Source.OTHER, "Testing DataUnit performance, " + TestLength.ToString("N0", CultureInfo.InvariantCulture) + " iterations."); Log.Output(Log.Severity.INFO, Log.Source.OTHER, "Generating keyset..."); string[] Values = { "Erza", "Homura", "Reika", "Jibril", "Aqua", "Kurisu" }; byte[] IDs = new byte[TestLength]; Random Random = new Random(); for (int i = 0; i < IDs.Length; i++) { IDs[i] = (byte)Random.Next(Values.Length); } DataUnit DUT = new DataUnit("Testing Structure"); // DataUnit under Test Log.Output(Log.Severity.INFO, Log.Source.OTHER, "Writing to DataUnit..."); Stopwatch Stopwatch = Stopwatch.StartNew(); for (int i = 0; i < IDs.Length; i++) { DUT.Add(i.ToString(), Values[IDs[i]]); } Stopwatch.Stop(); Log.Output(Log.Severity.INFO, Log.Source.OTHER, " Took " + Math.Round(Stopwatch.ElapsedTicks * 1000F / Stopwatch.Frequency, 5) + "ms."); Log.Output(Log.Severity.INFO, Log.Source.OTHER, "Reading from DataUnit..."); Stopwatch = Stopwatch.StartNew(); for (int i = 0; i < IDs.Length; i++) { DUT.GetValue <string>(i.ToString()); } Stopwatch.Stop(); Log.Output(Log.Severity.INFO, Log.Source.OTHER, " Took " + Math.Round(Stopwatch.ElapsedTicks * 1000F / Stopwatch.Frequency, 5) + "ms."); break; } case "filter": { if (args.Length < 3) { TestMain.ErrorExit("perf filter command requires filter type to test."); } if (args[2] != "lowpass" && args[2] != "average") { TestMain.ErrorExit("Invalid filter type supplied."); } if (args.Length < 4) { TestMain.ErrorExit("perf filter command requires # of cycles to test."); } IFilter <double> FUT = null; switch (args[2].ToLower()) { case "lowpass": { FUT = new LowPass <double>(); break; } case "average": { FUT = new Average <double>(); break; } } int TestLength = int.Parse(args[3]); Log.Output(Log.Severity.INFO, Log.Source.OTHER, "Testing Filter performance, " + TestLength.ToString("N0", CultureInfo.InvariantCulture) + " iterations."); Log.Output(Log.Severity.INFO, Log.Source.OTHER, "Generating inputs..."); double[] Inputs = new double[TestLength]; Random Random = new Random(); for (int i = 0; i < Inputs.Length; i++) { Inputs[i] = Random.NextDouble(); } Log.Output(Log.Severity.INFO, Log.Source.OTHER, "Cycling Filter..."); Stopwatch Stopwatch = Stopwatch.StartNew(); for (int i = 0; i < Inputs.Length; i++) { FUT.Feed(Inputs[i]); double Output = FUT.GetOutput(); } Stopwatch.Stop(); Log.Output(Log.Severity.INFO, Log.Source.OTHER, " Took " + Math.Round(Stopwatch.ElapsedTicks * 1000F / Stopwatch.Frequency, 5) + "ms."); break; } } }
/// <summary> /// FFT Spectrum /// </summary> /// <param name="Wave">Input Wave</param> /// <param name="SampleRate">Sampling Rate</param> /// <param name="df">Frequency interval</param> /// <param name="Unit">Date Unit: V/Vrms/DBV</param> /// <returns>Spectrum result</returns> public static double[] FFTSpectrum(double[] Wave, int SampleRate, ref double df, DataUnit Unit) { MWNumericArray WaveMatlab = Wave; MWArray WavePointMatlab = Wave.Length; MWArray SampleRateMatlab = SampleRate; MWArray UnitMatlab = (int)Unit; MWArray[] FFTResult; double[,] X2D, Y2D; double[] Y; DSPClass DSPTask = new DSPClass(); FFTResult = DSPTask.Spectrum(2, WaveMatlab, WavePointMatlab, SampleRateMatlab, UnitMatlab); X2D = (double[, ])FFTResult[1].ToArray(); Y2D = (double[, ])FFTResult[0].ToArray(); Y = new double[Y2D.Length]; df = X2D[0, 0]; Buffer.BlockCopy(Y2D, 0, Y, 0, Y2D.Length * sizeof(double)); return(Y); }
private DataJsonConverter(DataUnit unit) { this.unit = unit; }
private void SetUpDataProcessors() { IXmlDataService xmlDataService = new XmlDataService(Configuration, GameData, DefaultData); DataHero dataHero = new DataHero(new HeroDataParser(xmlDataService.GetInstance(), (HeroOverrideLoader)XmlDataOverriders.GetOverrider(typeof(HeroDataParser)))); DataUnit dataUnit = new DataUnit(new UnitParser(xmlDataService.GetInstance(), (UnitOverrideLoader)XmlDataOverriders.GetOverrider(typeof(UnitParser)))); DataMatchAward dataMatchAward = new DataMatchAward(new MatchAwardParser(xmlDataService.GetInstance(), (MatchAwardOverrideLoader)XmlDataOverriders.GetOverrider(typeof(MatchAwardParser)))); DataHeroSkin dataHeroSkin = new DataHeroSkin(new HeroSkinParser(xmlDataService.GetInstance())); DataMount dataMount = new DataMount(new MountParser(xmlDataService.GetInstance())); DataBanner dataBanner = new DataBanner(new BannerParser(xmlDataService.GetInstance())); DataSpray dataSpray = new DataSpray(new SprayParser(xmlDataService.GetInstance())); DataAnnouncer dataAnnouncer = new DataAnnouncer(new AnnouncerParser(xmlDataService.GetInstance())); DataVoiceLine dataVoiceLine = new DataVoiceLine(new VoiceLineParser(xmlDataService.GetInstance())); DataPortrait dataPortrait = new DataPortrait(new PortraitParser(xmlDataService.GetInstance())); DataEmoticon dataEmoticon = new DataEmoticon(new EmoticonParser(xmlDataService.GetInstance())); DataEmoticonPack dataEmoticonPack = new DataEmoticonPack(new EmoticonPackParser(xmlDataService.GetInstance())); DataBehaviorVeterancy dataBehaviorVeterancy = new DataBehaviorVeterancy(new BehaviorVeterancyParser(xmlDataService.GetInstance())); ImageHero filesHero = new ImageHero(CASCHotsStorage?.CASCHandler, StoragePath); ImageUnit filesUnit = new ImageUnit(CASCHotsStorage?.CASCHandler, StoragePath); ImageMatchAward filesMatchAward = new ImageMatchAward(CASCHotsStorage?.CASCHandler, StoragePath); ImageAnnouncer filesAnnouncer = new ImageAnnouncer(CASCHotsStorage?.CASCHandler, StoragePath); ImageVoiceLine filesVoiceLine = new ImageVoiceLine(CASCHotsStorage?.CASCHandler, StoragePath); ImageSpray filesSpray = new ImageSpray(CASCHotsStorage?.CASCHandler, StoragePath); ImageEmoticon filesEmoticon = new ImageEmoticon(CASCHotsStorage?.CASCHandler, StoragePath); DataProcessors.Add(new DataProcessor() { IsEnabled = ExtractDataOption.HasFlag(ExtractDataOption.HeroData), Name = dataHero.Name, Parse = (localization) => dataHero.Parse(localization), Validate = (localization) => dataHero.Validate(localization), Extract = (data) => filesHero.ExtractFiles(data), }); DataProcessors.Add(new DataProcessor() { IsEnabled = ExtractDataOption.HasFlag(ExtractDataOption.Unit), Name = dataUnit.Name, Parse = (localization) => dataUnit.Parse(localization), Validate = (localization) => dataUnit.Validate(localization), Extract = (data) => filesUnit.ExtractFiles(data), }); DataProcessors.Add(new DataProcessor() { IsEnabled = ExtractDataOption.HasFlag(ExtractDataOption.MatchAward), Name = dataMatchAward.Name, Parse = (localization) => dataMatchAward.Parse(localization), Validate = (localization) => dataMatchAward.Validate(localization), Extract = (data) => filesMatchAward.ExtractFiles(data), }); DataProcessors.Add(new DataProcessor() { IsEnabled = ExtractDataOption.HasFlag(ExtractDataOption.HeroSkin), Name = dataHeroSkin.Name, Parse = (localization) => dataHeroSkin.Parse(localization), Validate = (localization) => dataHeroSkin.Validate(localization), }); DataProcessors.Add(new DataProcessor() { IsEnabled = ExtractDataOption.HasFlag(ExtractDataOption.Mount), Name = dataMount.Name, Parse = (localization) => dataMount.Parse(localization), Validate = (localization) => dataMount.Validate(localization), }); DataProcessors.Add(new DataProcessor() { IsEnabled = ExtractDataOption.HasFlag(ExtractDataOption.Banner), Name = dataBanner.Name, Parse = (localization) => dataBanner.Parse(localization), Validate = (localization) => dataBanner.Validate(localization), }); DataProcessors.Add(new DataProcessor() { IsEnabled = ExtractDataOption.HasFlag(ExtractDataOption.Spray), Name = dataSpray.Name, Parse = (localization) => dataSpray.Parse(localization), Validate = (localization) => dataSpray.Validate(localization), Extract = (data) => filesSpray.ExtractFiles(data), }); DataProcessors.Add(new DataProcessor() { IsEnabled = ExtractDataOption.HasFlag(ExtractDataOption.Announcer), Name = dataAnnouncer.Name, Parse = (localization) => dataAnnouncer.Parse(localization), Validate = (localization) => dataAnnouncer.Validate(localization), Extract = (data) => filesAnnouncer.ExtractFiles(data), }); DataProcessors.Add(new DataProcessor() { IsEnabled = ExtractDataOption.HasFlag(ExtractDataOption.VoiceLine), Name = dataVoiceLine.Name, Parse = (localization) => dataVoiceLine.Parse(localization), Validate = (localization) => dataVoiceLine.Validate(localization), Extract = (data) => filesVoiceLine.ExtractFiles(data), }); DataProcessors.Add(new DataProcessor() { IsEnabled = ExtractDataOption.HasFlag(ExtractDataOption.Portrait), Name = dataPortrait.Name, Parse = (localization) => dataPortrait.Parse(localization), Validate = (localization) => dataPortrait.Validate(localization), }); DataProcessors.Add(new DataProcessor() { IsEnabled = ExtractDataOption.HasFlag(ExtractDataOption.Emoticon), Name = dataEmoticon.Name, Parse = (localization) => dataEmoticon.Parse(localization), Validate = (localization) => dataEmoticon.Validate(localization), Extract = (data) => filesEmoticon.ExtractFiles(data), }); DataProcessors.Add(new DataProcessor() { IsEnabled = ExtractDataOption.HasFlag(ExtractDataOption.EmoticonPack), Name = dataEmoticonPack.Name, Parse = (localization) => dataEmoticonPack.Parse(localization), Validate = (localization) => dataEmoticonPack.Validate(localization), }); DataProcessors.Add(new DataProcessor() { IsEnabled = ExtractDataOption.HasFlag(ExtractDataOption.Veterancy), Name = dataBehaviorVeterancy.Name, Parse = (localization) => dataBehaviorVeterancy.Parse(localization), Validate = (localization) => dataBehaviorVeterancy.Validate(localization), }); }
private void updateEvadersMemory() { foreach (Evader ei in gm.A_E) { //if (!state.L[state.MostUpdatedEvadersLocationRound].Keys.Contains(ei) || state.L[state.MostUpdatedEvadersLocationRound][ei].locationType != Location.Type.Node) //if (state.L[state.MostUpdatedEvadersLocationRound][ei].locationType == Location.Type.Captured) // continue; state.M[t][ei] = state.M[state.MostUpdatedEvadersMemoryRound][ei]; state.M[state.MostUpdatedEvadersMemoryRound][ei] = null; //for (int i = 0; i < t - 1; ++i) // Fixme: even though deleting previous memory states doesn't hurt any policy, it MIGHT! //state.M[i] = null; if (!state.L[state.MostUpdatedEvadersLocationRound].Keys.Contains(ei) || state.L[state.MostUpdatedEvadersLocationRound][ei].locationType != Location.Type.Node) { continue; } // if the target was in radius when evader started listening to it, add it: if (state.B_I[state.MostUpdatedEvadersLocationRound][ei].locationType == Location.Type.Node && gr.getMinDistance(state.L[state.MostUpdatedEvadersLocationRound - 1][ei].nodeLocation, state.B_I[state.MostUpdatedEvadersLocationRound][ei].nodeLocation) <= gm.r_e) { state.M[t][ei].Add(new DataUnit() { sourceTarget = state.B_I[state.MostUpdatedEvadersLocationRound][ei], round = state.MostUpdatedEvadersLocationRound }); } if (Params.canEvadersReceiveMultipleBroadcasts) { var targetMem = state.M[t][ei]; var currentB_O = state.B_O[state.MostUpdatedEvadersLocationRound]; DataUnit newDataUnit = DataUnit.NIL; foreach (Evader ej in currentB_O.Keys) { if (ei == ej || targetMem.Contains(currentB_O[ej])) { continue; } var prevLocations = state.L[state.MostUpdatedEvadersLocationRound - 1]; if (!prevLocations.ContainsKey(ei) || !prevLocations.ContainsKey(ej)) { continue; } // if transmission was within distance when it started: if (gm.r_e >= gr.getMinDistance(prevLocations[ei].nodeLocation, prevLocations[ej].nodeLocation)) { if (state.L[state.MostUpdatedEvadersLocationRound].ContainsKey(ej) && state.L[state.MostUpdatedEvadersLocationRound][ej].locationType != Location.Type.Node) { newDataUnit = DataUnit.NIL; // some evader that tried sending data was destroyed mid transmission - this is considered noise anyway break; } targetMem.Add(currentB_O[ej]); } } } else { // O lists the evaders that transmitted data, and ei was able to receive it: List <Evader> O = new List <Evader>(); foreach (Evader ej in state.B_O[state.MostUpdatedEvadersLocationRound].Keys) { if (ei == ej) { continue; } if (state.B_O[state.MostUpdatedEvadersLocationRound][ej] != DataUnit.NIL && state.B_O[state.MostUpdatedEvadersLocationRound][ej] != DataUnit.NOISE && gm.r_e >= gr.getMinDistance(state.L[state.MostUpdatedEvadersLocationRound - 1][ei].nodeLocation, state.L[state.MostUpdatedEvadersLocationRound - 1][ej].nodeLocation)) { O.Add(ej); } } // if more than 1 packets were received, it is considered noise due to collision if (O.Count == 1 && !(state.L[state.MostUpdatedEvadersLocationRound].ContainsKey(O.First()) && state.L[state.MostUpdatedEvadersLocationRound][O.First()].locationType != Location.Type.Node)) // also make sure the evader is still alive { state.M[t][ei].Add(state.B_O[state.MostUpdatedEvadersLocationRound][O.First()]); } } } }
private void MoveToPos(Player player, UnitInfo unit, ActionHolder holder) { DataUnit dUnit = unit.dataUnit; NVector dPos = new NVector(holder.data["pos"]); int level = unit.Pos().level; //go to this field List <PPoint> points = S.Map().PathFinding(level).Path(player, dUnit.movement, unit.Pos(), dPos); NVector last = null; Debug.Log("Go to Goal " + unit.Pos() + " " + dPos); //find last possible point foreach (PPoint pp in points) { NVector p = new NVector(pp.x, pp.y, level); //free field? string s = unit.Passable(p); Debug.Log(p + ": " + s); if (s != null) { break; } //save it last = p; } Debug.Log("Go to Goal " + last); //move their? if (last == null) { if (holder.data.ContainsKey("posTried")) { unit.SetLastInfo(S.T("actionRepeatErrorMove", holder.DataAction().Name())); unit.SetRepeatAction(null); } else { unit.SetLastInfo(S.T("actionRepeatErrorPath", holder.DataAction().Name())); if (unit.data.ap == unit.data.apMax) { holder.data["posTried"] = "yes"; } } return; } //move their unit.MoveTo(last, true); holder.data.Remove("posTried"); if (dPos.Equals(last)) { //perform it holder.data.Remove("pos"); PerformRepeat(player, unit, dPos, holder); } //has enough ap for a next exploration? //todo dynamic if (dUnit.ap >= 10) { //Explore(player, unit, pos, holder); } }
protected static string CreateSuffix(SymbolFormat format, DataUnit unit) { return default(Data).ToString(unit, format).Trim('0'); }
/// <summary> /// Using the data units, which should have already been loaded by this /// time, load the contents of the web page. This includes the title, /// any links and forms. Div tags and spans are also processed. /// </summary> protected void LoadContents() { for (int index = 0; index < _page.getDataSize(); index++) { DataUnit du = _page.GetDataUnit(index); if (du is TagDataUnit) { Tag tag = ((TagDataUnit)du).Tag; if (tag.TagType != Tag.Type.End) { if (string.Compare(tag.Name, "a", true) == 0) { LoadLink(index, tag); } else if (string.Compare(tag.Name, "title", true) == 0) { LoadTitle(index, tag); } else if (string.Compare(tag.Name, "form", true) == 0) { LoadForm(index, tag); } else if (string.Compare(tag.Name, "input", true) == 0) { LoadInput(index, tag); } } if (tag.TagType == Tag.Type.Begin) { if (String.Compare(tag.Name, "div", true) == 0) { LoadDiv(index, tag); } else if (String.Compare(tag.Name, "span", true) == 0) { LoadSpan(index, tag); } } if (tag.TagType == Tag.Type.End) { if (string.Compare(tag.Name, "div") == 0) { if (_lastHierarchyElement != null) { _lastHierarchyElement = _lastHierarchyElement.Parent; } } else if (String.Compare(tag.Name, "span", true) == 0) { if (_lastHierarchyElement != null) { _lastHierarchyElement = _lastHierarchyElement.Parent; } } } } } }
void UpdateUI() { if (_unitData != null) { _model_User = InstancePlayer.instance.model_User; _model_Units = InstancePlayer.instance.model_User.unlockUnits; _dataUnit = _unitData.unitData; _TankNameLabel.text = _unitData.unitData.name.ToString(); _TankNameLabel.color = _unitData.nameColor; // Trace.trace("_unitData.nameColor " + _unitData.nameColor ,Trace.CHANNEL.UI); _iconBg.spriteName = _unitData.iconBgName; _icon.SetUnitSmallTexture(_unitData.id); if (_unitData.isUnLock) { _canResearch_Sprite.gameObject.SetActive(false); } else { _canResearch_Sprite.gameObject.SetActive(_unitData.isCanUnlock); } _format_Sprite.gameObject.SetActive(_unitData.isFormation); if (_unitData.isUnLock) { _model_Units.TryGetValue(_dataUnit.id, out _model_unit); } _lock_Container.gameObject.SetActive(!_unitData.isUnLock); _unlock_Container.gameObject.SetActive(_unitData.isUnLock); if (_model_unit != null && _model_unit.onProduce > 0) { if (_model_unit.produceLeftTime == 0) { _productBtn.gameObject.SetActive(false); _repairBtn.gameObject.SetActive(false); _harvestBtn.gameObject.SetActive(true); _speed_Container.gameObject.SetActive(false); } else { _productBtn.gameObject.SetActive(false); _repairBtn.gameObject.SetActive(false); _harvestBtn.gameObject.SetActive(false); _speed_Container.gameObject.SetActive(true); } } else { _productBtn.gameObject.SetActive(true); _repairBtn.gameObject.SetActive(true); _harvestBtn.gameObject.SetActive(false); _speed_Container.gameObject.SetActive(false); } // // bool isSpeedShow ; // if(_model_unit != null && _model_unit.produceLeftTime > 0) // { // isSpeedShow = true; // } // else // { // isSpeedShow = false; // } // _speed_Container.gameObject.SetActive(isSpeedShow); // _productBtn.gameObject.SetActive(!isSpeedShow); // _repairBtn.gameObject.SetActive(!isSpeedShow); //坦克研发红点 _researchRedPoint.gameObject.SetActive(_unitData.isCanUnlock); _researchBtn.isEnabled = _unitData.isCanUnlock; // 所需图纸个数 _needPaperValue_Label.text = _unitData.unitData.chipCount.ToString(); Model_ItemGroup model_itemGroup = InstancePlayer.instance.model_User.model_itemGroup; Item item = model_itemGroup.QueryItem(_unitData.unitData.chipId); // 拥有的个数 _currentValue_Label.text = item.num.ToString(); // 生产的小红点 ConnectionValidateHelper.CostCheck costCheck = ConnectionValidateHelper.IsEnoughCost(_dataUnit.cost); if (costCheck == ConnectionValidateHelper.CostCheck.OK) { _product_redPoint.gameObject.SetActive(true); } else { _product_redPoint.gameObject.SetActive(false); } // Clear CD Need Cash if (_model_unit != null) { _Timer_Colored_Slider.value = (_model_unit.produceLeftTime) / (float)_model_unit.produceTotalTime; _timeLabel.text = UIHelper.setTimeDHMS(_model_unit.produceLeftTime); float needCash = _model_User.model_InitialConfig.GetClearUnitCDCash(_model_unit.produceLeftTime); _speedCoinLabel.text = (int)needCash + ""; } } }
/// <summary> /// Выполнить запрос в режиме RTU /// </summary> public bool RtuRequest(DataUnit dataUnit) { if (!CheckConnection()) return false; bool result = false; string logText; // отправка запроса ExecWriteToLog(dataUnit.ReqDescr); Connection.Write(dataUnit.ReqADU, 0, dataUnit.ReqADU.Length, CommUtils.ProtocolLogFormats.Hex, out logText); ExecWriteToLog(logText); // приём ответа // считывание начала ответа для определения длины PDU int readCnt = Connection.Read(InBuf, 0, 5, Timeout, CommUtils.ProtocolLogFormats.Hex, out logText); ExecWriteToLog(logText); if (readCnt == 5) { int pduLen; int count; if (InBuf[1] == dataUnit.FuncCode) { // считывание окончания ответа pduLen = dataUnit.RespPduLen; count = dataUnit.RespAduLen - 5; readCnt = Connection.Read(InBuf, 5, count, Timeout, CommUtils.ProtocolLogFormats.Hex, out logText); ExecWriteToLog(logText); } else // устройство вернуло исключение { pduLen = 2; count = 0; readCnt = 0; } if (readCnt == count) { if (InBuf[pduLen + 1] + InBuf[pduLen + 2] * 256 == CalcCRC16(InBuf, 0, pduLen + 1)) { // расшифровка ответа string errMsg; if (dataUnit.DecodeRespPDU(InBuf, 1, pduLen, out errMsg)) { ExecWriteToLog(Phrases.OK); result = true; } else { ExecWriteToLog(errMsg + "!"); } } else { ExecWriteToLog(Phrases.CrcError); } } else { ExecWriteToLog(Phrases.CommErrorWithExclamation); } } else { ExecWriteToLog(Phrases.CommErrorWithExclamation); } return result; }
/// <summary> /// Add a data unit to the collection. /// </summary> /// <param name="unit">The data unit to load.</param> public void AddDataUnit(DataUnit unit) { _data.Add(unit); }
/// <summary> /// Выполнить запрос в режиме TCP /// </summary> public bool TcpRequest(DataUnit dataUnit) { if (NetStream == null) { ExecWriteToLog(Phrases.RequestImpossible); return false; } bool result = false; bool closeNetStream = false; try { // отправка запроса WriteToLog(dataUnit.ReqDescr); WriteNetStream(dataUnit.ReqADU, dataUnit.ReqADU.Length); // приём ответа if (ReadNetStream(0, 7) /*считывание MBAP Header*/ == 7) { int pduLen = InBuf[4] * 256 + InBuf[5] - 1; if (InBuf[0] == 0 && InBuf[1] == 0 && InBuf[2] == 0 && InBuf[3] == 0 && pduLen > 0 && InBuf[6] == dataUnit.ReqADU[6]) { if (ReadNetStream(7, pduLen) /*считывание PDU*/ == pduLen) { // расшифровка ответа string errMsg; if (dataUnit.DecodeRespPDU(InBuf, 7, pduLen, out errMsg)) { ExecWriteToLog(Phrases.OK); result = true; } else { ExecWriteToLog(errMsg + "!"); } } else { WriteToLog(Phrases.CommErrorWithExclamation); } } else { WriteToLog(Phrases.IncorrectMbap); } } else { WriteToLog(Phrases.CommErrorWithExclamation); } } catch (Exception ex) { WriteToLog(Phrases.CommError + ": " + ex.Message); closeNetStream = true; } // очистка потока данных в случае ошибки if (!result) ClearNetStream(); if (closeNetStream) { NetStream.Close(); NetStream = null; } return result; }
/// <summary> /// Initializes a new instance of <see cref="Gu.Units.Wpf.DataConverter"/>. /// </summary> /// <param name="unit"><see cref="Gu.Units.DataUnit"/>.</param> public DataConverter(DataUnit unit) { Unit = unit; }
/// <summary> /// Add a data unit to the collection. /// </summary> /// <param name="unit">The data unit to load.</param> public void AddDataUnit(DataUnit unit) { this.data.Add(unit); }
/// <summary> /// Add a data unit to the collection. /// </summary> /// <param name="unit">The data unit to load.</param> public void AddDataUnit(DataUnit unit) { this.data.Add(unit); }
public void SendData(DataUnit dataUnit) { _svc.SomeMethod(dataUnit); }
public void AddDataUnit(DataUnit unit) { this._x4a3f0a05c02f235f.Add(unit); }
void UpdateUI() { if (_model_Unit != null) { _units = InstancePlayer.instance.model_User.unlockUnits; _units.TryGetValue(_model_Unit.unitId, out _model_Unit); _model_RepairUnit = InstancePlayer.instance.model_User.model_RepairUnit; _repairUnitsList = _model_RepairUnit.GetRepairUnits(); _dataUnit = DataManager.instance.dataUnitsGroup.GetUnit(_model_Unit.unitId); TankDataManager tankmanager = new TankDataManager(); _unitData = tankmanager.InitUnitData(_dataUnit); _canRepairUnitCount = (float)_model_Unit.onDamaged; _tankName.color = _unitData.nameColor; _iconBg.spriteName = _unitData.iconBgName; _icon.spriteName = _unitData.iconName; _thumbIcon.spriteName = _unitData.iconName; _tankName.text = _dataUnit.name; if (_tankSlider != null && _addTankNumLabel != null) { _addTankNumLabel.text = Mathf.RoundToInt(_tankSlider.value * _canRepairUnitCount).ToString(); _CurrentTankNum = Mathf.RoundToInt(_tankSlider.value * _canRepairUnitCount); } _Damage_3_ValueLabel.text = _model_Unit.onDamaged.ToString(); _Damage_2_ValueLabel.text = _model_Unit.num.ToString(); _Damage_1_ValueLabel.text = _model_Unit.onProduce.ToString(); bool isRepairIng = false; foreach (SlgPB.Unit unit in _repairUnitsList) { if (unit.unitId == _model_Unit.unitId) { if (_model_RepairUnit.repairLeftTime > 0) { isRepairIng = true; } break; } } if (isRepairIng) { if (_model_RepairUnit != null && _model_RepairUnit.repairLeftTime > 0) { _speed_Container.gameObject.SetActive(true); _recoverContainer.gameObject.SetActive(false); _Timer_Colored_Slider.value = (float)_model_RepairUnit.repairLeftTime / _model_RepairUnit.repairTotalTimeSec; } } else { _speed_Container.gameObject.SetActive(false); _recoverContainer.gameObject.SetActive(true); } ResData(); if ((_model_Unit.onDamaged == 0) && (_model_Unit.onRepair == 0)) { NGUITools.Destroy(this.gameObject); NotificationCenter.instance.DispatchEvent(Notification_Type.RequestRepairTank, new Notification(_model_Unit)); } } }
public void Update(DataUnit dataUnit) { throw new NotImplementedException(); }
private string GetDescription(string descript) { switch (command) { case "CommanderLv": //指挥官提升到N级 { descript = StringHelper.GenerateCompleteDescription(descript, source); } break; case "PassMission": //完成系统指定的关卡 { int magicId = (int)source; DataMission dataMission = DataManager.instance.dataMissionGroup.GetMission(magicId); descript = StringHelper.GenerateCompleteDescription(descript, dataMission.name, destination); } break; case "SpecifiedUnitPartLv": //指定unitpart强化到N级 { int unitId = (int)source; DataUnit dataUnit = DataManager.instance.dataUnitsGroup.GetUnit(unitId); int partId = (int)destination; DataUnitPart dataUnitPart = DataManager.instance.dataUnitPartGroup.GetPart(partId, 1); descript = StringHelper.GenerateCompleteDescription(descript, dataUnit.name, dataUnitPart.name, additional); } break; case "SpecifiedHeroLv": //指定hero升级到N级 { int heroId = (int)source; DataHero dataHero = DataManager.instance.dataHeroGroup.GetHeroPrimitive(heroId); descript = StringHelper.GenerateCompleteDescription(descript, dataHero.name, destination); } break; case "SpecifiedHeroStage": //指定hero升衔到N阶 { int heroId = (int)source; DataHero dataHero = DataManager.instance.dataHeroGroup.GetHeroPrimitive(heroId); descript = StringHelper.GenerateCompleteDescription(descript, dataHero.name, destination); } break; case "ConsumeStar": //获得N颗星星 { descript = StringHelper.GenerateCompleteDescription(descript, source); } break; case "GainUnit": //获得指定unit { int unitId = (int)source; DataUnit dataUnit = DataManager.instance.dataUnitsGroup.GetUnit(unitId); descript = StringHelper.GenerateCompleteDescription(descript, dataUnit.name, destination); } break; case "GainHero": //获得指定hero { int heroId = (int)source; DataHero dataHero = DataManager.instance.dataHeroGroup.GetHeroPrimitive(heroId); descript = StringHelper.GenerateCompleteDescription(descript, dataHero.name); } break; case "ArenaRankings": //在竞技场达到指定排名 { descript = StringHelper.GenerateCompleteDescription(descript, source); } break; case "BuildingLv": //相应建筑提升到N级 { int buildingId = (int)source; DataBuilding dataBuilding = DataManager.instance.dataBuildingGroup.GetBuilding(buildingId, 1); descript = StringHelper.GenerateCompleteDescription(descript, dataBuilding.name, destination); } break; } return(descript); }
protected abstract Notification DoValidate(DataUnit dataUnit, Notification notification);
public static void DataConnect(DataUnit source, DataUnit target) { Builder.DataConnect(source, target, String.Empty); }
public Data(Pedigree pedigree, DataUnit dataunit) : this() { this.Pedigree = pedigree; this.Dataunit = dataunit; }
/// <inheritdoc /> public string DataUnitHumanize(DataUnit dataUnit, double count, bool toSymbol = true) => Transformer.Transform(Inner.DataUnitHumanize(dataUnit, count, toSymbol));
public void Read(TProtocol iprot) { iprot.IncrementRecursionDepth(); try { bool isset_pedigree = false; bool isset_dataunit = false; TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.Struct) { Pedigree = new Pedigree(); Pedigree.Read(iprot); isset_pedigree = true; } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 2: if (field.Type == TType.Struct) { Dataunit = new DataUnit(); Dataunit.Read(iprot); isset_dataunit = true; } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); if (!isset_pedigree) { throw new TProtocolException(TProtocolException.INVALID_DATA); } if (!isset_dataunit) { throw new TProtocolException(TProtocolException.INVALID_DATA); } } finally { iprot.DecrementRecursionDepth(); } }
protected bool Equals(DataUnit other) { return Amount == other.Amount; }
protected bool Equals(DataUnit other) { return(Amount == other.Amount); }
/// <summary> /// Выполнить запрос в режиме ASCII /// </summary> public bool AsciiRequest(DataUnit dataUnit) { if (!CheckConnection()) return false; bool result = false; string logText; // отправка запроса ExecWriteToLog(dataUnit.ReqDescr); Connection.WriteLine(dataUnit.ReqStr, out logText); ExecWriteToLog(logText); // приём ответа string line = Connection.ReadLine(Timeout, out logText); ExecWriteToLog(logText); int lineLen = line == null ? 0 : line.Length; if (lineLen >= 3) { int aduLen = (lineLen - 1) / 2; if (aduLen == dataUnit.RespAduLen && lineLen % 2 == 1) { // получение ADU ответа byte[] aduBuf = new byte[aduLen]; bool parseOK = true; for (int i = 0, j = 1; i < aduLen && parseOK; i++, j += 2) { try { aduBuf[i] = byte.Parse(line.Substring(j, 2), NumberStyles.HexNumber); } catch { ExecWriteToLog(Phrases.IncorrectSymbol); parseOK = false; } } if (parseOK) { if (aduBuf[aduLen - 1] == Modbus.CalcLRC(aduBuf, 0, aduLen - 1)) { // расшифровка ответа string errMsg; if (dataUnit.DecodeRespPDU(aduBuf, 1, aduLen - 2, out errMsg)) { ExecWriteToLog(Phrases.OK); result = true; } else { ExecWriteToLog(errMsg + "!"); } } else { ExecWriteToLog(Phrases.LrcError); } } } else { ExecWriteToLog(Phrases.IncorrectAduLength); } } else { ExecWriteToLog(Phrases.CommErrorWithExclamation); } return result; }
public DataConverter(DataUnit unit) { this.Unit = unit; }
/// <summary> /// Add a data unit to the collection. /// </summary> /// <param name="unit">The data unit to load.</param> public void AddDataUnit(DataUnit unit) { _data.Add(unit); }
/// <summary> /// Выполнить запрос в режиме ASCII /// </summary> public bool AsciiRequest(DataUnit dataUnit) { bool result = false; // отправка запроса ExecWriteToLog(dataUnit.ReqDescr); string logText; KPUtils.WriteLineToSerialPort(SerialPort, dataUnit.ReqStr, out logText); ExecWriteToLog(logText); // приём ответа bool endFound; List<string> lines = KPUtils.ReadLinesFromSerialPort(SerialPort, Timeout, false, "", out endFound, out logText); ExecWriteToLog(logText); string line = lines.Count == 1 ? lines[0] : ""; int lineLen = line.Length; if (lineLen >= 3) { int aduLen = (lineLen - 1) / 2; if (aduLen == dataUnit.RespAduLen && lineLen % 2 == 1) { // получение ADU ответа byte[] aduBuf = new byte[aduLen]; bool parseOK = true; for (int i = 0, j = 1; i < aduLen && parseOK; i++, j += 2) { try { aduBuf[i] = byte.Parse(line.Substring(j, 2), NumberStyles.HexNumber); } catch { ExecWriteToLog(Phrases.IncorrectSymbol); parseOK = false; } } if (parseOK) { if (aduBuf[aduLen - 1] == Modbus.CalcLRC(aduBuf, 0, aduLen - 1)) { // расшифровка ответа string errMsg; if (dataUnit.DecodeRespPDU(aduBuf, 1, aduLen - 2, out errMsg)) { ExecWriteToLog(Phrases.OK); result = true; } else { ExecWriteToLog(errMsg + "!"); } } else { ExecWriteToLog(Phrases.LrcError); } } } else { ExecWriteToLog(Phrases.IncorrectAduLength); } } else { ExecWriteToLog(Phrases.CommErrorWithExclamation); } return result; }