public override void OnSetBusyResult(string callId, OpStatus status, bool flag, int errorCode) { if (ReceiveSetBusyResult != null) { ReceiveSetBusyResult(callId, status, flag, errorCode); } }
public void ReceiveAgentStatusChangeResult(string callId, OpStatus status, bool flag, int errorCode) { try { // Se reporta el resultado de la operación Dictionary <string, object> salida = new Dictionary <string, object>(); salida.Add("callId", callId); salida.Add("opStatus", status); salida.Add("flag", flag); salida.Add("errorCode", errorCode); operaciones.Enqueue(salida); waitChangeStatusResult.Set(); // Se muestra el resultado de la operación logger.Trace("Change status result [{0}]", errorCode); // Se valida el resultado de la operación if (errorCode != 0) { return; } } catch (Exception ex) { // Se detecto un error en el procedimiento logger.Error("Error en el procedimiento de cambio de status. {0} {1}", callId, ex.Message, ex); } }
private void StatusTick(OpStatus opstatus) { GameCore.TheGameCore.OnGameEventHandler(new GameEventArgs(GameEventArgs.Types.StatusGameEngine) { TheOpStatus = opstatus }); }
internal void SetStatus(OpStatus status, Exception ex = null) { Status = status; if (status == OpStatus.Complete || status == OpStatus.Failed) { Exception = ex; FinishedAt = DateTime.Now; IsFinished = true; FinishedEvent.Set(); OpFinished?.Invoke(this, this); } }
/*! \brief Executes the operations: /, MOD, ** (POW), *. * * \param lhs pointer to the left hand side operand and result. * \param operation \ref BinaryOp enum value. * \param rhs pointer to the right hand side operand. * \returns #OK enum value if processed without error, appropriate \ref OpStatus enum value if not. */ private OpStatus execute_binary1(ref double lhs, BinaryOp operation, ref double rhs) { OpStatus status = OpStatus.OK; switch (operation) { case BinaryOp.DividedBy: if (rhs == 0d || rhs == -0d) { status = OpStatus.ExpressionDivideByZero; // Attempt to divide by zero } else { lhs = lhs / rhs; } break; case BinaryOp.Modulo: // always calculates a positive answer lhs = (lhs % rhs); if (lhs < 0d) { lhs = lhs + Math.Abs(rhs); } break; case BinaryOp.Power: if (lhs < 0d && Math.Floor(rhs) != rhs) { status = OpStatus.ExpressionInvalidArgument; // Attempt to raise negative value to non-integer power } else { lhs = Math.Pow(lhs, rhs); } break; case BinaryOp.Times: lhs = lhs * rhs; break; default: status = OpStatus.ExpressionUknownOp; break; } return(status); }
public OpStatus ReadComment(string line, ref int pos, out string comment) { comment = string.Empty; int end = pos + 1; while (end < line.Length && line[end] != ')') { end++; } comment = line.Substring(pos, end - pos + 1); /* && code.Length > 5 && code.Substring(0, 5).ToUpperInvariant() == "(MSG,"*/ pos = end + 1; return(LastError = line[end] == ')' ? OpStatus.OK : OpStatus.BadComment); }
/// <summary> /// Initialize a bunch of rasters with multiple outputs /// </summary> /// <param name="rRasters"></param> /// <param name="rOutputRaster"></param> /// <param name="newRect"></param> protected BaseOperator(List <Raster> rRasters, List <Raster> rOutputRasters = null) { _inputRasters = new List <Raster>(); _outputRasters = new List <Raster>(); inNodataVals = new List <T>(); outNodataVals = new List <T>(); _opStatus = new OpStatus(); if (rOutputRasters == null) { rOutputRasters = new List <Raster>(); } _init(rRasters, rOutputRasters); // Now that we have our rasters tested and a unioned extent we can set the operation extent SetOpExtent(InExtent); }
public OpStatus ReadSetParameter(string line, ref int pos) { double value; OpStatus status = OpStatus.BadNumberFormat; if (line[++pos] == '<') { int end = ++pos; while (end < line.Length && line[end] != '>') { end++; } if (line[end] == '>' && line[++end] == '=') { string param = line.Substring(pos, end - pos - 1); pos = ++end; ReadParameter(line, ref pos, out value); SetNamedParameter(param, value); } } else { double param; if ((status = ReadParameter(line, ref pos, out param)) == OpStatus.OK) { if (line[pos] == '=') { pos++; ReadParameter(line, ref pos, out value); SetNumberedParameter((int)param, value); } } } return(status); }
/*! \brief Reads the value out of a parameter of the line, starting at the * index given by the pos offset. * * According to the RS274/NGC manual [NCMS, p. 62], the characters following # may be any "parameter expression". Thus, the following are legal # and mean the same thing (the value of the parameter whose number is # stored in parameter 2): ##2 #[#2] # # Parameter setting is done in parallel, not sequentially. For example # if #1 is 5 before the line "#1=10 #2=#1" is read, then after the line # is is executed, #1 is 10 and #2 is 5. If parameter setting were done # sequentially, the value of #2 would be 10 after the line was executed. # # \param line pointer to RS274/NGC code (block). # \param pos offset into line where expression starts. # \param value pointer to double where result is to be stored. # \returns #OK enum value if processed without error, appropriate \ref OpStatus enum value if not. */ private OpStatus read_parameter(string line, ref int pos, ref double value, bool check) { OpStatus status = OpStatus.BadNumberFormat; if (line[pos] == '#') { pos++; if (line[pos] == '<') { int end = ++pos; while (end < line.Length && line[end] != '>') { end++; } if (line[end] == '>') { if (GetNamedParameter(line.Substring(pos, end - pos), out value)) { status = OpStatus.OK; } pos = end + 1; } } else if (read_double(line, ref pos, ref value)) { if (GetNumberedParameter((int)value, out value)) { status = OpStatus.OK; } } } return(status); }
private void SeekAddressData(byte ByteRead, OpStatus NextStatus, bool Check) { damBytesChecked++; switch (opStatus) { case OpStatus.SeekingIDAM: if (IndexesFound >= 5) { SeekError = true; opStatus = OpStatus.NMI; } else { switch (ByteRead) { case Floppy.IDAM: if (track?.HasIdamAt(TrackDataIndex, DoubleDensitySelected) ?? false) { readAddressIndex = 0; ResetCRC(); crc = Lib.Crc(crc, ByteRead); opStatus = OpStatus.ReadingAddressData; } idamBytesFound = 0; break; default: idamBytesFound = 0; break; } } break; case OpStatus.ReadingAddressData: readAddressData[readAddressIndex] = ByteRead; if (readAddressIndex == ADDRESS_DATA_CRC_HIGH_BYTE - 1) { // save the value before the first crc on the sector comes in crcCalc = crc; } else if (readAddressIndex >= ADDRESS_DATA_CRC_LOW_BYTE) { damBytesChecked = 0; crcHigh = readAddressData[ADDRESS_DATA_CRC_HIGH_BYTE]; crcLow = readAddressData[ADDRESS_DATA_CRC_LOW_BYTE]; CrcError = crcCalc != Lib.CombineBytes(crcLow, crcHigh); var match = (TrackRegister == readAddressData[ADDRESS_DATA_TRACK_REGISTER_BYTE] && (!command.SideSelectVerify || (command.SideOneExpected == (readAddressData[ADDRESS_DATA_SIDE_ONE_BYTE] != 0))) && (SectorRegister == readAddressData[ADDRESS_DATA_SECTOR_REGISTER_BYTE])); if (Check && !match) { opStatus = OpStatus.SeekingIDAM; } else { sectorLength = Floppy.GetDataLengthFromCode(readAddressData[ADDRESS_DATA_SECTOR_SIZE_BYTE]); if (CrcError) { opStatus = OpStatus.SeekingIDAM; } else { opStatus = NextStatus; } } } readAddressIndex++; break; default: throw new Exception(); } }
/*! \brief Reads the name of an unary operation out of the line * starting at the index given by the pos offset. If a valid one is found, the * value of operation is set to the symbolic value for that operation. * * \param line pointer to RS274/NGC code (block). * \param pos offset into line where expression starts. * \param operation pointer to \ref UnaryOp enum value. * \returns #OK enum value if processed without error, appropriate \ref OpStatus enum value if not. */ private OpStatus read_operation_unary(string line, ref int pos, ref UnaryOp operation) { char c = line[pos]; OpStatus status = OpStatus.OK; pos++; switch (c) { case 'A': if (line.Substring(pos).StartsWith("BS")) { operation = UnaryOp.ABS; pos += 2; } else if (line.Substring(pos).StartsWith("COS")) { operation = UnaryOp.ACOS; pos += 3; } else if (line.Substring(pos).StartsWith("SIN")) { operation = UnaryOp.ASIN; pos += 3; } else if (line.Substring(pos).StartsWith("TAN")) { operation = UnaryOp.ATAN; pos += 3; } else { status = OpStatus.ExpressionUknownOp; } break; case 'C': if (line.Substring(pos).StartsWith("OS")) { operation = UnaryOp.COS; pos += 2; } else { status = OpStatus.ExpressionUknownOp; } break; case 'E': if (line.Substring(pos).StartsWith("XP")) { operation = UnaryOp.EXP; pos += 2; } else if (line.Substring(pos).StartsWith("XISTS")) { operation = UnaryOp.Exists; pos += 5; } else { status = OpStatus.ExpressionUknownOp; } break; case 'F': if (line.Substring(pos).StartsWith("IX")) { operation = UnaryOp.FIX; pos += 2; } else if (line.Substring(pos).StartsWith("UP")) { operation = UnaryOp.FUP; pos += 2; } else { status = OpStatus.ExpressionUknownOp; } break; case 'L': if (line[pos] == 'N') { operation = UnaryOp.LN; pos++; } else { status = OpStatus.ExpressionUknownOp; } break; case 'R': if (line.Substring(pos).StartsWith("OUND")) { operation = UnaryOp.Round; pos += 4; } else { status = OpStatus.ExpressionUknownOp; } break; case 'S': if (line.Substring(pos).StartsWith("IN")) { operation = UnaryOp.SIN; pos += 2; } else if (line.Substring(pos).StartsWith("QRT")) { operation = UnaryOp.SQRT; pos += 3; } else { status = OpStatus.ExpressionUknownOp; } break; case 'T': if (line.Substring(pos).StartsWith("AN")) { operation = UnaryOp.TAN; pos += 2; } else { status = OpStatus.ExpressionUknownOp; } break; default: status = OpStatus.ExpressionUknownOp; break; } return(status); }
/*! \brief Reads a binary operation out of the line * starting at the index given by the pos offset. If a valid one is found, the * value of operation is set to the symbolic value for that operation. * * \param line pointer to RS274/NGC code (block). * \param pos offset into line where expression starts. * \param operation pointer to \ref BinaryOp enum value. * \returns #OK enum value if processed without error, appropriate \ref OpStatus enum value if not. */ private OpStatus read_operation(string line, ref int pos, ref BinaryOp operation) { char c = line[pos]; OpStatus status = OpStatus.OK; pos++; switch (c) { case '+': operation = BinaryOp.Plus; break; case '-': operation = BinaryOp.Minus; break; case '/': operation = BinaryOp.DividedBy; break; case '*': if (line[pos] == '*') { operation = BinaryOp.Power; pos++; } else { operation = BinaryOp.Times; } break; case ']': operation = BinaryOp.RightBracket; break; case 'A': if (line.Substring(pos).StartsWith("ND")) { operation = BinaryOp.And2; pos += 2; } else { status = OpStatus.ExpressionUknownOp; // Unknown operation name starting with A } break; case 'M': if (line.Substring(pos).StartsWith("OD")) { operation = BinaryOp.Modulo; pos += 2; } else { status = OpStatus.ExpressionUknownOp; // Unknown operation name starting with M } break; case 'R': if (line[pos] == 'R') { operation = BinaryOp.NotExclusiveOR; pos++; } else { status = OpStatus.ExpressionUknownOp; // Unknown operation name starting with R } break; case 'X': if (line.Substring(pos).StartsWith("OR")) { operation = BinaryOp.ExclusiveOR; pos += 2; } else { status = OpStatus.ExpressionUknownOp; // Unknown operation name starting with X } break; /* relational operators */ case 'E': if (line[pos] == 'Q') { operation = BinaryOp.EQ; pos++; } else { status = OpStatus.ExpressionUknownOp; // Unknown operation name starting with E } break; case 'N': if (line[pos] == 'E') { operation = BinaryOp.NE; pos++; } else { status = OpStatus.ExpressionUknownOp; // Unknown operation name starting with N } break; case 'G': if (line[pos] == 'E') { operation = BinaryOp.GE; pos++; } else if (line[pos] == 'T') { operation = BinaryOp.GT; pos++; } else { status = OpStatus.ExpressionUknownOp; // Unknown operation name starting with G } break; case 'L': if (line[pos] == 'E') { operation = BinaryOp.LE; pos++; } else if (line[pos] == 'T') { operation = BinaryOp.LT; pos++; } else { status = OpStatus.ExpressionUknownOp; }; // Unknown operation name starting with L break; // case '\0': // status = OpStatus.ExpressionUknownOp; // No operation name found default: status = OpStatus.ExpressionUknownOp; // Unknown operation name break; } return(status); }
/*! \brief Executes an unary operation: ABS, ACOS, ASIN, COS, EXP, FIX, FUP, LN, ROUND, SIN, SQRT, TAN * * All angle measures in the input or output are in degrees. * * \param operand pointer to the operand. * \param operation \ref BinaryOp enum value. * \returns #OK enum value if processed without error, appropriate \ref OpStatus enum value if not. */ private OpStatus execute_unary(ref double operand, UnaryOp operation) { OpStatus status = OpStatus.OK; switch (operation) { case UnaryOp.ABS: if (operand < 0d) { operand = (-1d * operand); } break; case UnaryOp.ACOS: if (operand < -1d || operand > 1d) { status = OpStatus.ExpressionArgumentOutOfRange; // Argument to ACOS out of range } else { operand = Math.Acos(operand) * DEGRAD; } break; case UnaryOp.ASIN: if (operand < -1d || operand > 1d) { status = OpStatus.ExpressionArgumentOutOfRange; // Argument to ASIN out of range } else { operand = Math.Asin(operand) * DEGRAD; } break; case UnaryOp.COS: operand = Math.Cos(operand * RADDEG); break; case UnaryOp.Exists: // do nothing here, result for the EXISTS function is set by read_unary() break; case UnaryOp.EXP: operand = Math.Exp(operand); break; case UnaryOp.FIX: operand = Math.Floor(operand); break; case UnaryOp.FUP: operand = Math.Ceiling(operand); break; case UnaryOp.LN: if (operand <= 0d) { status = OpStatus.ExpressionArgumentOutOfRange; // Argument to LN out of range } else { operand = Math.Log(operand); } break; case UnaryOp.Round: operand = (double)((int)(operand + ((operand < 0d) ? -0.5f : 0.5f))); break; case UnaryOp.SIN: operand = Math.Sin(operand * RADDEG); break; case UnaryOp.SQRT: if (operand < 0d) { status = OpStatus.ExpressionArgumentOutOfRange; // Negative argument to SQRT } else { operand = Math.Sqrt(operand); } break; case UnaryOp.TAN: operand = Math.Tan(operand * RADDEG); break; default: status = OpStatus.ExpressionUknownOp; break; } return(status); }
public OpStatus ReadParameter(string line, ref int pos, out double value) { char c = line[pos]; value = 0d; WasExpression = true; LastError = OpStatus.OK; if (c == '#') { pos++; if (line[pos] == '<') { int end = ++pos; while (end < line.Length && line[end] != '>') { end++; } if (line[end] == '>') { if (!GetNamedParameter(line.Substring(pos, end - pos), out value)) { LastError = OpStatus.BadNumberFormat; } pos = end + 1; } else { LastError = OpStatus.BadNumberFormat; } } else if (read_double(line, ref pos, ref value)) { if (!GetNumberedParameter((int)value, out value)) { LastError = OpStatus.BadNumberFormat; } } else { LastError = OpStatus.BadNumberFormat; } } else if (c == '[') { LastError = eval(line, ref pos, ref value); } else { WasExpression = false; if (!read_double(line, ref pos, ref value)) { value = double.NaN; } } return(LastError); }
public OpStatus Eval(string line, ref int pos, out double value) { value = 0d; return(LastError = eval(line, ref pos, ref value)); }