private void BtnSelectFile_Click(object sender, EventArgs e) { if (openFileDialogSelectImport.ShowDialog(this) == DialogResult.OK) { this.lblPercentage.Visible = true; var pt = new PassThrough() { File = openFileDialogSelectImport.OpenFile(), ImportProvider = cmbImport.SelectedItem as string }; var importProvider = ImportProviders.GetImportProvider(pt.ImportProvider); importProvider.GetRecords(pt.File, (data) => { // set the import result Data = data.ImportRules.ToList(); var ds = new BindingSource(); ds.DataSource = data.ImportRulesAsDataTable(); this.dataGridView1.DataSource = ds; this.progressBar1.Value = 0; this.lblPercentage.Visible = false; if (data.ImportRules.Count > 0) { this.btnImport.Visible = true; } }, (p) => { this.lblPercentage.Text = p.ToString(); this.progressBar1.Value = p; }); } }
private void _writeSocket(byte[] buffer, int length) { if (_socket != null && _socket.Connected && _dtuconnected) { try { byte[] sn = BitConverter.GetBytes(ulong.Parse(_connectionInfo.DtuSn, NumberStyles.AllowHexSpecifier)); Array.Reverse(sn); byte[] bytes = buffer.Take(length).ToArray(); if (GetType() == typeof(NetTransService)) { MonitorDataManager.instance.Add(_connectionInfo.DtuSn, bytes, MonitorDataType.MDT_LOC); PassThrough passthrough = new PassThrough(sn, bytes); Package pkg = new Package(passthrough); Logger.Trace("[{0}] ===> {1}", _connectionInfo.DtuSn, pkg.ToString()); _socket.Send(pkg.toBytes()); } else if (GetType() == typeof(ComTransService)) { if (_connector.GetType() == typeof(ComConnector)) { ComConnector cc = _connector as ComConnector; MonitorDataManager.instance.Add(_connectionInfo.DtuSn, bytes, MonitorDataType.MDT_COM); byte syncflag = 1; //同步波特率 ComPassThrough compassthrough = new ComPassThrough(sn, syncflag, cc.VCom.DCBlock.BaudRate, cc.VCom.DCBlock.ByteSize, cc.VCom.DCBlock.Parity, cc.VCom.DCBlock.StopBits, bytes); Package pkg = new Package(compassthrough); Logger.Trace("[{0}] ===> {1}", _connectionInfo.DtuSn, pkg.ToString()); _socket.Send(pkg.toBytes()); } } } catch (Exception e) { Logger.Error(e.ToString()); } } }
public PassThroughLogic(PassThrough emit) : base(emit.Shape) { SetHandler(emit.In, onPush: () => Push(emit.Out, Grab(emit.In)), onUpstreamFinish: () => Complete(emit.Out)); SetHandler(emit.Out, onPull: () => Pull(emit.In)); }
public ModelLevel() { this.auto = new Auto(); this.demo = new Demo(); this.passthrough = new PassThrough(); }
public KStream <K, VR> Join <K, V, V0, VR>( KStream <K, V> joinLeft, KStream <K, V0> joinRight, IValueJoiner <V, V0, VR> joiner, JoinWindowOptions windows, StreamJoinProps <K, V, V0> joined) { var named = new Named(joined.Name); var joinLeftSuffix = rightOuter ? "-outer-this-join" : "-this-join"; var joinRightSuffix = leftOuter ? "-outer-other-join" : "-other-join"; var leftWindowStreamProcessorName = named.SuffixWithOrElseGet("-this-windowed", builder, KStream.WINDOWED_NAME); var rightWindowStreamProcessorName = named.SuffixWithOrElseGet("-other-windowed", builder, KStream.WINDOWED_NAME); var joinLeftGeneratedName = rightOuter ? builder.NewProcessorName(KStream.OUTERTHIS_NAME) : builder.NewProcessorName(KStream.JOINTHIS_NAME); var joinRightGeneratedName = leftOuter ? builder.NewProcessorName(KStream.OUTEROTHER_NAME) : builder.NewProcessorName(KStream.JOINOTHER_NAME); var joinLeftName = named.SuffixWithOrElseGet(joinLeftSuffix, joinLeftGeneratedName); var joinRightName = named.SuffixWithOrElseGet(joinRightSuffix, joinRightGeneratedName); var joinMergeName = named.SuffixWithOrElseGet("-merge", builder, KStream.MERGE_NAME); StreamGraphNode leftStreamsGraphNode = joinLeft.Node; StreamGraphNode rightStreamsGraphNode = joinRight.Node; var userProvidedBaseStoreName = joined.StoreName; var leftStoreSupplier = joined.LeftStoreSupplier; var rightStoreSupplier = joined.RightStoreSupplier; StoreBuilder <WindowStore <K, V> > leftWindowStore; StoreBuilder <WindowStore <K, V0> > rightWindowStore; AssertUniqueStoreNames(leftStoreSupplier, rightStoreSupplier); if (leftStoreSupplier == null) { var thisJoinStoreName = userProvidedBaseStoreName == null ? joinLeftGeneratedName : userProvidedBaseStoreName + joinLeftSuffix; leftWindowStore = JoinWindowStoreBuilder(thisJoinStoreName, windows, joined.KeySerdes, joined.LeftValueSerdes); } else { AssertWindowSettings(leftStoreSupplier, windows); leftWindowStore = Stores.WindowStoreBuilder(leftStoreSupplier, joined.KeySerdes, joined.LeftValueSerdes); } if (rightStoreSupplier == null) { var otherJoinStoreName = userProvidedBaseStoreName == null ? joinRightGeneratedName : userProvidedBaseStoreName + joinRightSuffix; rightWindowStore = JoinWindowStoreBuilder(otherJoinStoreName, windows, joined.KeySerdes, joined.RightValueSerdes); } else { AssertWindowSettings(rightStoreSupplier, windows); rightWindowStore = Stores.WindowStoreBuilder(rightStoreSupplier, joined.KeySerdes, joined.RightValueSerdes); } var leftStream = new KStreamJoinWindow <K, V>(leftWindowStore.Name); var leftStreamParams = new ProcessorParameters <K, V>(leftStream, leftWindowStreamProcessorName); var leftNode = new ProcessorGraphNode <K, V>(leftWindowStreamProcessorName, leftStreamParams); builder.AddGraphNode(leftStreamsGraphNode, leftNode); var rightStream = new KStreamJoinWindow <K, V0>(rightWindowStore.Name); var rightStreamParams = new ProcessorParameters <K, V0>(rightStream, rightWindowStreamProcessorName); var rightNode = new ProcessorGraphNode <K, V0>(rightWindowStreamProcessorName, rightStreamParams); builder.AddGraphNode(rightStreamsGraphNode, rightNode); var joinL = new KStreamKStreamJoin <K, V, V0, VR>(joinLeftName, rightWindowStore.Name, windows.beforeMs, windows.afterMs, joiner, leftOuter); var joinLParams = new ProcessorParameters <K, V>(joinL, joinLeftName); var joinR = new KStreamKStreamJoin <K, V0, V, VR>(joinRightName, leftWindowStore.Name, windows.beforeMs, windows.afterMs, joiner.Reverse(), rightOuter); var joinRParams = new ProcessorParameters <K, V0>(joinR, joinRightName); var merge = new PassThrough <K, VR>(); var mergeParams = new ProcessorParameters <K, VR>(merge, joinMergeName); var joinNode = new StreamStreamJoinNode <K, V, V0, VR>( joinMergeName, joiner, joinLParams, joinRParams, mergeParams, leftStreamParams, rightStreamParams, leftWindowStore, rightWindowStore, joined); builder.AddGraphNode(new List <StreamGraphNode> { leftStreamsGraphNode, rightStreamsGraphNode }, joinNode); ISet <string> allSourceNodes = new HashSet <string>(joinLeft.SetSourceNodes); allSourceNodes.AddRange(joinRight.SetSourceNodes); return(new KStream <K, VR>( joinMergeName, joined.KeySerdes, null, allSourceNodes.ToList(), joinNode, builder)); }
internal async Task <RateOptionsSubmissionResult> SubmitRateOptions() { var equipmentAmount = EquipmentAmount.AsDouble(); if (equipmentAmount > MaxEquipmentAmount || equipmentAmount < MinEquipmentAmount) { return(RateOptionsSubmissionResult.InvalidEquipmentAmount); } var pointAmount = Points.AsInt(); if (pointAmount > MaxPoints) { return(RateOptionsSubmissionResult.InvalidPointAmount); } //need to get max points value var terms = Terms.Where(t => t.IsSelected); var rateCards = RateCards.Where(r => r.IsSelected); var maintenanceTypes = MaintenanceTypes.Where(m => m.IsSelected); var purchaseOptions = PurchaseOptions.Where(p => p.IsSelected); var advancePayments = AdvancePayments.Where(a => a.IsSelected); _quoteBuilder.SetRateOptions(new RateOptions { CompanyName = CompanyName, EquipmentAmount = EquipmentAmount.AsDouble(), EquipmentDescription = EquipmentDescription, RateCards = rateCards.ToList(), Terms = terms.ToList(), MaintenanceTypes = maintenanceTypes.ToList(), PurchaseOptions = purchaseOptions.ToList(), Points = Points.AsInt(), PassThrough = PassThrough.AsInt(), AdvancePayments = advancePayments.ToList() }); try { _hudProvider.DisplayProgress("Retrieving Payment Options"); var response = await _monthlyPaymentService.GetMonthlyPayments(_quoteBuilder.GetQuote()); if (response != null) { if (response.ErrorStatusCode == 400) { return(RateOptionsSubmissionResult.UnableToRetrieveData); } else if (response.ErrorStatusCode == 401) { return(RateOptionsSubmissionResult.Unauthorized); } else if (response.MonthlyPayments == null || response.MonthlyPayments.Count() == 0) { return(RateOptionsSubmissionResult.Failure); } else { _quoteBuilder.SetMonthlyPayments(response.MonthlyPayments.ToList()); return(RateOptionsSubmissionResult.Success); } } return(RateOptionsSubmissionResult.Failure); } catch (Exception ex) { return(RateOptionsSubmissionResult.Failure); //tell view to pop alert } finally { _hudProvider.Dismiss(); } }
static void Main(string[] args) { uint timeout = 0; uint configFlags = 0; List <byte> buffer = new List <byte>(); byte flags = 0; PassThrough passThroughOp; byte[] passThroughResp; // Program setup if (1 > args.Length) { Usage(); } try { // Create Reader object, connecting to physical device. // Wrap reader in a "using" block to get automatic // reader shutdown (using IDisposable interface). using (Reader r = Reader.Create(args[0])) { //Uncomment this line to add default transport listener. //r.Transport += r.SimpleTransportListener; r.Connect(); // Perform sync read for 500ms SimpleReadPlan plan = new SimpleReadPlan(null, TagProtocol.ISO15693, null, null, 1000); // Set the created readplan r.ParamSet("/reader/read/plan", plan); // Read tags TagReadData[] tagReads = r.Read(500); // Print first tag read epc byte[] epc = tagReads[0].Epc; Console.WriteLine("Tag ID: " + tagReads[0].EpcString); //Select Tag timeout = 500; //timeout in milliseconds. flags = 0x22; configFlags = (uint)(ConfigFlags.ENABLE_TX_CRC | ConfigFlags.ENABLE_RX_CRC | ConfigFlags.ENABLE_INVENTORY); //Frame payload data as per 15693 protocol(ICODE Slix-S) buffer.Add(flags); buffer.Add(OPCODE_SELECT_TAG); //Append UID(reverse). buffer.AddRange(appendReverseUID(epc)); //Execute passthrough tag op to select a tag passThroughOp = new PassThrough(timeout, configFlags, buffer); passThroughResp = (byte[])r.ExecuteTagOp(passThroughOp, null); if (passThroughResp.Length > 0) { Console.WriteLine("Select Tag| Data(" + passThroughResp.Length + "): " + ByteFormat.ToHex(passThroughResp, "", "")); } //Reset command buffer buffer.Clear(); //Get random number // Initialize passthrough tag operation with all the required fields flags = 0x12; configFlags = (uint)(ConfigFlags.ENABLE_TX_CRC | ConfigFlags.ENABLE_RX_CRC | ConfigFlags.ENABLE_INVENTORY); //Extract random number from response(ICODE Slix-S) buffer.Add(flags); buffer.Add(GET_RANDOM_NUMBER); buffer.Add(IC_MFG_CODE_NXP); passThroughOp = new PassThrough(timeout, configFlags, buffer); passThroughResp = (byte[])r.ExecuteTagOp(passThroughOp, null); if (passThroughResp.Length > 0) { Console.WriteLine("RN number | Data(" + passThroughResp.Length + "): " + ByteFormat.ToHex(passThroughResp, "", "")); } } } catch (ReaderException re) { Console.WriteLine("Error: " + re.Message); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } }
public void _doLocalSend(byte[] buffer, int length) { try { byte[] bytes = buffer.Take(length).ToArray(); Package package = new Package(bytes); Logger.Trace("[{0}] <=== {1}", _connectionInfo.DtuSn, package.ToString()); if (package.Id == Protocol.ID_HEARTBEAT) { HeartBeat heartbeat = new HeartBeat(package.getPayload()); HeartBeat myheartbeat = new HeartBeat(); Package pkg = new Package(myheartbeat); Logger.Trace("[{0}] ===> {1}", _connectionInfo.DtuSn, pkg.ToString()); _socket.Send(pkg.toBytes()); } else if (package.Id == Protocol.ID_CONNECTRESPONSE && !_dtuconnected) { ConnectResponse response = new ConnectResponse(package.getPayload()); if (response.Result == 0) { //连接成功 _dtuconnected = true; } else if (response.Result == 1) { //连接失败 if (response.Reason == 1) { //DTU不存在 _connectionInfo.Status = (int)RunningStatus.RS_DTUNOTFOUND; Logger.Info("[{0}] dtu:[{1}] not found!", _connectionInfo.DtuSn, _connectionInfo.DtuSn); } else if (response.Reason == 2) { //DTU未在线 _connectionInfo.Status = (int)RunningStatus.RS_DTUNOTCONNECTED; Logger.Info("[{0}] dtu:[{1}] not online!", _connectionInfo.DtuSn, _connectionInfo.DtuSn); } else if (response.Reason == 3) { //DTU调试中 _connectionInfo.Status = (int)RunningStatus.RS_DTUALREADYDEBUGING; Logger.Info("[{0}] dtu:[{1}] is debugging!", _connectionInfo.DtuSn, _connectionInfo.DtuSn); } else if (response.Reason == 4) { //DTU监控中 _connectionInfo.Status = (int)RunningStatus.RS_DTUNOTDEBUGMODE; Logger.Info("[{0}] dtu:[{1}] is monitoring!", _connectionInfo.DtuSn, _connectionInfo.DtuSn); } } _waitdtuconnect = false; } else if (_dtuconnected) { if (package.Id == Protocol.ID_PLCCONNECTRESPONSE && _waitplcconnect) { PlcConnectResponse response = new PlcConnectResponse(package.getPayload()); if (response.Result == 0) { //连接成功 _plcconnected = true; } else if (response.Result == 1) { } _waitplcconnect = false; } else if (_plcconnected) { if (package.Id == Protocol.ID_PASSTHROUGH) { PassThrough passthrough = new PassThrough(package.getPayload()); MonitorDataManager.instance.Add(_connectionInfo.DtuSn, passthrough.Data, MonitorDataType.MDT_NET); _connector.Send(passthrough.Data, passthrough.Data.Length); Logger.Debug("passthrough: {0}", passthrough.ToString()); } if (package.Id == Protocol.ID_COMPASSTHROUGH) { ComPassThrough compassthrough = new ComPassThrough(package.getPayload()); MonitorDataManager.instance.Add(_connectionInfo.DtuSn, compassthrough.Data, MonitorDataType.MDT_NET); _connector.Send(compassthrough.Data, compassthrough.Data.Length); Logger.Debug("passthrough: {0}", compassthrough.ToString()); } else if (package.Id == Protocol.ID_DEBUGEXCEPTION) { DebugException exception = new DebugException(package.getPayload()); if (exception.Reason == 1) { _dtuconnected = false; //DTU监控中 _connectionInfo.Status = (int)RunningStatus.RS_CONNECTBREAK; Logger.Info("[{0}] connection break!", _connectionInfo.DtuSn); } Logger.Debug("DebugException: {0}", exception.ToString()); } } } } catch (Exception e) { Logger.Error(e.ToString()); } }
public bool PassThroughSolid(ref Entity passThroughEntity, ref Entity solidAgentEntity, ref ComponentDataFromEntity <PassThrough> PassThroughGroup, ref RigidBody passThroughRigidBody, ref RigidBody colliderRigidBody) { //Check each side PassThrough passThrough = PassThroughGroup[passThroughEntity]; Aabb passThroughAabb = passThroughRigidBody.CalculateAabb(); Aabb colliderAabb = colliderRigidBody.CalculateAabb(); bool shouldDisable = true; bool clearsLeft = (colliderAabb.Max.x <= passThroughAabb.Min.x); bool clearsTop = (colliderAabb.Min.y >= passThroughAabb.Max.y); bool clearsRight = (colliderAabb.Min.x >= passThroughAabb.Max.x); bool clearsBottom = (colliderAabb.Max.y <= passThroughAabb.Min.y); bool fullyClearsLeft = (colliderAabb.Max.x < passThroughAabb.Min.x); bool fullyClearsTop = (colliderAabb.Min.y > passThroughAabb.Max.y); bool fullyClearsRight = (colliderAabb.Min.x > passThroughAabb.Max.x); bool fullyClearsBottom = (colliderAabb.Max.y < passThroughAabb.Min.y); //Left if (shouldDisable) { if (((uint)passThrough.Directions & (uint)PassThroughDirections.Left) == 0) { //This side may be hit if (clearsLeft && (!fullyClearsTop || !fullyClearsBottom)) { shouldDisable = false; } } } //Top if (shouldDisable) { if (((uint)passThrough.Directions & (uint)PassThroughDirections.Top) == 0) { //This side may be hit if (clearsTop && (!fullyClearsLeft || !fullyClearsRight)) { shouldDisable = false; } } } //Right if (shouldDisable) { if (((uint)passThrough.Directions & (uint)PassThroughDirections.Right) == 0) { //This side may be hit if (clearsRight && (!fullyClearsTop || !fullyClearsBottom)) { shouldDisable = false; } } } //Bottom if (shouldDisable) { if (((uint)passThrough.Directions & (uint)PassThroughDirections.Bottom) == 0) { //This side may be hit if (clearsBottom && (!fullyClearsLeft || !fullyClearsRight)) { shouldDisable = false; } } } return(shouldDisable); }