protected override void MoveCar(object sender, DoWorkEventArgs e) { while (!_backgroundWorker.CancellationPending) { Thread.Sleep((int)(Interval / Speed)); Record record = new Record(Car.Center, Car.Left, Car.Forward, Car.Right, Degree); Recorder.Add(record); Car.Move(Degree); Degree /= 2; } }
private void ProcessConditionalExpression(BinaryExpression b) { VisitPreservingQuery(b.Left); VisitPreservingQuery(b.Right); switch (b.NodeType) { case ExpressionType.AndAlso: Recorder.Add(ctx => ctx.ApplyConstraint(c => c.And(ctx.PopConstraint()))); break; case ExpressionType.OrElse: Recorder.Add(ctx => ctx.ApplyConstraint(c => c.Or(ctx.PopConstraint()))); break; } }
public override IEnumerable <FileSystemInfoBase> EnumerateFileSystemInfos() { Recorder.Add("EnumerateFileSystemInfos", new { FullName, Name }); var names = new HashSet <string>(); foreach (var path in Paths) { if (!path.Replace('\\', '/').StartsWith(FullName.Replace('\\', '/'))) { continue; } var beginPath = FullName.Length; var endPath = path.Length; var beginSegment = beginPath; var endSegment = NextIndex(path, new[] { '/', '\\' }, beginSegment, path.Length); if (endPath == endSegment) { yield return(new MockFileInfo( recorder: Recorder, parentDirectory: this, fullName: path, name: path.Substring(beginSegment, endSegment - beginSegment))); } else { var name = path.Substring(beginSegment, endSegment - beginSegment); if (!names.Contains(name)) { names.Add(name); yield return(new MockDirectoryInfo( recorder: Recorder, parentDirectory: this, fullName: path.Substring(0, endSegment + 1), name: name, paths: Paths)); } } } }
protected override void MoveCar(object sender, DoWorkEventArgs e) { try { while (!_backgroundWorker.CancellationPending) { Thread.Sleep((int)(Interval / Speed)); Record record = new Record(Car.Center, Car.Left, Car.Forward, Car.Right, Degree); Recorder.Add(record); Degree = SelectedAlgorithm.GetDegree(Car.Forward, Car.Left, Car.Right); Car.Move(Degree); } } catch (NullReferenceException) { _backgroundWorker.CancelAsync(); MessageBox.Show("Please specify the alogrithm"); _status = Status.Stop; } }
protected override void VisitConstant(ConstantExpression c) { var value = c.Value; Recorder.Add(ctx => ctx.PushConstraint(ctx.CurrentQuery.Constrain(ctx.ResolveValue(value)))); }
private void PreservingQuery(Action action) { Recorder.Add(ctx => ctx.SaveQuery()); action(); Recorder.Add(ctx => ctx.RestoreQuery()); }
private void RecordConstraintApplication(Func <IConstraint, IConstraint> application) { Recorder.Add(ctx => ctx.ApplyConstraint(application)); }
public int Calculate(int left, int right) { Recorder.Add(left); Recorder.Add(right); return(left + right); }
public void Boardcast(int result) { Recorder.Add(result); }
private void Initialize() { int port, scan, count; string name, logPath, logName; EEthernetMode mode; EEthernetLogging logging; int i = 1; int length = 0; string section = $"PowerMeter.{i:d2}"; string ip = server.Ini.GetString(section, "ip"); PowerMeter.Clear(); PowerMeterValues.Clear(); while (ip != "") { name = server.Ini.GetString(section, "name"); port = server.Ini.GetInteger(section, "port"); scan = server.Ini.GetInteger(section, "scantime"); logPath = server.Ini.GetString(section, "logpath"); logName = server.Ini.GetString(section, "logfilename"); logging = GetEthernetLogging(section); mode = (server.Ini.GetString(section, "mode") == "Real") ? EEthernetMode.Real : EEthernetMode.Virtual; EWT330Phase phase = (server.Ini.GetString(section, "phase") == "P1") ? EWT330Phase.P1 : EWT330Phase.P3; length += 25; //if (phase == EWT330Phase.P1) length += 7; //else length += 25; UlWT330EthernetClient client = new UlWT330EthernetClient(name, phase, ip, port, scan); client.Mode = mode; client.Logging = logging; client.LogPath = logPath; client.LogFName = $"{logName}.{i:d2}"; PowerMeter.Add(client); CreatePowerMeterValues(i, phase); i++; section = $"PowerMeter.{i:d2}"; ip = server.Ini.GetString(section, "ip"); } i = 1; section = $"Recorder.{i:d2}"; ip = server.Ini.GetString(section, "ip"); Recorder.Clear(); while (ip != "") { name = server.Ini.GetString(section, "name"); port = server.Ini.GetInteger(section, "port"); count = server.Ini.GetInteger(section, "length"); scan = server.Ini.GetInteger(section, "scantime"); logPath = server.Ini.GetString(section, "logpath"); logName = server.Ini.GetString(section, "logfilename"); logging = GetEthernetLogging(section); mode = (server.Ini.GetString(section, "mode") == "Real") ? EEthernetMode.Real : EEthernetMode.Virtual; length += count; UlGM10EthernetClient client = new UlGM10EthernetClient(name, ip, port, count, scan); client.Mode = mode; client.Logging = logging; client.LogPath = logPath; client.LogFName = $"{logName}.{i:d2}"; Recorder.Add(client); CreateRecorderValues(i, count); i++; section = $"Recorder.{i:d2}"; ip = server.Ini.GetString(section, "ip"); } i = 1; section = $"Controller.{i:d2}"; ip = server.Ini.GetString(section, "ip"); Controller.Clear(); while (ip != "") { name = server.Ini.GetString(section, "name"); port = server.Ini.GetInteger(section, "port"); scan = server.Ini.GetInteger(section, "scantime"); logPath = server.Ini.GetString(section, "logpath"); logName = server.Ini.GetString(section, "logfilename"); logging = GetEthernetLogging(section); mode = (server.Ini.GetString(section, "mode") == "Real") ? EEthernetMode.Real : EEthernetMode.Virtual; int slaveAddr = server.Ini.GetInteger(section, "slaveaddress"); int slaveCount = server.Ini.GetInteger(section, "slavecount"); float defDecial = (float)server.Ini.GetDouble(section, "DefaultFixedDecimal"); length += (slaveCount * 12); UlUT55AEthernetClient client = new UlUT55AEthernetClient(name, ip, port, slaveAddr, slaveCount, scan); client.Mode = mode; client.Logging = logging; client.LogPath = logPath; client.LogFName = $"{logName}.{i:d2}"; int addr; float fixedDec; for (int j = 0; j < slaveCount; j++) { addr = slaveAddr + j; fixedDec = (float)server.Ini.GetDouble(section, $"FixedDecimal{addr}"); if (fixedDec < 0.1) { client.SetFixedDecimal(addr, defDecial); } else { client.SetFixedDecimal(addr, fixedDec); } } Controller.Add(client); CreateControllerValues(slaveAddr, slaveCount); i++; section = $"Controller.{i:d2}"; ip = server.Ini.GetString(section, "ip"); } Values = new float[length]; i = 1; section = $"Plc.{i:d2}"; ip = server.Ini.GetString(section, "ip"); Plc.Clear(); while (ip != "") { name = server.Ini.GetString(section, "name"); port = server.Ini.GetInteger(section, "port"); scan = server.Ini.GetInteger(section, "scantime"); logPath = server.Ini.GetString(section, "logpath"); logName = server.Ini.GetString(section, "logfilename"); logging = GetEthernetLogging(section); mode = (server.Ini.GetString(section, "mode") == "Real") ? EEthernetMode.Real : EEthernetMode.Virtual; string block = server.Ini.GetString(section, "block"); int blockLength = server.Ini.GetInteger(section, "blocklength"); UlMasterKEthernetClient client = new UlMasterKEthernetClient(name, ip, port, block, blockLength, scan); client.Mode = mode; client.Logging = logging; client.LogPath = logPath; client.LogFName = $"{logName}.{i:d2}"; Plc.Add(client); CreatePlcValues(i, blockLength); i++; section = $"Plc.{i:d2}"; ip = server.Ini.GetString(section, "ip"); } Bytes = new byte[length * 4 + PlcLength * 2]; }