void removeMenuBtn(int id) { FunctionEvent fe = new FunctionEvent(FunctionEvent.FUNCTION_LOCKED); fe.functionid = id; EventSystem.Instance.PushEvent(fe); }
protected override long RunDisruptorPass() { CountdownEvent latch = new CountdownEvent(1); stepThreeFunctionHandler.reset(latch, stepThreeBatchProcessor.Sequence.Value + ITERATIONS); Task.Run(() => stepOneBatchProcessor.Run()); Task.Run(() => stepTwoBatchProcessor.Run()); Task.Run(() => stepThreeBatchProcessor.Run()); Stopwatch start = Stopwatch.StartNew(); long operandTwo = OPERAND_TWO_INITIAL_VALUE; for (long i = 0; i < ITERATIONS; i++) { long sequence = ringBuffer.Next(); FunctionEvent @event = ringBuffer[sequence]; @event.OperandOne = i; @event.OperandTwo = operandTwo--; ringBuffer.Publish(sequence); } latch.Wait(); long opsPerSecond = (ITERATIONS * 1000L) / (start.ElapsedMilliseconds); stepOneBatchProcessor.Halt(); stepTwoBatchProcessor.Halt(); stepThreeBatchProcessor.Halt(); PerfTestUtil.failIfNot(expectedResult, stepThreeFunctionHandler.StepThreeCounter); return(opsPerSecond); }
/// <summary> /// Evaluates a function and returns its value. It is assumed the current /// position is at the opening parenthesis of the argument list. /// </summary> /// <param name="parser">TextParser object</param> /// <param name="name">Name of function</param> /// <param name="pos">Position at start of function</param> /// <returns></returns> protected object EvaluateFunction(TextParser parser, string name, int pos) { FunctionEvent f = new FunctionEvent() { Name = name, // Parse function parameters Parameters = ParseParameters(parser), Status = FunctionStatus.OK, }; ProcessFunction(ref f); if (f.Status == FunctionStatus.UndefinedFunction) { throw new EvalException(String.Format(ErrorMessages.ErrUndefinedFunction, name), name, pos); } if (f.Status == FunctionStatus.WrongParameterCount) { throw new EvalException(ErrorMessages.ErrWrongParamCount, name, pos); } if (f.Status == FunctionStatus.WrongArgument) { throw new EvalException(ErrorMessages.ErrWrongArguments, name, pos); } return(f.Result); }
public static void SetRedPointActive(int functionId, bool active) { FunctionEvent fe = new FunctionEvent(FunctionEvent.FUNCTION_RED_POINT); fe.functionid = functionId; fe.isShow = active; EventSystem.Instance.PushEvent(fe); }
public static FunctionEvent Read(BinaryReader reader) { FunctionEvent result = new FunctionEvent(); result.ThreadId = Utilities.Read7BitEncodedInt(reader); result.FunctionId = Utilities.Read7BitEncodedInt(reader); result.TimeStamp = Utilities.Read7BitEncodedInt64(reader); return(result); }
private void OnClickClose() { WindowManager.Instance.CloseUI("questAward"); if (!mModule.ShowNextAward()) { FunctionEvent ev = new FunctionEvent(FunctionEvent.FUNCTION_CHECK_EVENT); EventSystem.Instance.PushEvent(ev); //检测助手 ZhushouManager.Instance.Begin(); } SoundManager.Instance.Play(15); }
private void OnUnlockComplete(int id, bool guide = true) { mUnlocks.Add(id, true); FunctionEvent evt = new FunctionEvent(FunctionEvent.FUNCTION_UNLOCKED); evt.functionid = id; EventSystem.Instance.PushEvent(evt); //触发引导 if (guide) { GuideModule module = ModuleManager.Instance.FindModule <GuideModule>(); module.OnFunctionUnlock(id); } }
void onRedPointEvent(EventBase ev) { if (ev == null) { return; } FunctionEvent fe = ev as FunctionEvent; if (fe == null) { return; } setRedPointActive(fe.functionid, fe.isShow); }
/// <summary> /// Метод для добавления нового пункта меню /// </summary> /// <param name="name">Название пункта меню</param> /// <param name="functionEvent">Функция выполняемое пунктом меню</param> public void AddItem(string name, FunctionEvent functionEvent) // внесение в список нового айтема { menuItems.Insert(0, new menuItem(name, functionEvent)); }
public menuItem(string nameItem, FunctionEvent functionEvent) { this.nameItem = nameItem; this.functionEvent = functionEvent; }
protected void ProcessFunction(ref FunctionEvent e) { if (String.Compare(e.Name, Functions.abs.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Abs((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Abs((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.arcos.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Acos((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Acos((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.arsin.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Asin((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Asin((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.arctan.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Atan((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Atan((DoubleArray)e.Parameters[0]); } } else if (e.Parameters.Count == 2) { if (e.Parameters[0] is Double && e.Parameters[1] is Double) { e.Result = Math.Atan2((double)e.Parameters[0], (double)e.Parameters[1]); } else if (e.Parameters[0] is DoubleArray && e.Parameters[1] is Double) { e.Result = DoubleArray.Atan2((DoubleArray)e.Parameters[0], (double)e.Parameters[1]); } else if (e.Parameters[0] is Double && e.Parameters[1] is DoubleArray) { e.Result = DoubleArray.Atan2((Double)e.Parameters[0], (DoubleArray)e.Parameters[1]); } else { e.Status = FunctionStatus.WrongArgument; } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.ceiling.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Ceiling((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Ceiling((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.cos.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Cos((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Cos((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.cosh.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Cosh((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Cosh((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.exp.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Exp((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Exp((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.floor.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Floor((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Floor((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.log.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Log((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Log((DoubleArray)e.Parameters[0]); } } else if (e.Parameters.Count == 2) { if (e.Parameters[0] is Double && e.Parameters[1] is Double) { e.Result = Math.Log((double)e.Parameters[0], (int)e.Parameters[1]); } else if (e.Parameters[0] is DoubleArray && e.Parameters[1] is Double) { e.Result = DoubleArray.Log((DoubleArray)e.Parameters[0], (int)e.Parameters[1]); } else { e.Status = FunctionStatus.WrongArgument; } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.log10.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Log10((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Log10((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.pow.ToString(), true) == 0) { if (e.Parameters.Count == 2) { if (e.Parameters[0] is Double && e.Parameters[1] is Double) { e.Result = Math.Pow((double)e.Parameters[0], (double)e.Parameters[1]); } else if (e.Parameters[0] is DoubleArray && e.Parameters[1] is Double) { e.Result = DoubleArray.Pow((DoubleArray)e.Parameters[0], (double)e.Parameters[1]); } else { e.Status = FunctionStatus.WrongArgument; } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.round.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Round((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Round((DoubleArray)e.Parameters[0]); } } else if (e.Parameters.Count == 2) { if (e.Parameters[0] is Double && e.Parameters[1] is Double) { e.Result = Math.Round((double)e.Parameters[0], (int)((double)e.Parameters[1])); } else if (e.Parameters[0] is DoubleArray && e.Parameters[1] is Double) { e.Result = DoubleArray.Round((DoubleArray)e.Parameters[0], (int)((double)e.Parameters[1])); } else { e.Status = FunctionStatus.WrongArgument; } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.sin.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Sin((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Sin((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.sinh.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Sinh((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Sinh((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.sqrt.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Sqrt((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Sqrt((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.tan.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Tan((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Tan((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.tanh.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Tanh((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Tanh((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.truncate.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = Math.Truncate((double)e.Parameters[0]); } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.Truncate((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.mean.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.MeanValue((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } // Conversion Degree <-> Radian else if (String.Compare(e.Name, Functions.toDeg.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = (double)e.Parameters[0] / Math.PI * 180.0; } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.RadianToDegree((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } else if (String.Compare(e.Name, Functions.toRad.ToString(), true) == 0) { if (e.Parameters.Count == 1) { if (e.Parameters[0] is Double) { e.Result = (double)e.Parameters[0] * Math.PI / 180.0; } else if (e.Parameters[0] is DoubleArray) { e.Result = DoubleArray.DegreeToRadian((DoubleArray)e.Parameters[0]); } } else { e.Status = FunctionStatus.WrongParameterCount; } } // Unknown function name else { e.Status = FunctionStatus.UndefinedFunction; } }
public static FunctionEvent Read(BinaryReader reader) { FunctionEvent result = new FunctionEvent(); result.ThreadId = Utilities.Read7BitEncodedInt(reader); result.FunctionId = Utilities.Read7BitEncodedInt(reader); result.TimeStamp = Utilities.Read7BitEncodedInt64(reader); return result; }
void OnFuntionUnlock(EventBase evt) { FunctionEvent ev = (FunctionEvent)evt; AddMenu(ev.functionid); }
void OnFunctionLocked(EventBase evt) { FunctionEvent fe = (FunctionEvent)evt; RemoveMenu(fe.functionid); }