760 lines
39 KiB
C#
760 lines
39 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Text;
|
|||
|
using DBFactory;
|
|||
|
using ICommLayer;
|
|||
|
using System.Data;
|
|||
|
using Microsoft.VisualBasic;
|
|||
|
namespace OPCClient
|
|||
|
{
|
|||
|
public class CGetDeviceState:IGetDeviceState
|
|||
|
{
|
|||
|
string _commLayerError;
|
|||
|
|
|||
|
public string CommLayerError
|
|||
|
{
|
|||
|
get { return _commLayerError; }
|
|||
|
set { _commLayerError = value; }
|
|||
|
}
|
|||
|
DBOperator dbo = CCommonOPCClient.dbo;
|
|||
|
public CGetDeviceState()
|
|||
|
{
|
|||
|
dbo.Open();
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
///1<><31><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>Ϣ
|
|||
|
///<2F><><EFBFBD><EFBFBD>أ<EFBFBD> 0-<2D><EFBFBD>1-<2D>л<EFBFBD>
|
|||
|
///ȷ<>ϰ<EFBFBD>ť<EFBFBD><C5A5>
|
|||
|
///<2F><>1<EFBFBD>ֽڣ<D6BD>
|
|||
|
///һ<><D2BB><EFBFBD>仯<EFBFBD><E4BBAF>ֵ<EFBFBD><D6B5>ÿȷ<C3BF><C8B7>һ<EFBFBD>Σ<EFBFBD><CEA3><EFBFBD>ֵ<EFBFBD>仯һ<E4BBAF>Σ<EFBFBD><CEA3>Ա<EFBFBD>־һ<D6BE><D2BB>
|
|||
|
///<2F>µ<EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD>仯<EFBFBD><E4BBAF>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>
|
|||
|
///<2F><><EFBFBD>仯<EFBFBD><E4BBAF>
|
|||
|
///<2F><>2<EFBFBD>ֽڣ<D6BD>
|
|||
|
///1-<2D><EFBFBD>ȷ<EFBFBD><C8B7>
|
|||
|
///2-<2D>л<EFBFBD>ȷ<EFBFBD><C8B7>
|
|||
|
///<2F><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>
|
|||
|
///<2F><>1<EFBFBD><31> <09>ڣ<EFBFBD><DAA3>豸״̬
|
|||
|
///<2F>Ѷ<EFBFBD><D1B6><EFBFBD><EFBFBD><EFBFBD>0-<2D><><EFBFBD><EFBFBD>
|
|||
|
///1-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
///2-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
///3-Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
///4-֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|||
|
///<2F><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|||
|
/// <20><><EFBFBD><EFBFBD>
|
|||
|
/// 0-<2D><><EFBFBD><EFBFBD>
|
|||
|
/// 1-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// 2-<2D><><EFBFBD><EFBFBD>
|
|||
|
/// 3-Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// 4-֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|||
|
/// <20><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|||
|
/// <20><><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>
|
|||
|
/// 0-<2D><><EFBFBD><EFBFBD>
|
|||
|
/// 1-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// 2-<2D><><EFBFBD>ɣ<EFBFBD>ֻ<EFBFBD><D6BB>PC<50>·<EFBFBD><C2B7><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㱨<EFBFBD><E3B1A8><EFBFBD>ɣ<EFBFBD>
|
|||
|
/// <20><><EFBFBD>ϻ<EFBFBD><CFBB><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
|||
|
/// <20><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|||
|
/// <20><>2<EFBFBD><32>3<EFBFBD>ֽڣ<D6BD> <20><><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>´<EFBFBD><C2B4><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// <20><>4<EFBFBD><34>5<EFBFBD><35>6<EFBFBD><36>7<EFBFBD>ֽ<EFBFBD>
|
|||
|
/// <20>Ѷ<EFBFBD><D1B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// <20>յ<EFBFBD>X<EFBFBD><58><EFBFBD>꣨<EFBFBD>ع<EFBFBD><D8B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// <20><><EFBFBD><EFBFBD>8<EFBFBD>ֽ<EFBFBD><D6BD>Ժ<D4BA>ֻ<EFBFBD>ԶѶ<D4B6><D1B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>壩
|
|||
|
/// <20><>8<EFBFBD><38>9<EFBFBD><39>10<31><30>11<31>ֽ<EFBFBD>
|
|||
|
/// <20>յ<EFBFBD>Y<EFBFBD><59><EFBFBD>꣨<EFBFBD>ظ߶ȷ<DFB6><C8B7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
///
|
|||
|
/// 2.<2E><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룺
|
|||
|
/// <20><>1-10<31>ֽڣ<D6BD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>10λ<30><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD>룺
|
|||
|
/// <20><>1-9<>ֽڣ<D6BD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵĺ<CFB5>9λһ<CEBB>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
/// һ<>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>32λ<32><CEBB><EFBFBD><EFBFBD>ͬƷ<CDAC><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ23λ<33><CEBB>ͬ<EFBFBD><CDAC>
|
|||
|
/// <20><><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD>ź<EFBFBD>9λ<39><CEBB><EFBFBD>롣ÿ<EBA1A3><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>̿<EFBFBD><CCBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// <20><>18<31><38><EFBFBD>ֽڣ<D6BD><DAA3><EFBFBD>λ<EFBFBD><CEBB>һ<EFBFBD>ν<EFBFBD><CEBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣͬʱ<CDAC><CAB1>ȡ<EFBFBD><C8A1>
|
|||
|
/// <20><>λ<EFBFBD><CEBB><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>ȡ18<31><38><EFBFBD>ֽں<DABA><F3A3ACB0><EFBFBD>18<31><38><EFBFBD>ֽ<EFBFBD>ȫ<EFBFBD><C8AB>д<EFBFBD><D0B4><EFBFBD>㣬
|
|||
|
/// <20><>λ<EFBFBD><CEBB>ֻ<EFBFBD>м<EFBFBD><D0BC>18<31><38><EFBFBD>ֽ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ſ<EFBFBD><C5BF><EFBFBD>д<EFBFBD><D0B4><EFBFBD>µ<EFBFBD>һ<EFBFBD>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>
|
|||
|
///
|
|||
|
/// 3.<2E><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD><EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
|||
|
/// <20><>1<EFBFBD>ֽ<EFBFBD> <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
|||
|
/// 1- <09>ط<EFBFBD><D8B7><EFBFBD>ǰ<EFBFBD>豸ָ<E8B1B8><D6B8>
|
|||
|
/// 2- <09><><EFBFBD><EFBFBD><EFBFBD>ĵ<DEB8>ǰ<EFBFBD>豸<EFBFBD><E8B1B8>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>λ<EFBFBD><CEBB>
|
|||
|
/// <20><>2<EFBFBD><32>3<EFBFBD>ֽ<EFBFBD> <09>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// <20><>4<EFBFBD><34>5<EFBFBD>ֽ<EFBFBD> <09><><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD>Ҫ<EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>λ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>
|
|||
|
/// <20><>6<EFBFBD><36>15<31>ֽ<EFBFBD> <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>루<EFBFBD><EBA3A8>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD>룩
|
|||
|
/// <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F2BFAAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>䶪ʧ<E4B6AA><CAA7>
|
|||
|
/// <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// <20><>λ<EFBFBD><CEBB><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>͵<EFBFBD>ǰ<EFBFBD>豸<EFBFBD><E8B1B8>ָ<EFBFBD>
|
|||
|
/// <20><><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>λ<EFBFBD>á<EFBFBD>
|
|||
|
/// <20><>λ<EFBFBD><CEBB><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>µ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<DEB8><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD>Ŀ<EFBFBD><C4BF>λ<EFBFBD>á<EFBFBD>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>Ϊ1ʱ<31><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ſ<EFBFBD><C5BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>Ϊ2ʱ<32><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>
|
|||
|
/// </summary>
|
|||
|
/// <param name="DeviceIndex"><3E>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD></param>
|
|||
|
/// <returns><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><F3A3ACB7><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>22<32><32><EFBFBD>ֵ<EFBFBD>״̬</returns>
|
|||
|
public int[] GetDeviceState(int DeviceIndex, int TaskIndex)
|
|||
|
{//20091107
|
|||
|
//string[] itemnames;
|
|||
|
int[] _Rword = new int[20];
|
|||
|
//string[] www;
|
|||
|
//string[] wi;
|
|||
|
//int add = 0;
|
|||
|
//int Bit = 0;
|
|||
|
//string ivalue;
|
|||
|
//List< string> itemvalue = new List<string>();
|
|||
|
Model.MDevice devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIndex);
|
|||
|
//Model.MDevice askdev;
|
|||
|
//string sql = "";
|
|||
|
try
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
//DataView dv = dbo.ExceSQL("SELECT F_DBW2Address,F_DBWGetLength,F_DeviceIndex,F_DeviceKindIndex,F_OPCProgID, F_RemoteIP FROM T_Base_Device where F_DeviceIndex=" + DeviceIndex).Tables[0].DefaultView;
|
|||
|
if (devinfo.DeviceIndex == 0)
|
|||
|
{
|
|||
|
_commLayerError = "OPCClient.CGetDeviceState.GetDeviceState<74><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>û<EFBFBD>ҵ<EFBFBD><D2B5>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|||
|
|
|||
|
return null;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CCommonOPCClient.Hostname = CommonClassLib.AppSettings.GetValue("HostName");//20090922 devinfo.RemoteIP;
|
|||
|
CCommonOPCClient.ProgID = CommonClassLib.AppSettings.GetValue("OPCProgID");
|
|||
|
switch (devinfo.DeviceKind.ToString())
|
|||
|
{
|
|||
|
#region <EFBFBD><EFBFBD><EFBFBD>翪<EFBFBD><EFBFBD><EFBFBD>ܵIJɼ<EFBFBD>
|
|||
|
case "28":
|
|||
|
int[] _RRword = new int[(int)(devinfo.Dbw2Getlength )];
|
|||
|
byte[] br = CCommonOPCClient.SyncReadAllItems(devinfo.S7Connection);//20110216
|
|||
|
if (br == null)
|
|||
|
{
|
|||
|
_commLayerError = "OPCClient.CGetDeviceState.GetDeviceState<74><65>" + devinfo.S7Connection + CCommonOPCClient.OpcError;
|
|||
|
return null;
|
|||
|
}
|
|||
|
Array.Copy(br, _RRword, (int)(devinfo.Dbw2Getlength ));
|
|||
|
return _RRword;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
|
|||
|
#region <EFBFBD><EFBFBD><EFBFBD>翪<EFBFBD>ؼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
//case "18":
|
|||
|
// Bit = Convert.ToInt16(devinfo.Dbw2Getlength * 8) - 1;//ת<><D7AA><EFBFBD><EFBFBD>bit0--bit7
|
|||
|
// if (Bit > 7)
|
|||
|
// {
|
|||
|
// add = 1;
|
|||
|
// Bit = Bit - 8;
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// add = 0;
|
|||
|
// }
|
|||
|
// ivalue = CCommonOPCClient.SyncReadItemValue("DB2,X" + Convert.ToString(devinfo.Dbw2Address + add) + "." + Bit.ToString());
|
|||
|
// if ((ivalue == null) || (ivalue == ""))
|
|||
|
// {
|
|||
|
// _commLayerError = "OPCClient.CGetDeviceState.GetDeviceState<74><65>" + CCommonOPCClient.OpcError;
|
|||
|
// return null;
|
|||
|
// }
|
|||
|
// if (ivalue.ToLower() == "true")
|
|||
|
// {
|
|||
|
// _Rword[0] = 1;
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// _Rword[0] = 0;
|
|||
|
// }
|
|||
|
|
|||
|
// _Rword[1] = 3;//3-<2D><><EFBFBD><EFBFBD><E2BFAA>״̬
|
|||
|
// _Rword[2] = TaskIndex;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// _Rword[3] = 0;
|
|||
|
// _Rword[4] = 0;
|
|||
|
// _Rword[5] = DeviceIndex;//<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
// break;
|
|||
|
//#endregion
|
|||
|
//#region <20><>ť
|
|||
|
//case "14":
|
|||
|
// Bit = Convert.ToInt16(devinfo.Dbw2Getlength * 8) - 1;//ת<><D7AA><EFBFBD><EFBFBD>bit0--bit7
|
|||
|
// if (Bit > 7)
|
|||
|
// {
|
|||
|
// add = 1;
|
|||
|
// Bit = Bit - 8;
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// add = 0;
|
|||
|
// }
|
|||
|
// ivalue = CCommonOPCClient.SyncReadItemValue("DB2,X" + Convert.ToString(devinfo.Dbw2Address + add) + "." + Bit.ToString());
|
|||
|
// if ((ivalue == null) || (ivalue == ""))
|
|||
|
// {
|
|||
|
// _commLayerError = "OPCClient.CGetDeviceState.GetDeviceState<74><65>" + CCommonOPCClient.OpcError;
|
|||
|
// return null;
|
|||
|
// }
|
|||
|
|
|||
|
// _Rword[0] = Convert.ToInt32(ivalue);
|
|||
|
// _Rword[1] = 3;//3-<2D><><EFBFBD><EFBFBD><E2BFAA>״̬
|
|||
|
// _Rword[2] = TaskIndex;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// _Rword[3] = 0;
|
|||
|
// _Rword[4] = 0;
|
|||
|
// _Rword[5] = DeviceIndex;//<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
// break;
|
|||
|
//#endregion
|
|||
|
|
|||
|
|
|||
|
//#region <20>ֳ<EFBFBD><D6B3><EFBFBD><EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>16<31><36><EFBFBD>ֽڣ<D6BD>
|
|||
|
//case "22":
|
|||
|
// itemnames = new string[14];
|
|||
|
// itemnames[0] = "DB2,byte" + Convert.ToString((devinfo.Dbw2Address + 0));
|
|||
|
// itemnames[1] = "DB2,byte" + Convert.ToString((devinfo.Dbw2Address + 1));
|
|||
|
// itemnames[2] = "DB2,int" + Convert.ToString((devinfo.Dbw2Address + 2));
|
|||
|
// itemnames[3] = "DB2,int" + Convert.ToString((devinfo.Dbw2Address + 4));
|
|||
|
// for (int i = 6; i < 16; i++)
|
|||
|
// {
|
|||
|
// itemnames[i - 2] = "DB2,byte" + Convert.ToString((devinfo.Dbw2Address + i));
|
|||
|
// }
|
|||
|
// object[] obj = CCommonOPCClient.SyncReadItemValues(itemnames);
|
|||
|
|
|||
|
// if ((obj == null))
|
|||
|
// {
|
|||
|
// _commLayerError = "OPCClient.CGetDeviceState.GetDeviceState<74><65>" + CCommonOPCClient.OpcError;
|
|||
|
// return null;
|
|||
|
// }
|
|||
|
// if (obj[0].ToString() != "1") return null;
|
|||
|
// _Rword[0] = TaskIndex;
|
|||
|
// _Rword[1] = DeviceIndex;
|
|||
|
// _Rword[2] = Convert.ToInt32(obj[1]);
|
|||
|
// _Rword[3] = Convert.ToInt32(obj[2]);
|
|||
|
// _Rword[4] = Convert.ToInt32(obj[3]);
|
|||
|
// askdev = Model.CGetInfo.GetDeviceInfo(_Rword[3]);
|
|||
|
// //_Rword[2];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// //_Rword[3];//<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// //_Rword[4];//<2F><><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD>Ҫ<EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>λ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>
|
|||
|
// int bcz = 0;
|
|||
|
// www = new string[1];
|
|||
|
// wi = new string[1] { itemnames[0] };
|
|||
|
// string barcode = string.Empty;
|
|||
|
// for (int j = 6; j < 16; j++)
|
|||
|
// {
|
|||
|
// bcz = bcz + Convert.ToInt32(obj[j - 2]);
|
|||
|
// barcode += Convert.ToChar(obj[j - 2]).ToString().ToUpper();
|
|||
|
// _Rword[j - 1] = Convert.ToInt32(obj[j - 2]);
|
|||
|
// }
|
|||
|
// #region <20><><EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD><D8B7><EFBFBD>ǰ<EFBFBD>豸ָ<E8B1B8><D6B8>(1)
|
|||
|
|
|||
|
// if (_Rword[2] == 1)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// {
|
|||
|
// if (_Rword[4] == 0)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// {
|
|||
|
// if (bcz == 0)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// {
|
|||
|
// //32<33><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>붼<EFBFBD><EBB6BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// www[0] = "32";
|
|||
|
// CCommonOPCClient.SyncWriteAllItemValue(wi, www);
|
|||
|
// return null;
|
|||
|
// }
|
|||
|
// else//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// {
|
|||
|
// #region <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// //DataView dv = dbo.ExceSQL("SELECT F_BarCode, F_Askkind, F_DeviceIndex FROM T_Base_PLC_Ask where F_DeviceIndex=" + DeviceIndex).Tables[0].DefaultView;
|
|||
|
// //if (dv.Count > 0)
|
|||
|
// //{
|
|||
|
// // if (barcode == dv[i]["F_BarCode"].ToString())
|
|||
|
// // {
|
|||
|
// // return null;
|
|||
|
// // }
|
|||
|
// // else
|
|||
|
// // {
|
|||
|
|
|||
|
// if (askdev.UseCommonDB == "1")
|
|||
|
// {
|
|||
|
// sql = "SELECT F_MonitorIndex,F_DeviceIndex,F_DeviceCommandIndex,F_NumParam1,F_NumParam2," +
|
|||
|
// "F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6 FROM T_Monitor_Task WHERE F_TxtParam = '" +
|
|||
|
// barcode + "' order by F_MonitorIndex asc";
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// sql = "SELECT F_MonitorIndex,F_DeviceIndex,F_DeviceCommandIndex,F_NumParam1,F_NumParam2," +
|
|||
|
// "F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6 FROM T_Monitor_Task WHERE F_TxtParam = '" +
|
|||
|
// barcode + "' and F_DeviceIndex=" + _Rword[3] + " order by F_MonitorIndex asc";
|
|||
|
// }
|
|||
|
// DataView dvbc = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
|||
|
// if (dvbc.Count > 0)
|
|||
|
// {
|
|||
|
// if (askdev.UseCommonDB == "1")
|
|||
|
// {
|
|||
|
// dbo.ExceSQL("update T_Monitor_Task set F_AheadDetect='',F_DeviceIndex=" + _Rword[3] + " where F_MonitorIndex=" + dvbc[0]["F_MonitorIndex"] + "");
|
|||
|
// }
|
|||
|
|
|||
|
// www[0] = "4";
|
|||
|
// CCommonOPCClient.SyncWriteAllItemValue(wi, www);
|
|||
|
// return _Rword;
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// //35<33><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>벻ƥ<EBB2BB><C6A5>
|
|||
|
// www[0] = "35";
|
|||
|
// CCommonOPCClient.SyncWriteAllItemValue(wi, www);
|
|||
|
// return null;
|
|||
|
// }
|
|||
|
// // }
|
|||
|
// //}
|
|||
|
// #endregion
|
|||
|
// }
|
|||
|
// }
|
|||
|
// else//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// {
|
|||
|
// #region <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// //DataView dv = dbo.ExceSQL("SELECT F_TaskIndex, F_Askkind, F_DeviceIndex FROM T_Base_PLC_Ask where F_DeviceIndex=" + DeviceIndex).Tables[0].DefaultView;
|
|||
|
// //if (dv.Count > 0)
|
|||
|
// //{
|
|||
|
// // if (_Rword[4] == dv[i]["F_TaskIndex"].ToString())
|
|||
|
// // {
|
|||
|
// // return null;
|
|||
|
// // }
|
|||
|
// // else
|
|||
|
// // {
|
|||
|
// if (askdev.UseCommonDB == "1")
|
|||
|
// {
|
|||
|
// sql = "SELECT F_MonitorIndex,F_DeviceIndex,F_DeviceCommandIndex,F_NumParam1,F_NumParam2," +
|
|||
|
// "F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6 FROM T_Monitor_Task WHERE F_MonitorIndex = '" +
|
|||
|
// _Rword[4] + "' order by F_MonitorIndex asc";
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// sql = "SELECT F_MonitorIndex,F_DeviceIndex,F_DeviceCommandIndex,F_NumParam1,F_NumParam2," +
|
|||
|
// "F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6 FROM T_Monitor_Task WHERE F_MonitorIndex = '" +
|
|||
|
// _Rword[4] + "' and F_DeviceIndex=" + _Rword[3] + " order by F_MonitorIndex asc";
|
|||
|
// }
|
|||
|
// DataView dvbc = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
|||
|
// if (dvbc.Count > 0)
|
|||
|
// {
|
|||
|
// if (askdev.UseCommonDB == "1")
|
|||
|
// {
|
|||
|
// dbo.ExceSQL("update T_Monitor_Task set F_AheadDetect='',F_DeviceIndex=" + _Rword[3] + " where F_MonitorIndex=" + dvbc[0]["F_MonitorIndex"] + "");
|
|||
|
// }
|
|||
|
// //RestoreDevice(Convert.ToInt32(dvbc[0]["F_MonitorIndex"]));
|
|||
|
// www[0] = "4";
|
|||
|
// CCommonOPCClient.SyncWriteAllItemValue(wi, www);
|
|||
|
// ////<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// //dbo.ExceSQL("update T_Base_PLC_Ask set F_TaskIndex='" + _Rword[4]
|
|||
|
// // + "' where F_DeviceIndex=" + DeviceIndex);
|
|||
|
// return _Rword;
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// //36<33><36><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ų<EFBFBD>ƥ<EFBFBD><C6A5>
|
|||
|
// www[0] = "36";
|
|||
|
// CCommonOPCClient.SyncWriteAllItemValue(wi, www);
|
|||
|
// return null;
|
|||
|
// }
|
|||
|
// // }
|
|||
|
// //}
|
|||
|
// #endregion
|
|||
|
// }
|
|||
|
|
|||
|
// }
|
|||
|
|
|||
|
// #endregion
|
|||
|
|
|||
|
// #region <20><><EFBFBD><EFBFBD><EFBFBD>ĵ<DEB8>ǰ<EFBFBD>豸<EFBFBD><E8B1B8>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>λ<EFBFBD><CEBB>(2)
|
|||
|
|
|||
|
// else if (_Rword[2] == 2)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// {
|
|||
|
// //<2F><><EFBFBD><EFBFBD><EFBFBD>ĵ<DEB8>ǰ<EFBFBD>豸<EFBFBD><E8B1B8>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>λ<EFBFBD>õ<EFBFBD>F_TaskIndex<65>ظ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
// }
|
|||
|
|
|||
|
// #endregion
|
|||
|
|
|||
|
// #region <20>ϱ<EFBFBD><CFB1><EFBFBD><EFBFBD><EFBFBD>(3)
|
|||
|
// else if (_Rword[2] == 3)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// {
|
|||
|
// if (_Rword[4] == 0)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// {
|
|||
|
// if (bcz == 0)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// {
|
|||
|
// //32<33><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>붼<EFBFBD><EBB6BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// www[0] = "32";
|
|||
|
// CCommonOPCClient.SyncWriteAllItemValue(wi, www);
|
|||
|
// return null;
|
|||
|
// }
|
|||
|
// else//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// {
|
|||
|
// #region <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// sql = "SELECT F_MonitorIndex,F_DeviceIndex,F_DeviceCommandIndex,F_NumParam1,F_NumParam2," +
|
|||
|
// "F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6 FROM T_Monitor_Task WHERE F_TxtParam = '" +
|
|||
|
// barcode + "' order by F_MonitorIndex asc";
|
|||
|
// DataView dvbc = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
|||
|
|
|||
|
// if (dvbc.Count > 0)
|
|||
|
// {
|
|||
|
// www[0] = "2";
|
|||
|
// CCommonOPCClient.SyncWriteAllItemValue(wi, www);
|
|||
|
|
|||
|
// return _Rword;
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// //30<33><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>벻<EFBFBD><EBB2BB><EFBFBD><EFBFBD>
|
|||
|
// www[0] = "30";
|
|||
|
// CCommonOPCClient.SyncWriteAllItemValue(wi, www);
|
|||
|
// return null;
|
|||
|
// }
|
|||
|
// #endregion
|
|||
|
// }
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
|
|||
|
// #region <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
// sql = "SELECT F_MonitorIndex,F_DeviceIndex,F_DeviceCommandIndex,F_NumParam1,F_NumParam2," +
|
|||
|
// "F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6 FROM T_Monitor_Task WHERE F_MonitorIndex = '" +
|
|||
|
// _Rword[4] + "' order by F_MonitorIndex asc";
|
|||
|
|
|||
|
// DataView dvbc = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
|||
|
|
|||
|
// if (dvbc.Count > 0)
|
|||
|
// {
|
|||
|
// www[0] = "2";
|
|||
|
// CCommonOPCClient.SyncWriteAllItemValue(wi, www);
|
|||
|
|
|||
|
// return _Rword;
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// //31<33><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// www[0] = "31";
|
|||
|
// CCommonOPCClient.SyncWriteAllItemValue(wi, www);
|
|||
|
// return null;
|
|||
|
// }
|
|||
|
// // }
|
|||
|
// //}
|
|||
|
// #endregion
|
|||
|
// }
|
|||
|
// }
|
|||
|
// #endregion
|
|||
|
|
|||
|
// #region ɾ<><C9BE><EFBFBD><EFBFBD>ǰ<EFBFBD>豸<EFBFBD><E8B1B8>ִ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>(4)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD>
|
|||
|
// else if (_Rword[2] == 4)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// {
|
|||
|
// if (_Rword[4] == 0)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// {
|
|||
|
// if (bcz == 0)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// {
|
|||
|
// //32<33><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>붼<EFBFBD><EBB6BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// www[0] = "32";
|
|||
|
// CCommonOPCClient.SyncWriteAllItemValue(wi, www);
|
|||
|
// return null;
|
|||
|
// }
|
|||
|
// else//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// {
|
|||
|
// #region <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// sql = "SELECT F_MonitorIndex,F_DeviceIndex,F_DeviceCommandIndex,F_NumParam1,F_NumParam2," +
|
|||
|
// "F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6 FROM T_Monitor_Task WHERE F_TxtParam = '" +
|
|||
|
// barcode + "' order by F_MonitorIndex asc";
|
|||
|
// DataView dvbc = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
|||
|
|
|||
|
// if (dvbc.Count > 0)
|
|||
|
// {
|
|||
|
// www[0] = "2";
|
|||
|
// CCommonOPCClient.SyncWriteAllItemValue(wi, www);
|
|||
|
|
|||
|
// return _Rword;
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// //30<33><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>벻<EFBFBD><EBB2BB><EFBFBD><EFBFBD>
|
|||
|
// www[0] = "30";
|
|||
|
// CCommonOPCClient.SyncWriteAllItemValue(wi, www);
|
|||
|
// return null;
|
|||
|
// }
|
|||
|
// #endregion
|
|||
|
// }
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
|
|||
|
// #region <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
// sql = "SELECT F_MonitorIndex,F_DeviceIndex,F_DeviceCommandIndex,F_NumParam1,F_NumParam2," +
|
|||
|
// "F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6 FROM T_Monitor_Task WHERE F_MonitorIndex = '" +
|
|||
|
// _Rword[4] + "' order by F_MonitorIndex asc";
|
|||
|
|
|||
|
// DataView dvbc = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
|||
|
// if (dvbc.Count > 0)
|
|||
|
// {
|
|||
|
// www[0] = "3";
|
|||
|
// CCommonOPCClient.SyncWriteAllItemValue(wi, www);
|
|||
|
|
|||
|
// return _Rword;
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// //31<33><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// www[0] = "31";
|
|||
|
// CCommonOPCClient.SyncWriteAllItemValue(wi, www);
|
|||
|
// return null;
|
|||
|
// }
|
|||
|
// #endregion
|
|||
|
// }
|
|||
|
// }
|
|||
|
// #endregion
|
|||
|
// break;
|
|||
|
//#endregion
|
|||
|
|
|||
|
|
|||
|
//#region <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
//case "24":
|
|||
|
// itemnames = new string[3];
|
|||
|
// itemnames[0] = "DB2,byte" + Convert.ToString((devinfo.Dbw2Address + 0));
|
|||
|
// itemnames[1] = "DB2,byte" + Convert.ToString((devinfo.Dbw2Address + 1));
|
|||
|
// itemnames[2] = "DB2,byte" + Convert.ToString((devinfo.Dbw2Address + 2));
|
|||
|
// obj = CCommonOPCClient.SyncReadItemValues(itemnames);
|
|||
|
|
|||
|
// if ((obj == null))
|
|||
|
// {
|
|||
|
// _commLayerError = "OPCClient.CGetDeviceState.GetDeviceState<74><65>" + CCommonOPCClient.OpcError;
|
|||
|
// return null;
|
|||
|
// }
|
|||
|
// if (obj[0].ToString() != "1") return null;
|
|||
|
// _Rword[0] = TaskIndex;
|
|||
|
// _Rword[1] = DeviceIndex;
|
|||
|
// _Rword[2] = Convert.ToInt32(obj[1]);//<2F><><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD><CBB6><EFBFBD>:1-ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;2-<2D>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD><EFBFBD>;3-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// _Rword[3] = Convert.ToInt32(obj[2]);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// www = new string[1];
|
|||
|
// wi = new string[1] { itemnames[0] };
|
|||
|
// www[0] = "2";
|
|||
|
// CCommonOPCClient.SyncWriteAllItemValue(wi, www);
|
|||
|
|
|||
|
// break;
|
|||
|
//#endregion
|
|||
|
|
|||
|
//#region <20><><EFBFBD><EFBFBD><EFBFBD>豸
|
|||
|
//case "1"://<2F>Ѷ<EFBFBD><D1B6><EFBFBD>
|
|||
|
// itemnames = new string[5];
|
|||
|
// itemnames[0] = "DB2,byte" + Convert.ToString((devinfo.Dbw2Address + 0));
|
|||
|
// itemnames[1] = "DB2,byte" + Convert.ToString((devinfo.Dbw2Address + 1));
|
|||
|
// itemnames[2] = "DB2,int" + Convert.ToString((devinfo.Dbw2Address + 2));
|
|||
|
// itemnames[3] = "DB2,DWORD" + Convert.ToString((devinfo.Dbw2Address + 4));
|
|||
|
// itemnames[4] = "DB2,DWORD" + Convert.ToString((devinfo.Dbw2Address + 8));
|
|||
|
// itemvalue = CCommonOPCClient.SyncReadAllItems(itemnames);
|
|||
|
// if (itemvalue.Count == 0)
|
|||
|
// {
|
|||
|
// _commLayerError = "OPCClient.CGetDeviceState.GetDeviceState<74><65>" + CCommonOPCClient.OpcError;
|
|||
|
// return null;
|
|||
|
// }
|
|||
|
// _Rword[0] = Convert.ToInt32(itemvalue[0]);//<2F><>д<EFBFBD><D0B4>־
|
|||
|
// _Rword[1] = Convert.ToInt32(itemvalue[1]);//״̬
|
|||
|
// _Rword[2] = Convert.ToInt32(itemvalue[2]);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// _Rword[3] = Convert.ToInt32(itemvalue[3]);//X<><58><EFBFBD><EFBFBD>
|
|||
|
// _Rword[4] = Convert.ToInt32(itemvalue[4]);//Y<><59><EFBFBD><EFBFBD>
|
|||
|
// _Rword[5] = DeviceIndex;//<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// break;
|
|||
|
//case "2"://<2F><><EFBFBD>ͻ<EFBFBD>
|
|||
|
// itemnames = new string[3];
|
|||
|
// itemnames[0] = "DB2,byte" + Convert.ToString((devinfo.Dbw2Address + 0));
|
|||
|
// itemnames[1] = "DB2,byte" + Convert.ToString((devinfo.Dbw2Address + 1));
|
|||
|
// itemnames[2] = "DB2,int" + Convert.ToString((devinfo.Dbw2Address + 2));
|
|||
|
|
|||
|
// itemvalue = CCommonOPCClient.SyncReadAllItems(itemnames);
|
|||
|
// if ((itemvalue == null) || (itemvalue.Count == 0))
|
|||
|
// {
|
|||
|
// _commLayerError = "OPCClient.CGetDeviceState.GetDeviceState<74><65>" + CCommonOPCClient.OpcError;
|
|||
|
// return null;
|
|||
|
// }
|
|||
|
// _Rword[0] = Convert.ToInt32(itemvalue[0]);//<2F><>д<EFBFBD><D0B4>־
|
|||
|
// _Rword[1] = Convert.ToInt32(itemvalue[1]);//״̬
|
|||
|
// _Rword[2] = Convert.ToInt32(itemvalue[2]);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// _Rword[3] = 0;
|
|||
|
// _Rword[4] = 0;
|
|||
|
// _Rword[5] = DeviceIndex;//<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// break;
|
|||
|
//case "4"://RGV
|
|||
|
// itemnames = new string[4];
|
|||
|
// itemnames[0] = "DB2,byte" + Convert.ToString((devinfo.Dbw2Address + 0));
|
|||
|
// itemnames[1] = "DB2,byte" + Convert.ToString((devinfo.Dbw2Address + 1));
|
|||
|
// itemnames[2] = "DB2,int" + Convert.ToString((devinfo.Dbw2Address + 2));
|
|||
|
// itemnames[3] = "DB2,DWORD" + Convert.ToString((devinfo.Dbw2Address + 4));
|
|||
|
|
|||
|
// itemvalue = CCommonOPCClient.SyncReadAllItems(itemnames);
|
|||
|
// if ((itemvalue == null) || (itemvalue.Count == 0))
|
|||
|
// {
|
|||
|
// _commLayerError = "OPCClient.CGetDeviceState.GetDeviceState<74><65>" + CCommonOPCClient.OpcError;
|
|||
|
// return null;
|
|||
|
// }
|
|||
|
// _Rword[0] = Convert.ToInt32(itemvalue[0]);//<2F><>д<EFBFBD><D0B4>־
|
|||
|
// _Rword[1] = Convert.ToInt32(itemvalue[1]);//״̬
|
|||
|
// _Rword[2] = Convert.ToInt32(itemvalue[2]);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// _Rword[3] = Convert.ToInt32(itemvalue[3]);//X<><58><EFBFBD><EFBFBD>
|
|||
|
// _Rword[4] = 0;
|
|||
|
// _Rword[5] = DeviceIndex;//<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// break;
|
|||
|
//case "13"://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// itemnames = new string[4];
|
|||
|
// itemnames[0] = "DB2,byte" + Convert.ToString((devinfo.Dbw2Address + 0));
|
|||
|
// itemnames[1] = "DB2,byte" + Convert.ToString((devinfo.Dbw2Address + 1));
|
|||
|
// itemnames[2] = "DB2,byte" + Convert.ToString((devinfo.Dbw2Address + 2));
|
|||
|
// itemnames[3] = "DB2,byte" + Convert.ToString((devinfo.Dbw2Address + 3));
|
|||
|
|
|||
|
// itemvalue = CCommonOPCClient.SyncReadAllItems(itemnames);
|
|||
|
// if ((itemvalue == null) || (itemvalue.Count == 0))
|
|||
|
// {
|
|||
|
// _commLayerError = "OPCClient.CGetDeviceState.GetDeviceState<74><65>" + CCommonOPCClient.OpcError;
|
|||
|
// return null;
|
|||
|
// }
|
|||
|
// if (itemvalue[0] != "1") return null;
|
|||
|
// _Rword[0] = Convert.ToInt32(itemvalue[1]);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
|||
|
// _Rword[1] = Convert.ToInt32(itemvalue[2]);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
|||
|
// _Rword[2] = Convert.ToInt32(itemvalue[3]);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
|||
|
// _Rword[3] = 0;
|
|||
|
// _Rword[4] = 0;
|
|||
|
// _Rword[5] = DeviceIndex;//<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// break;
|
|||
|
#endregion
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
return _Rword;
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
_commLayerError = "OPCClient.CGetDeviceState.GetDeviceState<74><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + ex.Message;
|
|||
|
return null;
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
//itemnames=null;
|
|||
|
_Rword = null;
|
|||
|
//www=null;
|
|||
|
//wi=null;
|
|||
|
//ivalue=null;
|
|||
|
//itemvalue =null;
|
|||
|
devinfo = null;
|
|||
|
//askdev=null;
|
|||
|
//sql = null;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
public string GetStringData(int DeviceIndex, int TaskIndex)
|
|||
|
{//20091107
|
|||
|
string headstr = "";
|
|||
|
string[] itemnames;
|
|||
|
string retdata = "";
|
|||
|
string[] witemnames;
|
|||
|
byte[] itemvalue;
|
|||
|
object[] obj;
|
|||
|
Model.MDevice devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIndex);
|
|||
|
try
|
|||
|
{
|
|||
|
|
|||
|
if (devinfo.DeviceIndex == 0)
|
|||
|
{
|
|||
|
_commLayerError = "OPCClient.CGetDeviceState.GetStringData<74><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>û<EFBFBD>ҵ<EFBFBD><D2B5>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|||
|
|
|||
|
return null;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CCommonOPCClient.Hostname = CommonClassLib.AppSettings.GetValue("HostName");//20090922 devinfo.RemoteIP;
|
|||
|
CCommonOPCClient.ProgID = CommonClassLib.AppSettings.GetValue("OPCProgID");
|
|||
|
CCommonOPCClient.PlcConnectionID = devinfo.S7Connection;//20110216
|
|||
|
witemnames = new string[1] { Model.CGeneralFunction.DBGet+",byte" + Convert.ToString((devinfo.Dbw2Address + 0)) };
|
|||
|
switch (devinfo.DeviceKind.ToString())
|
|||
|
{
|
|||
|
|
|||
|
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ(10<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>)
|
|||
|
case "7":
|
|||
|
itemnames = new string[11];
|
|||
|
itemnames[0] = Model.CGeneralFunction.DBGet+",byte" + Convert.ToString((devinfo.Dbw2Address + 0));
|
|||
|
for (int i = 1; i < 11; i++)
|
|||
|
{
|
|||
|
itemnames[i] = Model.CGeneralFunction.DBGet+",byte" + Convert.ToString((devinfo.Dbw2Address + i));
|
|||
|
}
|
|||
|
obj = CCommonOPCClient.SyncReadItemValues(itemnames);
|
|||
|
if ((obj == null))
|
|||
|
{
|
|||
|
_commLayerError = "OPCClient.CGetDeviceState.GetDeviceState<74><65>" + CCommonOPCClient.OpcError;
|
|||
|
return null;
|
|||
|
}
|
|||
|
if (obj[0].ToString() != "1") return null;
|
|||
|
itemvalue = new byte[obj.Length];
|
|||
|
Array.Copy(obj, itemvalue, obj.Length);
|
|||
|
|
|||
|
headstr = itemvalue[0].ToString();
|
|||
|
for (int i = 1; i <= 10; i++)
|
|||
|
{
|
|||
|
retdata += Convert.ToChar(itemvalue[i]);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
break;
|
|||
|
#endregion
|
|||
|
|
|||
|
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>Ź<EFBFBD><EFBFBD><EFBFBD><EFBFBD>루<EFBFBD><EFBFBD><EFBFBD>鹲32<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>+һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>־ͷ<EFBFBD><EFBFBD>
|
|||
|
case "21":
|
|||
|
itemnames = new string[33];
|
|||
|
itemnames[0] = Model.CGeneralFunction.DBGet+",byte" + Convert.ToString((devinfo.Dbw2Address + 0));
|
|||
|
for (int i = 1; i < 33; i++)
|
|||
|
{
|
|||
|
itemnames[i] = Model.CGeneralFunction.DBGet+",byte" + Convert.ToString((devinfo.Dbw2Address + i));
|
|||
|
}
|
|||
|
obj = CCommonOPCClient.SyncReadItemValues(itemnames);
|
|||
|
if ((obj == null))
|
|||
|
{
|
|||
|
_commLayerError = "OPCClient.CGetDeviceState.GetDeviceState<74><65>" + CCommonOPCClient.OpcError;
|
|||
|
return null;
|
|||
|
}
|
|||
|
if (obj[0].ToString() != "1") return null;
|
|||
|
itemvalue = new byte[obj.Length];
|
|||
|
Array.Copy(obj, itemvalue, obj.Length);
|
|||
|
|
|||
|
headstr = itemvalue[0].ToString();
|
|||
|
for (int i = 1; i <= 32; i++)
|
|||
|
{
|
|||
|
retdata += Convert.ToChar(itemvalue[i]);
|
|||
|
|
|||
|
}
|
|||
|
break;
|
|||
|
#endregion
|
|||
|
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
if (headstr == "1")
|
|||
|
{
|
|||
|
string[] wv = new string[1] { "2" };
|
|||
|
if (CCommonOPCClient.SyncWriteAllItemValue(witemnames, wv) == false)
|
|||
|
{
|
|||
|
_commLayerError = "OPCClient.CGetDeviceState.GetDeviceState<74><65>" + CCommonOPCClient.OpcError;
|
|||
|
return null;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return retdata;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
_commLayerError = "OPCClient.CGetDeviceState.GetStringData<74><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + ex.Message;
|
|||
|
return null;
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
headstr = null;
|
|||
|
itemnames=null;
|
|||
|
retdata = null;
|
|||
|
witemnames=null;
|
|||
|
itemvalue=null;
|
|||
|
obj = null ;
|
|||
|
devinfo = null;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|