Only Archive on “Status change”

Forum Home Forums Understanding the Software Only Archive on “Status change”

Viewing 10 posts - 16 through 25 (of 25 total)
  • Author
    Posts
  • #17547
    TroyV23
    Participant

    Im attempting a different path, so I’ve created this feed using the API:

    https://i.postimg.cc/sxZ2X3B3/tmp-1de38a8b-3926-45a1-9bc3-bfc23f60969d.png

    I am not able to display the channel number it always displays as undefined.

    mainApi.getHistData(ARCHIVE_BIT, timeRange, “55500-55508”, function (dto) {
    let outElem = $(“#divData2”);

    if (dto.ok) {
    outElem.html(“”);
    let timestamps = dto.data.timestamps;

    if (timestamps.length > 0) {

    let trend = dto.data.trends[0];

    let table = $(“<table></table>”);
    table.append(“<tr><th>Date</th><th>Time</th><th>Channel</th><th>State</th></tr>”);

    for (let i = 0; i < timestamps.length; i++) {
    let timestamp = timestamps[i];
    let record = trend[i];
    let state = record.df.dispVal;
    let channel = record.cnlNum;

    // Only show On/Off
    if (state !== “On” && state !== “Off”) continue;

    let dt = new Date(timestamp.lt);

    let day = String(dt.getDate()).padStart(2, “0”);
    let month = dt.toLocaleString(“en-US”, { month: “short” });
    let year = dt.getFullYear();

    let hours = String(dt.getHours()).padStart(2, “0”);
    let minutes = String(dt.getMinutes()).padStart(2, “0”);

    let dateStr = ${day}-${month}-${year};
    let timeStr = ${hours}:${minutes};

    // Pick CSS class
    let stateClass = state === “On” ? “state-on” : “state-off”;

    table.append(
    `<tr>
    <td>${dateStr}</td>
    <td>${timeStr}</td>
    <td>${channel}</td>
    <td class=”${stateClass}”>${state}</td>
    </tr>`
    );

    • This reply was modified 5 months, 3 weeks ago by TroyV23.
    • This reply was modified 5 months, 3 weeks ago by Mikhail.
    #17554
    Mikhail
    Moderator

    The existing API does not return a channel name. However, you could implement your own API to do that.

    About the 2nd question:
    Perform console.log(dto) to check the object contents.

    #18031
    TroyV23
    Participant

    I’ve made my own custom html using the API and a imported CSV to fill channel names which is working really well now.

    The problem I’m still having is the polling timing, even though I have it configured to write on change, you said it should be checking status approx. 10 times a second.

    My data shows it is only checking approx. every 102 to 105 seconds for changes, and then it posts a whole bunch of “changes” with identical time stamps, when in reality those events all took places many seconds apart.

    Any idea what can cause this delay for checking on change status?

    #18033
    Mikhail
    Moderator

    Hello,
    What is the architecture of your solution?

    #18036
    TroyV23
    Participant

    This is how it is set up right now:

    Diagram

    Running Windows Server 2019 (x64) on Web server, and 2022 (x64) on the Application Server.

    #18037
    TroyV23
    Participant

    Is this possibly an issue?

    https://iili.io/CCFzeCg.md.png

    • This reply was modified 3 weeks, 3 days ago by Mikhail.
    #18040
    Mikhail
    Moderator

    The architecture is OK.
    The last image cannot be open.

    #18046
    TroyV23
    Participant

    [img]https://i.imghippo.com/files/U9965lM.png[/img]

    Is this ok?

    • This reply was modified 3 weeks, 2 days ago by TroyV23.
    #18048
    TroyV23
    Participant

    setting

    #18055
    Mikhail
    Moderator

    The highlighted value is too big. Use a value from 0 to 1000.

Viewing 10 posts - 16 through 25 (of 25 total)
  • You must be logged in to reply to this topic.