本文整理汇总了C#中System.Environment.Log方法的典型用法代码示例。如果您正苦于以下问题:C# Environment.Log方法的具体用法?C# Environment.Log怎么用?C# Environment.Log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Environment
的用法示例。
在下文中一共展示了Environment.Log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Customer
private IEnumerable<Event> Customer(Environment env, string name, Resource counter, TimeSpan meanTimeInBank)
{
var arrive = env.Now;
env.Log("{0} {1}: Here I am", arrive, name);
using (var req = counter.Request()) {
// Wait for the counter or abort at the end of our tether
var timeout = env.TimeoutUniform(MinPatience, MaxPatience);
yield return req | timeout;
var wait = env.Now - arrive;
if (req.IsProcessed) {
// We got the counter
env.Log("{0} {1}: waited {2}", env.Now, name, wait);
yield return env.TimeoutExponential(meanTimeInBank);
env.Log("{0} {1}: Finished", env.Now, name);
} else {
// We reneged
env.Log("{0} {1}: RENEGED after {2}", env.Now, name, wait);
}
}
}
示例2: Car
private IEnumerable<Event> Car(string name, Environment env, Resource gasStation, Container fuelPump)
{
/*
* A car arrives at the gas station for refueling.
*
* It requests one of the gas station's fuel pumps and tries to get the
* desired amount of gas from it. If the stations reservoir is
* depleted, the car has to wait for the tank truck to arrive.
*/
var fuelTankLevel = env.RandUniform(MinFuelTankLevel, MaxFuelTankLevel + 1);
env.Log("{0} arriving at gas station at {1}", name, env.Now);
using (var req = gasStation.Request()) {
var start = env.Now;
// Request one of the gas pumps
yield return req;
// Get the required amount of fuel
var litersRequired = FuelTankSize - fuelTankLevel;
yield return fuelPump.Get(litersRequired);
// The "actual" refueling process takes some time
yield return env.Timeout(TimeSpan.FromSeconds(litersRequired / RefuelingSpeed));
env.Log("{0} finished refueling in {1} seconds.", name, (env.Now - start).TotalSeconds);
}
}
示例3: Simulate
public void Simulate()
{
var env = new Environment(TimeSpan.FromMinutes(1));
env.Log("== Steel Factory ==");
var crane = new Resource(env, 1);
env.Process(Cast(env, crane, "CC1", new[] { new Slab(4), new Slab(4), new Slab(8), new Slab(3), new Slab(2) }));
env.Process(Cast(env, crane, "CC2", new[] { new Slab(2), new Slab(3), new Slab(3), new Slab(4), new Slab(3) }));
env.Run(TimeSpan.FromMinutes(100));
}
示例4: Cast
private IEnumerable<Event> Cast(Environment env, Resource crane, string name, IEnumerable<Slab> castQueue)
{
foreach (var slab in castQueue) {
yield return env.TimeoutD(slab.CastTime);
env.Log("Caster {0} finished at {1}", name, env.Now);
var token = crane.Request();
yield return token;
env.Process(Transport(env, crane, token, name));
}
}
示例5: Simulate
private static readonly TimeSpan MinPatience = TimeSpan.FromMinutes(1); // Min. customer patience
#endregion Fields
#region Methods
public void Simulate(int rseed = 41)
{
// Setup and start the simulation
var start = new DateTime(2014, 2, 1);
// Create an environment and start the setup process
var env = new Environment(start, 41);
env.Log("== Bank renege ==");
var counter = new Resource(env, capacity: 1);
env.Process(Source(env, counter));
env.Run();
}
示例6: Simulate
public void Simulate(int rseed = 42)
{
// Setup and start the simulation
var env = new Environment(rseed, TimeSpan.FromSeconds(1));
env.Log("== Process communication ==");
var pipe = new Store(env);
env.Process(MessageGenerator("Generator A", env, pipe));
env.Process(MessageConsumer("Consumer A", env, pipe));
env.Run(TimeSpan.FromSeconds(100));
}
示例7: Simulate
public void Simulate()
{
queueSize = 0;
env = new Environment();
server = new Resource(env, capacity: 1);
statistics = new ContinuousStatistics(env);
env.Log("== m/m/1 queuing system ==");
env.Process(Source());
env.Run(TimeSpan.FromDays(180));
Console.WriteLine("QueueSize Statistics:");
Console.WriteLine("Min: {0}; Max: {1}; Mean: {2:F2}; StdDev: {3:F2}", statistics.Min, statistics.Max, statistics.Mean, statistics.StdDev);
}
示例8: Simulate
public void Simulate()
{
completedOrders = 0;
env = new Environment();
env.Log("== Kanban controlled production system ==");
kanban = new Resource(env, capacity: 15);
server = new Resource(env, capacity: 1);
stockStat = new ContinuousStatistics(env);
env.Process(Source());
env.Run(TimeSpan.FromDays(180));
Console.WriteLine("Stock: {0} ; {1:F3}±{2:F3} ; {3} (Min;Mean±StdDev;Max) kanbans ", stockStat.Min, stockStat.Mean, stockStat.StdDev, stockStat.Max);
Console.WriteLine("Produced kanbans: {0:N0}", completedOrders);
}
示例9: Simulate
private static readonly TimeSpan TankTruckTime = TimeSpan.FromMinutes(10); // Minutes it takes the tank truck to arrive
#endregion Fields
#region Methods
public void Simulate(int rseed = RandomSeed)
{
// Setup and start the simulation
// Create environment and start processes
var env = new Environment(rseed);
env.Log("== Gas Station refuelling ==");
var gasStation = new Resource(env, 2);
var fuelPump = new Container(env, GasStationSize, GasStationSize);
env.Process(GasStationControl(env, fuelPump));
env.Process(CarGenerator(env, gasStation, fuelPump));
// Execute!
env.Run(SimTime);
}
示例10: MessageConsumer
private IEnumerable<Event> MessageConsumer(string name, Environment env, Store inPipe)
{
// A process which consumes messages.
while (true) {
// Get event for message pipe
var get = inPipe.Get();
yield return get;
var msg = (object[])get.Value;
if (((DateTime)msg[0]) < env.Now) {
// if message was already put into pipe, then
// message_consumer was late getting to it. Depending on what
// is being modeled this, may, or may not have some
// significance
env.Log("LATE Getting Message: at time {0}: {1} received message: {2}", env.Now, name, msg[1]);
} else {
// message_consumer is synchronized with message_generator
env.Log("at time {0}: {1} received message: {2}.", env.Now, name, msg[1]);
}
// Process does some other work, which may result in missing messages
yield return env.TimeoutUniformD(4, 9);
}
}
示例11: TankTruck
private IEnumerable<Event> TankTruck(Environment env, Container fuelPump)
{
// Arrives at the gas station after a certain delay and refuels it.
yield return env.Timeout(TankTruckTime);
env.Log("Tank truck arriving at time {0}", env.Now);
var amount = fuelPump.Capacity - fuelPump.Level;
env.Log("Tank truck refuelling {0} liters.", amount);
yield return fuelPump.Put(amount);
}
示例12: GasStationControl
private IEnumerable<Event> GasStationControl(Environment env, Container fuelPump)
{
/*
* Periodically check the level of the *fuel_pump* and call the tank
* truck if the level falls below a threshold.
*/
while (true) {
if (fuelPump.Level / fuelPump.Capacity * 100 < Threshold) {
// We need to call the tank truck now!
env.Log("Calling tank truck at {0}", env.Now);
// Wait for the tank truck to arrive and refuel the station
yield return env.Process(TankTruck(env, fuelPump));
}
yield return env.Timeout(TimeSpan.FromSeconds(10)); // Check every 10 seconds
}
}
示例13: Transport
private IEnumerable<Event> Transport(Environment env, Resource crane, Request token, string caster)
{
env.Log("Crane transporting from caster {0} at {1}", caster, env.Now);
yield return env.TimeoutD(4);
crane.Release(token);
}
示例14: FilterStoreProducer
private IEnumerable<Event> FilterStoreProducer(Environment env, FilterStore sto)
{
while (true) {
yield return env.Timeout(TimeSpan.FromSeconds(4));
yield return sto.Put(FilterStoreObjA);
env.Log("{0}: Produce A", env.Now.Second);
yield return env.Timeout(TimeSpan.FromSeconds(2));
yield return sto.Put(FilterStoreObjB);
env.Log("{0}: Produce B", env.Now.Second);
}
}
示例15: FilterStoreConsumerB
private IEnumerable<Event> FilterStoreConsumerB(Environment env, FilterStore sto)
{
while (true) {
yield return sto.Get(x => x == FilterStoreObjB);
env.Log("{0}: Consume B", env.Now.Second);
yield return env.Timeout(TimeSpan.FromSeconds(3));
}
}