How to use the Graph widget to actively view the changing variable values? Is there a Demo for it?

Comments

1 comment

  • Avatar
    Peter Fischer

    Hi,

    seems like the tricky part is filling the lists correctly.

    I've played around with the Graph Widget a while ago when trying to add new items at the left end.

    Here is the method of the script called every 100ms and filling two lists with some sample data displayed by two Graph Widgets then:

    void $addToList$ ()
    {
    int result = 0;

    if (value0 < 6.28) {
    value0 += 0.1;
    } else {
    value0 = 0;
    }

    value1 += 0.5;
    if (value1 == 100) {
    value1 = -100;
    }

    smWrite(VariableIDs.data1, value1);

    CustomListData data1;
    data1.WriteDouble(CustomListColumn.TestList1_Column_0, value1);
    data1.WriteDouble(CustomListColumn.TestList1_Column_1, cos(value0) * 90);
    data1.WriteDouble(CustomListColumn.TestList1_Column_2, tan(value0) * 20);

    // append items at the right end
    if (ListManagerGetCount(ListDataType.TestList1) == 100) {
    ListManagerRemoveItem(ListDataType.TestList1, 99);
    }
    result = ListManagerAddItem(ListDataType.TestList1, data1);
    ListManagerSetPosition(ListDataType.TestList1, ListManagerGetCount(ListDataType.TestList1) - 1);
    ListManagerMoveTo(ListDataType.TestList1, 0);
    ListManagerSetPosition(ListDataType.TestList1, ListManagerGetCount(ListDataType.TestList1) - 1);



    CustomListData data2;
    data2.WriteDouble(CustomListColumn.TestList2_Column_0, value1);
    data2.WriteDouble(CustomListColumn.TestList2_Column_1, cos(value0) * 90);
    data2.WriteDouble(CustomListColumn.TestList2_Column_2, tan(value0) * 20);

    // append items at the left end
    result = ListManagerAddItem(ListDataType.TestList2, data2);
    ListManagerSetPosition(ListDataType.TestList2, ListManagerGetCount(ListDataType.TestList2) - 1);
    if (ListManagerGetCount(ListDataType.TestList2) == 100) {
    ListManagerRemoveItem(ListDataType.TestList2, 0);
    }

    }

    0
    Comment actions Permalink

Please sign in to leave a comment.