示例#1
0
        public Data()
        {
            _start    = Properties.Settings.Default.Start;
            _minimize = Properties.Settings.Default.Minimize;
            _noStereo = Properties.Settings.Default.NoStereo;
            _latch    = Properties.Settings.Default.Latch;
            _manual   = Properties.Settings.Default.Manual;

            _devicePort = Properties.Settings.Default.Device;
            _otrspPort  = Properties.Settings.Default.Otrsp;
            _keyerPort  = Properties.Settings.Default.Keyer;

            _rx = (RX)Properties.Settings.Default.RxRadio;
            _tx = (TX)Properties.Settings.Default.TxRadio;

            _ptt = false;
        }
示例#2
0
文件: OM2.cs 项目: nHapiNET/nHapi
 ///<summary>
 /// Returns all repetitions of SI Conversion Factor (OM2-6).
 ///</summary>
 public TX[] GetSIConversionFactor()
 {
     TX[] ret = null;
     try {
         IType[] t = this.GetField(6);
         ret = new TX[t.Length];
         for (int i = 0; i < ret.Length; i++)
         {
             ret[i] = (TX)t[i];
         }
     } catch (HL7Exception he) {
         HapiLogFactory.GetHapiLog(this.GetType()).Error("Unexpected problem obtaining field value.  This is a bug.", he);
         throw new System.Exception("An unexpected error ocurred", he);
     } catch (System.Exception cce) {
         HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value.  This is a bug.", cce);
         throw new System.Exception("An unexpected error ocurred", cce);
     }
     return(ret);
 }
示例#3
0
 public override VR CreateVR(string str, Rule rule, int length)
 {
     {
         VR vr = null;
         if (str == "SS")
         {
             vr = new SS(rule, length);
         }
         else if (str == "US")
         {
             vr = new US(rule, length);
         }
         else if (str == "UL")
         {
             vr = new UL(rule, length);
         }
         else if (str == "SL")
         {
             vr = new SL(rule, length);
         }
         else if (str == "IS")
         {
             vr = new IS(rule, length);
         }
         else if (str == "FS")
         {
             vr = new FS(rule, length);
         }
         else if (str == "AS")
         {
             vr = new AS(rule, length);
         }
         else if (str == "DA")
         {
             vr = new DA(rule, length);
         }
         else if (str == "UI")
         {
             vr = new TX(rule, length);
         }
         return(vr);
     }
 }
        /// <summary>
        /// 简单类型工厂创建primitiveType,如ID等
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="product"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public override abstractType Create(compositeType parent, Enum product, string name)
        {
            abstractType tmp = null;

            switch (product)
            {
            case enumPrimitive.DR: tmp = new DR(name); break;

            case enumPrimitive.DT: tmp = new DT(name); break;

            case enumPrimitive.FT: tmp = new FT(name); break;

            case enumPrimitive.ID: tmp = new ID(name); break;

            case enumPrimitive.IS: tmp = new IS(name); break;

            case enumPrimitive.NM: tmp = new NM(name); break;

            case enumPrimitive.SAD: tmp = new SAD(name); break;

            case enumPrimitive.SI: tmp = new SI(name); break;

            case enumPrimitive.ST: tmp = new ST(name); break;

            case enumPrimitive.TM: tmp = new TM(name); break;

            case enumPrimitive.TN: tmp = new TN(name); break;

            case enumPrimitive.TS: tmp = new TS(name); break;

            case enumPrimitive.TX: tmp = new TX(name); break;

            case enumPrimitive.VARIES: tmp = new VARIES(name); break;

            case enumPrimitive.MO: tmp = new MO(name); break;

            default:
                throw new NotSupportedException();
            }
            return(tmp);
        }
示例#5
0
        static void Main(string[] args)
        {
            CB cb = new CB();

            Console.WriteLine("== test CB =====");
            Console.WriteLine("give price 149.9, idx = {0}, tick_size={1:n}", cb.inPriceRange(149.9m), cb.getTickSize(149.9m));
            Console.WriteLine("give price 100 and 101, ticks  = {0}", cb.TicksBetween(100m, 101m));
            Console.WriteLine("give price 153.5 and 155, ticks  = {0}", cb.TicksBetween(153.5m, 155m));

            Console.WriteLine("give price 149.9 and 150, ticks  = {0}", cb.TicksBetween(149.9m, 150m));
            Console.WriteLine("give price 150 and 999, ticks  = {0}", cb.TicksBetween(150m, 999m));
            Console.WriteLine("give price 150 and 1000, ticks  = {0}", cb.TicksBetween(150m, 1000m));
            Console.WriteLine("give price 149.9 and 1005, ticks  = {0}", cb.TicksBetween(149.9m, 1005m));
            Console.WriteLine("give price 149.9 and 1003, ticks  = {0}", cb.TicksBetween(149.9m, 1003m));

            Console.WriteLine("price 100.5 move 3 ticks  = {0:n}", cb.TickMove(100.5m, 3));
            Console.WriteLine("price 149.9 move 5 ticks  = {0:n}", cb.TickMove(149.9m, 5));
            Console.WriteLine("price 998 move 5 ticks  = {0:n}", cb.TickMove(998m, 5));


            Console.WriteLine("== test ETF =====");
            ETF etf = new ETF();

            Console.WriteLine("give price 40 and 41, ticks  = {0}", etf.TicksBetween(40m, 41m));
            Console.WriteLine("give price 60 and 62, ticks  = {0}", etf.TicksBetween(60m, 62m));
            Console.WriteLine("price 50.2 move -5 ticks  = {0:n}", etf.TickMove(50.2m, -5));
            Console.WriteLine("price 49.98 move 5 ticks  = {0:n}", etf.TickMove(49.98m, 5));


            Console.WriteLine("== test X =====");
            TX tx = new TX();

            Console.WriteLine("give price 49.5 and 51, ticks  = {0}", tx.TicksBetween(49.5m, 51m));
            Console.WriteLine("give price 498.5 and 501, ticks  = {0}", tx.TicksBetween(498.5m, 501m));
            Console.WriteLine("price 49.6 move 8 ticks  = {0:n}", tx.TickMove(49.6m, 8));
            Console.WriteLine("price 498.5 move 6 ticks  = {0:n}", tx.TickMove(498.5m, 6));
            Console.WriteLine("price 51.5 move -6 ticks  = {0:n}", tx.TickMove(51.5m, -6));
            Console.WriteLine("price 505 move -6 ticks  = {0:n}", tx.TickMove(505m, -6));

            Console.Read();
        }
示例#6
0
 /// <summary> Returns all repetitions of SI Conversion Factor (OM2-6).</summary>
 public virtual TX[] getSIConversionFactor()
 {
     TX[] ret = null;
     try
     {
         Type[] t = this.getField(6);
         ret = new TX[t.Length];
         for (int i = 0; i < ret.Length; i++)
         {
             ret[i] = (TX)t[i];
         }
     }
     catch (System.InvalidCastException)
     {
         throw new Exception();
     }
     catch (NuGenHL7Exception)
     {
         throw new Exception();
     }
     return(ret);
 }
示例#7
0
 /// <summary> Returns all repetitions of Command Response Parameters (ECR-3).</summary>
 public virtual TX[] getCommandResponseParameters()
 {
     TX[] ret = null;
     try
     {
         Type[] t = this.getField(3);
         ret = new TX[t.Length];
         for (int i = 0; i < ret.Length; i++)
         {
             ret[i] = (TX)t[i];
         }
     }
     catch (System.InvalidCastException)
     {
         throw new Exception();
     }
     catch (NuGenHL7Exception)
     {
         throw new Exception();
     }
     return(ret);
 }
示例#8
0
 /// <summary> Returns all repetitions of PATIENT INSTRUCTIONS (RX1-29).</summary>
 public virtual TX[] getPATIENTINSTRUCTIONS()
 {
     TX[] ret = null;
     try
     {
         Type[] t = this.getField(29);
         ret = new TX[t.Length];
         for (int i = 0; i < ret.Length; i++)
         {
             ret[i] = (TX)t[i];
         }
     }
     catch (System.InvalidCastException)
     {
         throw new Exception();
     }
     catch (NuGenHL7Exception)
     {
         throw new Exception();
     }
     return(ret);
 }
示例#9
0
 public Point3D GetPoint(double t)
 {
     return(new Point3D(TX.Transform(t), TY.Transform(t), TZ.Transform(t)));
 }
示例#10
0
 /// <summary>
 /// Initializes this instance of the <see cref="Point3DTransform"/> class.
 /// </summary>
 public void Init(Point3D p0, Point3D p1, double t0 = 0, double t1 = 1)
 {
     TX.Init(t0, t1, p0.X, p1.X);
     TY.Init(t0, t1, p0.Y, p1.Y);
     TZ.Init(t0, t1, p0.Z, p1.Z);
 }
示例#11
0
 /// <summary>
 /// Gets the inverse transformed vector.
 /// </summary>
 public Vector3D BackTransform(Vector3D v)
 {
     return(new Vector3D(TX.BackTransform(v.X),
                         TY.BackTransform(v.Y), TZ.BackTransform(v.Z)));
 }
示例#12
0
		/// <summary> Creates a RFR.</summary>
		/// <param name="message">the Message to which this Type belongs
		/// </param>
		public RFR(Message message):base(message)
		{
			data = new Type[7];
			data[0] = new NR(message);
			data[1] = new IS(message, 1);
			data[2] = new NR(message);
			data[3] = new NR(message);
			data[4] = new ST(message);
			data[5] = new ST(message);
			data[6] = new TX(message);
		}
 public static TX Default(TX a)
 {
     return(default(TX));
 }
 public static BL Equals(TX first, TX second)
 {
     return(first.Span.SequenceEqual(second.Span));
 }
示例#15
0
 /// <summary>
 /// Initializes this instance of the <see cref="Vector3DTransform"/> class.
 /// </summary>
 public void Init(Vector3D v0, Vector3D v1, double t0 = 0, double t1 = 1)
 {
     TX.Init(t0, t1, v0.X, v1.X);
     TY.Init(t0, t1, v0.Y, v1.Y);
     TZ.Init(t0, t1, v0.Z, v1.Z);
 }
示例#16
0
 public void SetValue(TX value)
 {
     SetType(ExprTypeKind.TX);
     ExprValue = value;
 }
示例#17
0
            public TX CreateAnchorToken(
                byte[] dataOPReturn)
            {
                ulong fee = 28000;

                TXOutputWallet outputSpendable =
                    TXOutputsSpendable.Find(t => t.Value > fee);

                if (outputSpendable == null)
                {
                    throw new BitcoinException("No spendable output found.");
                }

                List <byte> tXRaw = new List <byte>();

                byte[] version = { 0x01, 0x00, 0x00, 0x00 };
                tXRaw.AddRange(version);

                byte countInputs = 1;

                tXRaw.Add(countInputs);

                tXRaw.AddRange(outputSpendable.TXID);

                tXRaw.AddRange(BitConverter.GetBytes(
                                   outputSpendable.OutputIndex));

                int indexScriptSig = tXRaw.Count;

                tXRaw.Add(LENGTH_P2PKH);

                tXRaw.AddRange(outputSpendable.ScriptPubKey);

                byte[] sequence = { 0xFF, 0xFF, 0xFF, 0xFF };
                tXRaw.AddRange(sequence);

                byte countOutputs = 2; //(byte)(valueChange == 0 ? 1 : 2);

                tXRaw.Add(countOutputs);

                ulong valueChange = outputSpendable.Value - fee;

                tXRaw.AddRange(BitConverter.GetBytes(
                                   valueChange));

                tXRaw.Add(LENGTH_P2PKH);

                tXRaw.AddRange(PREFIX_P2PKH);
                tXRaw.AddRange(PublicKeyHash160);
                tXRaw.AddRange(POSTFIX_P2PKH);

                tXRaw.AddRange(BitConverter.GetBytes(
                                   (ulong)0));

                tXRaw.Add((byte)(dataOPReturn.Length + 2));
                tXRaw.Add(OP_RETURN);
                tXRaw.Add((byte)dataOPReturn.Length);
                tXRaw.AddRange(dataOPReturn);

                var lockTime = new byte[4];

                tXRaw.AddRange(lockTime);

                byte[] sigHashType = { 0x01, 0x00, 0x00, 0x00 };
                tXRaw.AddRange(sigHashType);

                byte[] signature = Crypto.GetSignature(
                    PrivKeyDec,
                    tXRaw.ToArray());

                var scriptSig = new List <byte>();

                scriptSig.Add((byte)(signature.Length + 1));
                scriptSig.AddRange(signature);
                scriptSig.Add(0x01);

                byte[] publicKey = Crypto.GetPubKeyFromPrivKey(PrivKeyDec);

                scriptSig.Add((byte)publicKey.Length);
                scriptSig.AddRange(publicKey);

                var tXRawPreScriptSig  = tXRaw.Take(indexScriptSig);
                var tXRawPostScriptSig = tXRaw.Skip(indexScriptSig + LENGTH_P2PKH + 1);

                tXRaw = tXRawPreScriptSig
                        .Concat(new byte[] { (byte)scriptSig.Count })
                        .Concat(scriptSig)
                        .Concat(tXRawPostScriptSig)
                        .ToList();

                tXRaw.RemoveRange(tXRaw.Count - 4, 4);

                var parser     = new BlockParser();
                int indexTXRaw = 0;

                byte[] tXRawArray = tXRaw.ToArray();

                TX tX = parser.ParseTX(
                    false,
                    tXRawArray,
                    ref indexTXRaw);

                tX.TXRaw = tXRawArray;

                return(tX);
            }
示例#18
0
		/// <summary> Returns all repetitions of Command Response Parameters (ECR-3).</summary>
		public virtual TX[] getCommandResponseParameters()
		{
			TX[] ret = null;
			try
			{
				Type[] t = this.getField(3);
				ret = new TX[t.Length];
				for (int i = 0; i < ret.Length; i++)
				{
					ret[i] = (TX) t[i];
				}
			}
			catch (System.InvalidCastException )
			{
				throw new Exception();
			}
			catch (NuGenHL7Exception)
			{
				throw new Exception();
			}
			return ret;
		}
示例#19
0
            public void DetectTXOutputsSpendable(TX tX)
            {
                for (int i = 0; i < tX.TXOutputs.Count; i += 1)
                {
                    TXOutput tXOutput = tX.TXOutputs[i];

                    if (tXOutput.LengthScript != LENGTH_P2PKH)
                    {
                        continue;
                    }

                    int indexScript = tXOutput.StartIndexScript;

                    if (!PREFIX_P2PKH.IsEqual(
                            tXOutput.Buffer,
                            indexScript))
                    {
                        continue;
                    }

                    indexScript += 3;

                    if (!PublicKeyHash160.IsEqual(
                            tXOutput.Buffer,
                            indexScript))
                    {
                        continue;
                    }

                    indexScript += 20;

                    if (POSTFIX_P2PKH.IsEqual(
                            tXOutput.Buffer,
                            indexScript))
                    {
                        byte[] scriptPubKey = new byte[LENGTH_P2PKH];

                        Array.Copy(
                            tXOutput.Buffer,
                            tXOutput.StartIndexScript,
                            scriptPubKey,
                            0,
                            LENGTH_P2PKH);

                        TXOutputsSpendable.Add(
                            new TXOutputWallet
                        {
                            TXID         = tX.Hash,
                            TXIDShort    = tX.TXIDShort,
                            OutputIndex  = i,
                            Value        = tXOutput.Value,
                            ScriptPubKey = scriptPubKey
                        });

                        Console.WriteLine(
                            "Detected spendable output {0} " +
                            "in tx {1} with {2} satoshis.",
                            i,
                            tX.Hash.ToHexString(),
                            tXOutput.Value);
                    }
                }
            }
示例#20
0
            public TX ParseTX(
                bool isCoinbase,
                byte[] buffer,
                ref int indexBuffer)
            {
                TX tX = new TX();

                try
                {
                    int tXStartIndex = indexBuffer;

                    indexBuffer += 4; // BYTE_LENGTH_VERSION

                    bool isWitnessFlagPresent = buffer[indexBuffer] == 0x00;
                    if (isWitnessFlagPresent)
                    {
                        throw new NotImplementedException(
                                  "Parsing of segwit txs not implemented");
                        //BufferIndex += 2;
                    }

                    int countInputs = VarInt.GetInt32(
                        buffer, ref indexBuffer);

                    if (isCoinbase)
                    {
                        new TXInput(buffer, ref indexBuffer);
                    }
                    else
                    {
                        for (int i = 0; i < countInputs; i += 1)
                        {
                            tX.TXInputs.Add(
                                new TXInput(
                                    buffer,
                                    ref indexBuffer));
                        }
                    }

                    int countTXOutputs = VarInt.GetInt32(
                        buffer,
                        ref indexBuffer);

                    for (int i = 0; i < countTXOutputs; i += 1)
                    {
                        tX.TXOutputs.Add(
                            new TXOutput(
                                buffer,
                                ref indexBuffer));
                    }

                    //if (isWitnessFlagPresent)
                    //{
                    //var witnesses = new TXWitness[countInputs];
                    //for (int i = 0; i < countInputs; i += 1)
                    //{
                    //  witnesses[i] = TXWitness.Parse(Buffer, ref BufferIndex);
                    //}
                    //}

                    indexBuffer += 4; //BYTE_LENGTH_LOCK_TIME

                    tX.Hash = SHA256.ComputeHash(
                        SHA256.ComputeHash(
                            buffer,
                            tXStartIndex,
                            indexBuffer - tXStartIndex));

                    tX.TXIDShort = BitConverter.ToInt32(tX.Hash, 0);

                    int lengthUTXOBits =
                        COUNT_NON_OUTPUT_BITS + countTXOutputs;

                    return(tX);
                }
                catch (ArgumentOutOfRangeException)
                {
                    throw new BitcoinException(
                              "ArgumentOutOfRangeException thrown in ParseTX.");
                }
            }
示例#21
0
            List <TX> ParseTXs(
                byte[] hashMerkleRoot)
            {
                List <TX> tXs = new List <TX>();

                int tXCount = VarInt.GetInt32(
                    Buffer,
                    ref IndexBuffer);

                if (tXCount == 0)
                {
                }
                else if (tXCount == 1)
                {
                    TX tX = ParseTX(
                        isCoinbase: true,
                        Buffer,
                        ref IndexBuffer);

                    tXs.Add(tX);

                    if (!tX.Hash.IsEqual(hashMerkleRoot))
                    {
                        throw new BitcoinException(
                                  "Payload merkle root corrupted");
                    }
                }
                else
                {
                    int tXsLengthMod2 = tXCount & 1;
                    var merkleList    = new byte[tXCount + tXsLengthMod2][];

                    TX tX = ParseTX(
                        isCoinbase: true,
                        Buffer,
                        ref IndexBuffer);

                    tXs.Add(tX);

                    merkleList[0] = tX.Hash;

                    for (int t = 1; t < tXCount; t += 1)
                    {
                        tX = ParseTX(
                            isCoinbase: false,
                            Buffer,
                            ref IndexBuffer);

                        tXs.Add(tX);

                        merkleList[t] = tX.Hash;
                    }

                    if (tXsLengthMod2 != 0)
                    {
                        merkleList[tXCount] = merkleList[tXCount - 1];
                    }

                    if (!GetRoot(merkleList).IsEqual(hashMerkleRoot))
                    {
                        throw new BitcoinException(
                                  "Payload hash unequal with merkle root.");
                    }
                }

                return(tXs);
            }
示例#22
0
 /// <summary>
 /// Gets the transformed point.
 /// </summary>
 public Point3D Transform(Point3D pt)
 {
     return(new Point3D(TX.Transform(pt.X),
                        TY.Transform(pt.Y), TZ.Transform(pt.Z)));
 }
示例#23
0
        public void AddLabelToLocation(TX.Framework.WindowUI.Controls.TXPanel panel,int column, RectangleLabel label)
        {
            int labelCount = panel.Controls.Count;
            int lines = labelCount / column;
            int left = labelCount % column;
            int X = (left * WIDTH) + (left + 1) * (MARGIN*3);
            int Y = lines * HEIGHT + (lines + 1) * (MARGIN*3);
            //LabelWithCheck label = new LabelWithCheck();

            label.Location = new Point(X,Y);
            panel.Controls.Add(label);
        }
示例#24
0
 /// <summary>
 /// Gets the inverse transformed point.
 /// </summary>
 public Point3D BackTransform(Point3D pt)
 {
     return(new Point3D(TX.BackTransform(pt.X),
                        TY.BackTransform(pt.Y), TZ.BackTransform(pt.Z)));
 }
示例#25
0
 get => new Point(TX, TY);
示例#26
0
		/// <summary> Creates a PRL.</summary>
		/// <param name="message">the Message to which this Type belongs
		/// </param>
		public PRL(Message message):base(message)
		{
			data = new Type[3];
			data[0] = new CE(message);
			data[1] = new ST(message);
			data[2] = new TX(message);
		}
示例#27
0
		/// <summary> Creates a SPS.</summary>
		/// <param name="message">the Message to which this Type belongs
		/// </param>
		public SPS(Message message):base(message)
		{
			data = new Type[7];
			data[0] = new CWE(message);
			data[1] = new CWE(message);
			data[2] = new TX(message);
			data[3] = new CWE(message);
			data[4] = new CWE(message);
			data[5] = new CWE(message);
			data[6] = new CWE(message);
		}
 public static BL NotEquals(TX first, TX second)
 {
     return(!Equals(first, second));
 }
示例#29
0
 /// <summary>
 /// Gets the transformed vector.
 /// </summary>
 public Vector3D Transform(Vector3D v)
 {
     return(new Vector3D(TX.Transform(v.X),
                         TY.Transform(v.Y), TZ.Transform(v.Z)));
 }
 public static I4 Len(TX a)
 {
     return(a.Length);
 }
 public static T Dump <T>(TX fmt, T a)
 {
     OutWriter.WriteLine(fmt.ToString(), a);
     return(a);
 }
示例#32
0
 public Vector3D GetVector(double t)
 {
     return(new Vector3D(TX.Transform(t), TY.Transform(t), TZ.Transform(t)));
 }
示例#33
0
		/// <summary> Creates a TQ.</summary>
		/// <param name="message">the Message to which this Type belongs
		/// </param>
		public TQ(Message message):base(message)
		{
			data = new Type[12];
			data[0] = new CQ(message);
			data[1] = new RI(message);
			data[2] = new ST(message);
			data[3] = new TS(message);
			data[4] = new TS(message);
			data[5] = new ST(message);
			data[6] = new ST(message);
			data[7] = new TX(message);
			data[8] = new ID(message, 472);
			data[9] = new OSD(message);
			data[10] = new CE(message);
			data[11] = new NM(message);
		}