{"id":559,"date":"2005-08-24T10:42:01","date_gmt":"2005-08-24T10:42:01","guid":{"rendered":"http:\/\/ellery.no-ip.info\/wp\/thinkingmore\/2005\/08\/24\/rfmaintainer-%e7%9a%84-statechart-%e8%a3%9c\/"},"modified":"2005-08-24T10:42:01","modified_gmt":"2005-08-24T10:42:01","slug":"rfmaintainer-%e7%9a%84-statechart-%e8%a3%9c","status":"publish","type":"post","link":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/2005\/08\/rfmaintainer-%e7%9a%84-statechart-%e8%a3%9c\/","title":{"rendered":"RFMaintainer \u7684 statechart (\u88dc)"},"content":{"rendered":"<p>\u6628\u5929\u7684<a href=\"000685.html\" title=\"RFMaintainer \u7684 statechart\">RFMaintainer \u7684 statechart<\/a>\u4e26\u6c92\u6709\u5be6\u4f5c\u90e8\u4efd,\u4eca\u5929\u88dc\u4e0a&#8230;<br \/>\n\u4f60\u53ef\u4ee5\u770b\u5230\u9019\u4e9b\u90fd\u662f\u5beb\u5728 Form \u88e1\u9762,\u4e26\u6c92\u6709\u8ddf UI \u5207\u958b&#8230;.<br \/>\n\u9019\u5c31\u662f\u6211\u7591\u554f\u7684\u5730\u65b9&#8230;<br \/>\n\u4e0d\u904e\u5c0d\u7167\u5716\u4e4b\u5f8c,\u4f60\u6703\u767c\u73fe\u9019\u6a23\u7684\u5beb\u6cd5\u5f88\u6e05\u695a&#8230;\u4e0d\u6703\u6709\u88dc\u6771\u7246\u6316\u897f\u7246,\u6771\u6539\u4e00\u584a\u897f\u6539\u4e00\u584a\u7684\u554f\u984c&#8230;<\/p>\n<pre>\t\t#region State Chart Implementation.\nprivate int _StateVariable = 0;\nprivate int _StateVariable_A = 0;\nprivate int _StateVariable_B = 0;\nprivate int _StateVariable_C = 0;\n\/\/\/ <summary>\n\/\/\/ State 1: Transient\n\/\/\/ <\/summary>\nprivate void go_state_1()\n{\n_StateVariable = 1;\nif( txtConnectString.Text == \"\" )\ngo_state_2();\nelse\ngo_state_3();\n}\n\/\/\/ <summary>\n\/\/\/ State 2: Connection string null\n\/\/\/ <\/summary>\nprivate void go_state_2()\n{\n_StateVariable = 2;\n\/\/ disable controls.\nradioButton1.Enabled = false;\nradioButton2.Enabled = false;\ndtpFrom.Enabled = false;\ndtpTo.Enabled = false;\ncboType.Enabled = false;\ntxtPath.Enabled = false;\nbtnBrowse.Enabled = false;\nbtnExport.Enabled = false;\n}\n\/\/\/ <summary>\n\/\/\/ State 3: Connection string not null\n\/\/\/ <\/summary>\nprivate void go_state_3()\n{\n_StateVariable = 3;\n\/\/ enable controls.\nradioButton1.Enabled = true;\nradioButton1.Checked = true;\nradioButton2.Enabled = true;\ncboType.Enabled = true;\ntxtPath.Enabled = true;\nbtnBrowse.Enabled = true;\ngo_state_4();\ngo_state_7();\ngo_state_10();\n}\n\/\/\/ <summary>\n\/\/\/ State 4: Region A: Transient\n\/\/\/ <\/summary>\nprivate void go_state_4()\n{\n_StateVariable_A = 4;\nif( radioButton2.Checked )\ngo_state_5();\nelse if( radioButton1.Checked )\ngo_state_6();\n}\n\/\/\/ <summary>\n\/\/\/ State 5: Region A: \"Period\" checked\n\/\/\/ <\/summary>\nprivate void go_state_5()\n{\n_StateVariable_A = 5;\ndtpFrom.Enabled = true;\ndtpTo.Enabled = true;\n}\n\/\/\/ <summary>\n\/\/\/ State 6: Region A: \"All\" checked\n\/\/\/ <\/summary>\nprivate void go_state_6()\n{\n_StateVariable_A = 6;\ndtpFrom.Enabled = false;\ndtpTo.Enabled = false;\n}\n\/\/\/ <summary>\n\/\/\/ State 7: Region B: Transient\n\/\/\/ <\/summary>\nprivate void go_state_7()\n{\n_StateVariable_B = 7;\nif( txtPath.Text == \"\" )\ngo_state_8();\nelse\ngo_state_9();\n}\n\/\/\/ <summary>\n\/\/\/ State 8: Region B: \"output file\" null\n\/\/\/ <\/summary>\nprivate void go_state_8()\n{\nbtnExport.Enabled = false;\n}\n\/\/\/ <summary>\n\/\/\/ State 9: Region B: \"output file\" not null\n\/\/\/ <\/summary>\nprivate void go_state_9()\n{\nbtnExport.Enabled = true;\n}\n\/\/\/ <summary>\n\/\/\/ State 10: Region C: \"Export type\" is XML\n\/\/\/ <\/summary>\nprivate void go_state_10()\n{\n_StateVariable_C = 10;\ncboType.SelectedIndex = 0;\n}\n\/\/\/ <summary>\n\/\/\/ State 11: Export\n\/\/\/ <\/summary>\n\/\/\/ \nprivate void go_state_11()\n{\n}\n#endregion\n#region UI independence routines\n\/\/\/ <summary>\n\/\/\/ I don't consider this button in State chart.\n\/\/\/ And I am lazy to change....\n\/\/\/ <\/summary>\n\/\/\/ \nprivate bool testConnection( string connectString )\n{\n}\nprivate bool export( int type, DateTime dtFrom, DateTime dtTo, string outputFile )\n{\n}\n#endregion\n#region Event handler\nprivate void btnExport_Click(object sender, System.EventArgs e)\n{\nint iType = 0;\nif( radioButton1.Checked == true )\niType = 1;\nelse if( radioButton2.Checked == true )\niType = 2;\nif( export( iType, dtpFrom.Value, dtpTo.Value, txtPath.Text ) )\nMessageBox.Show( \"Finished!\" );\nelse\nMessageBox.Show( \"Fail!!\" );\n}\nprivate void btnBrowse_Click(object sender, System.EventArgs e)\n{\n\/\/ Displays a SaveFileDialog so the user can save the Image\nSaveFileDialog saveFileDialog1 = new SaveFileDialog();\nsaveFileDialog1.Filter = \"XML file|*.xml\";\nsaveFileDialog1.Title = \"Save to XML File\";\nsaveFileDialog1.ShowDialog();\nsaveFileDialog1.OverwritePrompt = true;\n\/\/ If the file name is not an empty string open it for saving.\nif(saveFileDialog1.FileName != \"\")\n{\ntxtPath.Text = saveFileDialog1.FileName;\n}\n}\nprivate void btnTest_Click(object sender, System.EventArgs e)\n{\ntestConnection( txtConnectString.Text );\n}\nprivate void radioButton1_CheckedChanged(object sender, System.EventArgs e)\n{\ngo_state_6();\n}\nprivate void radioButton2_CheckedChanged(object sender, System.EventArgs e)\n{\ngo_state_5();\n}\nprivate void txtPath_TextChanged(object sender, System.EventArgs e)\n{\ngo_state_7();\n}\nprivate void txtConnectString_TextChanged(object sender, System.EventArgs e)\n{\ngo_state_1();\n}\n#endregion\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6628\u5929\u7684RFMaintainer \u7684 statechart\u4e26\u6c92\u6709\u5be6\u4f5c\u90e8\u4efd,\u4eca\u5929\u88dc\u4e0a&#8230; \u4f60\u53ef\u4ee5\u770b\u5230\u9019\u4e9b\u90fd\u662f\u5beb\u5728 Form \u88e1\u9762,\u4e26\u6c92\u6709\u8ddf UI \u5207\u958b&#8230;. \u9019\u5c31\u662f\u6211\u7591\u554f\u7684\u5730\u65b9&#8230; \u4e0d\u904e\u5c0d\u7167\u5716\u4e4b\u5f8c,\u4f60\u6703\u767c\u73fe\u9019\u6a23\u7684\u5beb\u6cd5\u5f88\u6e05\u695a&#8230;\u4e0d\u6703\u6709\u88dc\u6771\u7246\u6316\u897f\u7246,\u6771\u6539\u4e00\u584a\u897f\u6539\u4e00\u584a\u7684\u554f\u984c&#8230; #region State Chart Implementation. private int _StateVariable = 0; private int _StateVariable_A = 0; private int _StateVariable_B = 0; private int _StateVariable_C = 0; \/\/\/ \/\/\/ State 1: Transient \/\/\/ private void go_state_1() { _StateVariable = 1; if( txtConnectString.Text == &#8220;&#8221; ) go_state_2(); else go_state_3(); &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/2005\/08\/rfmaintainer-%e7%9a%84-statechart-%e8%a3%9c\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;RFMaintainer \u7684 statechart (\u88dc)&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5],"tags":[],"class_list":["post-559","post","type-post","status-publish","format-standard","hentry","category-idea"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2MOxp-91","_links":{"self":[{"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/posts\/559","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/comments?post=559"}],"version-history":[{"count":0,"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/posts\/559\/revisions"}],"wp:attachment":[{"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/media?parent=559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/categories?post=559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/tags?post=559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}