/// <summary> /// /// </summary> /// <param name="source"></param> /// <param name="bs"></param> private void Transmit(object source, byte[] bs) { if (this.Transmitter.Enable && this.Transmitter.CanTransmit()) { ITransmit d = this.Transmitter.GetTo(source); if (d != null) { d.Write(bs); string from = string.Empty; string to = string.Empty; if (source is SocketClient) { from = this.GetMe(); to = this.GetSerialPortName(); } if (source is SerialPortManager) { from = this.GetLocalString(); to = this.GetRemoteString(); } this.AddSend( from, to, bs); } } }
public override void Reset() { Status = WorkflowStatus.Undetermined; _child.Reset(); _onTimeout.Reset(); _childScope = null; _onTimeoutScope = null; _timeoutToken?.Dispose(); _timeoutToken = null; _timedOut = false; }
/// <summary> /// /// </summary> /// <param name="from"></param> /// <param name="bytes"></param> void OnReceived(object from, byte[] bytes) { if (this.Transmitter.Enable) { ITransmit to = this.Transmitter.GetTo(from); if (to != null) { to.Write(bytes); } } }
public override void Run(IContext context) { if (Status.IsCompleted()) { return; } var wfContext = context as WFContext; if (_childScope == null) { _childScope = (_child as ITransmit) ?? new ScopeWF(_child, wfContext.Root); } if (_onTimeoutScope == null) { _onTimeoutScope = (_onTimeout as ITransmit) ?? new ScopeWF(_onTimeout, wfContext.Root); } if (_timeoutToken == null) { _timeoutId = Guid.NewGuid(); _timeoutToken = context.Host.ScheduleMessage(_delay(context), new WFTimeout { Id = _timeoutId }); Status = WorkflowStatus.Running; } if (!_timedOut) { _childScope.Run(context); if (_childScope.Status.IsCompleted()) { Status = _childScope.Status; _timeoutToken.Dispose(); } } else { _onTimeoutScope.Run(context); if (_onTimeoutScope.Status.IsCompleted()) { Status = _onTimeoutScope.Status; } } }
/// <summary> /// /// </summary> /// <param name="d1"></param> /// <param name="d2"></param> public Transmitter(ITransmit d1, ITransmit d2) { D1 = d1; D2 = d2; }