public async Task <SpecificParameter> AddParameter(SpecificParameter specificParameter)
        {
            var thingGroup = await _otherApiService.GetThingGroup(specificParameter.thingGroupId);

            List <PhaseParameter> PhaseParameterList = new List <PhaseParameter>();
            // LSE
            var parameterLSE = ReturnIdTag(specificParameter.tagGroup, "lse", thingGroup.tags.ToList());

            parameterLSE.setupValue = specificParameter.LSE.ToString();
            PhaseParameterList.Add(parameterLSE);
            //LSC
            var parameterLSC = ReturnIdTag(specificParameter.tagGroup, "lsc", thingGroup.tags.ToList());

            parameterLSC.setupValue = specificParameter.LSC.ToString();
            PhaseParameterList.Add(parameterLSC);
            //LIC
            var parameterLIC = ReturnIdTag(specificParameter.tagGroup, "lic", thingGroup.tags.ToList());

            parameterLIC.setupValue = specificParameter.LIC.ToString();
            PhaseParameterList.Add(parameterLIC);
            //LIE
            var parameterLIE = ReturnIdTag(specificParameter.tagGroup, "lie", thingGroup.tags.ToList());

            parameterLIE.setupValue = specificParameter.LIE.ToString();
            PhaseParameterList.Add(parameterLIE);
            //Nominal
            var parameterVN = ReturnIdTag(specificParameter.tagGroup, "vn", thingGroup.tags.ToList());

            parameterVN.setupValue = specificParameter.value.ToString();
            PhaseParameterList.Add(parameterVN);
            //unidade
            var parameterUN = ReturnIdTag(specificParameter.tagGroup, "unidade", thingGroup.tags.ToList());

            parameterUN.setupValue = specificParameter.Unit.ToString();
            PhaseParameterList.Add(parameterUN);

            foreach (var phaseParameter in PhaseParameterList)
            {
                var phaseParameterCreated = await _otherApiService.PostPhaseParameter(phaseParameter);
            }

            return(specificParameter);
        }
        private async Task <bool> OpTypeTira(ProductionOrder productionOrder)
        {
            var trigger = _configuration["TagIdTrigger"];
            // Finaliza Ordem anterior
            var triggerPlc = _interleverDb.Write("2", trigger, "Linha");


            List <Thing> thingsGetList = new List <Thing>();
            var          trigger3      = _configuration["TagIdTrigger"];
            await _interleverDb.Write("2", trigger, "Linha");

            var phases = productionOrder.recipe.phases;

            /*Console.WriteLine("");
             * Console.WriteLine("");
             * Console.WriteLine("");
             * Console.WriteLine("Phase: ------------------------------------------------------------ ");
             * Console.WriteLine("Phase-> " +JsonConvert.SerializeObject(phases).ToString() );
             * Console.WriteLine("");
             * Console.WriteLine("");
             * Console.WriteLine("");
             * Console.WriteLine("Loop de phases");
             * Console.WriteLine(""); */
            foreach (var phase in phases)
            {
                foreach (var phaseParameter in phase.phaseParameters)
                {
                    /*Console.WriteLine("");
                    *  Console.WriteLine("");
                    *  Console.WriteLine("");
                    *  Console.WriteLine("phaseParameter: ------------------------------------------------------------ ");
                    *  Console.WriteLine("phaseParameter-> " +JsonConvert.SerializeObject(phaseParameter).ToString() );
                    *  Console.WriteLine("");
                    *  Console.WriteLine("");
                    *  Console.WriteLine("");*/
                    string value = phaseParameter.setupValue;

                    var tag = await _otherApi.GetTag(phaseParameter.tag.tagId);

                    //var tag = phaseParameter.tag;
                    //Console.WriteLine("tag: ------------------------------------------------------------ ");
                    //Console.WriteLine("tag-> " +JsonConvert.SerializeObject(tag).ToString() );
                    var thingGroup = await _otherApi.GetThingGroup(tag.thingGroupId);

                    //Console.WriteLine("Loop thingGroup: ------------------------------------------------------------ ");

                    foreach (var thingId in thingGroup.thingsIds)
                    {
                        Console.WriteLine("Foi no Foreach");
                        Console.WriteLine("");
                        Thing thing = null;

                        thing = thingsGetList.Where(x => x.thingId == thingId).FirstOrDefault();
                        Console.WriteLine("thingId" + thingId.ToString());
                        if (thing == null)
                        {
                            Console.WriteLine("get na thing");
                            thing = await _otherApi.GetThing(thingId);

                            //Console.WriteLine(JsonConvert.SerializeObject(await _otherApi.GetThing(thingId)).ToString() );
                            if (thing != null)
                            {
                                thingsGetList.Add(thing);
                            }
                        }
                        //Console.WriteLine(JsonConvert.SerializeObject(thing).ToString() );
                        if (string.IsNullOrEmpty(tag.physicalTag))
                        {
                            Console.WriteLine("");
                            Console.WriteLine("");
                            Console.WriteLine("Deu ruim");
                            Console.WriteLine("");
                            Console.WriteLine("");
                            continue;
                        }
                        Console.Write("Physical da tag :");
                        Console.WriteLine(tag.physicalTag);
                        Console.Write("Valor da tag :");
                        Console.WriteLine(value);
                        Console.Write("phisical connection : ");
                        Console.WriteLine(thing.physicalConnection);
                        Console.WriteLine("");
                        var e = _interleverDb.Write(value, tag.physicalTag, thing.physicalConnection);
                        Console.WriteLine("Fim");
                    }
                }
            }

            // envia o trigger para o PLC
            var triggerPlc2 = await _interleverDb.Write("5", trigger, "Linha");

            return(true);
        }