本文整理汇总了C#中States.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# States.ToString方法的具体用法?C# States.ToString怎么用?C# States.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类States
的用法示例。
在下文中一共展示了States.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNextState
//public static States GetPreviousState(States currentState)
//{
// switch (currentState)
// {
// case States.Eating:
// return States.Ordering;
// case States.Checkout:
// return States.Eating;
// case States.Paying:
// return States.Checkout;
// default:
// throw new NotSupportedException("currentState not supported: " + currentState.ToString());
// }
//}
public static States GetNextState(States currentState)
{
switch (currentState)
{
case States.Ordering:
return States.Eating;
case States.Eating:
return States.Checkout;
case States.Checkout:
return States.Finished;
default:
throw new NotSupportedException("currentState not supported: " + currentState.ToString());
}
}
示例2: TestAndUpdateStateAsync
private async Task TestAndUpdateStateAsync()
{
switch (currentState)
{
case States.Init:
currentState = States.Ready;
VisualStateManager.GoToState(this, currentState.ToString(), true);
break;
case States.Ready:
if(currentReading > 0)
{
currentReading = 0;
maxReading = 0;
currentcaptureSecond = captureSeconds;
currentState = States.Capturing;
VisualStateManager.GoToState(this, currentState.ToString(), true);
countdownTimer.Start();
}
break;
case States.Capturing:
if (currentcaptureSecond <= 0)
{
currentState = States.Sending;
VisualStateManager.GoToState(this, currentState.ToString(), true);
await SendReadingAsync();
currentState = States.Cooldown;
VisualStateManager.GoToState(this, currentState.ToString(), true);
}
break;
case States.Cooldown:
if (currentReading < 1)
{
currentState = States.Ready;
VisualStateManager.GoToState(this, currentState.ToString(), true);
//AliasBlock.Text = string.Empty;
}
break;
}
}
示例3: SetState
public void SetState(States newState)
{
curState = newState;
Debug.Log(gameObject.name + " is " + curState.ToString());
}
示例4: TakeMeasurements
//=================================================================================================//
private bool TakeMeasurements(States callerState, ref Measurement measurement)
{
const string STRLOG_MethodName = "TakeMeasurements";
string logMessage = STRLOG_CallerState + callerState.ToString();
Logfile.WriteCalled(this.logLevel, STRLOG_ClassName, STRLOG_MethodName, logMessage);
bool success = false;
//
// Create the data structure for storing the measurements
//
measurement = new Measurement();
//
// Initialise state machine
//
this.lastError = null;
States state = States.MeasureFieldCurrent;
//
// State machine loop
//
while (state != States.Done)
{
double value = 0;
string units = String.Empty;
//Trace.WriteLine("state: " + state.ToString());
switch (state)
{
case States.MeasureFieldCurrent:
//
// Measure the field current
//
if ((success = this.plc.GetSyncFieldCurrent(ref value, ref units)) == true)
{
//
// Save the field current measurement
//
measurement.fieldCurrent = value;
if (this.measurements.units.fieldCurrent == null)
{
this.measurements.units.fieldCurrent = units;
}
state = States.MeasureSyncVoltage;
}
else
{
this.lastError = this.plc.LastError;
}
break;
case States.MeasureSyncVoltage:
//
// Measure the sync voltage
//
if ((success = this.plc.SyncMonitor.GetSyncVoltage(ref value, ref units)) == true)
{
//
// Save the sync voltage measurement
//
measurement.syncVoltage = value;
if (this.measurements.units.syncVoltage == null)
{
this.measurements.units.syncVoltage = units;
}
//
// Determine next state
//
if (callerState == States.TakeMeasurementsForVoltages)
{
state = States.MeasureMainsVoltage;
}
else if (callerState == States.TakeMeasurementsForSynchronism)
{
state = States.MeasureSyncToMainsPhase;
}
else
{
state = States.MeasureSyncFrequency;
}
}
else
{
this.lastError = this.plc.SyncMonitor.LastError;
}
break;
case States.MeasureMainsVoltage:
//
// Measure the mains voltage
//
if ((success = this.plc.SyncMonitor.GetMainsVoltage(ref value, ref units)) == true)
{
//.........这里部分代码省略.........
示例5: Idle
public States Idle(States state)
{
foreach (string direction in DIRECTIONS)
{
if (state.ToString().Contains(direction))
{
return (States) Enum.Parse(typeof(States), direction + "_IDLE");
}
}
Debug.Log("You must've fallen somehow.");
return state;
}