문제

어떻게 검색할 수 있습니 raw 시간-데이터 시리즈에서 Proficy 역사가/iHistorian?

이상적으로,저는 이렇게 묻고 싶 위한 데이터를 위한 특정표입니다.

도움이 되었습니까?

해결책

실험 할 수있는 여러 가지 샘플링 모드가 있습니다.

  • 날것의
  • 보간
  • 경향
  • 계획된

이 모드는 다음 모든 API를 사용하여 사용할 수 있습니다.

  • 사용자 API (ihuapi.dll)
  • sdk (ihsdk.dll)
  • OLEDB (iholedb.dll)
  • Client Acess API (Proficy.historian.clientAccess.api)

이 중 트렌드 샘플링 모드는 아마도 차트/트렌드를 위해 특별히 설계 되었기 때문에 원하는 것일 것입니다. 그러나 실험실과 보간도 유용 할 수 있습니다.

각 샘플링 모드에 대한 자세한 내용은 전자 북을 읽으십시오. 내 컴퓨터에서는 다음과 같이 저장됩니다 C:\Program Files\GE Fanuc\Proficy Historian\Docs\iHistorian.chm 그리고 버전 3.5가 설치되어 있습니다. 다음 섹션에 특히주의하십시오.

  • 역사가 Ole DB 제공 업체 사용
  • 고급 주제 | 검색

트렌드 샘플링을 수행하기 위해 OLEDB를 구성하는 방법은 다음과 같습니다.

set 
    SamplingMode = 'Trend',
    StartTime = '2010-07-01 00:00:00',
    EndTime = '2010-07-02 00:00:00',
    IntervalMilliseconds = 1h
select 
    timestamp, 
    value, 
    quality 
from 
    ihRawData 
where 
    tagname = 'YOUR_TAG'

사용자 API와 SDK를 사용하여 동등한 방법을 표시하는 것은 코드에서 많은 배관이 필요하기 때문에 복잡합니다 (사용자 API는 더 많음). 클라이언트 액세스 API는 더 새롭고 무대 뒤에서 WCF를 사용합니다.

그건 그렇고, OLEDB 방법에는 몇 가지 제한이 있습니다.

  • 문서의 말에도 불구하고 내가 가진 것 절대 기본 쿼리 매개 변수를 작동시킬 수있었습니다. 예를 들어 SQL Server Reporting Services와 함께 사용하려는 경우 Showstopper입니다.
  • 샘플을 아카이브에 쓸 수 없거나 태그 추가/변경, 메시지 작성 등을 포함하여 역사가 구성을 변경할 수 없습니다.
  • 어떤 경우에는 조금 느릴 수 있습니다.
  • 여러 개의 태그 이름을 열에 크로스 팅 한 다음 각 타임 스탬프 및 태그 조합에 대한 값이 존재하도록 전진 샘플을 전달할 수있는 규정이 없습니다. 트렌드 샘플링 모드는 중간에 당신을 데려 오지만 여전히 크로스 탭은 아니며 실제로 원시 샘플을로드하지는 않습니다. 그런 다음 사용자 API와 SDK도 다시 수행 할 수 없습니다.

다른 팁

동료의 나이를 함께:

웹.config:

<add name="HistorianConnectionString" 
     providerName="ihOLEDB.iHistorian.1" 
     connectionString="
       Provider=ihOLEDB.iHistorian;
       User Id=;
       Password=;
       Data Source=localhost;"
/>

에서 데이터 레이어:

public DataTable GetProficyData(string tagName, DateTime startDate, DateTime endDate)
{
    using (System.Data.OleDb.OleDbConnection cn = new System.Data.OleDb.OleDbConnection())
    {
        cn.ConnectionString = webConfig.ConnectionStrings.ConnectionStrings["HistorianConnectionString"];
        cn.Open();

        string queryString = string.Format(
                "set samplingmode = rawbytime\n select value as theValue,Timestamp from ihrawdata where tagname = '{0}' AND timestamp between '{1}' and '{2}' and value > 0 order by timestamp",
                tagName.Replace("'", "\""), startDate, endDate);

        System.Data.OleDb.OleDbDataAdapter adp = new System.Data.OleDb.OleDbDataAdapter(queryString, cn);
        DataSet ds = new DataSet();

        adp.Fill(ds);
        return ds.Tables[0];
    }
}

업데이트:

이 일을 잘 하지만 우리는으로 태그하지 않는데 매우 많습니다.면 태그하지 않았 업데이트 근처의 시작과 끝을 요청한 보고 종료,트렌드는 보이는 것이 나쁘다.더 나쁘고,여전히이 있는 경우는 없었다는 명시적인 동안 창문 요청-우리는 얻을 수 없습니다.

나는 해결함으로써 이 세 가지 쿼리:

  1. 이전 값 시작 날짜
  2. 포인트 사을 보고 종료
  3. 다음 값 후에 의 종료

이것은 잠재적으로 비효율적인 방법 그것을 하지만 그것은 작품:

public DataTable GetProficyData(string tagName, DateTime startDate, DateTime endDate)
{
    DataSet ds = new DataSet();
    string queryString;
    System.Data.OleDb.OleDbDataAdapter adp;

    using (System.Data.OleDb.OleDbConnection cn = new System.Data.OleDb.OleDbConnection())
    {
        cn.ConnectionString = proficyConn.ConnectionString;
        cn.Open();

        // always get a start value
        queryString = string.Format(
             "set samplingmode = lab\nselect value as theValue,Timestamp from ihrawdata where tagname = '{0}' AND timestamp between '{1}' and '{2}' order by timestamp",
            tagName.Replace("'", "\""), startDate.AddMinutes(-1), startDate);
        adp = new System.Data.OleDb.OleDbDataAdapter(queryString, cn);
        adp.Fill(ds);

        // get the range
        queryString = string.Format(
             "set samplingmode = rawbytime\nselect value as theValue,Timestamp from ihrawdata where tagname = '{0}' AND timestamp between '{1}' and '{2}' order by timestamp",
            tagName.Replace("'", "\""), startDate, endDate);
        adp = new System.Data.OleDb.OleDbDataAdapter(queryString, cn);
        adp.Fill(ds);

        // always get an end value
        queryString = string.Format(
             "set samplingmode = lab\nselect value as theValue,Timestamp from ihrawdata where tagname = '{0}' AND timestamp between '{1}' and '{2}' order by timestamp",
        tagName.Replace("'", "\""), endDate.AddMinutes(-1), endDate);
        adp = new System.Data.OleDb.OleDbDataAdapter(queryString, cn);
        adp.Fill(ds);

        return ds.Tables[0];
    }
}

그리고 그렇다,나는 알고,그 쿼리를해야한 매개 변수가 있으면 안 됩니다.

Michael-IP21에는 "보간 된"테이블과 "실제"데이터 포인트 테이블이 있습니다. Proficy도 그거가 있습니까?

우리는 다음과 같이 보이는 래퍼 DLL을 썼습니다.

[DllImport("IHUAPI.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "ihuReadRawDataByTime@24")]
public static extern int ihuReadRawDataByTime(int serverhandle, string tagname, ref IHU_TIMESTAMP startTime, ref IHU_TIMESTAMP endTime, ref int noOfSamples, ref IHU_DATA_SAMPLE* dataValues);
...
private int _handle;

public HistorianTypes.ErrorCode ReadRawByTime(string tagName, DateTime startTime, DateTime endTime,
                                              out double[] timeStamps, out double[] values, out IhuComment [] comments)
{
    var startTimeStruct = new IhuApi.IHU_TIMESTAMP();  //Custom datetime to epoch extension method
    var endTimeStruct = new IhuApi.IHU_TIMESTAMP();

    int lRet = 0;
    int noOfSamples = 0;
    startTimeStruct = DateTimeToTimeStruct(dstZone.ToUniversalTime(startTime));
    endTimeStruct = DateTimeToTimeStruct(dstZone.ToUniversalTime(endTime));
    IhuApi.IHU_DATA_SAMPLE* dataSample = (IhuApi.IHU_DATA_SAMPLE*)new IntPtr(0);

    try {
        lRet = IhuApi.ihuReadRawDataByTime
            (
                _handle, // the handle returned from the connect
                tagName, // the single tagname to retrieve
                ref startTimeStruct, // start time for query
                ref endTimeStruct, // end time for query
                ref noOfSamples, // will be set by API
                ref dataSample // will be allocated and populated in the user API
            );
            ....

일부 참고 사항은 IFIX가 시작시 DLL이로드되었는지 확인하므로 다른 응용 프로그램이 충돌하지 않도록 DLL을 동적으로로드/언로드하는 것과 같은 작업을 수행해야합니다. 레지스트리 키를 즉시 삭제/추가하여이 작업을 수행했습니다.

또 다른 하나는 10,000 개의 샘플을 폴링하고 샘플 중 하나가 손상되면 10,000 개의 샘플을 모두 떨어 뜨릴 것입니다. 잘못된 데이터의 양쪽에서 시작하는 잘못된 데이터 핸들러를 구현하고 잘못된 샘플의 양쪽에 모든 데이터를 얻기 위해 단계를 증가시켜야합니다.

모든 오류 코드와 DLL의 함수 헤더가 포함 된 여러 C 헤더 파일이 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top