Example #1
0
    public float GetEstimParam(PName p, BattleTemp observer = null)
    {//経験誤差を加えて返す
        float estim = observer == null ? expEstim : observer.expEstim;

        estim = Random.Range(-estim, estim);
        return(parameters[(int)p] * (1 + 0.5f * estim));
    }
        private void MakeIdentifier()
        {
            if (identifier != null)
            {
                return;
            }

            if (IsWildcard)
            {
                errorReason = "wildcard has no identifier";
                isError     = true;
                return;
            }

            string rawIdentifier = tree.Text;

            identifier = new PName();

            int colon = rawIdentifier.IndexOf(':');

            if (colon < 0)
            {
                identifier.local = rawIdentifier;
            }
            else
            {
                if (colon > 0)
                {
                    identifier.prefix = rawIdentifier.Substring(0, colon);
                    identifier.ns     = prefixMap[identifier.prefix];
                }
                identifier.local = rawIdentifier.Substring(colon + 1);
            }
        }
Example #3
0
        public void TestUriRef()
        {
            IDictionary <String, String> prefixMap = QueryUtils.ParsePrefixes(PREFIXES);

            WhereClause where = QueryUtils.ParseWhere(
                "qm:testCase=<http://example.org/tests/24>", prefixMap);

            IList <SimpleTerm> children = where.Children;

            Assert.AreEqual(1, children.Count, "Where clause should only have one term");

            SimpleTerm simpleTerm = children[0];
            PName      prop       = simpleTerm.Property;

            Assert.AreEqual(prop.ns + prop.local, "http://qm.example.com/ns/testCase");
            Assert.IsTrue(simpleTerm is ComparisonTerm);

            ComparisonTerm comparison = (ComparisonTerm)simpleTerm;

            Assert.AreEqual(comparison.Operator, Operator.EQUALS);

            IValue v = comparison.Operand;

            Assert.IsTrue(v is IUriRefValue);

            IUriRefValue uriRef = (IUriRefValue)v;

            Assert.AreEqual("http://example.org/tests/24", uriRef.Value);
        }
        void PacketReceivedEventHandler(PName packet_type, int flags)
        {
            string message;

            if (packet_type == PName.COMMAND_FAILED)
            {
                message = "Command Failed: ";
                message += System.Enum.Format(typeof(PName), (PName)flags, "G");
                message += "\r\n";
            }
            else if (packet_type == PName.COMMAND_COMPLETE)
            {
                message = "Command Complete: ";
                message += System.Enum.Format(typeof(PName), (PName)flags, "G");
                message += "\r\n";
            }
            else
            {
                message = "Received ";
                message += System.Enum.Format(typeof(PName), packet_type, "G");
                message += " packet\r\n";
            }

           
        }
Example #5
0
 private void clear()
 {
     PName.Clear();
     PEXP.Clear();
     PTottal.Clear();
     PCost.Clear();
     PSubS.Clear();
     Pnote.Clear();
 }
Example #6
0
        public override string GetFile(PName pname, int octive, int dynam)
        {
            string file = @"wav\Piano\" + pname.ToString() + octive.ToString() + ".wav";

            if (File.Exists(file))
            {
                return(file);
            }
            return("");
        }
Example #7
0
    public void SetParam(PName p, float value)
    {
        if (value < 0)
        {
            value = 0;
        }
        parameters[(int)p] = value;

        if (p == PName.hp)
        {
            CalcParams();
        }
    }
Example #8
0
        public Beat Add(Iinstrument ins, PName pname, int octive = 1, int duration = 8, int dynam = 60, float volume = 0.8F)
        {
            Note _n = new Note()
            {
                Instrument = ins,
                pName      = pname,
                Octive     = octive,
                Dynam      = dynam,
                Volume     = volume,
                Duration   = duration
            };

            _notes.Add(_n);
            return(this);
        }
Example #9
0
        public override string GetFile(PName pname, int octive, int dynam)
        {
            switch (pname)
            {
            case PName.Kick:
                return("wav/底鼓.wav");

            case PName.OpenHat:
                return("wav/开放擦.wav");

            case PName.Snare:
                return("wav/军鼓.wav");

            case PName.CloseHat:
                return("wav/踩擦.wav");
            }
            return("");
        }
Example #10
0
        private List <OrderProductViewModel> MapOrderDetailData(DataTable orderDetailData)
        {
            List <OrderProductViewModel> result = new List <OrderProductViewModel>();

            foreach (DataRow row in orderDetailData.Rows)
            {
                PName ProductName = new PName();
                ProductName.ProductId   = (int)row["ProductId"];
                ProductName.ProductName = row["ProductName"].ToString();
                result.Add(new OrderProductViewModel()
                {
                    ProductName = ProductName,
                    UnitPrice   = (decimal)row["UnitPrice"],
                    Qty         = (Int16)row["Qty"],
                    Sum         = (Int16)row["Qty"] * (int)(decimal)row["UnitPrice"]
                });
            }
            return(result);
        }
Example #11
0
        void orderGenerateId()
        {
            string         OID = "select ORDER_ID from PURCHASE_ORDER ORDER BY ORDER_ID";
            string         PName;
            int            PID;
            String         format = "000000";
            SqlDataAdapter ad     = new SqlDataAdapter(OID, consql);
            DataSet        ds     = new DataSet();

            ad.Fill(ds, "PurchaseOrder");
            if (ds.Tables["PurchaseOrder"].Rows.Count > 0)
            {
                PName   = ds.Tables["PurchaseOrder"].Rows[ds.Tables["PurchaseOrder"].Rows.Count - 1][0].ToString();
                PID     = int.Parse(PName.Substring(2, (PName.Length - 2)));
                orderID = "PO" + ((PID + 1).ToString(format));
            }
            else
            {
                orderID = "PO000001";
            }
        }
Example #12
0
        public override string GetFile(PName pname, int octive, int dynam)
        {
            switch (pname)
            {
            case PName.Kick:
                return("wav/BreakDown/kick.wav");

            case PName.OpenHat:
                return("wav/BreakDown/hihat.wav");

            case PName.CloseHat:
                return("wav/踩擦.wav");

            case PName.Snare:
                return("wav/BreakDown/snare.wav");

            case PName.Crash:
                return("wav/BreakDown/crash.wav");
            }
            return("");
        }
Example #13
0
        internal void Encode(AsnWriter writer, Asn1Tag tag)
        {
            writer.PushSequence(tag);

            writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 0));
            Key?.Encode(writer);
            writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 0));

            if (Asn1Extension.HasValue(Realm))
            {
                writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 1));
                writer.WriteCharacterString(UniversalTagNumber.GeneralString, Realm);
                writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 1));
            }


            if (Asn1Extension.HasValue(PName))
            {
                writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 2));
                PName?.Encode(writer);
                writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 2));
            }
            writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 3));
            writer.WriteBitString(Flags.AsReadOnly());
            writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 3));

            if (Asn1Extension.HasValue(AuthTime))
            {
                writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 4));
                writer.WriteGeneralizedTime(AuthTime.Value);
                writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 4));
            }

            if (Asn1Extension.HasValue(StartTime))
            {
                writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 5));
                writer.WriteGeneralizedTime(StartTime.Value);
                writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 5));
            }

            if (Asn1Extension.HasValue(EndTime))
            {
                writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 6));
                writer.WriteGeneralizedTime(EndTime.Value);
                writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 6));
            }

            if (Asn1Extension.HasValue(RenewTill))
            {
                writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 7));
                writer.WriteGeneralizedTime(RenewTill.Value);
                writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 7));
            }

            if (Asn1Extension.HasValue(SRealm))
            {
                writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 8));
                writer.WriteCharacterString(UniversalTagNumber.GeneralString, SRealm);
                writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 8));
            }


            if (Asn1Extension.HasValue(SName))
            {
                writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 9));
                SName?.Encode(writer);
                writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 9));
            }

            if (Asn1Extension.HasValue(AuthorizationData))
            {
                writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 10));
                writer.PushSequence();

                for (int i = 0; i < AuthorizationData.Length; i++)
                {
                    AuthorizationData[i]?.Encode(writer);
                }

                writer.PopSequence();

                writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 10));
            }

            writer.PopSequence(tag);
        }
Example #14
0
        /* **********************************************************************************
         *
         * Function: private void updatePacketSynch
         * Inputs: PName packet
         * Outputs: None
         * Return Value: None
         * Dependencies: None
         * Description:
         *
         * The AHRS class keeps track of packets it has sent and received - if a packet requesting
         * data is sent to the AHRS device, then the class will watch to receive the data.
         * If the data is not received in MaxDelay milliseconds, then a PacketTimeoutEvent is
         * fired (from elsewhere in the class, not from the updatePacketSynch function).
         *
         * Timing is tracked using several arrays:
         * The ElapsedTime[] array keeps track of how much time has elapsed since a packet
         * requesting data was sent.
         * The DataPending[] array keeps track of which channels have "pending" data - ie.
         * which channels the AHRS class is expecting to receive data on.
         * The Measured[] array keeps track of which data has been received at least once
         * from the AHRS - this allows the AHRS class to synchronize itself with the device.
         * The UpdatePending[] arrays keeps track of which internal class data has been changed,
         * but has not yet been written to the AHRS.
         *
         * Whenever a new packet is received from the AHRS device, the DataPending array
         * needs to be updated to reflect the data that was just received - if data was received,
         * then it is no longer "pending."
         *
         * The updatePacketSynch function performs the aforementioned tasks.
         *
         * *********************************************************************************/
        private void updatePacketSynch(PName packet, byte[] data)
        {
            switch (packet)
            {
                case PName.WHO_AM_I:
                    updatePacketSynchHelper(StateName.STATE_WHO_AM_I);
                    break;

                case PName.FIRMWARE_VERSION:
                    updatePacketSynchHelper(StateName.STATE_FIRMWARE_VERSION);
                    break;

                case PName.ID_STATUS:
                    updatePacketSynchHelper(StateName.STATE_ID_STATUS);
                    break;

                case PName.PWM_PARAMETER:
                    updatePacketSynchHelper(StateName.STATE_PWM_PARAMETER);
                    break;

                case PName.REPORT_SENSOR_ADC:
                    updatePacketSynchHelper(StateName.STATE_REPORT_SENSOR_ADC);
                    break;

                case PName.CMD_COMPLETE:
                    if (data[0] == PID[(int)PName.KICK_OFF_CONTROLLER])
                    {
                        updatePacketSynchHelper(StateName.STATE_KICK_OFF_CONTROLLER);
                    }
                    else if (data[0] == PID[(int)PName.RESET_CONTROLLER])
                    {
                        updatePacketSynchHelper(StateName.STATE_RESET_CONTROLLER);
                    }
                    else if (data[0] == PID[(int)PName.HOME_CMD])
                    {
                        updatePacketSynchHelper(StateName.STATE_HOME_CMD);
                    }
                    else if (data[0] == PID[(int)PName.PAUSE_REPORT_INFO])
                    {
                        updatePacketSynchHelper(StateName.STATE_PAUSE_REPORT_INFO);
                    }
                    else if (data[0] == PID[(int)PName.CONTINUE_REPORT_INFO])
                    {
                        updatePacketSynchHelper(StateName.STATE_CONTINUE_REPORT_INFO);
                    }
                    else if (data[0] == PID[(int)PName.ALL_OF_PID_PARAM])
                    {
                        updatePacketSynchHelper(StateName.STATE_ALL_OF_PID_PARAM);
                    }
                    else if (data[0] == PID[(int)PName.MAX_OF_POSITION_CMD])
                    {
                        updatePacketSynchHelper(StateName.STATE_MAX_OF_POSITION_CMD);
                    }
                    else if (data[0] == PID[(int)PName.MAX_OF_VELOCITY_CMD])
                    {
                        updatePacketSynchHelper(StateName.STATE_MAX_OF_VELOCITY_CMD);
                    }
                    else if (data[0] == PID[(int)PName.MAX_OF_TORQUE_CMD])
                    {
                        updatePacketSynchHelper(StateName.STATE_MAX_OF_TORQUE_CMD);
                    }
                    else if (data[0] == PID[(int)PName.MAX_OF_PWM_DUTYCYCLE])
                    {
                        updatePacketSynchHelper(StateName.STATE_MAX_OF_PWM_DUTYCYCLE);
                    }
                    else if (data[0] == PID[(int)PName.POSITION_TARGET_CMD])
                    {
                        updatePacketSynchHelper(StateName.STATE_POSITION_TARGET_CMD);
                    }
                    else if (data[0] == PID[(int)PName.VELOCITY_EXT_CMD])
                    {
                        updatePacketSynchHelper(StateName.STATE_VELOCITY_EXT_CMD);
                    }
                    else if (data[0] == PID[(int)PName.TORQUE_EXT_CMD])
                    {
                        updatePacketSynchHelper(StateName.STATE_TORQUE_EXT_CMD);
                    }

                    break;

                default:
                    break;
            }
        }
        void PacketReceivedEventHandler(PName packet_type, int flags)
        {
            string message;

            if (packet_type == PName.COMMAND_FAILED)
            {
                message = "Command Failed: ";
                message += System.Enum.Format(typeof(PName), (PName)flags, "G");
                message += "\r\n";
            }
            else if (packet_type == PName.COMMAND_COMPLETE)
            {
                message = "Command Complete: ";
                message += System.Enum.Format(typeof(PName), (PName)flags, "G");
                message += "\r\n";
            }
            else
            {
                message = "Received ";
                message += System.Enum.Format(typeof(PName), packet_type, "G");
                message += " packet\r\n";
            }
        }
Example #16
0
 public abstract string GetFile(PName pname, int octive, int dynam);
Example #17
0
 /* **********************************************************************************
  *
  * Function: void PacketSentEventHandler
  * Inputs: PName packet_type, int flags
  * Outputs: None
  * Return Value: None
  * Dependencies: None
  * Description:
  *
  * Handles PacketReceived events generated by the AHRS.
  *
  * *********************************************************************************/
 void PacketSentEventHandler(PName packet_type, int flags)
 {
 }
Example #18
0
 /* **********************************************************************************
 *
 * Function: void PacketSentEventHandler
 * Inputs: PName packet_type, int flags
 * Outputs: None
 * Return Value: None
 * Dependencies: None
 * Description:
 *
 * Handles PacketReceived events generated by the AHRS.
 *
 * *********************************************************************************/
 void PacketSentEventHandler(PName packet_type, int flags)
 {
 }
Example #19
0
 public float GetCorrectParam(PName p)
 //自パラメータの際は誤差半減
 {
     return(parameters[(int)p]);
 }
Example #20
0
        public void SetName(PName node)
        {
            if (_name_ != null)
            {
                _name_.Parent(null);
            }

            if (node != null)
            {
                if (node.Parent() != null)
                {
                    node.Parent().RemoveChild(node);
                }

                node.Parent(this);
            }

            _name_ = node;
        }
Example #21
0
 internal override void RemoveChild(Node child)
 {
     if (_ambiguous_ == child)
     {
         _ambiguous_ = null;
         return;
     }
 }
Example #22
0
 public AAmbiguousNameLvalue(
         PName _ambiguous_
 )
 {
     SetAmbiguous(_ambiguous_);
 }
Example #23
0
        public void SetAmbiguous(PName node)
        {
            if (_ambiguous_ != null)
            {
                _ambiguous_.Parent(null);
            }

            if (node != null)
            {
                if (node.Parent() != null)
                {
                    node.Parent().RemoveChild(node);
                }

                node.Parent(this);
            }

            _ambiguous_ = node;
        }
Example #24
0
        /* **********************************************************************************
        *
        * Function: void PacketReceivedEventHandler
        * Inputs: PName packet_type, int flags
        * Outputs: None
        * Return Value: None
        * Dependencies: None
        * Description:
        *
        * Handles PacketReceived events generated by the AHRS.
        *
        * *********************************************************************************/
        void PacketReceivedEventHandler(PName packet_type, int flags , int motor_channel)
        {
            string message;

            if (packet_type == PName.CMD_NO_SUPPORT)
            {
                message = "Command Failed: ";
                message += System.Enum.Format(typeof(PName), flags, "G");
                message += "\r\n";
            }
            else if (packet_type == PName.CMD_COMPLETE)
            {
                message = "Command Complete: ";
                message += System.Enum.Format(typeof(PName), flags, "G");
                message += "\r\n";
            }
            else if (packet_type == PName.CMD_CRC_FAILED)
            {
                if (flags == -1)
                {
                    message = "Device CRC Failed:: ";
                }
                else
                {
                    message = "Command CRC Failed:: ";
                }
                message += System.Enum.Format(typeof(PName), 0, "G");
                message += "\r\n";

            }
            else if (packet_type == PName.CMD_OVER_DATA_LENGTH)
            {
                if (flags == -1)
                {
                    message = "Device Over Data Length: ";
                }
                else
                {
                    message = "Command Over Data Length: ";
                }
                message += System.Enum.Format(typeof(PName), 0, "G");
                message += "\r\n";
            }
            else
            {
                message = "Received ";
                message += System.Enum.Format(typeof(PName), packet_type, "G");
                message += " packet\r\n";

                // sync會佔去大量時間
                //motor.synch();

            }

            AppendStatusText(message, Color.Green , channel);
        }
Example #25
0
 public ANamedType(
         PName _name_
 )
 {
     SetName(_name_);
 }
Example #26
0
        /* **********************************************************************************
        *
        * Function: void PacketSentEventHandler
        * Inputs: PName packet_type, int flags
        * Outputs: None
        * Return Value: None
        * Dependencies: None
        * Description:
        *
        * Handles PacketReceived events generated by the AHRS.
        *
        * *********************************************************************************/
        void PacketSentEventHandler(PName packet_type, int flags , int motor_channel)
        {
            channel = motor_channel;
            string message;

            message = "Sent ";
            message += System.Enum.Format(typeof(PName), packet_type, "G");
            message += " packet\r\n";

            AppendStatusText(message, Color.Blue,channel);
        }
Example #27
0
 internal override void RemoveChild(Node child)
 {
     if (_name_ == child)
     {
         _name_ = null;
         return;
     }
 }
Example #28
0
 /* **********************************************************************************
  *
  * Function: void PacketReceivedEventHandler
  * Inputs: PName packet_type, int flags
  * Outputs: None
  * Return Value: None
  * Dependencies: None
  * Description:
  *
  * Handles PacketReceived events generated by the AHRS.
  *
  * *********************************************************************************/
 void PacketReceivedEventHandler(PName packet_type, int flags)
 {
 }
Example #29
0
 public override string GetFile(PName pname, int octive, int dynam)
 {
     throw new NotImplementedException();
 }
Example #30
0
 /* **********************************************************************************
 *
 * Function: void PacketReceivedEventHandler
 * Inputs: PName packet_type, int flags
 * Outputs: None
 * Return Value: None
 * Dependencies: None
 * Description:
 *
 * Handles PacketReceived events generated by the AHRS.
 *
 * *********************************************************************************/
 void PacketReceivedEventHandler(PName packet_type, int flags)
 {
 }