예제 #1
0
 void print(IntPtr sdkContext, BS2InputConfig config)
 {
     Console.WriteLine(">>>> Input configuration ");
     Console.WriteLine("     |--numInputs     : {0}", config.numInputs);
     Console.WriteLine("     |--numSupervised : {0}", config.numSupervised);
     for (int idx = 0; idx < BS2Envirionment.BS2_MAX_INPUT_NUM; idx++)
     {
         Console.WriteLine("     +--supervised_inputs[{0}]", idx);
         Console.WriteLine("     |--    portIndex        : {0}", config.supervised_inputs[idx].portIndex);
         Console.WriteLine("     |--    enabled          : {0}", config.supervised_inputs[idx].enabled);
         Console.WriteLine("     |--    supervised_index : {0}", config.supervised_inputs[idx].supervised_index);
         Console.WriteLine("     |--    config.shortInput.minValue : {0}", config.supervised_inputs[idx].config.shortInput.minValue);
         Console.WriteLine("     |--    config.shortInput.maxValue : {0}", config.supervised_inputs[idx].config.shortInput.maxValue);
         Console.WriteLine("     |--    config.openInput.minValue  : {0}", config.supervised_inputs[idx].config.openInput.minValue);
         Console.WriteLine("     |--    config.openInput.maxValue  : {0}", config.supervised_inputs[idx].config.openInput.maxValue);
         Console.WriteLine("     |--    config.onInput.minValue    : {0}", config.supervised_inputs[idx].config.onInput.minValue);
         Console.WriteLine("     |--    config.onInput.maxValue    : {0}", config.supervised_inputs[idx].config.onInput.maxValue);
         Console.WriteLine("     |--    config.offInput.minValue   : {0}", config.supervised_inputs[idx].config.offInput.minValue);
         Console.WriteLine("     +--    config.offInput.maxValue   : {0}", config.supervised_inputs[idx].config.offInput.maxValue);
     }
     Console.WriteLine("<<<< ");
 }
예제 #2
0
        public void setInputConfig(IntPtr sdkContext, UInt32 deviceID, bool isMasterDevice)
        {
            BS2InputConfig config = Util.AllocateStructure <BS2InputConfig>();

            Console.WriteLine("Please enter Number of inputs.");
            Console.Write(">>>> ");
            config.numInputs = (byte)Util.GetInput();
            if (config.numInputs < 0 || config.numInputs > 10)
            {
                Console.WriteLine("Invalid parameter (numInputs)");
                return;
            }

            Console.WriteLine("Please enter Number of supervised-inputs.");
            Console.Write(">>>> ");
            config.numSupervised = (byte)Util.GetInput();
            if (config.numSupervised < 0 || config.numSupervised > 8)
            {
                Console.WriteLine("Invalid parameter (numSupervised)");
                return;
            }

            for (int idx = 0; idx < BS2Envirionment.BS2_MAX_INPUT_NUM; ++idx)
            {
                if (idx < config.numSupervised)
                {
                    Console.WriteLine(">>>> supervised_inputs[{0}]", idx);

                    config.supervised_inputs[idx].portIndex = (byte)idx;

                    Console.Write("    Please enter enabled (0, 1) : ");
                    config.supervised_inputs[idx].enabled = (byte)Util.GetInput();

                    Console.Write("    Please enter superviced_index : ");
                    config.supervised_inputs[idx].supervised_index = (byte)Util.GetInput();

                    if (255 == config.supervised_inputs[idx].supervised_index)
                    {
                        Console.Write("    Please enter shortInput.minValue : ");
                        config.supervised_inputs[idx].config.shortInput.minValue = (UInt16)Util.GetInput();
                        Console.Write("    Please enter shortInput.maxValue : ");
                        config.supervised_inputs[idx].config.shortInput.maxValue = (UInt16)Util.GetInput();

                        Console.Write("    Please enter openInput.minValue : ");
                        config.supervised_inputs[idx].config.openInput.minValue = (UInt16)Util.GetInput();
                        Console.Write("    Please enter openInput.maxValue : ");
                        config.supervised_inputs[idx].config.openInput.maxValue = (UInt16)Util.GetInput();

                        Console.Write("    Please enter onInput.minValue : ");
                        config.supervised_inputs[idx].config.onInput.minValue = (UInt16)Util.GetInput();
                        Console.Write("    Please enter onInput.maxValue : ");
                        config.supervised_inputs[idx].config.onInput.maxValue = (UInt16)Util.GetInput();

                        Console.Write("    Please enter offInput.minValue : ");
                        config.supervised_inputs[idx].config.offInput.minValue = (UInt16)Util.GetInput();
                        Console.Write("    Please enter offInput.maxValue : ");
                        config.supervised_inputs[idx].config.offInput.maxValue = (UInt16)Util.GetInput();
                    }
                    else
                    {
                        config.supervised_inputs[idx].config.shortInput.minValue = 0;
                        config.supervised_inputs[idx].config.shortInput.maxValue = 0;
                        config.supervised_inputs[idx].config.openInput.minValue  = 0;
                        config.supervised_inputs[idx].config.openInput.maxValue  = 0;
                        config.supervised_inputs[idx].config.onInput.minValue    = 0;
                        config.supervised_inputs[idx].config.onInput.maxValue    = 0;
                        config.supervised_inputs[idx].config.offInput.minValue   = 0;
                        config.supervised_inputs[idx].config.offInput.maxValue   = 0;
                    }
                }
                else
                {
                    config.supervised_inputs[idx].portIndex                  = (byte)idx;
                    config.supervised_inputs[idx].enabled                    = 0;
                    config.supervised_inputs[idx].supervised_index           = 1;
                    config.supervised_inputs[idx].config.shortInput.minValue = 0;
                    config.supervised_inputs[idx].config.shortInput.maxValue = 0;
                    config.supervised_inputs[idx].config.openInput.minValue  = 0;
                    config.supervised_inputs[idx].config.openInput.maxValue  = 0;
                    config.supervised_inputs[idx].config.onInput.minValue    = 0;
                    config.supervised_inputs[idx].config.onInput.maxValue    = 0;
                    config.supervised_inputs[idx].config.offInput.minValue   = 0;
                    config.supervised_inputs[idx].config.offInput.maxValue   = 0;
                }
            }

            Console.WriteLine("Trying to set input configuration.");
            BS2ErrorCode result = (BS2ErrorCode)API.BS2_SetInputConfig(sdkContext, deviceID, ref config);

            if (result != BS2ErrorCode.BS_SDK_SUCCESS)
            {
                Console.WriteLine("Got error({0}).", result);
                return;
            }
            else
            {
                Console.WriteLine("Set InputConfig Succeeded");
            }
        }
예제 #3
0
 extern public static int BS2_SetInputConfig(IntPtr context, UInt32 deviceId, ref BS2InputConfig config);