コード例 #1
0
        private static void DrawLink(Texture texture, string heading, string body, LinkFunction func, object userData)
        {
            GUILayout.BeginHorizontal();

            GUILayout.Space(64);
            GUILayout.Box(texture, GUIStyle.none, GUILayout.MaxWidth(48));
            GUILayout.Space(10);

            GUILayout.BeginVertical();
            GUILayout.Space(1);
            GUILayout.Label(heading, EditorStyles.boldLabel);
            GUILayout.Label(body, labelWithWordWrap);
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            var rect = GUILayoutUtility.GetLastRect();

            EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link);

            if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition))
            {
                func(userData);
                GUIUtility.ExitGUI();
            }

            GUILayout.Space(10);
        }
コード例 #2
0
ファイル: PlayMakerWelcomeWindow.cs プロジェクト: malering/ET
        private static void DrawLink(Texture texture, string heading, string body, LinkFunction func, object userData)
        {
            GUILayout.BeginHorizontal();

            var guiColor = GUI.color;

            GUI.color = EditorGUIUtility.isProSkin ? EditorStyles.label.normal.textColor : new Color(0.3f, 0.3f, 0.3f);
            GUILayout.Space(64);
            GUILayout.Box(texture, linkIcon);
            GUILayout.Space(10);
            GUI.color = guiColor;

            GUILayout.BeginVertical();
            GUILayout.Space(4);
            GUILayout.Label(heading, EditorStyles.boldLabel);
            GUILayout.Label(body, labelWithWordWrap);
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            var rect = GUILayoutUtility.GetLastRect();

            EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link);

            if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition))
            {
                func(userData);
                GUIUtility.ExitGUI();
            }

            GUILayout.Space(10);
        }
コード例 #3
0
        public string LinkFunctionToString(LinkFunction arg)
        {
            switch (arg)
            {
            case (LinkFunction.PRI_RESET_LINK_STATES):
                return("PRI_RESET_LINK_STATES");

            case (LinkFunction.PRI_TEST_LINK_STATES):
                return("PRI_TEST_LINK_STATES");

            case (LinkFunction.PRI_CONFIRMED_USER_DATA):
                return("PRI_CONFIRMED_USER_DATA");

            case (LinkFunction.PRI_UNCONFIRMED_USER_DATA):
                return("PRI_UNCONFIRMED_USER_DATA");

            case (LinkFunction.PRI_REQUEST_LINK_STATUS):
                return("PRI_REQUEST_LINK_STATUS");

            case (LinkFunction.SEC_ACK):
                return("SEC_ACK");

            case (LinkFunction.SEC_NACK):
                return("SEC_NACK");

            case (LinkFunction.SEC_LINK_STATUS):
                return("SEC_LINK_STATUS");

            case (LinkFunction.SEC_NOT_SUPPORTED):
                return("SEC_NOT_SUPPORTED");

            default:
                return("INVALID");
            }
        }
コード例 #4
0
 public LinkHeaderFields(LinkFunction func_, bool isMaster_, bool fcb_, bool fcvdfc_, UInt16 dest_, UInt16 source_)
 {
     func         = func_;
     isFromMaster = isMaster_;
     fcb          = fcb_;
     fcvdfc       = fcvdfc_;
     dest         = dest_;
     src          = source_;
 }
コード例 #5
0
        public double[] Weight(double[] meanResponse)
        {
            double[] weight     = new double[meanResponse.Length];
            double[] derivative = LinkFunction.FirstDerivative(meanResponse);

            for (int i = 0; i < derivative.Length; i++)
            {
                weight[i] = 1.0 / (derivative[i] * derivative[i] * Variance);
            }

            return(weight);
        }
コード例 #6
0
        static void Main(string[] args)
        {
            try
            {
                if (args.Count() > 0)
                {
                    if (args[0] == Link)
                    {
                        LinkFunction.SendLink(args[1]);
                    }
                    else
                    {
                        bool hasSecondArgument = args.Count() > 1 ? true : false;
                        switch (args[0])
                        {
                        case Update:
                            if (hasSecondArgument && args[1] == UpdateArgument.Restart)
                            {
                                UpdateFunction.Update(true);
                            }
                            else
                            {
                                UpdateFunction.Update(false);
                            }
                            break;

                        case Ngen:
                            break;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Puuuuuuuu 我才不要理你。"
                                    + Environment.NewLine + Environment.NewLine +
                                    "Ps:如果你想启动 osi 的话 你应该双击 osi.exe");
                }
            }
            catch (Exception e)
            {
#if DEBUG
                MessageBox.Show(e.Message + "   " + e.Source
                                + Environment.NewLine +
                                e.StackTrace);
#endif
                exitCode = ExitCode.Error;
            }
            Environment.Exit(exitCode);
        }
コード例 #7
0
 public LinkHeader(
     LinkFunction function,
     bool isFromMaster,
     bool FCB,
     bool FCV,
     UInt16 destination,
     UInt16 source
     )
 {
     this.Function     = function;
     this.IsFromMaster = isFromMaster;
     this.FCB          = FCB;
     this.FCV          = FCV;
     this.Destination  = destination;
     this.Source       = source;
 }
コード例 #8
0
        public byte ControlByte(bool aIsMaster, bool aFcb, bool aFcvDfc, LinkFunction aFunc)
        {
            var  field = new LinkFunctionClass();
            byte ret   = field.LinkFunctionToType(aFunc);

            if (aIsMaster)
            {
                ret |= (byte)ControlMask.MASK_DIR;
            }
            if (aFcb)
            {
                ret |= (byte)ControlMask.MASK_FCB;
            }
            if (aFcvDfc)
            {
                ret |= (byte)ControlMask.MASK_FCV;
            }

            return(ret);
        }
コード例 #9
0
        private static byte[] FormatHeader(ref Byte[] buffer, byte aDataLength, bool aIsMaster, bool aFcb, bool aFcvDfc, LinkFunction aFuncCode, UInt16 aDest, UInt16 aSrc)
        {
            if (buffer.Length < (int)LinkLayerConstants.LPDU_HEADER_SIZE)
            {
                return(null);
            }
            LinkHeader header = new LinkHeader((byte)(aDataLength + LinkLayerConstants.LPDU_MIN_LENGTH), aSrc, aDest, aIsMaster, aFcvDfc, aFcb, aFuncCode);

            header.Write(buffer);
            var temp = buffer;
            var ret  = temp.Take(10).ToArray();

            temp   = ResizeByteArray(temp, 10);
            buffer = temp;
            return(ret);
        }
コード例 #10
0
 public LinkHeader(byte aLen, UInt16 aSrc, UInt16 aDest, bool aFromMaster, bool aFcvDfc, bool aFcb, LinkFunction aCode)
 {
     length = aLen;
     src    = aSrc;
     dest   = aDest;
     ctrl   = ControlByte(aFromMaster, aFcb, aFcvDfc, aCode);
 }
コード例 #11
0
 public byte LinkFunctionToType(LinkFunction arg)
 {
     return((byte)arg);
 }
コード例 #12
0
        private static void DrawLink(Texture texture, string heading, string body, LinkFunction func, object userData)
        {
            GUILayout.BeginHorizontal();

            GUILayout.Space(64);
            GUILayout.Box(texture, GUIStyle.none, GUILayout.MaxWidth(48));
            GUILayout.Space(10);

            GUILayout.BeginVertical();
            GUILayout.Space(1);
            GUILayout.Label(heading, EditorStyles.boldLabel);
            GUILayout.Label(body, labelWithWordWrap);
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            var rect = GUILayoutUtility.GetLastRect();
            EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link);

            if (Event.current.type == EventType.mouseDown && rect.Contains(Event.current.mousePosition))
            {
                func(userData);
            }

            GUILayout.Space(10);
        }
        public void getGlmModel(string modelPath, bool BuildModel=false)
        {
            using (System.IO.StreamReader sr = new System.IO.StreamReader(modelPath))
            {
                string mType = sr.ReadLine();
                modelTypes m = (modelTypes)Enum.Parse(typeof(modelTypes), mType);
                if (m != modelTypes.GLM)
                {
                    System.Windows.Forms.MessageBox.Show("Model file specified is not a GLM!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    return;
                }
                InTablePath = sr.ReadLine();
                IndependentFieldNames = sr.ReadLine().Split(new char[] { ',' });
                DependentFieldNames = sr.ReadLine().Split(new char[] { ',' });
                ClassFieldNames = sr.ReadLine().Split(new char[] { ',' });
                n = System.Convert.ToInt32(sr.ReadLine());
                nvars = System.Convert.ToInt32(sr.ReadLine());
                iterations = System.Convert.ToInt32(sr.ReadLine());
                delta = System.Convert.ToDouble(sr.ReadLine());
                loglikelihood=System.Convert.ToDouble(sr.ReadLine());
                loglikelihoodratio = System.Convert.ToDouble(sr.ReadLine());
                pv = System.Convert.ToDouble(sr.ReadLine());
                deviance = System.Convert.ToDouble(sr.ReadLine());
                chisqr = System.Convert.ToDouble(sr.ReadLine());
                linkfunction = (LinkFunction)Enum.Parse(typeof(LinkFunction), sr.ReadLine());
                coefficients = (from string s in (sr.ReadLine().Split(new char[]{' '})) select System.Convert.ToDouble(s)).ToArray();
                stdError = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray();
                waldTestValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray();
                waldTestPValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray();
                minValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray();
                maxValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray();
                sumValues = (from string s in (sr.ReadLine().Split(new char[] { ' ' })) select System.Convert.ToDouble(s)).ToArray();
                sr.Close();

            }
            if (BuildModel)
            {
                Accord.Statistics.Links.ILinkFunction lFunc = new Accord.Statistics.Links.IdentityLinkFunction();
                switch (Link)
                {
                    case LinkFunction.Absolute:
                        lFunc = new Accord.Statistics.Links.AbsoluteLinkFunction();
                        break;
                    case LinkFunction.Cauchit:
                        lFunc = new Accord.Statistics.Links.CauchitLinkFunction();
                        break;
                    case LinkFunction.Inverse:
                        lFunc = new Accord.Statistics.Links.InverseLinkFunction();
                        break;
                    case LinkFunction.InverseSquared:
                        lFunc = new Accord.Statistics.Links.InverseSquaredLinkFunction();
                        break;
                    case LinkFunction.Logit:
                        lFunc = new Accord.Statistics.Links.LogitLinkFunction();
                        break;
                    case LinkFunction.Log:
                        lFunc = new Accord.Statistics.Links.LogLinkFunction();
                        break;
                    case LinkFunction.LogLog:
                        lFunc = new Accord.Statistics.Links.LogLogLinkFunction();
                        break;
                    case LinkFunction.Probit:
                        lFunc = new Accord.Statistics.Links.ProbitLinkFunction();
                        break;
                    case LinkFunction.Sin:
                        lFunc = new Accord.Statistics.Links.SinLinkFunction();
                        break;
                    case LinkFunction.Threshold:
                        lFunc = new Accord.Statistics.Links.ThresholdLinkFunction();
                        break;
                    default:
                        break;
                }
                glm = new Accord.Statistics.Models.Regression.GeneralizedLinearRegression(lFunc, coefficients, stdError);
            }
        }
コード例 #14
0
 public double[] Fit(double[] linearPredicton)
 {
     return(LinkFunction.Inverse(linearPredicton));
 }
コード例 #15
0
 public double[] Predict(double[] meanResponse)
 {
     return(LinkFunction.Evaluate(meanResponse));
 }
コード例 #16
0
 public double LogLikelihood(double[] response, double[] meanResponse, double[] weights, double scale = 1.0)
 {
     return(LinkFunction.LogLikelihood(response, meanResponse, weights, scale));
 }