public Form1() { InitializeComponent(); m_b5000 = true; // set to true for module on ADAM-5000; set to false for module on ADAM-5000/TCP if (m_b5000) { m_iCom = 4; // using COM4 adamCom = new AdamCom(m_iCom); adamCom.Checksum = false; // disbale checksum } else { m_szIP = "172.18.3.179"; adamSocket = new AdamSocket(); adamSocket.SetTimeout(1000, 1000, 1000); // set timeout } m_iAddr = 3; // the slave address is 1 m_iSlot = 0; // the slot index of the module m_iCount = 0; // the counting start from 0 m_bStart = false; m_Adam5000Type = Adam5000Type.Adam5017H; // the sample is for ADAM-5017H //m_Adam5000Type = Adam5000Type.Adam5017UH; // the sample is for ADAM-5017UH //m_Adam5000Type = Adam5000Type.Adam5018P; // the sample is for ADAM-5018P m_iChTotal = AnalogInput.GetChannelTotal(m_Adam5000Type); m_byRange = new byte[m_iChTotal]; txtModule.Text = m_Adam5000Type.ToString(); // if (m_Adam5000Type == Adam5000Type.Adam5018P) { chkboxCh7.Visible = false; txtAIValue7.Visible = false; } }
public Form1() { InitializeComponent(); int iIdx; m_bStart = false; // the action stops at the beginning m_szIP = "172.18.3.200"; // modbus slave IP address m_iPort = 502; // modbus TCP port is 502 adamModbus = new AdamSocket(); adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP m_Adam6000Type = Adam6000Type.Adam6024; // the sample is for ADAM-6050 // modbus current list view item m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type); m_iDiTotal = DigitalInput.GetChannelTotal(m_Adam6000Type); m_iAoTotal = AnalogOutput.GetChannelTotal(m_Adam6000Type); m_iDoTotal = DigitalOutput.GetChannelTotal(m_Adam6000Type); m_bChEnabled = new bool[m_iAiTotal]; m_byAiRange = new byte[m_iAiTotal]; m_byAoRange = new byte[m_iAoTotal]; for (iIdx = 0; iIdx < m_iAoTotal; iIdx++) { // cbxAOChannel.Items.Add(iIdx.ToString()); // } cbxAOChannel.SelectedIndex = -1; txtModule.Text = m_Adam6000Type.ToString(); }
public void info() { #region 定义模块参数 // m_bStart = false; // the action stops at the beginning m_szIP1 = "10.0.0.2"; // modbus slave IP address m_szIP2 = "10.0.0.3"; // modbus slave IP address m_szIP3 = "10.0.0.4"; // modbus slave IP address m_szIP4 = "10.0.0.5"; // modbus slave IP address m_szIP5 = "10.0.0.6"; // modbus slave IP address m_szIP6 = "10.0.0.7"; // modbus slave IP address m_szIP7 = "10.0.0.8"; // modbus slave IP address m_szIP8 = "10.0.0.9"; // modbus slave IP address m_szIP9 = "10.0.0.10"; // modbus slave IP address m_iPort = 502; // modbus TCP port is 502 adamModbus1 = new AdamSocket(); adamModbus1.SetTimeout(500, 500, 500); // 设置超时时间 adamModbus1.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for ADAM-6217 adamModbus2 = new AdamSocket(); adamModbus2.SetTimeout(500, 500, 500); // 设置超时时间 adamModbus2.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for ADAM-6217 adamModbus3 = new AdamSocket(); adamModbus3.SetTimeout(500, 500, 500); // 设置超时时间 adamModbus3.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for ADAM-6217 adamModbus4 = new AdamSocket(); adamModbus4.SetTimeout(500, 500, 500); // 设置超时时间 adamModbus4.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for ADAM-6217 adamModbus5 = new AdamSocket(); adamModbus5.SetTimeout(500, 500, 500); // 设置超时时间 adamModbus5.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for ADAM-6217 adamModbus6 = new AdamSocket(); adamModbus6.SetTimeout(500, 500, 500); // 设置超时时间 adamModbus6.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for ADAM-6217 adamModbus7 = new AdamSocket(); adamModbus7.SetTimeout(500, 500, 500); // 设置超时时间 adamModbus7.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for ADAM-6217 adamModbus8 = new AdamSocket(); adamModbus8.SetTimeout(500, 500, 500); // 设置超时时间 adamModbus8.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for ADAM-6217 adamModbus9 = new AdamSocket(); adamModbus9.SetTimeout(500, 500, 500); // 设置超时时间 adamModbus9.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for ADAM-6217 m_Adam6000Type = Adam6000Type.Adam6217; // the sample is for ADAM-6217 m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type); m_bChEnabled = new bool[m_iAiTotal]; m_byRange = new ushort[m_iAiTotal]; #endregion red_net = new Thread(red); red_net.Start(); }
private ushort[] m_usRange; //for newer version void Application_Start(object sender, EventArgs e) { // Code that runs on application startup RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); Database.SetInitializer(new CpDashboardDatabaseInitializer()); RouteTable.Routes.MapHttpRoute( name: "Alert", routeTemplate: "api/{controller}/{id}", defaults: new { id = System.Web.Http.RouteParameter.Optional } ); CpDashboardContext cont = new CpDashboardContext(); cont.Database.Initialize(true); cont.Database.CreateIfNotExists(); //set a timer //adam initializer m_bStart = false; // the action stops at the beginning m_szIP = "192.168.10.10"; // modbus slave IP address m_iPort = 502; // modbus TCP port is 502 adamModbus = new AdamSocket(); adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP adamUDP = new AdamSocket(); adamUDP.SetTimeout(1000, 1000, 1000); // set timeout for UDP m_Adam6000Type = Adam6000Type.Adam6015; // the sample is for ADAM-6015 adamUDP.Connect(AdamType.Adam6000, m_szIP, ProtocolType.Udp); if (adamUDP.Configuration().GetFirmwareVer(out m_szFwVersion)) { m_DeviceFwVer = int.Parse(m_szFwVersion.Trim().Substring(0, 1)); } adamUDP.Disconnect(); m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type); m_iDoTotal = DigitalOutput.GetChannelTotal(m_Adam6000Type); //txtModule.Text = m_Adam6000Type.ToString(); m_bChEnabled = new bool[m_iAiTotal]; //firmware version //fwversion.Text = m_DeviceFwVer.ToString(); if (m_DeviceFwVer > m_Adam6000NewerFwVer) { m_usRange = new ushort[m_iAiTotal]; } if (cont.Database.Exists()) { // start the retrieving datas and save to db; startSending(); } }
/// <summary> /// 初始化modbus配置 /// </summary> private void Initalize() { modbusStart = false; adamModbus.AdamSeriesType = adamSeries; channelTotal = AnalogInput.GetChannelTotal(adamType); channelEnabled = new bool[channelTotal]; channelRange = new ushort[channelTotal]; SetTimeOut(); }
private void RefreshAdam5000Information() { int iIdx; byte byCode; Adam5000Type adamType; adamType = (Adam5000Type)cbxModuleType.SelectedItem; // AI information txtAITotal.Text = AnalogInput.GetChannelTotal(adamType).ToString(); listViewAI.Items.Clear(); for (iIdx = 0; iIdx < AnalogInput.GetRangeTotal(adamType); iIdx++) { byCode = AnalogInput.GetRangeCode(adamType, iIdx); listViewAI.Items.Add(new ListViewItem("0x" + byCode.ToString("X02"))); // range code listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetRangeName(adamType, byCode)); // range name listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetUnitName(adamType, byCode)); // range name } // AO information txtAOTotal.Text = AnalogOutput.GetChannelTotal(adamType).ToString(); listViewAO.Items.Clear(); for (iIdx = 0; iIdx < AnalogOutput.GetRangeTotal(adamType); iIdx++) { byCode = AnalogOutput.GetRangeCode(adamType, iIdx); listViewAO.Items.Add(new ListViewItem("0x" + byCode.ToString("X02"))); // range code listViewAO.Items[iIdx].SubItems.Add(AnalogOutput.GetRangeName(adamType, byCode)); // range name listViewAO.Items[iIdx].SubItems.Add(AnalogOutput.GetUnitName(adamType, byCode)); // range name } // DIO txtDITotal.Text = DigitalInput.GetChannelTotal(adamType).ToString(); txtDOTotal.Text = DigitalOutput.GetChannelTotal(adamType).ToString(); // counter txtCounterTotal.Text = Counter.GetChannelTotal(adamType).ToString(); listViewCounter.Items.Clear(); if (Counter.GetModeTotal(adamType) > 0) { listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam5080_CounterMode.Bi_Direction))); // mode name listViewCounter.Items[0].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam5080_CounterMode.Bi_Direction)); // unit name listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam5080_CounterMode.Up_Down))); // mode name listViewCounter.Items[1].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam5080_CounterMode.Up_Down)); // unit name listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam5080_CounterMode.Frequency))); // mode name listViewCounter.Items[2].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam5080_CounterMode.Frequency)); // unit name } // alarm listViewAlarm.Items.Clear(); for (iIdx = 0; iIdx < Alarm.GetModeTotal(adamType); iIdx++) { byCode = Alarm.GetModeCode(adamType, iIdx); listViewAlarm.Items.Add(new ListViewItem(Alarm.GetModeName(adamType, byCode))); // mode name } }
public Adam6000(string name, Adam6000Type model) : base(name, new ChannelsInfo { AnalogInputsCount = AnalogInput.GetChannelTotal(model), AnalogOutputsCount = AnalogOutput.GetChannelTotal(model), DiscreteInputsCount = DigitalInput.GetChannelTotal(model), DiscreteOutputsCount = DigitalOutput.GetChannelTotal(model), CounterInputsCount = DigitalInput.GetChannelTotal(model) }) { Model = model; if (AnalogInputs != null) { AIRanges = new List <byte>(new byte[AnalogInputs.Count]); } }
public Form1() { InitializeComponent(); m_iCom = 4; // using COM1 m_iAddr = 1; // the slave address is 1 m_iCount = 0; // the counting start from 0 m_bStart = false; m_Adam4000Type = Adam4000Type.Adam4018M; // the sample is for ADAM-4018M m_iChTotal = AnalogInput.GetChannelTotal(m_Adam4000Type); m_bCh = new bool[m_iChTotal]; adamCom = new AdamCom(m_iCom); adamCom.Checksum = false; // disbale checksum txtModule.Text = m_Adam4000Type.ToString(); }
public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // m_iSlot = 1; // the slot index of the module m_iCount = 0; // the counting start from 0 m_bStart = false; adamCtl = new AdamControl(); //m_Adam5000Type = Adam5000Type.Adam5013; // the sample is for ADAM-5013 //m_Adam5000Type = Adam5000Type.Adam5017; // the sample is for ADAM-5017 m_Adam5000Type = Adam5000Type.Adam5018; // the sample is for ADAM-5018 m_iChTotal = AnalogInput.GetChannelTotal(m_Adam5000Type); txtModule.Text = m_Adam5000Type.ToString(); // if (m_Adam5000Type == Adam5000Type.Adam5013) { chkboxCh3.Visible = false; txtAIValue3.Visible = false; chkboxCh4.Visible = false; txtAIValue4.Visible = false; chkboxCh5.Visible = false; txtAIValue5.Visible = false; chkboxCh6.Visible = false; txtAIValue6.Visible = false; chkboxCh7.Visible = false; txtAIValue7.Visible = false; } else if (m_Adam5000Type == Adam5000Type.Adam5018) { chkboxCh7.Visible = false; txtAIValue7.Visible = false; } }
public void Initialize() { m_bStart = false; // the action stops at the beginning m_szIP = "192.168.1.3"; // modbus slave IP address m_iPort = 502; // modbus TCP port is 502 adamModbus = new AdamSocket(); adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP adamModbus.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for ADAM-6217 m_Adam6000Type = Adam6000Type.Adam6217; // the sample is for ADAM-6217 m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type); //channel number m_bChEnabled = new bool[m_iAiTotal]; m_byRange = new ushort[m_iAiTotal]; fValue = new float[m_iAiTotal]; pool = new MysqlConnectionPool(); Connect2Adam(); }
public VoltageController(VM_MSConfig msConfig) { Config = msConfig; m_iCom = 3; // using COM4 m_iAddr = 1; // the slave address is 1 m_iCount = 0; // the counting start from 0 m_bStart = false; m_Adam4000Type = Adam4000Type.Adam4019P; // the sample is for ADAM-4019P m_iChTotal = AnalogInput.GetChannelTotal(m_Adam4000Type); m_byRange = new byte[m_iChTotal]; adamCom = new AdamCom(m_iCom); adamCom.Checksum = false; // disbale checksum Module = m_Adam4000Type.ToString(); if (adamCom.OpenComPort()) { // set COM port state, 9600,N,8,1 adamCom.SetComPortState(Baudrate.Baud_9600, Databits.Eight, Parity.None, Stopbits.One); // set COM port timeout adamCom.SetComPortTimeout(500, 500, 0, 500, 0); m_iCount = 0; // reset the reading counter // get module config if (!adamCom.Configuration(m_iAddr).GetModuleConfig(out m_adamConfig)) { adamCom.CloseComPort(); LogHelper.WriteErrorLog("Failed to get module config!"); return; } // RefreshChannelEnable(); RefreshChannelRange(); // m_bStart = true; // starting flag } else { LogHelper.WriteErrorLog("Failed to open COM port!"); } }
public AdamRetriever(int sensorNum) { sensorStatus = "false"; sensorNumber = sensorNum; m_bStart = false; // the action stops at the beginning m_szIP = "192.168.10.10"; // modbus slave IP address m_iPort = 502; // modbus TCP port is 502 adamModbus = new AdamSocket(); adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP adamUDP = new AdamSocket(); adamUDP.SetTimeout(1000, 1000, 1000); // set timeout for UDP m_Adam6000Type = Adam6000Type.Adam6015; // the sample is for ADAM-6015 adamUDP.Connect(AdamType.Adam6000, m_szIP, ProtocolType.Udp); if (adamUDP.Configuration().GetFirmwareVer(out m_szFwVersion)) { m_DeviceFwVer = int.Parse(m_szFwVersion.Trim().Substring(0, 1)); } adamUDP.Disconnect(); m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type); m_iDoTotal = DigitalOutput.GetChannelTotal(m_Adam6000Type); //txtModule.Text = m_Adam6000Type.ToString(); m_bChEnabled = new bool[m_iAiTotal]; //firmware version //fwversion.Text = m_DeviceFwVer.ToString(); if (m_DeviceFwVer > m_Adam6000NewerFwVer) { m_usRange = new ushort[m_iAiTotal]; } // start the retrieving datas and save to db; startRetrieving(); }
public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // m_iSlot = 4; // the slot index of the module m_iCount = 0; // the counting start from 0 m_bStart = false; adamCtl = new AdamControl(); m_Adam5000Type = Adam5000Type.Adam5017UH; // the sample is for ADAM-5017UH m_iChTotal = AnalogInput.GetChannelTotal(m_Adam5000Type); m_byRange = new byte[m_iChTotal]; txtModule.Text = m_Adam5000Type.ToString(); }
public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // m_bStart = false; // the action stops at the beginning m_szIP = "172.18.3.189"; // modbus slave IP address m_iPort = 502; // modbus TCP port is 502 adamModbus = new AdamSocket(); adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP adamModbus.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for ADAM-6217 m_Adam6000Type = Adam6000Type.Adam6217; // the sample is for ADAM-6217 m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type); txtModule.Text = m_Adam6000Type.ToString(); m_bChEnabled = new bool[m_iAiTotal]; m_byRange = new ushort[m_iAiTotal]; }
private ushort[] m_usRange; //for newer version public Form1() { InitializeComponent(); m_bStart = false; // the action stops at the beginning m_szIP = "172.18.3.222"; // modbus slave IP address m_iPort = 502; // modbus TCP port is 502 adamModbus = new AdamSocket(); adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP adamUDP = new AdamSocket(); adamUDP.SetTimeout(1000, 1000, 1000); // set timeout for UDP m_Adam6000Type = Adam6000Type.Adam6015; // the sample is for ADAM-6015 //m_Adam6000Type = Adam6000Type.Adam6017; // the sample is for ADAM-6017 //m_Adam6000Type = Adam6000Type.Adam6018; // the sample is for ADAM-6018 adamUDP.Connect(AdamType.Adam6000, m_szIP, ProtocolType.Udp); if (adamUDP.Configuration().GetFirmwareVer(out m_szFwVersion)) { m_DeviceFwVer = int.Parse(m_szFwVersion.Trim().Substring(0, 1)); } adamUDP.Disconnect(); m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type); m_iDoTotal = DigitalOutput.GetChannelTotal(m_Adam6000Type); txtModule.Text = m_Adam6000Type.ToString(); m_bChEnabled = new bool[m_iAiTotal]; if (m_DeviceFwVer < m_Adam6000NewerFwVer) { m_byRange = new byte[m_iAiTotal]; } else { //for newer version Adam6017 m_usRange = new ushort[m_iAiTotal]; } // arrange channel text box if (m_Adam6000Type == Adam6000Type.Adam6015) { // Channel chkboxCh7.Visible = false; txtAIValue7.Visible = false; // DO panelDO.Visible = false; } else if (m_Adam6000Type == Adam6000Type.Adam6017) { // DO btnCh2.Visible = false; txtCh2.Visible = false; btnCh3.Visible = false; txtCh3.Visible = false; btnCh4.Visible = false; txtCh4.Visible = false; btnCh5.Visible = false; txtCh5.Visible = false; btnCh6.Visible = false; txtCh6.Visible = false; btnCh7.Visible = false; txtCh7.Visible = false; } else //Adam6018 { ; } }
private void RefreshAdam6000Information() { byte byCode; ushort usCode; int intAdamType; Adam6000Type adamType; adamType = (Adam6000Type)cbxModuleType.SelectedItem; intAdamType = (int)adamType; // AI information txtAITotal.Text = AnalogInput.GetChannelTotal(adamType).ToString(); listViewAI.Items.Clear(); if ((intAdamType == 6017) || ((intAdamType >= 6217) && (intAdamType <= 6224))) { for (int iIdx = 0; iIdx < AnalogInput.GetRangeTotal(adamType, Adam6000_RangeFormat.Ushort); iIdx++) { usCode = AnalogInput.GetRangeCode2Byte(adamType, iIdx); listViewAI.Items.Add(new ListViewItem("0x" + usCode.ToString("X04"))); // range code listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetRangeName(adamType, usCode)); // range name listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetUnitName(adamType, usCode)); // unit name } } else { for (int iIdx = 0; iIdx < AnalogInput.GetRangeTotal(adamType, Adam6000_RangeFormat.Byte); iIdx++) { byCode = AnalogInput.GetRangeCode(adamType, iIdx); listViewAI.Items.Add(new ListViewItem("0x" + byCode.ToString("X02"))); // range code listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetRangeName(adamType, byCode)); // range name listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetUnitName(adamType, byCode)); // unit name } } // AO information txtAOTotal.Text = AnalogOutput.GetChannelTotal(adamType).ToString(); listViewAO.Items.Clear(); if ((intAdamType >= 6217) && (intAdamType <= 6224)) { for (int iIdx = 0; iIdx < AnalogOutput.GetRangeTotal(adamType, Adam6000_RangeFormat.Ushort); iIdx++) { usCode = AnalogOutput.GetRangeCode2Byte(adamType, iIdx); listViewAO.Items.Add(new ListViewItem("0x" + usCode.ToString("X04"))); // range code listViewAO.Items[iIdx].SubItems.Add(AnalogInput.GetRangeName(adamType, usCode)); // range name listViewAO.Items[iIdx].SubItems.Add(AnalogInput.GetUnitName(adamType, usCode)); // unit name } } else { for (int iIdx = 0; iIdx < AnalogInput.GetRangeTotal(adamType, Adam6000_RangeFormat.Byte); iIdx++) { byCode = AnalogOutput.GetRangeCode(adamType, iIdx); listViewAO.Items.Add(new ListViewItem("0x" + byCode.ToString("X02"))); // range code listViewAO.Items[iIdx].SubItems.Add(AnalogOutput.GetRangeName(adamType, byCode)); // range name listViewAO.Items[iIdx].SubItems.Add(AnalogOutput.GetUnitName(adamType, byCode)); // range name } } // DIO txtDITotal.Text = DigitalInput.GetChannelTotal(adamType).ToString(); txtDOTotal.Text = DigitalOutput.GetChannelTotal(adamType).ToString(); // counter txtCounterTotal.Text = Counter.GetChannelTotal(adamType).ToString(); listViewCounter.Items.Clear(); if (Counter.GetModeTotal(adamType) > 0) { listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam6051_CounterMode.Counter))); // mode name listViewCounter.Items[0].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam6051_CounterMode.Counter)); // unit name listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam6051_CounterMode.Frequency))); // mode name listViewCounter.Items[1].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam6051_CounterMode.Frequency)); // unit name } // alarm listViewAlarm.Items.Clear(); for (int iIdx = 0; iIdx < Alarm.GetModeTotal(adamType); iIdx++) { byCode = Alarm.GetModeCode(adamType, iIdx); listViewAlarm.Items.Add(new ListViewItem(Alarm.GetModeName(adamType, byCode))); // mode name } }
public bool Connect() { _adamSocket = new AdamSocket(); _channelsTotal = AnalogInput.GetChannelTotal(adamtype); return(_adamSocket.Connect(AdamType.Adam6000, ip, ProtocolType.Tcp)); }