public async Task GetBlockHeader() { string[][] mockedResponses = { new[] { "getblockheader", "btc_GetBlockHeader_1.json" } }; IN3 in3 = _builder.ConstructClient(mockedResponses); BlockHeader result = await in3.Btc.GetBlockHeader("0000000000000000000cd3c5d7638014e78a5fba33be5fa5cb10ef9f03d99e60"); Assert.That(result.Hash, Is.EqualTo("0000000000000000000cd3c5d7638014e78a5fba33be5fa5cb10ef9f03d99e60")); Assert.That(result.Confirmations, Is.EqualTo(13)); Assert.That(result.Height, Is.EqualTo(634026)); Assert.That(result.Version, Is.EqualTo(1073676288)); Assert.That(result.VersionHex, Is.EqualTo("3fff0000")); Assert.That(result.Merkleroot, Is.EqualTo("0b27b05fb5c9c53f595cf12696daa3ea4fb03ea67e0ffd909a1f2bb6544b63c1")); Assert.That(result.Time, Is.EqualTo(1591782412)); Assert.That(result.Mediantime, Is.EqualTo(1591778995)); Assert.That(result.Nonce, Is.EqualTo(783981944)); Assert.That(result.Bits, Is.EqualTo("17147f35")); Assert.That(result.Difficulty, Is.EqualTo(13732352106018.34f)); Assert.That(result.Chainwork, Is.EqualTo("00000000000000000000000000000000000000001038fd1e673c4ff045dbd6c1")); Assert.That(result.NTx, Is.EqualTo(1659)); Assert.That(result.Previousblockhash, Is.EqualTo("00000000000000000013a6ca3921ce63af646ac191c733d9728103d7a9e3236e")); Assert.That(result.Nextblockhash, Is.EqualTo("0000000000000000000d1e4cf9f6f0a6fa88aa162e08a966bf3043f7f77e21bb")); }
public async Task SendTransactionAndWait() { string[][] mockedResponses = { new[] { "eth_gasPrice", "eth_gasPrice.json" }, new[] { "eth_estimateGas", "eth_estimateGas.json" }, new[] { "eth_getTransactionCount", "eth_getTransactionCount.json" }, new[] { "eth_sendRawTransaction", "eth_sendRawTransaction.json" }, new[] { "eth_getTransactionReceipt", "eth_getTransactionReceipt.json" } }; IN3 in3 = _factory.CreateIn3(mockedResponses); string pk = "0x0829B3C639A3A8F2226C8057F100128D4F7AE8102C92048BA6DE38CF4D3BC6F1"; SimpleWallet sw = (SimpleWallet)in3.Signer; string from = sw.AddRawKey(pk); TransactionRequest request = new TransactionRequest { From = @from, To = "0x3940256B93c4BE0B1d5931A6A036608c25706B0c", Gas = 21000, Value = 100000000 }; TransactionReceipt receipt = await in3.Eth1.SendTransactionAndWait(request); Assert.That(receipt.To, Is.EqualTo("0x5b8174e20996ec743f01d3b55a35dd376429c596")); Assert.That(receipt.Status); Assert.That(receipt.Logs[0].Address, Is.EqualTo("0x5b8174e20996ec743f01d3b55a35dd376429c596")); }
public async Task GetBlockWithTxData() { string[][] mockedResponses = { new[] { "getblock", "btc_GetBlockWithTxData_1.json" } }; IN3 in3 = _builder.ConstructClient(mockedResponses); Block <Transaction> result = await in3.Btc.GetBlockWithTxData("000000000000000000064ba7512ecc70cabd7ed17e31c06f2205d5ecdadd6d22"); Assert.That(result.Hash, Is.EqualTo("000000000000000000064ba7512ecc70cabd7ed17e31c06f2205d5ecdadd6d22")); Assert.That(result.Confirmations, Is.EqualTo(83)); Assert.That(result.Height, Is.EqualTo(634007)); Assert.That(result.Version, Is.EqualTo(536870912)); Assert.That(result.VersionHex, Is.EqualTo("20000000")); Assert.That(result.Merkleroot, Is.EqualTo("22f78daf63c48b582142421ea17e3a989b1421c1a9d07585668962f19fe12558")); Assert.That(result.Time, Is.EqualTo(1591770949)); Assert.That(result.Mediantime, Is.EqualTo(1591768893)); Assert.That(result.Nonce, Is.EqualTo(3201445374)); Assert.That(result.Bits, Is.EqualTo("17147f35")); Assert.That(result.Difficulty, Is.EqualTo(13732352106018.34f)); Assert.That(result.Chainwork, Is.EqualTo("000000000000000000000000000000000000000010380fd08a8436abc886cbc8")); Assert.That(result.NTx, Is.EqualTo(131)); Assert.That(result.Previousblockhash, Is.EqualTo("00000000000000000008c486d4d80a3bd24cc33b0011538baa8d1c3fa7d54c76")); Assert.That(result.Nextblockhash, Is.EqualTo("00000000000000000001d7fb302a3c72f7cc77d4def5d1d9503195469eb2049f")); Assert.That(result.Tx.Length, Is.EqualTo(131)); }
public ORM(compositeType parent, string name) : base(parent, name) { data = new abstractType[19]; data[0] = new MSH(this, "MSH"); data[1] = new NTE(this, "NTE"); //Patient data[2] = new PID(this, "PID"); data[3] = new PD1(this, "PD1"); //Patient_VISIT data[4] = new PV1(this, "PV1"); data[5] = new PV2(this, "PV2"); //INsurance data[6] = new IN1(this, "IN1"); data[7] = new IN2(this, "IN2"); data[8] = new IN3(this, "IN3"); data[9] = new GT1(this, "GT1"); data[10] = new AL1(this, "AL1"); //Order data[11] = new ORC(this, "ORC"); //Order_Detail data[12] = new OBR(this, "OBR"); data[13] = new NTE(this, "NTE"); data[14] = new DG1(this, "DG1"); //Observation data[15] = new OBX(this, "OBX"); data[16] = new NTE(this, "NTE"); data[17] = new CTI(this, "CTI"); data[18] = new BLG(this, "BLG"); }
public async Task SendTransaction() { string[][] mockedResponses = { new[] { "eth_gasPrice", "eth_gasPrice.json" }, new[] { "eth_estimateGas", "eth_estimateGas.json" }, new[] { "eth_getTransactionCount", "eth_getTransactionCount.json" }, new[] { "eth_sendRawTransaction", "eth_sendRawTransaction.json" } }; IN3 in3 = _factory.CreateIn3(mockedResponses); string expectedHash = "0xd5651b7c0b396c16ad9dc44ef0770aa215ca795702158395713facfbc9b55f38"; string pk = "0x0829B3C639A3A8F2226C8057F100128D4F7AE8102C92048BA6DE38CF4D3BC6F1"; SimpleWallet sw = (SimpleWallet)in3.Signer; string from = sw.AddRawKey(pk); TransactionRequest request = new TransactionRequest { From = @from, To = "0x3940256B93c4BE0B1d5931A6A036608c25706B0c", Gas = 21000, Value = 100000000 }; object txHash = await in3.Eth1.SendTransaction(request); Assert.That(txHash, Is.EqualTo(expectedHash)); }
public void Setup() { ClientFactory factory = new ProoflessClientFactory(Chain.Mainnet); IN3 in3 = factory.CreateIn3(new string[][] { }); _wallet = (SimpleWallet)in3.Signer; }
static async Task Main() { // Define an upper limit for poll since we dont want our application potentially running forever. int maxIterations = 500; int oneSecond = 1000; // in ms // Connect to mainnet. IN3 mainnetClient = IN3.ForChain(Chain.Mainnet); // Create a filter object pointing, in this case, to an "eventful" contract address. LogFilter tetherUsFilter = new LogFilter { Address = "0xdAC17F958D2ee523a2206206994597C13D831ec7" }; // Create the filter to be polled for logs. long filterId = await mainnetClient.Eth1.NewLogFilter(tetherUsFilter); // Loop to initiate the poll for the logs. for (int i = 0; i < maxIterations; i++) { // Query for the log events since the creation of the filter or the previous poll (this method in NOT idempotent as it retrieves a diff). Log[] tetherLogs = await mainnetClient.Eth1.GetFilterChangesFromLogs(filterId); if (tetherLogs.Length > 0) { Console.Out.WriteLine("Logs found: " + tetherLogs.Length); break; } // Wait before next query. Thread.Sleep(oneSecond); } }
public void Setup() { ClientBuilder builder = new ClientBuilder(Chain.Mainnet); IN3 in3 = builder.ConstructClient(new string[][] { }); _wallet = (SimpleWallet)in3.Signer; }
private void SetGPIOWrite2(int in3, int in4) { if (in3 == 0 || in3 == -1) { IN3.Write(GpioPinValue.Low); } if (in3 == 1) { IN3.Write(GpioPinValue.High); } if (in3 == -1) { IN3.Dispose(); } if (in4 == 0 || in4 == -1) { IN4.Write(GpioPinValue.Low); } if (in4 == 1) { IN4.Write(GpioPinValue.High); } if (in4 == -1) { IN4.Dispose(); } }
/// <summary> /// Create an instance of the ULN2003 driver (currently only supports 28BYJ step motor) /// </summary> public ULN2003(int IN1pin, int IN2pin, int IN3pin, int IN4pin, ULN2003Enums motorType = ULN2003Enums.STEP_28BYJ) { if (motorType == ULN2003Enums.Other) { IsSupported = false; } else { var gpio = GpioController.GetDefault(); if (gpio != null) { IN1 = gpio.OpenPin(IN1pin); IN2 = gpio.OpenPin(IN2pin); IN3 = gpio.OpenPin(IN3pin); IN4 = gpio.OpenPin(IN4pin); IN1.SetDriveMode(GpioPinDriveMode.Output); IN2.SetDriveMode(GpioPinDriveMode.Output); IN3.SetDriveMode(GpioPinDriveMode.Output); IN4.SetDriveMode(GpioPinDriveMode.Output); SetGPIOWrite(0, 0, 0, 0); SetStepSequences(motorType); SafeBreakMe = new SafeBreak(); SafeBreakMe.PropertyChanged += SafeBreakMe_PropertyChanged; IsInitialized = true; } } }
static async Task Main() { Console.Out.WriteLine("Ethereum Main Network"); IN3 mainnetClient = IN3.ForChain(Chain.Mainnet); BigInteger mainnetLatest = await mainnetClient.Eth1.BlockNumber(); BigInteger mainnetCurrentGasPrice = await mainnetClient.Eth1.GetGasPrice(); Console.Out.WriteLine($"Latest Block Number: {mainnetLatest}"); Console.Out.WriteLine($"Gas Price: {mainnetCurrentGasPrice} Wei"); Console.Out.WriteLine("Ethereum Kovan Test Network"); IN3 kovanClient = IN3.ForChain(Chain.Kovan); BigInteger kovanLatest = await kovanClient.Eth1.BlockNumber(); BigInteger kovanCurrentGasPrice = await kovanClient.Eth1.GetGasPrice(); Console.Out.WriteLine($"Latest Block Number: {kovanLatest}"); Console.Out.WriteLine($"Gas Price: {kovanCurrentGasPrice} Wei"); Console.Out.WriteLine("Ethereum Goerli Test Network"); IN3 goerliClient = IN3.ForChain(Chain.Goerli); BigInteger goerliLatest = await goerliClient.Eth1.BlockNumber(); BigInteger clientCurrentGasPrice = await goerliClient.Eth1.GetGasPrice(); Console.Out.WriteLine($"Latest Block Number: {goerliLatest}"); Console.Out.WriteLine($"Gas Price: {clientCurrentGasPrice} Wei"); }
/// <summary> /// Create an instance of the L298N driver (PCA9685 driver can be used as extension to have more /// stable PWM outputs as Windows IOT is not a real time operating system) /// </summary> /// <param name="motor1">initialize the motor1 with available pins for the driver</param> /// <param name="motor2">initialize the motor2 with available pins for the driver</param> /// <param name="pwnDriver">pwm driver to control the speed of the motor (PCA9685 chip)</param> public L298N(L298NMotors motor1, L298NMotors motor2, PCA9685 pwnDriver = null) { var gpio = GpioController.GetDefault(); if (gpio != null) { GetPCA9685 = pwnDriver; if (GetPCA9685 != null) { GetPCA9685.SetDesiredFrequency(60); } if (motor1 != null) { IN1 = gpio.OpenPin(motor1.INAPin); IN2 = gpio.OpenPin(motor1.INBPin); IN1.SetDriveMode(GpioPinDriveMode.Output); IN2.SetDriveMode(GpioPinDriveMode.Output); ENA = motor1.ENPin; SetGPIOWrite1(0, 0); if (GetPCA9685 != null) { GetPCA9685.SetPulseParameters(ENA, 0); } Motor1Available = true; } if (motor2 != null) { IN3 = gpio.OpenPin(motor2.INAPin); IN4 = gpio.OpenPin(motor2.INBPin); IN3.SetDriveMode(GpioPinDriveMode.Output); IN4.SetDriveMode(GpioPinDriveMode.Output); ENB = motor2.ENPin; SetGPIOWrite2(0, 0); if (GetPCA9685 != null) { GetPCA9685.SetPulseParameters(ENB, 0); } Motor2Available = true; } if (Motor1Available || Motor2Available) { IsInitialized = true; } } }
public NativeClient(IN3 in3, Chain chainId) { Client = in3; NativeHandlers.Add(new RegistrableStorageHandler(this)); Pointer = in3_for_chain_auto_init(chainId); NativeHandlers.ForEach(handler => handler.RegisterNativeHandler()); }
public async Task ChecksumAddress() { IN3 in3 = _factory.CreateIn3(new string[][] { }); string expectedAddress = "0xBc0ea09C1651A3D5D40Bacb4356FB59159A99564"; string address = await in3.Eth1.ChecksumAddress("0xbc0ea09c1651a3d5d40bacb4356fb59159a99564"); Assert.That(address, Is.EqualTo(expectedAddress)); }
/// <summary> /// GetPV1 /// Get the HL7 IN3 segment and parse into the IN2 object. /// Also perform field validation of required fields and types /// Verify no errors have been detected during processing /// </summary> /// <param name="line">HL7 segment to parse</param> /// <returns>IN3 object</returns> public IN3 GetIN3(HL7Encoding _encode, string line) { const string fnName = "GetIN3"; List <SegmentError> segError = null; IN3 ins = new IN3(); int nIdx = 0; try { ins.SegmentMsg = line; ins.Segment = "IN3"; segError = Validate(ins, _encode); // var enumCnt = Enum.GetNames(typeof(mshElements)).Length; foreach (int i in Enum.GetValues(typeof(in3Elements))) { nIdx = i; object obj = GetElement(_encode, line, i); if (obj == null) { // check if this a required field string sTmp1 = ((Gt1Elements)i).ToString(); RequiredField rqFld = ins.RequiredFields.Find(x => x.FieldName.Equals(sTmp1)); if (rqFld != null && rqFld.IsRequired) { ins.Errors.Add(string.Format("{0}:{1} - WARNING Element ({2}) not found in segment, at field {3}", modName, fnName, ((in3Elements)i).ToString(), i)); } continue; } switch ((in3Elements)i) { case in3Elements.Segment: ins.Segment = (string)obj; break; case in3Elements.SeqId: if (!string.IsNullOrEmpty((string)obj)) { ins.SeqId = int.Parse((string)obj); } break; default: ins.Errors.Add(string.Format("{0}:{1} - Error element ({2}) not found", modName, fnName, ((in3Elements)i).ToString())); break; } } } catch (Exception ex) { string sErr = string.Format("Exception:{0}:{1} - ({2}) {3}", modName, fnName, ((in3Elements)nIdx).ToString(), ex); ins.Errors.Add(sErr); Console.WriteLine(sErr); } return(ins); }
///<summary> /// Returns first repetition of IN3 (Insurance Additional Information, Certification) - creates it if necessary ///</summary> public IN3 GetIN3() { IN3 ret = null; try { ret = (IN3)this.GetStructure("IN3"); } catch(HL7Exception e) { HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected error accessing data - this is probably a bug in the source code generator.", e); throw new System.Exception("An unexpected error ocurred",e); } return ret; }
static async Task Main() { IN3 in3 = IN3.ForChain(Chain.Mainnet); string cryptoKittiesDomain = "cryptokitties.eth"; string resolver = await in3.Eth1.Ens(cryptoKittiesDomain, ENSParameter.Resolver); string owner = await in3.Eth1.Ens(cryptoKittiesDomain, ENSParameter.Owner); Console.Out.WriteLine($"The owner of {cryptoKittiesDomain} is {owner}, resolver is {resolver}."); }
public async Task Ens_1() { string[][] mockedResponses = { new[] { "eth_call", "eth_call_3.json" } }; IN3 in3 = _factory.CreateIn3(mockedResponses); string result = await in3.Eth1.Ens("cryptokitties.eth"); Assert.That(result, Is.EqualTo("0x06012c8cf97bead5deae237070f9587f8e7a266d")); }
public async Task BlockNumber() { string[][] mockedResponses = { new[] { "eth_blockNumber", "eth_blockNumber.json" } }; IN3 in3 = _builder.ConstructClient(mockedResponses); BigInteger result = await in3.Eth1.BlockNumber(); Assert.That(result, Is.EqualTo(new BigInteger(3220))); }
public async Task GetUncleCountByBlockHash() { string[][] mockedResponses = { new[] { "eth_getUncleCountByBlockHash", "eth_getUncleCountByBlockHash.json" } }; IN3 in3 = _factory.CreateIn3(mockedResponses); long uncleCount = await in3.Eth1.GetUncleCountByBlockHash("0x884aaab2f9116742e693ced034a2dff840b45f21709025f7d69cde26d071068b"); Assert.That(uncleCount, Is.EqualTo(1)); }
public async Task GetUncleCountByBlockNumber() { string[][] mockedResponses = { new[] { "eth_getUncleCountByBlockNumber", "eth_getUncleCountByBlockNumber.json" } }; IN3 in3 = _factory.CreateIn3(mockedResponses); long uncleCount = await in3.Eth1.GetUncleCountByBlockNumber(9830239); Assert.That(uncleCount, Is.EqualTo(2)); }
public async Task GetTransactionBytes() { string[][] mockedResponses = { new[] { "getrawtransaction", "btc_GetTransactionBytes_1.json" } }; IN3 in3 = _builder.ConstructClient(mockedResponses); byte[] result = await in3.Btc.GetTransactionBytes("1427c7d1698e61afe061950226f1c149990b8c1e1b157320b0c4acf7d6b5605d"); Assert.That(result.Length, Is.EqualTo(225)); }
public void Setup() { string[][] mockedResponses = { new[] { "ipfs_get", "ipfs_get.json" }, new[] { "ipfs_put", "ipfs_put.json" } }; ClientBuilder builder = new ClientBuilder(Chain.Ipfs);; _in3 = builder.ConstructClient(mockedResponses); }
public async Task GetStorageAt() { string[][] mockedResponses = { new [] { "eth_getStorageAt", "eth_getStorageAt.json" } }; IN3 in3 = _factory.CreateIn3(mockedResponses); string storage = await in3.Eth1.GetStorageAt("0x862174623bc39e57de552538f424806b947d3d05", 0, BlockParameter.Latest); Assert.That(storage, Is.EqualTo("0x0000000000000000000000000000000000000000000000000000000000000000")); }
public async Task BlockNumber() { string[][] mockedResponses = { new[] { "eth_blockNumber", "eth_blockNumber.json" } }; IN3 in3 = _factory.CreateIn3(mockedResponses); BigInteger result = await in3.Eth1.BlockNumber(); Assert.That(result, Is.EqualTo(new BigInteger(3220))); }
public async Task GetCode() { string[][] mockedResponses = { new [] { "eth_getCode", "eth_getCode.json" } }; IN3 in3 = _factory.CreateIn3(mockedResponses); string response = await in3.Eth1.GetCode("0xdAC17F958D2ee523a2206206994597C13D831ec7", BlockParameter.Latest); Assert.NotNull(response); }
public async Task GetChainId() { string[][] mockedResponses = { new [] { "eth_estimateGas", "eth_estimateGas.json" } }; IN3 in3 = _factory.CreateIn3(mockedResponses); Chain currentChain = await in3.Eth1.GetChainId(); Assert.That(currentChain, Is.EqualTo(Chain.Mainnet)); }
public async Task GetGasPrice() { string[][] mockedResponses = { new [] { "eth_gasPrice", "eth_gasPrice.json" } }; IN3 in3 = _factory.CreateIn3(mockedResponses); BigInteger currentGasPrice = await in3.Eth1.GetGasPrice(); Assert.That(currentGasPrice, Is.EqualTo(new BigInteger(2100000000))); }
public async Task GetBlockBytes() { string[][] mockedResponses = { new[] { "getblock", "btc_GetBlockBytes_1.json" } }; IN3 in3 = _builder.ConstructClient(mockedResponses); byte[] result = await in3.Btc.GetBlockBytes("000000000000000000064ba7512ecc70cabd7ed17e31c06f2205d5ecdadd6d22"); Assert.That(result.Length, Is.EqualTo(55812)); }
public void Setup() { string[][] mockedResponses = { new[] { "ipfs_get", "ipfs_get.json" }, new[] { "ipfs_put", "ipfs_put.json" } }; ClientFactory factory = new ProoflessClientFactory(Chain.Ipfs);; _in3 = factory.CreateIn3(mockedResponses); }