Ejemplo n.º 1
0
 public void Detect()
 {
     var method = new Detect() {
         Text = "你好, friend"
     };
     var result = ApiClient.ExecuteWrap(method).Result;
 }
Ejemplo n.º 2
0
    protected bool DetectObstacle(Vector3 position)
    {
        var cols = Detect.DetectObject(position);

        foreach (var col in cols)
        {
            if (col.parent)
            {
                if (col.parent.GetComponent <Obstacle>())
                {
                    return(true);
                }
            }
        }
        return(false);
    }
Ejemplo n.º 3
0
    public override bool Check()
    {
        var list = Detect.DetectObject(focus);

        foreach (var p in list)
        {
            if (p.GetComponent <Unit>())
            {
                if (p.Find("Render").gameObject.activeInHierarchy)
                {
                    return(false);
                }
            }
        }
        return(true);
    }
Ejemplo n.º 4
0
        public void ConnectionDetection_GetInternalIp()
        {
            Detect det = new Detect();

            det.Port = 9005;
            det.Start(Detect.WorkMethod.NoThread);

            if (det.InternalIP != null)
            {
                // This is for debuging test case
                //throw new AssertFailedException(det.InternalIP.ToString());
            }
            else
            {
                throw new AssertFailedException("Unable to get Internal IP Adress");
            }
        }
Ejemplo n.º 5
0
        public void ConnectionDetection_GetExternalIp()
        {
            Detect det = new Detect();

            det.Port = 9004;
            det.Start(Detect.WorkMethod.NoThread);

            if (det.ExternalIP != null || det.ExternalIPUPnP != null)
            {
                // This is for debuging test case
                //throw new AssertFailedException(string.Format("{0} : {1}", det.ExternalIP, det.ExternalIPUPnP));
            }
            else
            {
                throw new AssertFailedException("Unable to get External IP Adress");
            }
        }
Ejemplo n.º 6
0
        private void CreateParamsDetect()
        {
            Detect detect = new Detect();

            detect.configuration = "detect_configuration";
            ParamsDetect paramsDetect = new ParamsDetect();

            paramsDetect.accuracy       = 600;
            paramsDetect.maxeye         = 250;
            paramsDetect.maxfaces       = 1;
            paramsDetect.mineye         = 35;
            paramsDetect.modedetect     = 1;
            paramsDetect.extractionmode = 0;
            //paramsDetect.refreshInterval = 2000;
            detect.Params = paramsDetect;
            diskPresenter.SaveDetectConfiguration(detect);
        }
Ejemplo n.º 7
0
        //public static void OperateDLL(string path)
        public static bool OperateDLL(string path)
        {
            IntPtr pDll = NativeMethods.LoadLibrary(path);

            //oh dear, error handling here
            if (pDll == IntPtr.Zero)
            {
                Console.WriteLine("Error in loading dll");
            }

            IntPtr CreateFuncAddress = NativeMethods.GetProcAddress(pDll, "Create");

            //oh dear, error handling here
            if (CreateFuncAddress == IntPtr.Zero)
            {
                Console.WriteLine("Error in loading create func");
                // should print an error accured and exit the app
            }
            IntPtr DetectFuncAddress = NativeMethods.GetProcAddress(pDll, "Detect");

            //oh dear, error handling here
            if (CreateFuncAddress == IntPtr.Zero)
            {
                Console.WriteLine("Error in loading detect func");
                // should print an error accured and exit the app
            }
            IntPtr FreeFuncAddress = NativeMethods.GetProcAddress(pDll, "Free");

            //oh dear, error handling here
            if (CreateFuncAddress == IntPtr.Zero)
            {
                Console.WriteLine("Error in loading free func");
                // should print an error accured and exit the app
            }
            Create create = (Create)Marshal.GetDelegateForFunctionPointer(CreateFuncAddress, typeof(Create));
            Detect detect = (Detect)Marshal.GetDelegateForFunctionPointer(DetectFuncAddress, typeof(Detect));
            Free   free   = (Free)Marshal.GetDelegateForFunctionPointer(FreeFuncAddress, typeof(Free));

            IntPtr p = create();

            detect(p);
            free(p);

            return(NativeMethods.FreeLibrary(pDll));
            //remaining code here
        }
Ejemplo n.º 8
0
    private void Update()
    {
        for (int i = 0; i < Input.touchCount; i++)
        {
            if (Detect.GetTouchedObj(i, TouchPhase.Began) != null)
            {
                for (int j = 0; j < Detect.GetTouchedObj(i, TouchPhase.Began).Length; j++)
                {
                    //檢查tag
                    if (!Detect.GetTouchedObj(i, TouchPhase.Began)[j].transform.CompareTag("CustumeNode"))
                    {
                        continue;
                    }

                    //已被選上=>刪除選取
                    if (SelectedObj.Contains(Detect.GetTouchedObj(i, TouchPhase.Began)[j].transform.gameObject))
                    {
                        SelectedObj.Find(SelectedObj => SelectedObj.gameObject == Detect.GetTouchedObj(i, TouchPhase.Began)[j].transform.gameObject).GetComponent <SpriteRenderer>().color = originColor;
                        SelectedObj.Remove(Detect.GetTouchedObj(i, TouchPhase.Began)[j].transform.gameObject);

                        //取消文字
                        Detect.GetTouchedObj(i, TouchPhase.Began)[j].transform.GetChild(0).GetChild(0).GetComponent <TextMeshProUGUI>().text = "";

                        //取消子物件的文字紀錄
                        Detect.GetTouchedObj(i, TouchPhase.Began)[j].transform.GetComponent <UntuchableOutsideCamera>().origineText = "";
                    }

                    //選取:
                    else
                    {
                        //紀錄原本的顏色
                        originColor = Detect.GetTouchedObj(i, TouchPhase.Began)[j].transform.gameObject.GetComponent <SpriteRenderer>().color;

                        SelectedObj.Add(Detect.GetTouchedObj(i, TouchPhase.Began)[j].transform.gameObject);
                        SelectedObj.Find(SelectedObj => SelectedObj.gameObject == Detect.GetTouchedObj(i, TouchPhase.Began)[j].transform.gameObject).GetComponent <SpriteRenderer>().color = Color.blue;


                        ShowNodeTimeText(Detect.GetTouchedObj(i, TouchPhase.Began)[j].transform.gameObject,
                                         Detect.GetTouchedObj(i, TouchPhase.Began)[j].transform.GetChild(0).GetChild(0).GetComponent <TextMeshProUGUI>());
                    }
                }
            }
        }
    }
Ejemplo n.º 9
0
        private void btnDetect_Click(object sender, EventArgs e)
        {
            if (VerifyInputDetect())
            {
                Detect   detect   = new Detect();
                Identify identify = new Identify();
                identify.configuration = "identify_configuration";
                detect.configuration   = "detect_configuration";
                ParamsIdentify paramsIdentify = new ParamsIdentify();
                ParamsDetect   paramsDetect   = new ParamsDetect();
                paramsDetect.accuracy       = Convert.ToInt16(txtAccurancy.Text);
                paramsDetect.maxeye         = Convert.ToInt16(txtMaxEye.Text);
                paramsDetect.maxfaces       = Convert.ToInt16(txtMaxDetect.Text);
                paramsDetect.mineye         = Convert.ToInt16(txtMinEye.Text);
                paramsDetect.extractionmode = cboExtractionMode.SelectedIndex;
                //paramsDetect.refreshInterval = Convert.ToInt16(txtTrackingRefresh.Text);
                paramsIdentify.A_MaxEyeDist            = Convert.ToInt16(txtMaxEye.Text);
                paramsIdentify.A_MinEyeDist            = Convert.ToInt16(txtMinEye.Text);
                paramsIdentify.A_FaceDetectionForced   = Convert.ToInt16(cboDetectForced.Text);
                paramsIdentify.A_IdentificationSpeed   = Convert.ToInt16(cboIdentificationSpeed.Text);
                paramsIdentify.A_SimilarityThreshold   = Convert.ToInt16(txtASimilarity.Text);
                paramsIdentify.A_FaceDetectThreshold   = Convert.ToInt16(txtAccurancy.Text);
                paramsIdentify.A_BestMatchedCandidates = Convert.ToInt16(txtBestMatched.Text);
                if (cboDetectorMode.SelectedIndex == 0)
                {
                    paramsDetect.modedetect = 1;
                }
                else
                {
                    paramsDetect.modedetect = 2;
                }

                detect.Params   = paramsDetect;
                identify.Params = paramsIdentify;
                diskPresenter.SaveDetectConfiguration(detect);
                diskPresenter.SaveIdentifyConfiguration(identify);
                this.lblOkDetect.Text = "Wait...";
                RequestAipu.Instance.StopAipu();
                Task.Delay(500).Wait();
                RequestAipu.Instance.ReloadAipu();
                this.lblOkDetect.Text = "OK";
            }
        }
        public Translate Detect(string q)
        {
            IGetAll      detectGoogle = new GetAll();
            Detect       data         = new Detect();
            double       temp         = 0;
            DetectGoogle detect       = detectGoogle.Detect(q);

            for (int i = 0; i < detect.data.detections.Count; i++)
            {
                for (int j = 0; j < detect.data.detections[i].Count; j++)
                {
                    if (temp < detect.data.detections[i][j].confidence)
                    {
                        temp          = detect.data.detections[i][j].confidence;
                        data.language = detect.data.detections[i][j].language;
                    }
                }
            }
            return(data);
        }
Ejemplo n.º 11
0
        public Detect ReadDetectConfiguration()
        {
            Detect detect = new Detect();

            try
            {
                string pathFile = directoryConfiguration + "/" + file_face;
                string content  = disk.ReadTextFile(pathFile);
                detect = JsonConvert.DeserializeObject <Detect>(content);
            }
            catch (System.IO.FileNotFoundException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (Newtonsoft.Json.JsonReaderException ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(detect);
        }
Ejemplo n.º 12
0
    public override bool Check()
    {
        var list = Detect.DetectObject(focus);

        foreach (var p in list)
        {
            if (p.GetComponent <CharacterStatus>())
            {
                if (!character.GetComponent <CharacterStatus>().IsEnemy(p.GetComponent <CharacterStatus>()))
                {
                    other.Add(p);
                }
            }
        }

        if (other.Count > 0)
        {
            return(true);
        }
        return(false);
    }
Ejemplo n.º 13
0
    protected override void InitSkill()
    {
        base.InitSkill();
        var list = Detect.DetectObject <CharacterStatus>(character.position + character.right - character.forward);

        if (list.Count == 1)
        {
            var comboCS = list[0];
            if (comboCS != null && comboCS.roleEName == character.GetComponent <CharacterStatus>().roleEName)
            {
                comboCS.transform.forward = character.forward;
                comboCS.GetComponent <Animator>().SetInteger("Skill", 9);
                GameController.GetInstance().Invoke(() => { comboCS.GetComponent <Animator>().SetInteger("Skill", 0); }, 0.1f);
                damage *= 2;
            }
        }
        Camera.main.GetComponent <RTSCamera>().FollowTarget(character.position);
        GameController.GetInstance().Invoke(() => {
            FXManager.GetInstance().Spawn("Rasengan", character.GetComponent <Animator>().GetBoneTransform(HumanBodyBones.RightHand), 3.2f);
        }, 0.5f);
    }
Ejemplo n.º 14
0
    public override bool Check()
    {
        other.Clear();
        List <List <Transform> > list;

        if (customizedHoverRangeList.Count > 0)
        {
            list = Detect.DetectObjects(customizedHoverRangeList);
        }
        else
        {
            List <Vector3> hover = new List <Vector3>();
            foreach (var item in range.hoverRangeList)
            {
                hover.Add(item.transform.position);
            }
            list = Detect.DetectObjects(hover);
        }


        foreach (var l in list)
        {
            foreach (var u in l)
            {
                if (u.GetComponent <CharacterStatus>())
                {
                    if (character.GetComponent <CharacterStatus>().IsEnemy(u.GetComponent <CharacterStatus>()) && u.GetComponent <CharacterStatus>().characterIdentity != CharacterStatus.CharacterIdentity.obstacle)
                    {
                        other.Add(u);
                    }
                }
            }
        }

        if (other.Count > 0)
        {
            return(true);
        }
        return(false);
    }
Ejemplo n.º 15
0
        private void GetDetectionConfiguration()
        {
            Detect   detect   = diskPresenter.ReadDetectConfiguration();
            Identify identify = diskPresenter.ReadIdentifyConfiguration();

            if (detect != null && identify != null)
            {
                txtAccurancy.Text = (string.IsNullOrEmpty(detect.Params.accuracy.ToString())) ? "0" :
                                    detect.Params.accuracy.ToString();
                txtMaxEye.Text = (string.IsNullOrEmpty(detect.Params.maxeye.ToString())) ? "0" :
                                 detect.Params.maxeye.ToString();
                txtMaxDetect.Text = (string.IsNullOrEmpty(detect.Params.maxfaces.ToString())) ? "0" :
                                    detect.Params.maxfaces.ToString();
                txtMinEye.Text = (string.IsNullOrEmpty(detect.Params.mineye.ToString())) ? "0" :
                                 detect.Params.mineye.ToString();
                //txtTrackingRefresh.Text = (string.IsNullOrEmpty(detect.Params.refreshInterval.ToString())) ? "0" :
                //    detect.Params.refreshInterval.ToString();
                managerControlView.SetValueToComboBox(cboDetectForced,
                                                      identify.Params.A_FaceDetectionForced.ToString());
                managerControlView.SetValueToComboBox(cboIdentificationSpeed,
                                                      identify.Params.A_IdentificationSpeed.ToString());

                txtASimilarity.Text = (string.IsNullOrEmpty(identify.Params.A_SimilarityThreshold.ToString())) ? "0" :
                                      identify.Params.A_SimilarityThreshold.ToString();

                txtBestMatched.Text = (string.IsNullOrEmpty(identify.Params.A_BestMatchedCandidates.ToString())) ? "0" :
                                      identify.Params.A_BestMatchedCandidates.ToString();

                if (detect.Params.modedetect == 1)
                {
                    cboDetectorMode.SelectedIndex = 0;
                }
                else
                {
                    cboDetectorMode.SelectedIndex = 1;
                }

                cboExtractionMode.SelectedIndex = detect.Params.extractionmode;
            }
        }
Ejemplo n.º 16
0
    public static List <Transform> ComboDetect(Transform attacker, Transform defender)
    {
        var list = Detect.DetectObjects(Range.CreateRange(1, defender.position));

        List <Transform> comboUnits = new List <Transform>();

        if ((attacker.position - defender.position).magnitude == 1)
        {
            foreach (var l in list)
            {
                foreach (var u in l)
                {
                    if (u.position != attacker.position)
                    {
                        if (u.GetComponent <CharacterStatus>())
                        {
                            if (!attacker.GetComponent <CharacterStatus>().IsEnemy(u.GetComponent <CharacterStatus>()))
                            {
                                if (u.GetComponent <CharacterStatus>().skills.ContainsKey("NinjaCombo"))
                                {
                                    var uName = u.GetComponentsInChildren <Renderer>()[0].material.name;
                                    var aName = attacker.GetComponentsInChildren <Renderer>()[0].material.name;
                                    uName = uName.Replace(" (Instance)", "");
                                    aName = aName.Replace(" (Instance)", "");
                                    if (uName == aName)
                                    {
                                        comboUnits.Add(u);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        return(comboUnits);
    }
Ejemplo n.º 17
0
        public void ConnectionDetection_DoWeFindAConnection()
        {
            Detect det = new Detect();

            det.Port = 9001;
            det.Start(Detect.WorkMethod.NoThread);

            switch (det.ConnectionType)
            {
            case 0:
                throw new AssertFailedException("Can't find any usable Internet connection.");

            case 1:
                throw new AssertFailedException("You only seem to be able to be passive.");

            case 2:
            case 4:
                break;

            default:
                throw new AssertFailedException("We got a value that shouldn't be possible");
            }
        }
Ejemplo n.º 18
0
 // Update is called once per frame
 void Update()
 {
     GetMousePosition();
     unit = Selectunit(Detect.DetectObject(HandleMouse()));
     LogMessage();
 }
Ejemplo n.º 19
0
        public Task <string> Post([FromBody] Detect detect)
        {
            string appKey = ConfigurationManager.AppSettings["appKey"];

            var faceApi = new FaceApi()
            {
                SubscriptionKey = "",
                GroupName       = ""
            };



            var task = Task.Run(() =>
            {
                AppResponse todoList;
                try{
                    // 顔検出
                    var detectResponseJson = faceApi.detectPersonFace(detect.FaceUrl).Result;
                    var detectResponse     = JsonConvert.DeserializeObject <List <DetectResponse> >(detectResponseJson);

                    // 顔識別
                    var identifyResponseJson = faceApi.identifyPersonFace(detectResponse[0].FaceId).Result;
                    var identifyResponse     = JsonConvert.DeserializeObject <List <IdentifyResponse> >(identifyResponseJson);

                    //faceRectangleのみ抽出
                    FaceRectangle faceRectangle = detectResponse[0].FaceRectangle;

                    // PersonIdのみ抽出
                    var candidates  = identifyResponse[0].CandidatesInfo;
                    string personId = candidates[0].PersonId;

                    TodoDetail todo = new TodoDetail()
                    {
                        Title = getTodoTitle(personId).Result,
                    };

                    if (TodoDbExistPersonId(personId))
                    {
                        todoList = new AppResponse()
                        {
                            PersonId          = personId,
                            FaceRectangleInfo = faceRectangle,
                            TodoList          = todo,
                            Show = true,
                        };
                    }
                    else
                    {
                        todoList = new AppResponse()
                        {
                            PersonId          = null,
                            FaceRectangleInfo = null,
                            TodoList          = null,
                            Show = false,
                        };
                    }

                    string json = JsonConvert.SerializeObject(todoList);
                    return(json);
                } catch (Exception e) {
                    Console.WriteLine(e);
                    todoList = new AppResponse()
                    {
                        PersonId          = null,
                        FaceRectangleInfo = null,
                        TodoList          = null,
                        Show = false,
                    };
                    string json = JsonConvert.SerializeObject(todoList);
                    return(json);
                }
            });

            return(task);
        }
Ejemplo n.º 20
0
    //传入范围和创建范围角色的transform.position即可创建。p即transform.position
    public void CreateMoveRange(Transform character)
    {
        this.character = character;
        startRotation  = character.rotation;
        range          = character.GetComponent <CharacterStatus>().attributes.Find(d => d.eName == "mrg").value;
        if (range < 1)
        {
            return;
        }
        var list = CreateRange(range, character.position);
        //比list大一圈以保证enemy在范围外一圈时范围内颜色的正常显示。
        var detect = CreateRange(range + 1, character.position);    //此处创建范围比应有范围大1,正确的显示效果 是在下面 A*检测到路径但距离大于角色mrg的地块不显示 处得到保证。


        //检测到敌人时地块不显示,且加入名单。
        foreach (var position in detect)
        {
            if (CheckEnemy(Detect.DetectObject(position)) == 2)
            {
                enemyFloor.Add(position);
                continue;
            }
            //检测到障碍物时地块不显示。后期实现水上行走,跳远,树上行走。
            if (DetectObstacle(position))
            {
                continue;
            }

            BattleFieldManager.GetInstance().GetFloor(position).SetActive(true);
            rangeDic.Add(position, BattleFieldManager.GetInstance().GetFloor(position));
        }
        //添加enemyFloor周围的坐标进入容器。
        foreach (var floor in enemyFloor)
        {
            Vector3 V1 = new Vector3(floor.x - 1, 0, floor.z);
            Vector3 V2 = new Vector3(floor.x + 1, 0, floor.z);
            Vector3 V3 = new Vector3(floor.x, 0, floor.z - 1);
            Vector3 V4 = new Vector3(floor.x, 0, floor.z + 1);
            TryAddValue(floorAroundEnemy, V1);
            TryAddValue(floorAroundEnemy, V2);
            TryAddValue(floorAroundEnemy, V3);
            TryAddValue(floorAroundEnemy, V4);
        }

        var buffer0 = new List <Vector3>();

        foreach (var floor in rangeDic)
        {
            if (!list.Contains(floor.Key))
            {
                floor.Value.SetActive(false);
                buffer0.Add(floor.Key);
            }
        }
        foreach (var a in buffer0)
        {
            rangeDic.Remove(a);
        }

        //A*检测到路径但距离大于角色mrg的地块不显示。A*无法检测到路径的地块不显示。必须第二次遍历,即创建完成,A*寻路才有意义。
        //不能迭代时改变或删除Dictionary中的元素。
        var buffer = new List <Vector3>();

        foreach (var floor in rangeDic)
        {
            if ((UseAstar(character.position, floor.Key, range).Count > range + 1) || (floor.Key != character.position && UseAstar(character.position, floor.Key, range).Count == 0))
            {
                floor.Value.SetActive(false);
                buffer.Add(floor.Key);
            }
        }
        foreach (var a in buffer)
        {
            rangeDic.Remove(a);
        }

        RecoverColor();
    }
Ejemplo n.º 21
0
 private void Start()
 {
     camara = transform.parent.transform.GetChild(0).gameObject.GetComponent <Detect>();
 }
Ejemplo n.º 22
0
    public void CreateStraightSkillRange(int range, Transform character, bool aliesObstruct)
    {
        this.character = character;
        startRotation  = character.rotation;
        var list       = CreateStraightRange(range, character.position);
        var listBuffer = new List <Vector3>();

        foreach (var position in list)
        {
            int check = CheckEnemy(Detect.DetectObject(position));
            if (check > 0)
            {
                if (check == 2)
                {
                    enemyFloor.Add(position);
                }
                else if (check == 1 && aliesObstruct)
                {
                    listBuffer.Add(position);   //技能现在可被友军阻挡。
                }
            }
            else if (DetectObstacle(position))
            {
                obstacleFloor.Add(position);
                continue;
            }

            BFM.GetFloor(position).SetActive(true);
            rangeDic.Add(position, BFM.GetFloor(position));
        }

        //直线施法的障碍物遮挡效果
        var buffer = new Dictionary <Vector3, GameObject>();


        foreach (var a in enemyFloor)
        {
            listBuffer.Add(a);
        }

        foreach (var a in obstacleFloor)
        {
            if (!listBuffer.Contains(a))
            {
                listBuffer.Add(a);
            }
        }

        foreach (var floor in rangeDic.Values)
        {
            foreach (var f in listBuffer)
            {
                if (floor.activeInHierarchy)
                {
                    var dis  = floor.transform.position - character.position;
                    var eDis = f - character.position;
                    //两向量方向相同,且dis距离大于eDis,则不显示。即被遮挡住。
                    if ((dis.normalized == eDis.normalized) && (dis.magnitude > eDis.magnitude))
                    {
                        BFM.GetFloor(floor.transform.position).SetActive(false);
                        buffer.Add(floor.transform.position, floor);
                    }
                }
            }
        }
        foreach (var pair in buffer)
        {
            rangeDic.Remove(pair.Key);
        }
    }
Ejemplo n.º 23
0
 public Task <List <FaceResponse> > DetectAsync(Detect peticion)
 {
     return(ServicioWeb.DetectAsync(peticion));
 }
        //anomalies[i] contain anomalies with the column i, the first in the tuple is the column that anomaly was detect and the second is the line

        public List <List <Tuple <int, int> > > detectAnomalies()
        {
            IntPtr pDll = LoadLibrary(anomalyDetectionAlgorithemPath);

            //oh dear, error handling here
            if (pDll == IntPtr.Zero)
            {
                System.Windows.MessageBox.Show("Your dll file is incorrect, please try to load new file", "Alert", MessageBoxButton.OK);
                return(new List <List <Tuple <int, int> > >());
            }

            //set corrlation thereshold
            if (correlationThreshold != -1)
            {
                IntPtr pAddressOfFunctionToCallT = GetProcAddress(pDll, "setThreshold");
                //oh dear, error handling here
                if (pAddressOfFunctionToCallT == IntPtr.Zero)
                {
                    System.Windows.MessageBox.Show("Your dll file is incorrect, please try to load new file", "Alert", MessageBoxButton.OK);
                    return(new List <List <Tuple <int, int> > >());
                }
                SetThreshold setThreshold = (SetThreshold)Marshal.GetDelegateForFunctionPointer(
                    pAddressOfFunctionToCallT,
                    typeof(SetThreshold));
                setThreshold(CorrelationThreshold);
            }

            IntPtr pAddressOfFunctionToCall = GetProcAddress(pDll, "detect");

            //oh dear, error handling here
            if (pAddressOfFunctionToCall == IntPtr.Zero)
            {
                System.Windows.MessageBox.Show("Your dll file is incorrect, please try to load new file", "Alert", MessageBoxButton.OK);
                return(new List <List <Tuple <int, int> > >());
            }

            Detect detect = (Detect)Marshal.GetDelegateForFunctionPointer(
                pAddressOfFunctionToCall,
                typeof(Detect));

            IntPtr arrayPtr = detect(normalCsvPath, anomalyCsvPath);

            int[] size = new int[1];
            Marshal.Copy(arrayPtr, size, 0, 1);
            int[] anomaliesArray = new int[size[0] + 1];
            Marshal.Copy(arrayPtr, anomaliesArray, 0, size[0] + 1); //copy all the anomalies
            List <List <Tuple <int, int> > > anomalies = new List <List <Tuple <int, int> > >();

            int halfSize = size[0] / 2; //to indicate the location of the lines of the anomalies
            //count the number of columns in csv file
            int columnsNum = 0;

            for (int i = 1; i <= halfSize; i++)
            {
                if (anomaliesArray[i] == -1)
                {
                    columnsNum++;
                }
            }

            for (int i = 0; i < columnsNum; i++)
            {
                anomalies.Add(new List <Tuple <int, int> >());
            }
            int column = 0;

            for (int i = 1; i <= halfSize; i++)
            {
                if (anomaliesArray[i] == -1)
                { //if end of column
                    column++;
                    continue;
                }
                anomalies[column].Add(new Tuple <int, int>(anomaliesArray[i], anomaliesArray[i + halfSize])); //add the column of anomaly and line
            }

            pAddressOfFunctionToCall = GetProcAddress(pDll, "delIntArray");
            DelIntArray delIntArray = (DelIntArray)Marshal.GetDelegateForFunctionPointer(
                pAddressOfFunctionToCall,
                typeof(DelIntArray));

            delIntArray(arrayPtr); //free the array
            FreeLibrary(pDll);
            return(anomalies);
        }
Ejemplo n.º 25
0
 void Start()
 {
     nma    = GetComponent <NavMeshAgent>();
     detect = GetComponent <Detect>();
 }
Ejemplo n.º 26
0
 void Start()
 {
     this.Detect = GetComponent <Detect>();
 }
Ejemplo n.º 27
0
 private void MDModel_CanDetectChanged(object sender, EventArgs ea) //CanPerformMDChangedEventArgs e)
 {
     Detect.RaiseCanExecuteChanged();
 }
Ejemplo n.º 28
0
        public MainViewModel(ICollection <IDetector> detectors, WoaDeployer deployer, IDialogService dialogService, IFilePicker filePicker, OperationProgressViewModel operationProgress)
        {
            OperationProgress = operationProgress;
            Detect            = ReactiveCommand.CreateFromTask(async() =>
            {
                var detections = await Task.WhenAll(detectors.Select(d => d.Detect()));
                return(detections.FirstOrDefault(d => d != null));
            });

            var hasDevice = this.WhenAnyValue(model => model.Device).Select(d => d != null);

            Detect.Subscribe(detected =>
            {
                Device = detected;
            }).DisposeWith(disposables);

            Detect.SelectMany(async d =>
            {
                if (d == null)
                {
                    await dialogService.Notice("Cannot autodetect any device",
                                               "Cannot detect any device. Please, select your device manually");
                }

                return(Unit.Default);
            })
            .Subscribe()
            .DisposeWith(disposables);

            GetRequirements = ReactiveCommand.CreateFromTask(() => deployer.GetRequirements(Device), hasDevice);
            requirements    = GetRequirements.ToProperty(this, model => model.Requirements);
            Deploy          = ReactiveCommand.CreateFromTask(async() =>
            {
                try
                {
                    await deployer.Deploy(Device);
                    messages.OnNext("Deployment finished!");
                }
                catch (DeploymentCancelledException)
                {
                    messages.OnNext("Deployment cancelled");
                    Log.Information("Deployment cancelled");
                }
                catch (Exception e)
                {
                    messages.OnNext("Deployment failed");
                    Log.Error(e, "Deployment failed");
                }
            }, hasDevice);

            RunScript = ReactiveCommand.CreateFromObservable(() =>
            {
                var filter = new FileTypeFilter("Deployer Script", new[] { "*.ds", "*.txt" });
                return(filePicker
                       .Open("Select a script", new[] { filter })
                       .Where(x => x != null)
                       .SelectMany(file => Observable.FromAsync(() => deployer.RunScript(file.Source.LocalPath))));
            });

            dialogService.HandleExceptionsFromCommand(RunScript);
            dialogService.HandleExceptionsFromCommand(Deploy);
            isDeploying = Deploy.IsExecuting.Merge(RunScript.IsExecuting).ToProperty(this, x => x.IsBusy);
        }