private void getSAMInfo(SAM sam)
        {
            string text = "";

            if (sam != null)
            {
                long tick = DateTime.Now.Ticks;

                /** Connect [Start] */
                try
                {
                    if (!sam.IsConnected)
                    {
                        sam.Connect();
                        text += GetString(Resource.String.message_sam_connected_successfully) + " " + sam.SamType + "(Slot " + sam.SamIndex + ")\n";
                    }
                }
                catch (SAMException ex)
                {
                    updateStatus(GetString(Resource.String.message_connect_error) + " " + SAMResults.GetErrorDescription(ex.Result));
                    return;
                }
                /** Connect [End] */

                /** Transceive [Start] */
                byte[] getVersionAPDU = null;
                getVersionAPDUs.TryGetValue(sam.SamType, out getVersionAPDU);
                byte[] response = null;
                try
                {
                    text    += GetString(Resource.String.message_transceive) + "\n";
                    response = sam.Transceive(getVersionAPDU, (short)0, false);
                    if (response != null)
                    {
                        text += GetString(Resource.String.version) + " " + getHexString(response) + "\n";
                    }
                    else
                    {
                        text += GetString(Resource.String.version_error) + "\n";
                    }
                }
                catch (SAMException ex)
                {
                    text += GetString(Resource.String.message_transceive_failed) + " " + SAMResults.GetErrorDescription(ex.Result) + "\n";
                }
                /**Transceive [End] */

                /** Disconnect [Start] */
                if (sam.IsConnected)
                {
                    sam.Disconnect();
                    text += GetString(Resource.String.message_disconnecting) + " " + sam.SamType + "(Slot " + sam.SamIndex + ")\n";
                }
                /** Disconnect [End] */

                long timetook = (DateTime.Now.Ticks - tick) / 10000;
                text += "Time taken to get version: " + timetook + "ms";
                updateStatus(text);
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello");
            SAM sam = new SAM(20);

            Console.WriteLine(sam.ToString());
            Console.ReadKey();
        }
Esempio n. 3
0
 void SAM_Refresh()         //This method is called when the Refresh Button is pressed.
 {
     if (tmrEvents.Enabled) //stop our timer first before we do anything.
     {
         tmrEvents.Stop();
     }
     SAM.Refresh();            //Perform the refresh.
     GUI_Reset();
     LoadSteamAppsToListBox(); //Reload data to list box.
 }
Esempio n. 4
0
        private SAM requestSAM()
        {
            SAMForm SAMForm = new SAMForm();

            SAMForm.ShowDialog();
            SAM response = SAMForm.getSAMResponse();
            ValenceAndArousalDao excitementAndArousalDao = new ValenceAndArousalDao();

            excitementAndArousalDao.InsertExcitementAndArousal(currentSession.TestName, EventTypes.INITIAL_SAM, response.Valence, response.Arousal, this.Seccion);
            return(response);
        }
Esempio n. 5
0
 void StartStopWatchEvents() //This method is called when the Start/Stop watching events button is pressed.
 {
     if (SAM.EventListenerRunning)
     {
         SAM.StopListeningForEvents();
         GUI_EventListenUpdate(false);
     }
     else
     {
         SAM.StartListeningForEvents();
         GUI_EventListenUpdate(true);
     }
 }
Esempio n. 6
0
 public void RunSAMTest(bool single, bool stop)
 {
     if (single)
     {
         SAM sam = new SAM(F1, COMPort);
         sam.Start_Test();
     }
     else
     {
         if (F1.getCheckStatus((COMPort == 1) ? (F1.SAMCheck) : (F1.SAMCheck2)) && !stop)
         {
             SAM sam = new SAM(F1, COMPort);
             sam.Start_Test();
         }
     }
 }
Esempio n. 7
0
    // Start is called before the first frame update
    void Start()
    {
        //Getting LSL stream
        marker = FindObjectOfType <LSLMarkerStream>();

        //Generating pseudo-randomized trial list
        for (int i = 0; i < (TotalNumberTrials / 3); i++)
        {
            DoorCaseList.Add(1);
            DoorCaseList.Add(2);
            DoorCaseList.Add(3);
            DoorCaseList = DoorCaseList.OrderBy(x => UnityEngine.Random.value).ToList();
        }

        //Generating pseudo-randomized GoNoGo list
        for (int i = 0; i < (TotalNumberTrials / 2); i++)
        {
            GoNoGoList.Add("Go");
            GoNoGoList.Add("NoGo");
            GoNoGoList = GoNoGoList.OrderBy(x => UnityEngine.Random.value).ToList();
        }

        //Generating randomized list of time in dark
        System.Random rnd = new System.Random();
        for (int i = 0; i < TotalNumberTrials; i++)
        {
            TimeInDarkList.Add(rnd.Next(TimeInDark - DarkSD, TimeInDark + DarkSD));
        }

        //Generating randomized list of time in dark
        for (int i = 0; i < TotalNumberTrials; i++)
        {
            TimeToImperativeList.Add(rnd.Next(TimeToImperative - LightSD, TimeToImperative + LightSD));
        }

        //Removing the cursor in-game
        Cursor.visible = false;

        //Setting start status
        isDark      = true;
        DarkTimer   = TimeInDarkList[CurrentTrial];
        LightTimer  = TimeToImperativeList[CurrentTrial];
        GoNoGoState = "";

        //Retrieving the SAM questionnaire
        SAMcode = gameobjectSAM.GetComponent <SAM>();
    }
Esempio n. 8
0
 /// <summary>
 /// Add a read being parsed to the index
 /// </summary>
 /// <param name="alignedSequence"></param>
 /// <param name="offset"></param>
 internal void AddReadToIndexInformation(SAM.SAMAlignedSequence alignedSequence, FileOffset offset)
 {
     if (offset < FirstOffSetSeen) { FirstOffSetSeen = offset; }
     else if (offset > LastOffSetSeen) { LastOffSetSeen = offset; }            
     //update meta-data
     if (alignedSequence.Pos < 1 || (alignedSequence.Flag&SAMFlags.UnmappedQuery)==SAMFlags.UnmappedQuery)
     {
         UnMappedReadsCount++;
         return;
     }
     else
     {
         MappedReadsCount++;
     }
     //update linear index
     LinearIndexMaker.UpdateLinearArrayIndex(alignedSequence, offset);
 }
Esempio n. 9
0
        /// <summary>
        ///
        /// </summary>
        public FormPhonemesEditor(SAM inst, SAMTimbre timbre, bool singleSelect)
        {
            this.inst   = inst;
            this.timbre = timbre;
            for (int i = 0; i < inst.BaseTimbres.Length; i++)
            {
                if (inst.BaseTimbres[i] == timbre)
                {
                    timbreNo = i;
                }
            }

            InitializeComponent();

            metroTextBoxAllophones.Text = timbre.Phonemes;

            Size = Settings.Default.PhonemesEdSize;
        }
Esempio n. 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService editorService = null;

            if (provider != null)
            {
                editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            }

            if (editorService == null)
            {
                return(value);
            }

            bool      singleSel = true;
            SAMTimbre tim       = context.Instance as SAMTimbre;

            SAMTimbre[] tims = value as SAMTimbre[];
            if (tims != null)
            {
                tim       = tims[0];
                singleSel = false;
            }

            SAM inst = null;

            try
            {
                //InstrumentManager.ExclusiveLockObject.EnterReadLock();

                inst = InstrumentManager.FindParentInstrument(InstrumentType.SAM, tim) as SAM;
            }
            finally
            {
                //InstrumentManager.ExclusiveLockObject.ExitReadLock();
            }

            using (var frm = new FormPhonemesEditor(inst, tim, singleSel))
            {
                frm.Tag           = context;
                frm.Allophones    = (string)value;
                frm.ValueChanged += (s, e) =>
                {
                    try
                    {
                        //InstrumentManager.ExclusiveLockObject.EnterWriteLock();

                        context.PropertyDescriptor.SetValue(context.Instance, frm.Allophones);
                    }
                    finally
                    {
                        //InstrumentManager.ExclusiveLockObject.ExitWriteLock();
                    }
                };

                DialogResult dr = frm.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    value = frm.Allophones;
                }
                else if (value != null)
                {
                    value = ((string)value + " ").Clone();
                }
            }
            return(value);
        }
        private void tagDetection(Intent intent)
        {
            tagOperationInProgress = true;

            if (samManager == null)
            {
                initSAMManager();
            }

            if (NfcAdapter.ActionNdefDiscovered.Equals(intent.Action) ||
                NfcAdapter.ActionTagDiscovered.Equals(intent.Action) ||
                NfcAdapter.ActionTechDiscovered.Equals(intent.Action))
            {
                Tag     lTag          = (Tag)intent.GetParcelableExtra(NfcAdapter.ExtraTag);
                SAM     sam           = null;
                SAMType samTypeForTag = null;

                samTypeForTag = findCompatibleSAM(lTag);

                string text = detectedTag + " " + GetString(Resource.String.message_tag_detected) + "\n";

                string compatibeSAMText = "";


                foreach (KeyValuePair <int, SAM> entry in presetSAMList)
                {
                    if (entry.Value.SamType == samTypeForTag)
                    {
                        sam = entry.Value;
                        compatibeSAMText += "\n\t" + sam.SamType + "(Slot " + sam.SamIndex + ")";
                    }
                }


                if (presetSAMList.Count > 0)
                {
                    if (compatibeSAMText != "")
                    {
                        text += GetString(Resource.String.message_tag_compatible) + " " + compatibeSAMText;

                        /**
                         * Connect to the appropriate SAM based on the Tag detected.
                         */
                        /**
                         * //Connect [Start]
                         * try
                         * {
                         *   if (!sam.IsConnected)
                         *   {
                         *       sam.Connect();
                         *   }
                         * }
                         * catch (SAMException ex)
                         * {
                         *   SAMResults.GetErrorDescription(ex.Result);
                         * }
                         * //Connect [End]
                         *
                         * //Transceive [Start]
                         *
                         * byte[] response = null;
                         * try
                         * {
                         *   response = sam.Transceive(transceive_apdu_1, (short)0, false);
                         *   response = sam.Transceive(transceive_apdu_2, (short)0, false);
                         *   response = sam.Transceive(transceive_apdu_3, (short)0, false);
                         *   response = sam.Transceive(transceive_apdu_4, (short)0, false);
                         *
                         * }
                         * catch (SAMException ex)
                         * {
                         *   SAMResults.GetErrorDescription(ex.Result);
                         * }
                         * //Transceive [End]
                         *
                         * //Disconnect [Start]
                         * if (sam.IsConnected)
                         * {
                         *   sam.Disconnect();
                         * }
                         * //Disconnect [End]
                         */
                    }
                    else
                    {
                        text += GetString(Resource.String.message_tag_not_compatible);
                    }
                }
                updateStatus(text);
            }
        }
Esempio n. 12
0
    // Update is called once per frame
    void Update()
    {
        if (m.isDark)
        {
            allAnswered       = false;
            answeredArousal   = false;
            answeredValence   = false;
            answeredDominance = false;
            selectionSquareArousal.SetActive(false);
            selectionSquareValence.SetActive(false);
            selectionSquareDominance.SetActive(false);
        }

        if (insideSquareScript.insideSquare && !m.isDark && m.circleTouched)
        {
            canAnswer = true;
        }
        else
        {
            canAnswer = false;
        }

        //The first questionnaire--Arousal
        if (canAnswer && !answeredArousal && !answeredValence && !answeredDominance)
        {
            //Setting Arousal on first
            Arousal.SetActive(true);

            if (Input.GetKeyDown("1"))
            {
                selectionSquareArousal.SetActive(true);
                if (Input.GetKeyDown("1") && selectionSquareArousal.transform.position == A0.transform.position)
                {
                    //Debug.Log(m.CurrentStatus + ";Arousal1");
                    m.eventMarkerRun = false;
                    sendMarker(";Arousal1");
                    StartCoroutine(Selected(A0));
                    StartCoroutine(Selected(selectionSquareArousal));
                    StartCoroutine(RemoveQuestionnaire(Arousal));
                }
                selectionSquareArousal.transform.position = A0.transform.position;
            }
            if (Input.GetKeyDown("2"))
            {
                selectionSquareArousal.SetActive(true);
                if (Input.GetKeyDown("2") && selectionSquareArousal.transform.position == A1.transform.position)
                {
                    //Debug.Log(m.CurrentStatus + ";Arousal2");
                    m.eventMarkerRun = false;
                    sendMarker(";Arousal2");
                    StartCoroutine(Selected(A1));
                    StartCoroutine(Selected(selectionSquareArousal));
                    StartCoroutine(RemoveQuestionnaire(Arousal));
                }
                selectionSquareArousal.transform.position = A1.transform.position;
            }
            if (Input.GetKeyDown("3"))
            {
                selectionSquareArousal.SetActive(true);
                if (Input.GetKeyDown("3") && selectionSquareArousal.transform.position == A2.transform.position)
                {
                    //Debug.Log(m.CurrentStatus + ";Arousal3");
                    m.eventMarkerRun = false;
                    sendMarker(";Arousal3");
                    StartCoroutine(Selected(A2));
                    StartCoroutine(Selected(selectionSquareArousal));
                    StartCoroutine(RemoveQuestionnaire(Arousal));
                }
                selectionSquareArousal.transform.position = A2.transform.position;
            }
            if (Input.GetKeyDown("4"))
            {
                selectionSquareArousal.SetActive(true);
                if (Input.GetKeyDown("4") && selectionSquareArousal.transform.position == A3.transform.position)
                {
                    //Debug.Log(m.CurrentStatus + ";Arousal4");
                    m.eventMarkerRun = false;
                    sendMarker(";Arousal4");
                    StartCoroutine(Selected(A3));
                    StartCoroutine(Selected(selectionSquareArousal));
                    StartCoroutine(RemoveQuestionnaire(Arousal));
                }
                selectionSquareArousal.transform.position = A3.transform.position;
            }
            if (Input.GetKeyDown("5"))
            {
                selectionSquareArousal.SetActive(true);
                if (Input.GetKeyDown("5") && selectionSquareArousal.transform.position == A4.transform.position)
                {
                    //Debug.Log(m.CurrentStatus + ";Arousal5");
                    m.eventMarkerRun = false;
                    sendMarker(";Arousal5");
                    StartCoroutine(Selected(A4));
                    StartCoroutine(Selected(selectionSquareArousal));
                    StartCoroutine(RemoveQuestionnaire(Arousal));
                }
                selectionSquareArousal.transform.position = A4.transform.position;
            }
        }

        //The second questionnaire--Valence
        if (canAnswer && answeredArousal && !answeredValence && !answeredDominance)
        {
            //Setting Valence on first
            Valence.SetActive(true);

            if (Input.GetKeyDown("1"))
            {
                selectionSquareValence.SetActive(true);
                if (Input.GetKeyDown("1") && selectionSquareValence.transform.position == V0.transform.position)
                {
                    //Debug.Log(m.CurrentStatus + ";Valence1");
                    m.eventMarkerRun = false;
                    sendMarker(";Valence1");
                    StartCoroutine(Selected(V0));
                    StartCoroutine(Selected(selectionSquareValence));
                    StartCoroutine(RemoveQuestionnaire(Valence));
                }
                selectionSquareValence.transform.position = V0.transform.position;
            }
            if (Input.GetKeyDown("2"))
            {
                selectionSquareValence.SetActive(true);
                if (Input.GetKeyDown("2") && selectionSquareValence.transform.position == V1.transform.position)
                {
                    //Debug.Log(m.CurrentStatus + ";Valence2");
                    m.eventMarkerRun = false;
                    sendMarker(";Valence2");
                    StartCoroutine(Selected(V1));
                    StartCoroutine(Selected(selectionSquareValence));
                    StartCoroutine(RemoveQuestionnaire(Valence));
                }
                selectionSquareValence.transform.position = V1.transform.position;
            }
            if (Input.GetKeyDown("3"))
            {
                selectionSquareValence.SetActive(true);
                if (Input.GetKeyDown("3") && selectionSquareValence.transform.position == V2.transform.position)
                {
                    //Debug.Log(m.CurrentStatus + ";Valence3");
                    m.eventMarkerRun = false;
                    sendMarker(";Valence3");
                    StartCoroutine(Selected(V2));
                    StartCoroutine(Selected(selectionSquareValence));
                    StartCoroutine(RemoveQuestionnaire(Valence));
                }
                selectionSquareValence.transform.position = V2.transform.position;
            }
            if (Input.GetKeyDown("4"))
            {
                selectionSquareValence.SetActive(true);
                if (Input.GetKeyDown("4") && selectionSquareValence.transform.position == V3.transform.position)
                {
                    //Debug.Log(m.CurrentStatus + ";Valence4");
                    m.eventMarkerRun = false;
                    sendMarker(";Valence4");
                    StartCoroutine(Selected(V3));
                    StartCoroutine(Selected(selectionSquareValence));
                    StartCoroutine(RemoveQuestionnaire(Valence));
                }
                selectionSquareValence.transform.position = V3.transform.position;
            }
            if (Input.GetKeyDown("5"))
            {
                selectionSquareValence.SetActive(true);
                if (Input.GetKeyDown("5") && selectionSquareValence.transform.position == V4.transform.position)
                {
                    //Debug.Log(m.CurrentStatus + ";Valence5");
                    m.eventMarkerRun = false;
                    sendMarker(";Valence5");
                    StartCoroutine(Selected(V4));
                    StartCoroutine(Selected(selectionSquareValence));
                    StartCoroutine(RemoveQuestionnaire(Valence));
                }
                selectionSquareValence.transform.position = V4.transform.position;
            }
        }

        //The third questionnaire--Dominance
        if (canAnswer && answeredArousal && answeredValence && !answeredDominance)
        {
            //Setting Dominance on
            Dominance.SetActive(true);

            if (Input.GetKeyDown("1"))
            {
                selectionSquareDominance.SetActive(true);
                if (Input.GetKeyDown("1") && selectionSquareDominance.transform.position == D0.transform.position)
                {
                    //Debug.Log(m.CurrentStatus + ";Dominance1");
                    m.eventMarkerRun = false;
                    sendMarker(";Dominance1");
                    StartCoroutine(Selected(D0));
                    StartCoroutine(Selected(selectionSquareDominance));
                    StartCoroutine(RemoveQuestionnaire(Dominance));
                }
                selectionSquareDominance.transform.position = D0.transform.position;
            }
            if (Input.GetKeyDown("2"))
            {
                selectionSquareDominance.SetActive(true);
                if (Input.GetKeyDown("2") && selectionSquareDominance.transform.position == D1.transform.position)
                {
                    //Debug.Log("#" + m.CurrentTrial.ToString() + "Dominance2");
                    m.eventMarkerRun = false;
                    sendMarker(";Dominance2");
                    StartCoroutine(Selected(D1));
                    StartCoroutine(Selected(selectionSquareDominance));
                    StartCoroutine(RemoveQuestionnaire(Dominance));
                }
                selectionSquareDominance.transform.position = D1.transform.position;
            }
            if (Input.GetKeyDown("3"))
            {
                selectionSquareDominance.SetActive(true);
                if (Input.GetKeyDown("3") && selectionSquareDominance.transform.position == D2.transform.position)
                {
                    //Debug.Log("#" + m.CurrentTrial.ToString() + "Dominance3");
                    m.eventMarkerRun = false;
                    sendMarker(";Dominance3");
                    StartCoroutine(Selected(D2));
                    StartCoroutine(Selected(selectionSquareDominance));
                    StartCoroutine(RemoveQuestionnaire(Dominance));
                }
                selectionSquareDominance.transform.position = D2.transform.position;
            }
            if (Input.GetKeyDown("4"))
            {
                selectionSquareDominance.SetActive(true);
                if (Input.GetKeyDown("4") && selectionSquareDominance.transform.position == D3.transform.position)
                {
                    //Debug.Log("#" + m.CurrentTrial.ToString() + "Dominance4");
                    m.eventMarkerRun = false;
                    sendMarker(";Dominance4");
                    StartCoroutine(Selected(D3));
                    StartCoroutine(Selected(selectionSquareDominance));
                    StartCoroutine(RemoveQuestionnaire(Dominance));
                }
                selectionSquareDominance.transform.position = D3.transform.position;
            }
            if (Input.GetKeyDown("5"))
            {
                selectionSquareDominance.SetActive(true);
                if (Input.GetKeyDown("5") && selectionSquareDominance.transform.position == D4.transform.position)
                {
                    //Debug.Log("#" + m.CurrentTrial.ToString() + "Dominance5");
                    m.eventMarkerRun = false;
                    sendMarker(";Dominance5");
                    StartCoroutine(Selected(D4));
                    StartCoroutine(Selected(selectionSquareDominance));
                    StartCoroutine(RemoveQuestionnaire(Dominance));
                }
                selectionSquareDominance.transform.position = D4.transform.position;
            }
        }

        //Resetting the color of the selection square for next trial
        if (!canAnswer || (answeredArousal && answeredDominance && answeredValence))
        {
            StartCoroutine(ResettingColor(selectionSquareArousal, A0, A1, A2, A3, A4));
            StartCoroutine(ResettingColor(selectionSquareValence, V0, V1, V2, V3, V4));
            StartCoroutine(ResettingColor(selectionSquareDominance, D0, D1, D2, D3, D4));
        }

        if (answeredArousal && answeredDominance && answeredValence)
        {
            allAnswered = true;
        }
        else
        {
            allAnswered = false;
        }

        //Fading the color of the square
        IEnumerator Selected(GameObject SAM)
        {
            for (float f = 1f; f > -0.05; f -= 0.01f)
            {
                selectedColor.a = f;
                SAM.GetComponent <SpriteRenderer>().color = selectedColor;
                yield return(new WaitForSeconds(0.01f));
            }
        }

        //Resetting the color for next trials
        IEnumerator ResettingColor(GameObject sq, GameObject one, GameObject two, GameObject three, GameObject four, GameObject five)
        {
            sq.GetComponent <SpriteRenderer>().color    = new Color(1, 1, 1, 1);
            one.GetComponent <SpriteRenderer>().color   = new Color(1, 1, 1, 1);
            two.GetComponent <SpriteRenderer>().color   = new Color(1, 1, 1, 1);
            three.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 1);
            four.GetComponent <SpriteRenderer>().color  = new Color(1, 1, 1, 1);
            five.GetComponent <SpriteRenderer>().color  = new Color(1, 1, 1, 1);
            yield return(null);
        }

        //Removing a questionnaire
        IEnumerator RemoveQuestionnaire(GameObject q)
        {
            yield return(new WaitForSeconds(1f));

            if (q.name == "SAM_Arousal")
            {
                answeredArousal = true;
            }
            if (q.name == "SAM_Valence")
            {
                answeredValence = true;
            }
            if (q.name == "SAM_Dominance")
            {
                answeredDominance = true;
            }
            q.SetActive(false);
        }

        void sendMarker(string SAM)
        {
            if (!m.eventMarkerRun)
            {
                print(m.CurrentStatus + SAM);
                sM.Write(m.CurrentStatus + SAM);
                m.eventMarkerRun = true;
            }
        }
    }