Beispiel #1
0
        public override bool TestGate()
        {
            Input1.SetValue(7);
            Input2.SetValue(7);

            if (Output.Get2sComplement() != 14)
            {
                return(false);
            }

            Input1.Set2sComplement(6);
            Input2.Set2sComplement(-6);


            if (Output.Get2sComplement() != 0)
            {
                return(false);
            }

            Input1.Set2sComplement(6);
            Input2.Set2sComplement(-1);


            if (Output.Get2sComplement() != 5)
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Validates class and collects errors and warnings.
        /// </summary>
        /// <param name="errors"></param>
        /// <param name="warnings"></param>
        public void Validate(out string[] errors, out string[] warnings)
        {
            errors   = new string[] { };
            warnings = new string[] { };

            List <string> errs = new List <string>();
            List <string> wars = new List <string>();

            if (!File.Exists(Input1))
            {
                errs.Add(String.Format("Input file does not exist: '{0}'", Input1));
            }

            if (!Input1.Equals(Input2, StringComparison.OrdinalIgnoreCase) && !File.Exists(Input2))
            {
                errs.Add(String.Format("Input file does not exist: '{0}'", Input2));
            }

            if (Operator == Operation.Unknown)
            {
                errs.Add("Operation is not specified. CADDIE doesn't know what to do.");
            }

            if (File.Exists(Output))
            {
                wars.Add(String.Format("Output file already exists, it will be overwritten: '{0}'", Output));
            }

            errors   = errs.ToArray();
            warnings = wars.ToArray();
        }
Beispiel #3
0
        public ActionResult Consumir(String dni)
        {
            var    a   = s.getByDNI(dni);
            Input1 tmp = new Input1();

            tmp.age           = a.Age.ToString();
            tmp.capitalgain   = a.Capital_gain.ToString();
            tmp.capitaloss    = a.Capital_loss.ToString();
            tmp.education     = a.Education.ToString();
            tmp.educationum   = a.Education_num.ToString();
            tmp.fnlwgt        = a.Fnlwgt.ToString();
            tmp.hoursperweek  = a.Hours_per_week.ToString();
            tmp.maritalstatus = a.Relationship.ToString();
            tmp.nativecountry = a.Id_Country.ToString();
            tmp.occupation    = a.Occupation.ToString();
            tmp.race          = a.Race.ToString();
            tmp.relationship  = a.Relationship.ToString();
            tmp.sex           = a.Id_Sex.ToString();
            tmp.workclass     = a.Workclass.ToString();

            var inputdatatmp = new InputDataMLS(tmp);

            Output1 output1 = new PredictML().ConsumeMLS(inputdatatmp).Result;


            return(RedirectToAction("Index", output1));
            //return View();
        }
        public void Transfer_to_destination()
        {
            var destination = new Input1();

            Transfer<StubRedirectable>.To(destination)
                .RedirectTo.AssertWasTransferedTo(destination);
        }
        public void Redirect_to_destination()
        {
            var destination = new Input1();

            Redirect<StubRedirectable>.To(destination)
                .RedirectTo.AssertWasRedirectedTo(destination);
        }
 public BitwiseMux(int iSize) : base(iSize)
 {
     Control = new Wire();
     Control.ConnectOutput(this);
     Input1.ConnectOutput(this);
     Input2.ConnectOutput(this);
 }
Beispiel #7
0
 sealed public override void Operation(RobotBase operatingRobotBase)
 {
     if (operatingRobotBase != null)
     {
         operatingRobotBase.SetRobotGlobalVariable(Input1.GetReporterStringValue(operatingRobotBase), Input2.GetReporterStringValue(operatingRobotBase));
     }
 }
Beispiel #8
0
        public override Type OutputType(out CompiledFragment newOperation)
        {
            newOperation = this;
            Type typeB = Input1.OutputType(out Input1);
            Type typeA = Input0.OutputType(out Input0);

            if (typeA != typeB)
            {
                bool BString = (typeB == typeof(string));
                if (typeA == typeof(string) || BString)
                {
                    if (BString)
                    {
                        // This is alright - convert Input0 to a ToString operation.
                        Input0 = Types.ToStringMethod(Method, Input0, typeA);
                        typeA  = typeof(string);
                    }
                    else
                    {
                        Input1 = Types.ToStringMethod(Method, Input1, typeB);
                        typeB  = typeof(string);
                    }
                }
            }
            if (typeA == typeof(string) && typeB == typeof(string))
            {
                // Adding two strings (concat).
                newOperation = new MethodOperation(Method, typeof(string).GetMethod("Concat", new Type[] { typeof(string), typeof(string) }), Input0, Input1);
            }
            else
            {
                typeA = Numerical(typeA, typeB, "Addition", ref newOperation);
            }
            return(typeA);
        }
 /// <summary>
 /// Creates a new <see cref="ReactionPipelineStage"/> with the specified name and reaction to the specified inputs.
 /// </summary>
 /// <param name="name">The name of the new reaction.</param>
 /// <param name="reaction">The reaction delegate.</param>
 /// <param name="input1">Input number 1.</param>
 /// <param name="input2">Input number 2.</param>
 /// <param name="input3">Input number 3.</param>
 /// <param name="input4">Input number 4.</param>
 /// <param name="input5">Input number 5.</param>
 /// <param name="input6">Input number 6.</param>
 /// <param name="input7">Input number 7.</param>
 /// <param name="reactImmediately">Denotes if the reaction should fire immediately upon construction.</param>
 public ReactionPipelineStage(
     string name,
     Action <TInput1, TInput2, TInput3, TInput4, TInput5, TInput6, TInput7> reaction,
     IPipelineStage <TInput1> input1,
     IPipelineStage <TInput2> input2,
     IPipelineStage <TInput3> input3,
     IPipelineStage <TInput4> input4,
     IPipelineStage <TInput5> input5,
     IPipelineStage <TInput6> input6,
     IPipelineStage <TInput7> input7,
     bool reactImmediately)
 {
     Name     = name ?? throw new ArgumentNullException(nameof(name));
     Reaction = reaction ?? throw new ArgumentNullException(nameof(reaction));
     Input1   = input1 ?? throw new ArgumentNullException(nameof(input1));
     Input2   = input2 ?? throw new ArgumentNullException(nameof(input2));
     Input3   = input3 ?? throw new ArgumentNullException(nameof(input3));
     Input4   = input4 ?? throw new ArgumentNullException(nameof(input4));
     Input5   = input5 ?? throw new ArgumentNullException(nameof(input5));
     Input6   = input6 ?? throw new ArgumentNullException(nameof(input6));
     Input7   = input7 ?? throw new ArgumentNullException(nameof(input7));
     this.AddDependencies(input1, input2, input3, input4, input5, input6, input7);
     if (reactImmediately)
     {
         Reaction(Input1.GetValue(), Input2.GetValue(), Input3.GetValue(), Input4.GetValue(), Input5.GetValue(), Input6.GetValue(), Input7.GetValue());
     }
 }
        private void TrainBtn_Click(object sender, EventArgs e)
        {
            UserInput.Clear();
            length = Input1.GetArray().Length;
            hfm    = new HopfieldModel(length, inputN);

            for (int i = 1; i <= inputN; i++)
            {
                DrawControl.DrawBox d = (DrawControl.DrawBox) this.Controls.Find("Input" + i, true)[0];

                bool[] array = d.GetArray();
                int[]  n     = new int[array.Length];
                Console.WriteLine(array.Length);
                for (int j = 0; j < array.Length; j++)
                {
                    if (array[j])
                    {
                        n[j] = 1;
                    }
                    else
                    {
                        n[j] = -1;
                    }
                }
                hfm.pushData(n);
            }


            hfm.GenerateWeight();
            DisplayUser(true);
            //int[] n4 = new int[] { 1, 1, 1, -1, 1, -1 };
            //hfm.SetInput(n4);
        }
 public DispatcherReactionPipelineStage(
     string name,
     Action <TInput1, TInput2, TInput3, TInput4, TInput5> reaction,
     Dispatcher dispatcher,
     IPipelineStage <TInput1> input1,
     IPipelineStage <TInput2> input2,
     IPipelineStage <TInput3> input3,
     IPipelineStage <TInput4> input4,
     IPipelineStage <TInput5> input5,
     bool reactImmediately)
 {
     Name       = name ?? throw new ArgumentNullException(nameof(name));
     Reaction   = reaction ?? throw new ArgumentNullException(nameof(reaction));
     Dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher));
     Input1     = input1 ?? throw new ArgumentNullException(nameof(input1));
     Input2     = input2 ?? throw new ArgumentNullException(nameof(input2));
     Input3     = input3 ?? throw new ArgumentNullException(nameof(input3));
     Input4     = input4 ?? throw new ArgumentNullException(nameof(input4));
     Input5     = input5 ?? throw new ArgumentNullException(nameof(input5));
     this.AddDependencies(input1, input2, input3, input4, input5);
     if (reactImmediately)
     {
         InvokeReaction(Input1.GetValue(), Input2.GetValue(), Input3.GetValue(), Input4.GetValue(), Input5.GetValue());
     }
 }
        private void TrainBtn_Click(object sender, EventArgs e)
        {
            if (locked)
            {
                return;
            }

            double a;
            double t;

            try
            {
                a = Convert.ToDouble(Tb1.Text);
                t = Convert.ToDouble(Tb2.Text);
            }
            catch
            {
                ErrorAnimator.ShowSync(error);
                return;
            }

            error.Hide();
            locked = true;
            pm     = new PerceptronModel(t, a, Input1.GetArray().Length, output1.GetArray().Length, this);


            for (int i = 1; i <= MAX; i++)
            {
                double[] tmpIN  = new double[Input1.GetArray().Length];
                double[] tmpOUT = new double[output1.GetArray().Length];
                bool[]   tmp;

                DrawControl.DrawBox d1 = (DrawControl.DrawBox) this.Controls.Find("Input" + i, true)[0];
                DrawControl.DrawBox d2 = (DrawControl.DrawBox) this.Controls.Find("output" + i, true)[0];
                d1.locked = true;
                d2.locked = true;

                Log.AppendText("Pattern " + i + " \n");
                tmp = d1.GetArray();
                for (int j = 0; j < tmp.Length; j++)
                {
                    tmpIN[j] = (tmp[j]) ? 1 : 0;
                }

                tmp = d2.GetArray();

                for (int j = 0; j < tmp.Length; j++)
                {
                    tmpOUT[j] = (tmp[j]) ? 1 : -1;
                }

                Log.AppendText("(" + String.Join(",", tmpIN) + ")\n(" + String.Join(",", tmpOUT) + ")\n\n");

                Data d = new Data(tmpIN, tmpOUT);
                pm.q.Enqueue(d);
            }

            pm.GenerateWeight();
            pm.Train();
        }
Beispiel #13
0
 public override void Move(Point delta)
 {
     base.Move(delta);
     Input1.Move(delta);
     Input2.Move(delta);
     Output.Move(delta);
 }
Beispiel #14
0
        public override bool GetResult()
        {
            input1 = Input1.GetResult();
            input2 = Input2.GetResult();

            return(base.GetResult());
        }
        public void Redirect_to_destination()
        {
            var destination = new Input1();

            Redirect <StubRedirectable> .To(destination)
            .RedirectTo.AssertWasRedirectedTo(destination);
        }
        public void Transfer_to_destination()
        {
            var destination = new Input1();

            Transfer <StubRedirectable> .To(destination)
            .RedirectTo.AssertWasTransferedTo(destination);
        }
        public override Type OutputType(out CompiledFragment v)
        {
            v = this;
            Type TypeA = Input1.OutputType(out Input1);
            Type TypeB = Input0.OutputType(out Input0);

            return(Numerical(TypeA, TypeB, "Multiply", ref v));
        }
Beispiel #18
0
        public override Type OutputType(out CompiledFragment v)
        {
            v = this;
            Type typeA = Input1.OutputType(out Input1);
            Type typeB = Input0.OutputType(out Input0);

            return(Numerical(typeA, typeB, "Division", ref v));
        }
Beispiel #19
0
 public void set1(Summary1 s1)
 {
     this.m1     = s1.m1;
     this.g1     = s1.g1;
     this.ic1    = s1.ic1;
     this.input1 = s1.input1;
     this.s1     = s1;
 }
Beispiel #20
0
    sealed public override void Operation(RobotBase operatingRobotBase)
    {
        JetEngine jetEngine = operatingRobotBase.GetRobotPart <JetEngine>();

        if (jetEngine != null)
        {
            jetEngine.Destination = new Vector2(Input1.GetReporterNumberValue(operatingRobotBase), Input2.GetReporterNumberValue(operatingRobotBase));
        }
    }
Beispiel #21
0
 public override void OutputIL(NitroIL into)
 {
     Input0.OutputIL(into);
     Input1.OutputIL(into);
     into.Emit(OpCodes.Clt);
     // Flip by comparing with 0:
     into.Emit(OpCodes.Ldc_I4_0);
     into.Emit(OpCodes.Ceq);
 }
    sealed public override void Operation(RobotBase operatingRobotBase)
    {
        InternetAntenna internetAntenna = operatingRobotBase.GetRobotPart <InternetAntenna>();

        if (internetAntenna != null)
        {
            internetAntenna.SendDataThroughInternet(Input1.GetReporterStringValue(operatingRobotBase), Input2.GetReporterStringValue(operatingRobotBase), Input3.GetReporterStringValue(operatingRobotBase));
        }
    }
Beispiel #23
0
        /**
         * Create a new instance of single input functions
         * @param name function name
         * @param var0 Input variable
         * @return Resulting operation
         */
        public Operation.Info create(string name, Variable var0)
        {
            Input1 func = input1[name];

            if (func == null)
            {
                return(null);
            }
            return(func.create(var0, managerTemp));
        }
 public override void Compute()
 {
     if (Control == null || Control.Value == 0)
     {
         Output.SetValue(Input1.GetValue());
     }
     else
     {
         Output.SetValue(Input2.GetValue());
     }
 }
Beispiel #25
0
 public override WireHandle HookInHandle(Point p)
 {
     if (Input1.Selected(p))
     {
         return(Input1);
     }
     else if (Input2.Selected(p))
     {
         return(Input2);
     }
     return(null);
 }
Beispiel #26
0
        private void Update(EvaluationContext context)
        {
            if (_analyzer == null)
            {
                _analyzer = new Analyzer();
            }

            //_analyzer.TimerUpdateEventHandler();

            _analyzer.SetDeviceIndex((int)Input1.GetValue(context));
            FftBuffer.Value     = _analyzer.FftBuffer.ToList();
            AvailableData.Value = _analyzer.AvailableData;
        }
        public MainPage()
        {
            this.InitializeComponent();

            bool isInternetConnected = NetworkInterface.GetIsNetworkAvailable();

            if (isInternetConnected == true)
            {
                conn = new SQLiteConnection(new SQLitePlatformWinRT(), path); //資料庫連接
                conn.CreateTable <Data>();                                    //建立資料表

                GpioController gpio = GpioController.GetDefault();
                Input0 = gpio.OpenPin(4);
                Input0.SetDriveMode(GpioPinDriveMode.Input);
                Input1 = gpio.OpenPin(5);
                Input1.SetDriveMode(GpioPinDriveMode.Input);
                Input2 = gpio.OpenPin(17);
                Input2.SetDriveMode(GpioPinDriveMode.Input);
                Input3 = gpio.OpenPin(18);
                Input3.SetDriveMode(GpioPinDriveMode.Input);
                Input4 = gpio.OpenPin(22);
                Input4.SetDriveMode(GpioPinDriveMode.Input);
                Input5 = gpio.OpenPin(23);
                Input5.SetDriveMode(GpioPinDriveMode.Input);
                Input6 = gpio.OpenPin(24);
                Input6.SetDriveMode(GpioPinDriveMode.Input);
                Input7 = gpio.OpenPin(25);
                Input7.SetDriveMode(GpioPinDriveMode.Input);

                timer = new DispatcherTimer
                {
                    Interval = TimeSpan.FromMilliseconds(400)
                };
                timer.Tick += Timer_Tick;
                timer.Start();



                bgwWorker.DoWork                    += new DoWorkEventHandler(bgwWorker_DoWork);
                bgwWorker.RunWorkerCompleted        += new RunWorkerCompletedEventHandler(bgwWorker_RunWorkerCompleted);
                bgwWorker.ProgressChanged           += new ProgressChangedEventHandler(bgwWorker_ProgressChanged);
                bgwWorker.WorkerReportsProgress      = true;
                bgwWorker.WorkerSupportsCancellation = true;
            }

            else
            {
                wifisettingAsync();
            }
        }
 public override void OutputIL(NitroIL into)
 {
     if (Input0 == null)
     {
         Input1.OutputIL(into);
         into.Emit(OpCodes.Neg);
     }
     else
     {
         Input0.OutputIL(into);
         Input1.OutputIL(into);
         into.Emit(OpCodes.Sub);
     }
 }
        public override Type OutputType(out CompiledFragment newOperation)
        {
            newOperation = this;
            Type typeB = Input1.OutputType(out Input1);

            if (Input0 == null)
            {
                // Negation
                return(Numerical(ref Input1, typeB, typeof(float)));
            }
            Type typeA = Input0.OutputType(out Input0);

            return(Numerical(typeA, typeB, "Subtraction", ref newOperation));
        }
Beispiel #30
0
 /// <summary>
 /// Creates a new <see cref="ReactionPipelineStage"/> with the specified name and reaction to the specified inputs.
 /// </summary>
 /// <param name="name">The name of the new reaction.</param>
 /// <param name="reaction">The reaction delegate.</param>
 /// <param name="input1">Input number 1.</param>
 /// <param name="reactImmediately">Denotes if the reaction should fire immediately upon construction.</param>
 public ReactionPipelineStage(
     string name,
     Action <TInput1> reaction,
     IPipelineStage <TInput1> input1,
     bool reactImmediately)
 {
     Name     = name ?? throw new ArgumentNullException(nameof(name));
     Reaction = reaction ?? throw new ArgumentNullException(nameof(reaction));
     Input1   = input1 ?? throw new ArgumentNullException(nameof(input1));
     this.AddDependencies(input1);
     if (reactImmediately)
     {
         Reaction(Input1.GetValue());
     }
 }
Beispiel #31
0
        public override Type OutputType(out CompiledFragment v)
        {
            v = this;
            Type typeA = Input0.OutputType(out Input0);
            Type typeB = Input1.OutputType(out Input1);

            CompiledFragment equalityOverload = null;

            FindOverload("Equality", typeA, typeB, ref equalityOverload);
            if (equalityOverload != null)
            {
                v = equalityOverload;
            }
            return(typeof(bool));
        }
Beispiel #32
0
        private void InitializeStageWatch()
        {
            deathCounter.Subscribe(count =>
            {
                for (int i = titleSettings.NextStageCount.Length - 1; i >= 0; --i)
                {
                    if (count < titleSettings.NextStageCount[i])
                    {
                        continue;
                    }
                    stageReactiveProperty.Value = i + 1;
                    return;
                }
            });
            stageReactiveProperty.Subscribe(stage =>
            {
                switch (stage)
                {
                case 0:
                    break;

                case 1:
                    EnemyPlayerCollisionSystem.Enabled = true;
                    break;

                case 2:
                    RainSystem.Enabled = true;
                    break;

                case 3:
                    Input1.Subscribe(ChangeWeapon1);
                    Input2.Subscribe(ChangeWeapon2);
                    武器欄.SetActive(true);
                    武器名 = 武器欄.transform.Find(nameof(武器名)).GetComponent <TMPro.TMP_Text>();
                    break;

                case 4:
                    // System.Buffer.BlockCopy(stage4EnemySpeed.Speeds, 0, enemySpeeds.Speeds, 0, enemySpeeds.Speeds.Length);
                    break;

                case 5:
                    // LastBossAppear();
                    break;

                default: break;
                }
            });
        }
 public string get_something(Input1 input)
 {
     throw new NotImplementedException();
 }
Beispiel #34
0
 public Output1 Symmetric(Input1 input)
 {
     return null;
 }
 public void MixedMethod(Input1 input)
 {
 }
 public Output1 MethodWithoutAF(Input1 input)
 {
     return null;
 }
 public void MethodWithOneRule(Input1 input)
 {
 }
 public Output1 NonJson(Input1 input)
 {
     return null;
 }
 public void GoPartial(Input1 input)
 {
 }
 public void MethodWithMultipleRules(Input1 input)
 {
 }
 public void Go(Input1 input)
 {
 }
 public IDictionary<string, object> ReturnsJson(Input1 input)
 {
     return  new Dictionary<string, object>();
 }
 public void Four(Input1 input)
 {
 }
 public Output1 OneInOneOut(Input1 input)
 {
     return new Output1();
 }
 public void M1(Input1 input){}
 public void Three(Input1 input)
 {
 }
 public void One(Input1 input)
 {
 }
 public Output1 M1(Input1 input)
 {
     return null;
 }
 public void Two(Input1 input)
 {
 }
 public void Call(Input1 input1)
 {
 }