protected virtual void UpdateItemInfo(TriplePairArbitrageInfo info) { double profit = info.Profit; OperationDirection direction = info.Direction; info.Calculate(); if (info.Profit != profit || direction != info.Direction) { StrategyData.Add(new TriplePairInfoHistoryItem(info)); if (EnableNotifications) { SendNotification("dir = " + info.Direction + " profit = " + info.Profit.ToString("0.########") + " disb = " + info.Disbalance.ToString("0.########")); } } if (!DemoMode && !ShouldProcessArbitrage && info.IsSelected) { ShouldProcessArbitrage = true; if (!info.MakeOperation()) { info.IsErrorState = true; Log(LogType.Error, GetLogDescription(info, "arbitrage failed. resolve conflicts manually."), 0, 0, StrategyOperation.MarketBuy); } if (info.OperationExecuted) { info.OperationExecuted = false; Log(LogType.Error, GetLogDescription(info, "operation executed"), 0, 0, StrategyOperation.MarketBuy); } ShouldProcessArbitrage = false; } info.IsUpdating = false; }
private void LogDiagnostics(string key, RedisValue serializedState, OperationDirection direction, Type grainStateType) { if (!_logger.IsEnabled(LogLevel.Warning)) { return; } var stateBytes = (byte[])serializedState; var stateSize = ByteSize.FromBytes(stateBytes.Length); var keySize = ByteSize.FromBytes(Encoding.UTF8.GetByteCount(key)); if (stateSize.MebiBytes > _options.FieldSizeWarningThresholdInMb) { _logger.LogWarning( "Redis value exceeds threshold {size}MB/{threshold}MB. Key: {redisKey}, Data Type: {dataType}, Type: {grainStateType}, Direction: {direction}", Math.Round(stateSize.MebiBytes, 2), _options.FieldSizeWarningThresholdInMb, key, "GrainState", grainStateType.GetDemystifiedName(), direction ); } if (keySize.MebiBytes > _options.FieldSizeWarningThresholdInMb) { _logger.LogWarning( "Redis value exceeds threshold {size}MB/{threshold}MB. Key: {redisKey}, Data Type: {dataType}, Direction: {direction}", Math.Round(stateSize.MebiBytes, 2), _options.FieldSizeWarningThresholdInMb, key, "Key", direction ); } }
public Operation(string accountId, decimal amount, OperationDirection direction) { AccountId = accountId; Amount = amount; Direction = direction; Date = DateTime.UtcNow; }
private async Task TimeAction(Func <Task> action, string key, OperationDirection direction, Type grainStateType) { if (!_logger.IsEnabled(LogLevel.Warning)) { await action(); return; } var watch = ValueStopwatch.StartNew(); await action(); var stopwatchElapsed = watch.GetElapsedTime(); var threshold = _options.ExecutionDurationWarnThreshold; if (_logger.IsEnabled(LogLevel.Warning) && stopwatchElapsed > threshold) { _logger.LogWarning( "Redis operation took longer than threshold {elapsed:n0}ms/{thresholdDuration:n0}ms. Key: {redisKey}, Type: {grainStateType}, Direction: {direction}", stopwatchElapsed.TotalMilliseconds, threshold.TotalMilliseconds, key, grainStateType.GetDemystifiedName(), direction ); } }
private void Shift(OperationDirection direction, ShiftType shiftType) { byte result = ALURightBuffer; bool leftmostBitIsSet = (result & B10000000) != 0; // Shift 1 bit to the left or to the right if (direction == OperationDirection.Left) { result <<= 1; if (shiftType == ShiftType.Logical) { result |= B00000001; } CF = leftmostBitIsSet; } else if (direction == OperationDirection.Right) { bool rightmostBitIsSet = (result & B00000001) != 0; result >>= 1; if (shiftType == ShiftType.Arithmetic && leftmostBitIsSet) { result |= B10000000; } CF = rightmostBitIsSet; } // Send result to the data bus InternalDataBus = result; // Compute flags // HF an NF are always reset // SF, ZF, PF, XF and YF will be updated F &= B00000001; // Flags bit 5 - YF flag - A copy of bit 5 of the result. // Flags bit 3 - XF flag - A copy of bit 3 of the result. F |= (byte)(result & B00101000); // Flags bit 7 - SF flag - Set if the 2-complement value is negative. It's simply a copy of the most signifcant bit of the result. F |= (byte)(result & B10000000); // Flags bit 6 - ZF flag Set if the result is zero. if (result == 0) { F |= B01000000; } // PF : parity of the result PF = numberOfBitsInByteParityTable[result]; if (TraceMicroInstructions) { TraceMicroInstruction(new MicroInstruction(Z80MicroInstructionTypes.BitOperationShift, direction, shiftType)); } }
private void RotateBCDDigit(OperationDirection direction) { int result = 0; if (direction == OperationDirection.Left) { // Move lower nibble to higher nibble in right buffer result = ALURightBuffer << 4; // Move lower nibble of left buffer to lower nibble of right buffer result |= ALULeftBuffer & B00001111; // Move higher nibble of right buffer to lower nibble of left buffer ALULeftBuffer = (byte)((ALULeftBuffer & B11110000) | (ALURightBuffer >> 4)); } else if (direction == OperationDirection.Right) { // Move higher nibble to lower nibble in right buffer result = ALURightBuffer >> 4; // Move lower nibble of left buffer to higher nibble of right buffer result |= (ALULeftBuffer << 4); // Move lower nibble of right buffer to lower nibble of left buffer ALULeftBuffer = (byte)((ALULeftBuffer & B11110000) | (ALURightBuffer & B00001111)); } // Send result to the data bus byte truncResult = (byte)result; InternalDataBus = truncResult; // Compute flags // HF an NF are always reset // SF, ZF, PF, XF and YF will be updated F &= B00000001; // Flags bit 5 - YF flag - A copy of bit 5 of the result. // Flags bit 3 - XF flag - A copy of bit 3 of the result. F |= (byte)(ALULeftBuffer & B00101000); // Flags bit 7 - SF flag - Set if the 2-complement value is negative. It's simply a copy of the most signifcant bit of the result. F |= (byte)(ALULeftBuffer & B10000000); // Flags bit 6 - ZF flag Set if the result is zero. if (ALULeftBuffer == 0) { F |= B01000000; } // PF : parity of the result PF = numberOfBitsInByteParityTable[ALULeftBuffer]; if (TraceMicroInstructions) { TraceMicroInstruction(new MicroInstruction(Z80MicroInstructionTypes.BitOperationRotateBCDDigit, direction)); } }
public bool UpdateResPraizedNum(string resCode, PraizeType praizeType, OperationDirection direction) { var op = Db.Updateable <EResourceInfo>().SetColumns(a => new EResourceInfo() { goodNum = a.goodNum - 1 }); if (praizeType == PraizeType.good && direction == OperationDirection.plus) { op = Db.Updateable <EResourceInfo>().SetColumns(a => new EResourceInfo() { goodNum = a.goodNum + 1 }); } else if (praizeType == PraizeType.bad && direction == OperationDirection.plus) { op = Db.Updateable <EResourceInfo>().SetColumns(a => new EResourceInfo() { badNum = a.badNum + 1 }); } else if (praizeType == PraizeType.bad && direction == OperationDirection.minus) { op = Db.Updateable <EResourceInfo>().SetColumns(a => new EResourceInfo() { badNum = a.badNum - 1 }); } else if (praizeType == PraizeType.good && direction == OperationDirection.update) { op = Db.Updateable <EResourceInfo>().SetColumns(a => new EResourceInfo() { goodNum = a.goodNum + 1, badNum = a.badNum - 1 }); } else if (praizeType == PraizeType.bad && direction == OperationDirection.update) { op = Db.Updateable <EResourceInfo>().SetColumns(a => new EResourceInfo() { badNum = a.badNum + 1, goodNum = a.goodNum - 1 }); } op = op.Where(a => a.Code == resCode); return(op.ExecuteCommandHasChange()); }
public bool UpdateBookResNum(string bookCode, OperationDirection direction) { var op = Db.Updateable <EBookInfo>().SetColumns(a => new EBookInfo() { ResoureNum = a.ResoureNum + 1, UpdateDateTime = DateTime.Now }); if (direction == OperationDirection.minus) { op = Db.Updateable <EBookInfo>().SetColumns(a => new EBookInfo() { ResoureNum = a.ResoureNum + 1, UpdateDateTime = DateTime.Now }); } op = op.Where(a => a.Code == bookCode); return(op.ExecuteCommandHasChange()); }
public bool UpdateCommentReplyPraized_GoodNum(long commentReplyId, OperationDirection direction, int num = 1) { var op = Db.Updateable <ECommentReply_Res>().SetColumns(a => new ECommentReply_Res() { goodNum = a.goodNum + num }); if (direction == OperationDirection.minus) { op = Db.Updateable <ECommentReply_Res>().SetColumns(a => new ECommentReply_Res() { goodNum = a.goodNum - num }); } op = op.Where(a => a.Id == commentReplyId); return(op.ExecuteCommandHasChange()); }
public static MessageHeaders GetMessageHeaders(this OperationContext context, OperationDirection direction) { MessageHeaders headers = null; if (context != null) { if (direction == OperationDirection.Incoming) { headers = context.IncomingMessageHeaders; } if (direction == OperationDirection.Outgoing) { headers = context.OutgoingMessageHeaders; } } return(headers); }
/// <summary> /// Tries to read some portion of the data stream. /// Returns the readed portion of data stream in a System.Byte[] array. /// </summary> public Byte[] Read(OperationDirection operationDirection, UInt32 numberOfBytes, Boolean asyncOperation) { Boolean _argumentValuesValid = new Boolean(); UInt32 _localValue = new UInt32(); switch (operationDirection) { case OperationDirection.Forward: { // The number of bytes must be greater than zero. _argumentValuesValid = (numberOfBytes > _localValue); }; break; case OperationDirection.Back: { // The number of bytes must be negative. _argumentValuesValid = (numberOfBytes < _localValue); }; break; default: // For the zero value, does nothing. break; } if (asyncOperation) { // Should use the async available methods for management of data stream. } else { // Should use the non-async available methods for management of data stream. }; return(this._internalStream); }
public static T GetHeader <T>(this OperationContext context, OperationDirection direction, string name) { return(context.GetMessageHeaders(direction).GetHeader <T>(name)); }
public Byte[] Read(OperationDirection operationDirection, UInt32 numberOfBytes, Boolean asyncOperation) { return(this._internalStream = base.Read(operationDirection, numberOfBytes, asyncOperation)); }
private void RotateBCDDigit(OperationDirection direction) { int result = 0; if (direction == OperationDirection.Left) { // Move lower nibble to higher nibble in right buffer result = ALURightBuffer << 4; // Move lower nibble of left buffer to lower nibble of right buffer result |= ALULeftBuffer & B00001111; // Move higher nibble of right buffer to lower nibble of left buffer ALULeftBuffer = (byte)((ALULeftBuffer & B11110000) | (ALURightBuffer >> 4)); } else if (direction == OperationDirection.Right) { // Move higher nibble to lower nibble in right buffer result = ALURightBuffer >> 4; // Move lower nibble of left buffer to higher nibble of right buffer result |= (ALULeftBuffer << 4); // Move lower nibble of right buffer to lower nibble of left buffer ALULeftBuffer = (byte)((ALULeftBuffer & B11110000) | (ALURightBuffer & B00001111)); } // Send result to the data bus byte truncResult = (byte)result; InternalDataBus = truncResult; // Compute flags // HF an NF are always reset // SF, ZF, PF, XF and YF will be updated F &= B00000001; // Flags bit 5 - YF flag - A copy of bit 5 of the result. // Flags bit 3 - XF flag - A copy of bit 3 of the result. F |= (byte)(ALULeftBuffer & B00101000); // Flags bit 7 - SF flag - Set if the 2-complement value is negative. It's simply a copy of the most signifcant bit of the result. F |= (byte)(ALULeftBuffer & B10000000); // Flags bit 6 - ZF flag Set if the result is zero. if (ALULeftBuffer == 0) F |= B01000000; // PF : parity of the result PF = numberOfBitsInByteParityTable[ALULeftBuffer]; if (TraceMicroInstructions) { TraceMicroInstruction(new MicroInstruction(Z80MicroInstructionTypes.BitOperationRotateBCDDigit, direction)); } }
private void Rotate(OperationDirection direction, bool includeCarryInRotation, bool forAccumulator) { // Select byte to rotate byte result = 0; if (forAccumulator) { result = ALULeftBuffer; } else { result = ALURightBuffer; } // Rotate 1 bit to the left or to the right if(direction == OperationDirection.Left) { bool leftmostBitIsSet = (result & B10000000) != 0; result <<= 1; if ((includeCarryInRotation && CF) | (!includeCarryInRotation && leftmostBitIsSet)) result |= B00000001; CF = leftmostBitIsSet; } else if(direction == OperationDirection.Right) { bool rightmostBitIsSet = (result & B00000001) != 0; result >>= 1; if ((includeCarryInRotation && CF) | (!includeCarryInRotation && rightmostBitIsSet)) result |= B10000000; CF = rightmostBitIsSet; } // Send result to the data bus InternalDataBus = result; // Compute flags // HF an NF are always reset // XF and YF will be updated F &= B11000101; // Flags bit 5 - YF flag - A copy of bit 5 of the result. // Flags bit 3 - XF flag - A copy of bit 3 of the result. F |= (byte)(result & B00101000); if (!forAccumulator) { // SF flag - Set if the 2-complement value is negative. It's simply a copy of the most signifcant bit of the result. SF = (result & B10000000) != 0; // ZF flag Set if the result is zero. ZF = result == 0; // PF : parity of the result PF = numberOfBitsInByteParityTable[result]; } if (TraceMicroInstructions) { TraceMicroInstruction(new MicroInstruction(Z80MicroInstructionTypes.BitOperationRotate, direction, includeCarryInRotation, forAccumulator)); } }
private void Shift(OperationDirection direction, ShiftType shiftType) { byte result = ALURightBuffer; bool leftmostBitIsSet = (result & B10000000) != 0; // Shift 1 bit to the left or to the right if (direction == OperationDirection.Left) { result <<= 1; if (shiftType == ShiftType.Logical) result |= B00000001; CF = leftmostBitIsSet; } else if (direction == OperationDirection.Right) { bool rightmostBitIsSet = (result & B00000001) != 0; result >>= 1; if (shiftType == ShiftType.Arithmetic && leftmostBitIsSet) result |= B10000000; CF = rightmostBitIsSet; } // Send result to the data bus InternalDataBus = result; // Compute flags // HF an NF are always reset // SF, ZF, PF, XF and YF will be updated F &= B00000001; // Flags bit 5 - YF flag - A copy of bit 5 of the result. // Flags bit 3 - XF flag - A copy of bit 3 of the result. F |= (byte)(result & B00101000); // Flags bit 7 - SF flag - Set if the 2-complement value is negative. It's simply a copy of the most signifcant bit of the result. F |= (byte)(result & B10000000); // Flags bit 6 - ZF flag Set if the result is zero. if (result == 0) F |= B01000000; // PF : parity of the result PF = numberOfBitsInByteParityTable[result]; if (TraceMicroInstructions) { TraceMicroInstruction(new MicroInstruction(Z80MicroInstructionTypes.BitOperationShift, direction, shiftType)); } }
public void BeginAddOperation(OperationDirection operationDirection, string operationName) { switch (operationDirection) { case OperationDirection.ClientToServer: ClientToServerOperationName = operationName; break; case OperationDirection.ServerToClient: ServerToClientOperationName = operationName; break; } }
public void EndAddOperation(OperationDirection operationDirection) { switch (operationDirection) { case OperationDirection.ClientToServer: ClientToServerOperationName = ""; break; case OperationDirection.ServerToClient: ServerToClientOperationName = ""; break; } }
private void Rotate(OperationDirection direction, bool includeCarryInRotation, bool forAccumulator) { // Select byte to rotate byte result = 0; if (forAccumulator) { result = ALULeftBuffer; } else { result = ALURightBuffer; } // Rotate 1 bit to the left or to the right if (direction == OperationDirection.Left) { bool leftmostBitIsSet = (result & B10000000) != 0; result <<= 1; if ((includeCarryInRotation && CF) | (!includeCarryInRotation && leftmostBitIsSet)) { result |= B00000001; } CF = leftmostBitIsSet; } else if (direction == OperationDirection.Right) { bool rightmostBitIsSet = (result & B00000001) != 0; result >>= 1; if ((includeCarryInRotation && CF) | (!includeCarryInRotation && rightmostBitIsSet)) { result |= B10000000; } CF = rightmostBitIsSet; } // Send result to the data bus InternalDataBus = result; // Compute flags // HF an NF are always reset // XF and YF will be updated F &= B11000101; // Flags bit 5 - YF flag - A copy of bit 5 of the result. // Flags bit 3 - XF flag - A copy of bit 3 of the result. F |= (byte)(result & B00101000); if (!forAccumulator) { // SF flag - Set if the 2-complement value is negative. It's simply a copy of the most signifcant bit of the result. SF = (result & B10000000) != 0; // ZF flag Set if the result is zero. ZF = result == 0; // PF : parity of the result PF = numberOfBitsInByteParityTable[result]; } if (TraceMicroInstructions) { TraceMicroInstruction(new MicroInstruction(Z80MicroInstructionTypes.BitOperationRotate, direction, includeCarryInRotation, forAccumulator)); } }
public void EndAddOperation(Guid uid, OperationDirection operationDirection) { Dispatcher.BeginInvoke(new Action( delegate() { var connectionViewModel = MainViewModel.Current.Clients.FirstOrDefault(x => x.UID == uid); if (connectionViewModel != null) { connectionViewModel.EndAddOperation(operationDirection); } } )); }
public Operation(string accountId, decimal amount, OperationDirection direction, DateTime timeStamp) { this.Amount = amount; this.Direction = direction; this.TimeStamp = timeStamp; }