Merdock

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 31 total)
  • Author
    Posts
  • Merdock
    Participant

    Add an overflow protection for the uint8_t value, so if it exceeds the value of 255 it will set the command to 255.
    You could also make it not modify the output value if the limit of 255 is exceeded.

    
    public double InsertByte(double valueToInsert, double destinationValue, bool insertInMostSignificantByte)
    {
        // Protect against overflow of valueToInsert
        if (valueToInsert > 255)
        {
            valueToInsert = 255;
        }
        
        // Convert the input values to the corresponding types
        ushort val = Convert.ToUInt16(valueToInsert);
        ushort destVal = Convert.ToUInt16(destinationValue);
        
        ushort result;
        if (insertInMostSignificantByte)
        {
            result = (ushort)((destVal & 0x00FF) | (val << 8));
        }
        else
        {
            result = (ushort)((destVal & 0xFF00) | val);
        }
        
        // Convert the result to double before returning it
        return Convert.ToDouble(result);
    }
    

    Here the protection of the input value is that nothing is modified if the value exceeds 255

    public double InsertByte(double valueToInsert, double destinationValue, bool insertInMostSignificantByte)
    {
        // We check if the value to insert is greater than 255 and we return the destination variable unchanged
        if (valueToInsert > 255)
        {
            return destinationValue;
        }
        
        // Convert the input values to the corresponding types
        ushort val = Convert.ToUInt16(valueToInsert);
        ushort destVal = Convert.ToUInt16(destinationValue);
        
        ushort result;
        if (insertInMostSignificantByte)
        {
            result = (ushort)((destVal & 0x00FF) | (val << 8));
        }
        else
        {
            result = (ushort)((destVal & 0xFF00) | val);
        }
        
        // Convert the result to double before returning it
        return Convert.ToDouble(result);
    }
    
    • This reply was modified 11 months, 2 weeks ago by Merdock.
    Merdock
    Participant

    Fixed, full explanation:
    Formula to read 2 int8_t data stored in 1 holding register.

    
    public byte GetUi8Byte(double val, int n)
    {
         int lVal = (int)val;
         return (byte)((lVal >> ((1 - n) * 8)) & 0xFF);
    }
    

    Script to write uint8_t values to the output

    
    public double InsertByte(double valueToInsert, double destinationValue, bool insertInMostSignificantByte)
    {
         // Convert the input values to the corresponding types
         ushort val = Convert.ToUInt16(valueToInsert);
         ushort destVal = Convert.ToUInt16(destinationValue);
        
         ushort result;
         if (insertInMostSignificantByte)
         {
             result = (ushort)((destVal & 0x00FF) | (val << 8));
         }
         else
         {
             result = (ushort)((destVal & 0xFF00) | val);
         }
        
         // Convert the result to double before returning it
         return Convert.ToDouble(result);
    }
    

    We create 3 input channels in the table:
    Channel 101 = data of 16 uint16_t
    Channel 102 = uint8_t data 1
    Input formula for channel 102 GetUi8Byte(Val(101),0); Stat(101)
    Channel 103 = data 2 uint8_t
    Input formula for channel 103 GetUi8Byte(Val(101),1); Stat(101)

    Formula to write to the output channel:
    Channel 102 InsertByte(Cmd, Val(101), true)
    channel 103 InsertByte(Cmd, Val(101), false)

    • This reply was modified 11 months, 2 weeks ago by Merdock.
    Merdock
    Participant

    @manjey73 Works perfect, thanks GetI8ByteDirect(Vol(118),0); Stat(118)

    • This reply was modified 11 months, 2 weeks ago by Merdock.
    in reply to: Elapsed Minute #10463
    Merdock
    Participant
    in reply to: Is that possible autologin just for localhost? #10398
    Merdock
    Participant

    Here some threads about autologin. Perhaps in version 5. You only need to configure the Autologin.aspx as local access.3

    https://forum.rapidscada.org/?action=bbp-search-request&bbp_search=Autologin

    Merdock
    Participant

    What I see in the properties of channel 9405 is that it is configured to show the value without decimals.
    You can double the channel and set it to 2 decimal places.

    in reply to: Access to SchemeEditor sourcecode ? #10318
    Merdock
    Participant

    https://www.hse.ru/en/edu/vkr/184623865

    Here a two places in Russia Crowdfunding
    or information about it.
    I hope this takes place.
    I also recommend you to enable donations in GitGub.
    Greetings.

    • This reply was modified 1 year, 11 months ago by Mikhail.
    in reply to: Access to SchemeEditor sourcecode ? #10310
    Merdock
    Participant

    Hello, I have been very excited about this thread, is there any news about it?
    this at the same time has given me an idea that you want the community to support.
    Estimate costs of improvements or addition of functions.
    Publish them on a site where one can donate in order to reach the cost of the project (some crowdfunding site) and thus accelerate its development with that financial aid.

    in reply to: Runtime Events #10142
    Merdock
    Participant

    Hello.
    As a recommendation to speed up the readings I create a line for each device.
    in this way, minimum times of 1 second between readings are achieved.
    It is also recommended that you try to get the maximum number of records per request.
    The minimum time between readings is 1 second, it is given by the writing in the Current Data file.
    The Web interface takes data from this file.
    This is in version 5x.
    Layers that in version 6 this changed.
    The Modbus Driver reads the 16 bit registers without problems.
    For reading 32-bit registers, the bit order must be changed in the configuration since it does not transpose the LSBs with the MSBs and Rapid Scada reads the 2 16-bit registers consecutively.
    in Default Byte Order you must put 2301.
    in most cases, except device specifications.

    in reply to: Lag issue on Webstation #9758
    Merdock
    Participant

    Now a question.
    If webstation depends on the data recorded in current data.
    and the minimum time is 1 second or when the value changes.
    that is the minimum time to update what is seen in webstation.
    Then set an update time of 500 ms.
    is it completely irrelevant?

    in reply to: Lag issue on Webstation #9757
    Merdock
    Participant

    Thanks for your answer. I have no events scheduled.
    0 events are generated.
    Probe change the setting from 1 second to On change in:
    Server / Saving Parameters / Current data = On change and it was solved.
    Thanks for your help.

    in reply to: Lag issue on Webstation #9752
    Merdock
    Participant

    Soon, my apologies.

    in reply to: Rapid SCADA tite text #8180
    Merdock
    Participant

    I think it would be interesting to be able to edit the names and titles of the pages.
    But I think it should have something like a watermark, with the text, Rapid Scada.

    in reply to: Virtual Keyboard #8179
    Merdock
    Participant

    Operation video.

    Video

    in reply to: Virtual Keyboard #8170
    Merdock
    Participant

    link to imagen
    Imagen 1
    Imagen 2
    Imagen 3

    • This reply was modified 3 years, 3 months ago by Merdock.
Viewing 15 posts - 1 through 15 (of 31 total)