VB プログラム Form1.vb メイン画面 Imports System.Windows.Forms.DataVisualization.Charting Imports System Imports System.Net Imports System.Net.Sockets Imports S

Similar documents
VB アプリケーション ComboBox IP アドレス ComboBox ポート番号 ListView TextBox VB2010 Express で作成しました 上のグラフは 2012 年 12 月 27 日 ~2013 年 1 月 10 日 つまり年末年始休業とその前後の社内の温湿度の変化で

メモリー MAP Data エリア [MPC] [ パネル ] MBK(0) = DT00000 : : MBK(7899) = DT07899 DT10000 DT10012 : タッチパネル DT (MPC Control) MPC 変数 2word SYSCLK の値 (2word Syste


3軸加速度センサーモジュール MM-2860 書込み済みマイコンプログラム通信コマンド概要


Microsoft Word 練習問題の解答.doc

プリンタ印字用 DLL 取扱説明書

VB 資料 電脳梁山泊烏賊塾 音声認識 System.Speech の利用 System.Speech に依るディクテーション ( 音声を文字列化 ).NetFramework3.0 以上 (Visual Studio 2010 以降 ) では 標準で System.Speech が用意されて居るの

VFD256 サンプルプログラム

データアダプタ概要

バスケットボール

ウィンドウ操作 応用

ルーレットプログラム

グラフィックス

ブロック パニック

ICONファイルフォーマット

ファイル操作

1. はじめにローテータをパソコンでコントロールする仕掛けを作りました もともと ローテータのコントローラ自体がリモコンな訳ですから リモコンのリモコンということになります 最近は 無線機をパソコンに接続してリモートシャックから運用されている方もかなりいらっしゃるようです となると 無線機だけではな

Secure iNetSuite for .NET 4.0Jの新仕様について

かべうちテニス

untitled

Oracle Lite Tutorial

Oracle Lite Tutorial

adr(Byte)

(Microsoft Word \203v\203\215\203O\203\211\203~\203\223\203O)

ブロック崩し風テニス

DAOの利用

GS1-128 の描画 DLL について (ver. 2.3) 動作環境など動作環境 WindowsXP Windows Vista Windows7 Windows8/8.1 Windows10 上記 OS について すべて日本語版を対象としております 32bit アプリケーションから呼び出される

Microsoft Word - DT-5100Lib_Manual_DotNet.doc

API 連携方式 外部 DLL の呼び出し宣言 外部 DLL の呼び出し宣言のサンプルコード (Microsoft Visual C#.NET の場合 ) プログラムコードの先頭で using System.Runtime.InteropServices; が必要 クラスの内部に以下のような外部 D

プロセス間通信

untitled

PowerPoint プレゼンテーション

コンピュータ概論

CashDrawer ライブラリ API 仕様書 2014/07/09 CashDrawer ライブラリ API 仕様書 Rev / 10

94 expression True False expression FalseMSDN IsNumber WorksheetFunctionIsNumberexpression expression True Office support.office.com/ja-jp/ S

IP RFID RFID IP RFID IP RFID IP RFID IP RFID IP RFID RFID RFID RFID RFID RFID POS IP RFID i

Userコントロール

ファイル監視

ドライブは安全運転で in 滋賀♪

csv csv

グラフィックトレーニング 概要.NET のグラフィック描画は どんなことができるのでしょうか? グラフィックオブジェクトやグラフィック環境 概念を理解するためには クラスを使って馴れることが近道です 本 書に記載されているコードをカットアンドペーストして 一つ一つの機能を体験してください 前提 グラ


VB.NET解説

第 3 章 Visual Studio Community 2015 の基本操作 1 起動と画面構成 (1)Visual Studio 2015 の起動 [ スタート ] ボタン [ すべてのプログラム ] [Visual Studio 2015] をクリックし, を選択します (2) 起動直後の画

ASP.NET 2.0 Provider Model 概要

Ethernet 開発支援ツール ACCEL ti2k (LastUpdate Mar 1, 2019) 概要ターミナルツール (1) TcpTermS.exe ターミナルツール (2) TcpTermM.exe ターミナルツール (3) UdpTermS.exe ターミナルツール (

Kikusui IVI-COM Driver Guidebook For Visual Basic.NET

ファイル操作-バイナリファイル

Msako技術資料 

ピコ秒パルスレーザ基板ライブラリ (tmhidld.dll) 説明書 珠電子株式会社 2013/04/30 概要 ピコ秒パルスレーザ基板を制御するための.Net Framework 4.0 ライブラリについて説明します ユーザアプリケーション (VB.net VC.net VC#.net LabVI

NotifyIconコントロール

sinfI2005_VBA.doc

BASICとVisual Basic

スレッド操作 タイマー

C#の基本2 ~プログラムの制御構造~

倉庫番

卒業論文.PDF

intra-mart Accel Platform — イベントナビゲータ 開発ガイド   初版   None

Public Grid As ReverseGrid Public Position As Point ' 論理位置 Public Rectangle As Rectangle ' 物理位置 Status; 黒 白 なしの状態 Grid; オセロの盤面 Position; 盤面内の説明 Rectan

Lesson 1 1 EXVBA2000 Lesson01 Lesson01.xls 2

My関数の作成演習問題集

Taro-H21VBテキスト.jtd

@(h) Select.vb ver 1.1 ( Select.vb ver 1.0 ( Option Explicit Private Structure SYMBOLINFO Dim SyDataType As String Dim

1 シミュレーションとは何か?

intra-mart Accel Platform — イベントナビゲータ 開発ガイド   初版  

VB実用⑦ エクセル操作Ⅰ

1. A/D 入力について分解能 12bit の A/D コンバータ入力です A/D 入力電圧とディジタル値との対応は理論上 入力電圧 0V : 0 入力電圧 +3V : 4095 です 実際はオフセットと傾きがあり ぴったりこの数値にはなりません 2. A/D 入力に使用する信号 STM32L_A

正規表現応用

データを TreeView コントロールで表示 VisualStudio2017 の Web サイトプロジェクトで bootstrap, 及び script フォルダの js ファイルが使用できるマスターページを親とする TestTreeView.aspx ページを作成します 下記の html コー

3D回転体プログラム

Canon Industrial Imaging Platform Vision Edition 使用説明書

チャットプログラム

C++ ++ Wago_io.dll DLLDynamicLinkLibrary Microsoft VisualBasic Visual C Wago_io.dll Wago_io.dll Wago_io.dll WAGO_OpenCommPort WAGO_CloseCommPort WAGO_

ListViewコントロール

TOEIC

Transcription:

Application Note Ref No: an2k-042 Last Modify 130123 テーマ MPC-IP で環境試験機の温湿度をモニタする使用機器 MPC-IP VB2010 Express 他 概要 監視室 試験室 VB アプリ WiFi ルータ ハブ 環境試験機 MPC-IP オンボード温湿度計で計測 製品の動作確認などを行う環境試験機の温湿度を別室でモニタします 温湿度の変化で工程の進捗状況を知ることができます 製品 (MPC) の稼動状態も確認しています アプリケーションノート an2k-041.pdf (MPC-2200 を使った温湿度ロガーに TPC アクセスする ) は日時と温湿度データを MPC-2200 の点データに蓄積 必要に応じて TCP 接続しますが 本サンプルは常時接続して MPC-IP オンボード温湿度計をリアルタイムに読み込んでいます VB アプリケーション ComboBox IP アドレス ComboBox ポート番号 TextBox MPC コマンド Label 時刻 温度 湿度 Label MPC コマンドレスポンス Chart X 軸が時刻 Y 軸が温度 ( 青 : ) と湿度 ( 橙 :%) MPC-2000 と接続して MPC コマンドで変数や I/O などの状態を監視することもできます ACCEL page 1

VB プログラム Form1.vb メイン画面 Imports System.Windows.Forms.DataVisualization.Charting Imports System Imports System.Net Imports System.Net.Sockets Imports System.Text Imports System.Threading.Thread Public Class Form1 Dim runable As Boolean = False Dim chart_x_cnt As Integer = 0 ''' [Connect] TCP 接続 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim ver As String = "" Dim res As Integer = 0 Dim Stream_Name As String Dim PortNum As Integer Stream_Name = ComboBox1.Text PortNum = Val(ComboBox2.Text) TcpClientA = New TcpClient() TcpClientA.Connect(Stream_Name, PortNum) ToolStripStatusLabel1.Text = "Connect" MyStreamA = TcpClientA.GetStream() If MPCIP.set_stream_timout(MyStreamA, 20000, 20000, res) < 1 Then Throw New Exception("set_stream_timout") If MPCIP.set_stream_ID(MyStreamA, Stream_Name, res) < 1 Then Throw New Exception("set_stream_ID") If MPCIP.set_mewnet_tmout(MyStreamA, 2000, res) < 1 Then Throw New Exception("set_mewnet_tmout") Button1.Enabled = False Button3.Enabled = True Button3.Focus() Panel2.Enabled = True MsgBox("Error " & vbcrlf & ex.message & " (" + res.tostring & ")") End Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ComboBox1.Text = "192.168.0.110" ComboBox1.Items.Add("192.168.0.110") ComboBox1.Items.Add("192.168.0.111") ComboBox2.Text = "50001" ComboBox2.Items.Add("50001") ComboBox2.Items.Add("50002") ComboBox3.Text = "1" ComboBox3.Items.Add("1") ComboBox3.Items.Add("2") ComboBox3.Items.Add("5") ComboBox3.Items.Add("10") ComboBox3.Items.Add("60") Label1.Text = "" Label2.Text = "" ToolStripStatusLabel1.Text = "" ToolStripStatusLabel2.Text = "" ToolStripStatusLabel3.Text = "" 'MPC コマンド TextBox1.Text = "PR SYSCLK TIME$(0) IN(0) IN(24)" ACCEL page 2

Panel1.Dock = DockStyle.Top Chart1.Dock = DockStyle.Fill Panel2.Enabled = False ChartClear(Chart1) Button3.Enabled = False Button4.Enabled = False ''' Timer で定期的に温湿度を計測 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim temp As Double Dim humi As Double Dim res As Integer Dim cmd As String = "" Dim ret As String = "" Dim date_str As String Dim time_str As String Dim min_str As String Dim sec_str As String Static write_flg As Boolean = False Static rec_start As Boolean = False Static temp_max As Double = -100 Static temp_min As Double = 100 Static humi_max As Double = -100 Static humi_min As Double = 100 Timer1.Enabled = False If runable = False Then Exit Sub ' PC の現在日時取得 min_str = Now.Minute.ToString("D2") sec_str = Now.Second.ToString("D2") date_str = String.Format("{0:0000}/{1:00}/{2:00}", Now.Year.ToString("D4"), Now.Month.ToString("D2"), Now.Day.ToString("D2")) time_str = String.Format("{0:00}:{1:00}:{2:00}", Now.Hour.ToString("D2"), min_str, sec_str) ' MPC-IP オンボード温湿度計読込 If MPCIP.temp_measure(MyStreamA, temp, humi, res) < 1 Then Throw New Exception("temp_measure") ' 温湿度の最低最高を記録する If temp < temp_min Then temp_min = temp If temp > temp_max Then temp_max = temp ToolStripStatusLabel2.Text = " Temp Max " & temp_max.tostring("f2") & " Min " & temp_min.tostring("f2") + " " If humi < humi_min Then humi_min = humi If humi > humi_max Then humi_max = humi ToolStripStatusLabel3.Text = " Humi Max " & humi_max.tostring("f2") & "% Min " & humi_min.tostring("f2") + "%" "%" Label1.Text = "[ " & time_str & " ] " & temp.tostring("f2") + " " + humi.tostring("f2") + ' 2 分間隔 ( 偶数分 ) で Chart に入れていく If ((Val(min_str(1)) Mod 2) = 0) Then If (write_flg = False) And (rec_start = True) Then Chart1.Series("Temp").Points.AddY(temp) Chart1.Series("Humi").Points.AddY(humi) Chart1.ChartAreas(0).AxisX.CustomLabels.Add((chart_x_cnt + 1) * 2, 0, time_str.substring(0, 8)) ACCEL page 3

chart_x_cnt = chart_x_cnt + 1 write_flg = True Else write_flg = False rec_start = True ' CheckBox1 がチェックなら MPC コマンドを実行する If CheckBox1.Checked = True Then cmd = TextBox1.Text If MPCIP.mpc_cmd(MyStreamA, cmd, ret, res) < 1 Then Throw New Exception(cmd) Label2.Text = ret Timer1.Interval = CInt(ComboBox3.Text) * 1000 Timer1.Enabled = True MsgBox("Error" & vbcrlf & ex.message + " (" + res.tostring + ")") runable = False Button3.Enabled = True Button4.Enabled = False End ''' Chart を初期状態にする Private Sub ChartClear(ByVal cht As Chart) Dim customlabel1 As New CustomLabel With cht.titles.clear() ' タイトルの初期化.BackGradientStyle = GradientStyle.None ' 背景グラデーション.BorderSkin.PageColor = SystemColors.ButtonFace ' 外形をデフォルトに.BorderSkin.SkinStyle = BorderSkinStyle.None.Legends.Clear() ' 凡例の初期化.Legends.Add("Legend1").Legends("Legend1").Alignment = StringAlignment.Center.Legends("Legend1").Docking = Docking.Top らしい.Series.Clear() ' 系列 ( データ関係 ) の初期化.ChartAreas.Clear() ' 軸メモリ 3D 表示関係の初期化.ChartAreas.Add("ChartArea1").ChartAreas("ChartArea1").Position = New ElementPosition(0, 10, 98, 90) ' 後ろのパラメータは %.Annotations.Clear().DataSource = Nothing ' グラフの注釈.Series.Add("Temp").Series.Add("Humi").Series("Temp").ChartType = SeriesChartType.Line.Series("Humi").ChartType = SeriesChartType.Line.Series("Temp").BorderWidth = 2.Series("Humi").BorderWidth = 2.ChartAreas(0).AxisX.CustomLabels.Add(customLabel1).ChartAreas(0).AxisX.LabelAutoFitMaxFontSize = 9.ChartAreas(0).AxisX.LabelAutoFitMinFontSize = 9.ChartAreas(0).AxisX.MajorGrid.Enabled = True.ChartAreas(0).AxisX.MajorGrid.LineColor = Color.Silver.ChartAreas(0).AxisX.MajorTickMark.Enabled = False.ChartAreas(0).AxisX.Interval = 1.ChartAreas(0).AxisY.Maximum = 100.ChartAreas(0).AxisY.Minimum = -10.ChartAreas(0).AxisY.MajorGrid.Interval = 10.ChartAreas(0).AxisY.Interval = 10.ChartAreas(0).AxisY.MinorGrid.Enabled = True.ChartAreas(0).AxisY.MinorGrid.LineColor = Color.Silver ACCEL page 4

End With Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Close() ''' [Start] 計測開始 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If Chart1.Series("Temp").Points.Count > 0 Then If MsgBox("Do you want to clear the Chart?", vbyesno) = vbyes Then ChartClear(Chart1) chart_x_cnt = 0 Timer1.Interval = 100 Timer1.Enabled = True runable = True TextBox1.Enabled = False Button3.Enabled = False Button4.Enabled = True Button4.Focus() ''' [Stop] 計測停止 Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click runable = False Button3.Enabled = True Button4.Enabled = False TextBox1.Enabled = True ''' [SYSCLK=0] MPC の SYSLCK を 0 にする Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Dim res As Integer Dim cmd As String = "" Dim ret As String = "" cmd = "SYSCLK=0" If MPCIP.mpc_cmd(MyStreamA, cmd, ret, res) < 1 Then Throw New Exception(cmd) MsgBox("Error" & vbcrlf & ex.message + " (" + res.tostring + ")") End ''' [SET_RTC] MPCの時計を調整する Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Dim res As Integer Dim ret As String = "" Dim date_str As String Dim time_str As String date_str = String.Format("&H{0:0000}{1:00}{2:00}", Now.Year.ToString("D4"), Now.Month.ToString("D2"), Now.Day.ToString("D2")) 'date_str = "&H20100123" ' debug time_str = String.Format("&H{0:0000}{1:00}{2:00}", Now.Hour.ToString("D4"), ACCEL page 5

Now.Minute.ToString("D2"), Now.Second.ToString("D2")) 'time_str = "&H00123456" ' debug If MPCIP.mpc_cmd(MyStreamA, "SET_RTC " + date_str, ret, res) < 1 Then Throw New Exception("SET_RTC date ") If MPCIP.mpc_cmd(MyStreamA, "SET_RTC " + time_str, ret, res) < 1 Then Throw New Exception("SET_RTC time ") End Class Dim buf As String buf = " 年月日 " + date_str + vbcrlf buf = buf & " 時分秒 " + time_str + vbcrlf + " にセットしました " MsgBox(buf) MsgBox("Error" & vbcrlf & ex.message + " (" + res.tostring + ")") End Module1.vb Imports System.Net Imports System.Net.Sockets Module Module1 Public MPCIP As New ACClass.MPCIP Public TcpClientA As New TcpClient() Public MyStreamA As NetworkStream Public MyStreamA_Name As String End Module --- End Of Doc --- ACCEL page 6