Dan Freve, Author at DMC, Inc. https://www.dmcinfo.com/blog/author/danf/ Tue, 23 Dec 2025 16:26:42 +0000 en-US hourly 1 https://wordpress.org/?v=6.8.3 https://cdn.dmcinfo.com/wp-content/uploads/2025/04/17193803/site-icon-150x150.png Dan Freve, Author at DMC, Inc. https://www.dmcinfo.com/blog/author/danf/ 32 32 Enhancing Customer Service with AI: Introducing Sales Buddy at DMC  https://www.dmcinfo.com/blog/16360/enhancing-customer-service-with-ai-introducing-sales-buddy-at-dmc/ Tue, 30 Apr 2024 12:16:14 +0000 https://www.dmcinfo.com/blog/16360/enhancing-customer-service-with-ai-introducing-sales-buddy-at-dmc/ DMC recently identified a critical need to enhance the speed and accuracy with which we handle incoming customer inquiries. Historically, our dedicated team of Project Coordinators managed this process. They played a crucial role in filtering and routing inquiries from potential customers who reached out through our website's contact page. This manual process, while effective, […]

The post Enhancing Customer Service with AI: Introducing Sales Buddy at DMC  appeared first on DMC, Inc..

]]>
DMC recently identified a critical need to enhance the speed and accuracy with which we handle incoming customer inquiries. Historically, our dedicated team of Project Coordinators managed this process. They played a crucial role in filtering and routing inquiries from potential customers who reached out through our website's contact page. This manual process, while effective, posed challenges in scalability and speed as DMC continued to grow.

The Need for Innovation

Our goal has always been to respond to potential clients swiftly, as we believe promptness is key to building trust and demonstrating our dedication to potential customers; however, the manual process required Project Coordinators to:

  1. Continually monitor a shared Outlook inbox for new leads.
  2. Pre-qualify each inquiry to filter out spam and identify legitimate leads.
  3. Determine the most appropriate service area within DMC for the lead.
  4. Assign the lead to the most appropriate engineer and ensure a timely response.
  5. Create a new lead in our Customer Relationship Management (CRM) system.

To streamline these steps and enhance our responsiveness, we introduced Sales Buddy.

How Sales Buddy Works

sales buddy's incoming lead notification in Slack.

Sales Buddy is an AI-powered Slack Bot that automates the initial stages of our customer inquiry handling process. It integrates cutting-edge technology using Azure OpenAI models, Slack's Webhook API, and Microsoft Power Automate. Here’s how it functions:

  • Monitoring and Qualification: Sales Buddy continually monitors our shared Outlook inbox for incoming leads. Utilizing Azure OpenAI, it evaluates each inquiry based on sophisticated criteria to determine its legitimacy and relevance.

  • Intelligent Routing: After qualifying an inquiry, Sales Buddy identifies the most suitable DMC service area to handle the request. This decision is based on predefined logic that understands our service offerings and their alignment with the potential needs of the customer.

  • Seamless Integration: Once an appropriate service area is selected, Sales Buddy communicates this via a message to one of many designated Slack channels, ensuring that the right sales teams are promptly notified about new opportunities.

  • CRM Integration: Finally, Sales Buddy automatically creates a new lead record in our Microsoft Dynamics CRM system. This reduces manual data entry, enabling faster and more efficient follow-ups from the DMC team.

Benefits and Impact

The implementation of Sales Buddy has transformed the way we manage customer inquiries. By automating the pre-qualification and routing processes, we have significantly reduced the response time, allowing our engineering teams to engage with potential clients quicker than ever before. This not only enhances customer satisfaction but also allows our Project Coordinators to focus on more strategic tasks, thereby improving overall productivity.

Furthermore, Sales Buddy serves as a perfect example of how AI and automation can be leveraged in a low-code environment: making advanced technology accessible to non-developers. This accessibility ensures that our teams can easily maintain and adapt the system as our needs evolve.

Looking Forward

The success of Sales Buddy is a steppingstone towards more comprehensive AI integration across various facets of DMC’s operations. We are committed to continuous improvement and innovation, ensuring that we not only meet but exceed the expectations of our clients and stakeholders.

If you’d like to stay informed on how DMC is leveraging the latest technologies to improve our operations, please subscribe to our newsletter.

The post Enhancing Customer Service with AI: Introducing Sales Buddy at DMC  appeared first on DMC, Inc..

]]>
DMC Boston’s 20th Anniversary Party https://www.dmcinfo.com/blog/25483/dmc-bostons-20th-anniversary-party/ Tue, 28 Jun 2016 10:35:49 +0000 https://www.dmcinfo.com/blog/25483/dmc-bostons-20th-anniversary-party/ DMC is turning 20 this year, and we're hosting events in each of our five office locations to celebrate. Although our official anniversary date is in July, we marked DMC's 20-year milestone at the Boston office at the end of June.  Before the party began, Dan took some of the Chicago office visitors sailing in […]

The post DMC Boston’s 20th Anniversary Party appeared first on DMC, Inc..

]]>
DMC is turning 20 this year, and we're hosting events in each of our five office locations to celebrate. Although our official anniversary date is in July, we marked DMC's 20-year milestone at the Boston office at the end of June. 

dan and clients

Before the party began, Dan took some of the Chicago office visitors sailing in the Boston Harbor. The weather was great and everyone got to see an amazing sunset. Some of the DMCer's had never been sailing before, so it was a unique experience. 

sailing

We were thrilled to celebrate our 20th Anniversary with clients, friends, family and DMC employees from across our offices. The party was in full swing all night with a caricaturist duo, DMC videos, video games, mini golf and lots of food and drinks. We featured food and flags representing DMC's five offices.

Offcies

The caricaturist duo was a big hit. One of them drew and the other colored in the picture. They drew an awesome picture of Adam, which you can see below. 

adam
Caricaturist
nick nikhil and jeff

Guests also had the opportunity to enjoy experiencing permanent office fixtures like the Bongo board, mini golf and giant bean bag chairs. In the 1996 room, representing the year DMC was founded, Phil set up an old school video game. Frank May demoed the FANUC robot arm to great fanfare.

FANUC robot
elizabeth

Just like the Chicago party, everyone enjoyed all of the 1996 videos. Once again, everyone was able to guess which photo was which employee back in 1996. Throughout the night, the office sound system was playing music from 1996 as well. Everyone loved grooving to these old school hits.

90s

The food and drink menu paid tribute to the five cities where DMC has an office. We served New York style pizza, Houston brisket, Chicago style hot dogs, Boston Crème Pie  and Denver beer on tap. According to the guests polled, the New York style pizza was hands down the best in terms of food.

Many guests loved trying the Boston Crème Pie in Boston. Out-of-towners didn’t know what real, authentic Boston Crème Pie was like, so the Boston natives were excited to show them how great it actually is. 

boston creme pie

The DMC Boston party had the same opinion on Malort (a bitter Chicago spirit) as Chicago and Houston's parties: it must be an acquired taste that no one has the intention of developing. Except, Bill seemed to be the only one that enjoyed the taste and said it tasted like "flowers". 

malort reaction

Guests left the party with a huge range of DMC SWAG items including 20th anniversary mugs, frisbees, dancing robots, ring pops, slap bracelets, magic eight balls, playing cards, mini footballs, and sunglasses. The evening was very successful and we thank everyone who came out and helped us celebrate our 20th Anniversary! 

talking

 

The post DMC Boston’s 20th Anniversary Party appeared first on DMC, Inc..

]]>
Celebrate Our 20th Anniversary With DMC Boston https://www.dmcinfo.com/blog/25811/celebrate-our-20th-anniversary-with-dmc-boston/ Fri, 18 Mar 2016 14:49:57 +0000 https://www.dmcinfo.com/blog/25811/celebrate-our-20th-anniversary-with-dmc-boston/ DMC is turning 20 this year, proving that time really does fly when you're having fun! We'll be celebrating throughout the year, and wanted to cordially invite you to help mark this milestone with a party at our Boston office! Join us on June 22, 2016 for food, drinks, and fun as we toast to […]

The post Celebrate Our 20th Anniversary With DMC Boston appeared first on DMC, Inc..

]]>
DMC is turning 20 this year, proving that time really does fly when you're having fun! We'll be celebrating throughout the year, and wanted to cordially invite you to help mark this milestone with a party at our Boston office! Join us on June 22, 2016 for food, drinks, and fun as we toast to 20 years of DMC and counting!

DMC's 20th Anniversary Party – Boston
June 22, 2016
4 – 10 p.m.
20 Holland St., Suite 408
Somerville, MA 02144
[Directions]

Our 20th Anniversary Party will feature food and beverages from our five office locations across the U.S., including Chicago vs. NYC pizza, Denver microbrews, and hometown Boston cream pie. Stop by anytime throughout the evening, and feel free to bring along significant or insignificant others (spouses, colleagues, girlfriends, college roommates, etc.).

If this is your first DMC event, check out highlights from some of our past parties: Chicago Oktoberfest, Boston Mad Science Party, Denver Opening Day Opening Day.

RSVP using the following quick links: RSVP Yes, RSVP No, RSVP Maybe or contact Jessica Mlinaric at 312.255.8757 or jessica.mlinaric@dmcinfo.com.

The post Celebrate Our 20th Anniversary With DMC Boston appeared first on DMC, Inc..

]]>
DMC Boston’s Grand Opening Party https://www.dmcinfo.com/blog/27488/dmc-bostons-grand-opening-party/ Tue, 10 Jun 2014 14:49:31 +0000 https://www.dmcinfo.com/blog/27488/dmc-bostons-grand-opening-party/ DMC's Boston Office held its Grand Opening Party last Thursday, June 5. Although the East Coast office has been open for over a year, we took our time getting it shipshape before inviting our clients, vendors, neighbors, and friends over to celebrate. Over 70 guests joined the DMC Boston team for a fun night at […]

The post DMC Boston’s Grand Opening Party appeared first on DMC, Inc..

]]>
DMC's Boston Office held its Grand Opening Party last Thursday, June 5. Although the East Coast office has been open for over a year, we took our time getting it shipshape before inviting our clients, vendors, neighbors, and friends over to celebrate.

Over 70 guests joined the DMC Boston team for a fun night at office, located in the heart of Davis Square. Everyone filled up on barbecue and mac & cheese from nearby Redbones BBQ and sampled a pale ale and bourbon ale from our office kegerator in commemorative party steins.

Visitors were greeted by our friendly infrared RC flying dolphin. This being a DMC party, there were plenty of opportunities for friendly competition including games of bags, putt-putt, and video games as well as an Anki DRIVE course. Another hit of the evening was our photo booth, which gave guests a fun reminder of party to take home. 

We capped off the evening with a champagne toast and ribbon cutting to officially dedicate the office. The party was a great way to celebrate DMC's first expansion office, and we look forward to a bright future of solving problems, cultivating relationships, and having fun in Boston. Thanks to everyone who was able to attend and all those who have shared in DMC's growth!

DMC Boston officially opens.DMC employees congregate in the kitchen for food and drinks.DMC engineers chat at the new Boston office space.Home baked boston mac and cheese, DMC style.Meat, meat, meat for the party.Two engineers from DMC smile for the camera.DMC employees hit the party scene in Boston.Boston engineer Adnaan strikes a silly pose.Team DMC Boston gets together for a group picture.The ribbon is finally cut and DMC Boston is ready to go.DMC employees get silly in the photo booth.DMC gets sillier in the photo booth.

DMC gets the silliest in the photo booth.

The post DMC Boston’s Grand Opening Party appeared first on DMC, Inc..

]]>
Attend DMC Boston’s Grand Opening Party https://www.dmcinfo.com/blog/27621/attend-dmc-bostons-grand-opening-party/ Mon, 21 Apr 2014 13:25:36 +0000 https://www.dmcinfo.com/blog/27621/attend-dmc-bostons-grand-opening-party/ DMC started doing business in our Boston office back in July of 2013, but now that the last nail is in place and coat of paint is dry we're ready for a party! You're cordially invited to join us for DMC Boston's Grand Opening party on Thursday, June 5, 2014.   DMC Boston's Grand Opening […]

The post Attend DMC Boston’s Grand Opening Party appeared first on DMC, Inc..

]]>
DMC started doing business in our Boston office back in July of 2013, but now that the last nail is in place and coat of paint is dry we're ready for a party! You're cordially invited to join us for DMC Boston's Grand Opening party on Thursday, June 5, 2014.

 

DMC Boston's Grand Opening Party

June 5, 2014

4 p.m. – 10 p.m.

20 Holland St., Suite 408

Somerville, MA 02144

[Driving Directions]

Join in celebrating DMC's newest office at our first ever Boston celebration. Stop by any time throughout the evening for food by Redbones BBQ, drinks, and fun. Feel free to bring along significant or insignificant others (spouses, colleagues, girlfriends, college roommates, etc.).

If you haven't attended one of DMC's events check out our highlights from some of DMC's past parties: Boston Bash, Tres De Mayo, Oktoberfest 2011, Oktoberfest 2012, and Oktoberfest 2013.

RSVP using the following quick links: RSVP Yes, RSVP No, RSVP Maybe or contact Jessica Mlinaric at 312.255.8757 or jessica.mlinaric@dmcinfo.com.

We hope to see you there!

The post Attend DMC Boston’s Grand Opening Party appeared first on DMC, Inc..

]]>
Meet the DMC Boston Team https://www.dmcinfo.com/blog/28195/meet-the-dmc-boston-team/ Tue, 30 Jul 2013 13:51:23 +0000 https://www.dmcinfo.com/blog/28195/meet-the-dmc-boston-team/ DMC is excited to have opened a Boston office to better serve our partners and customers in Massachusetts, the Northeast, and throughout the world. Allow us to proudly introduce you to our Boston staff:     Dan Freve, Project Director Hometown: Elkhart, IN Education: Rose-Hulman Institute of Technology Certifications: Siemens Solution Partner, MCPD Windows Developer 4 Favorite Gadget: Raspberry […]

The post Meet the DMC Boston Team appeared first on DMC, Inc..

]]>
DMC is excited to have opened a Boston office to better serve our partners and customers in Massachusetts, the Northeast, and throughout the world. Allow us to proudly introduce you to our Boston staff:

 

 

Dan Freve, Project Director

Hometown: Elkhart, IN

Education: Rose-Hulman Institute of Technology

Certifications: Siemens Solution Partner, MCPD Windows Developer 4

Favorite Gadget: Raspberry Pi

First Concert: Red Hot Chili Peppers

I’d Like to Meet: Tom Brady

Party Trick: Juggling

Favorite Thing About Boston: Fenway Park

Watch Dan’s Employee Spotlight video.
 

 

Dan Lawler, Systems Engineer

Hometown: Rochester, MN

Education: University of Wisconsin, Madison

Certifications: Siemens Solution Partner, LabVIEW Developer

Favorite Gadget: Phone saves the day when navigating spaghetti-like Cambridge

Random Fact: I’m way too good at Mariokart, almost embarrassing

Slogan for Life: Be nice

Proudest Achievement: Grade school chess champion!

Favorite Thing About Boston: The Boston accent, the movies don’t lie

Read Dan’s Employee Spotlight interview.
 

 

Frank May, Systems Engineer

Hometown: Franklin, MA

Education: UMass Amherst

Party Trick: Reciting pi

Favorite Gadget: A broken one that I’m allowed to take apart

Proudest Achievement: Winning a 5K in a banana costume

If I Won the Lottery: I’d buy a few hundred remote control helicopters and start scheming.

Slogan for Life: Google it

Favorite Thing About Boston: The disorganized roads – just kidding. Probably how important the Boston Marathon is to everyone.

 

 Jason Mayes, Project Engineer

Hometown: Longview, TX

Education: University of Notre Dame

Certifications: Certified LabVIEW Developer

First Concert: Beach Boys (with a guest appearance by John Stamos)

Random Fact: I’ve broken my nose 7 times

Proudest Achievement: Finishing my Ph.D.

What Inspired Me to Engineer: MacGyver and late 60’s muscle cars

Favorite Thing About Boston: Regina’s Pizzeria makes us forget Chicago. Mike’s Pastry cannolis are worth the trip alone.

Watch Jason’s Employee Spotlight video.

 Bill Sowerine, Systems Engineer

Hometown: McKinleyville, CA

Education: U.C. Santa Barbara, C.U. Boulder

I’d Like to Meet: John Mitzewich, internet chef

On the Weekend I Love: Hiking, rock climbing, and any opportunity to get outdoors

Random Fact: I’m knowledgeable about edible mushrooms in the Pacific Northwest

If I Won the Lottery: I’d reinvest in lottery tickets

What Inspired Me to Engineer: A lifelong interest in science and a need to understand how things work

Favorite Thing About Boston: Fresh seafood

 Adnaan Velji, Systems Engineer

Hometown: Mwanza, Tanzania

Education: Georgia Tech

Languages: English, Gujrati, Swahili, Kutchi, Hindi, survival Spanish, Python, C#/C/C+, MATLAB, Java, Siemens S7

First Concert: T.I.P. coming from G.I.T.

Slogan for Life: I have a different slogan every week. Open to suggestions.

Guilty Pleasure: Suits and boots

Party Trick: The tongue click

Favorite Thing About Boston: It’s very bikeable and there are many options for day trips

 

Adam Wójcik, Systems Engineer

Hometown: Pila, Poland

Education: University of Notre Dame

Languages: Polish, English, French, attempting German, C++, C, MATLAB, Java, FORTRAN 77

Favorite Gadget: 3D printers

First Concert: ACDC – old, but still great

Proudest Achievement: Translating a Polish novel to English

I’ve Always Wanted: To augment myself

What Inspired Me to Engineer: A childhood dream of creating a robotic pet dinosaur.  Also LEGOs.

Learn more about DMC’s company culture. 

The post Meet the DMC Boston Team appeared first on DMC, Inc..

]]>
DMC’s First Golf Tournament https://www.dmcinfo.com/blog/28908/dmcs-first-golf-tournament/ Wed, 13 Jun 2012 13:40:59 +0000 https://www.dmcinfo.com/blog/28908/dmcs-first-golf-tournament/ Several DMC employees recently took to the links for our first company golf tournament. Seven of us split into two teams and headed to the Sydney R. Marovitz golf course. Team A:  Devon Fritz, Dan Freve, and Rick Rietz Team B:  Jesse Batsche, Ken Brey, Spencer Glesmann, and Jason Mayes We played a scramble format on the […]

The post DMC’s First Golf Tournament appeared first on DMC, Inc..

]]>
Several DMC employees recently took to the links for our first company golf tournament. Seven of us split into two teams and headed to the Sydney R. Marovitz golf course.

Team A:  Devon Fritz, Dan Freve, and Rick Rietz

Team B:  Jesse Batsche, Ken Brey, Spencer Glesmann, and Jason Mayes

We played a scramble format on the 9-hole course, and everyone had a blast golfing adjacent to Lake Michigan. Team A finished 1 over par and Team B finished 3 over par.

We’re excited to tee it up again soon, so look forward to future updates from the DMC “Golf Club!”

The post DMC’s First Golf Tournament appeared first on DMC, Inc..

]]>
Automated Ping Pong Game https://www.dmcinfo.com/blog/30065/automated-ping-pong-game/ Thu, 17 Dec 2009 11:35:00 +0000 https://www.dmcinfo.com/blog/30065/automated-ping-pong-game/ Sometimes, it’s difficult to articulate exactly what type of work DMC does day to day. For example, in a career fair setting a DMC employee might only have a few minutes to describe our projects to a candidate. It quickly became apparent to us that a physical demo that highlights our capabilities would be very […]

The post Automated Ping Pong Game appeared first on DMC, Inc..

]]>
Sometimes, it’s difficult to articulate exactly what type of work DMC does day to day. For example, in a career fair setting a DMC employee might only have a few minutes to describe our projects to a candidate. It quickly became apparent to us that a physical demo that highlights our capabilities would be very beneficial in these situations.

Enter, the automated ping pong game! We decided to build a machine that plays ping pong – autonomously! Here’s a video showing the machine in action:

The beauty of this demo is that it involves many of the technologies and equipment that a DMC engineer works with any given day. Obviously, there was no way for us to encapsulate everything we do into one demo, but this demo includes quite a few of them.

The entire ping-pong demo is driven by a LabVIEW program.The LabVIEW program can be broken up into the following subsystems:

Camera: The camera we are currently using is a Prosilica monochrome camera with a resolution of 1280×1024 pixels.It takes around 40 pictures of the playing field per second.We use several of the NI vision VIs to identify the position of the ball on the illuminated background and filter out unwanted objects.

Trajectory Prediction: As the ball travels around the playing field, we keep a buffer of previous ball positions.We use a very basic least squares curve fit to predict the quadratic trajectory of the ball.

Servo System: To locate the hitting mechanism under the ball, we are using a Yaskawa Sigma-5 servo amplifier to drive a motor that is coupled to a linear slide. DMC developed a LabVIEW driver that communicates with Yaskawa Sigma V drives over their MECHATROLINK II protocol. Using these driver VIs, the predicted point of contact is being continuously relayed to the amplifier. Acceleration parameters are set on the drive to produce the fastest possible positioning.

Digital I/O: We are using a National Instruments USB-6009 module for our digital I/O. When the ball approaches the hitting head at the bottom of the playing field, it crosses a LASER line.Since we know the velocity of the ball (from the camera), and the distance between the LASER and the hitting head, we can calculate the precise time to hit the ball. After the necessary delay, the program activates an output to drive the solenoid that is mounted on the hitting mechanism.The solenoid is only pulsed for a very short time period (~15 ms).

A side note: One might think that the LASER is unnecessary for timing.We can get the velocity and distance of the ball from the camera, so why do we need the LASER for timing?The answer is that the information from the camera is simply not accurate enough. Since the solenoid is only activated for about 15 ms, we need very precise timing to ensure a clean hit.

During a recent brainstorming session, we came up with a few ideas for future improvements:

  1. “Inverted Pendulum” mode: The algorithm would position the hitter in such a way to keep the ball bouncing exactly in the middle of the playing field.
  2. “Target” mode: Use the curved hitting head to aim the ball at several targets on the screen.
  3. “User” mode: Give the user the ability to control the position of the hitting head (possibly using a Wii controller).

Feel free to comment on any ideas for future features that you may have!

The post Automated Ping Pong Game appeared first on DMC, Inc..

]]>
.NET Micro Framework Midi Player https://www.dmcinfo.com/blog/30137/net-micro-framework-midi-player/ Thu, 15 Oct 2009 10:43:32 +0000 https://www.dmcinfo.com/blog/30137/net-micro-framework-midi-player/ A few days ago, I was working on a project where I needed to control a stepper motor using the .NET Micro Framework on the GHI Embedded Master microprocessor. Stepper motors are a unique type of motor – the velocity is controlled by a pulse wave input. The faster the pulse frequency, the faster the […]

The post .NET Micro Framework Midi Player appeared first on DMC, Inc..

]]>
A few days ago, I was working on a project where I needed to control a stepper motor using the .NET Micro Framework on the GHI Embedded Master microprocessor. Stepper motors are a unique type of motor – the velocity is controlled by a pulse wave input. The faster the pulse frequency, the faster the motor rotates.

It turns out that most stepper motors will tend to vibrate enough that they can produce quite an audible tone at the frequency at which you are providing pulses. For instance, if you provided a pulse frequency of 440 Hz, the stepper motor would hum the pitch of concert A.

It occurred to me very quickly that I could easily program my device to use the stepper motor as a “speaker” and play a song! Programming each note one by one seemed too tedious, so I programmed a simple MIDI parser.

My project reads a MIDI file in from a USB flash drive, parses the file to gather note events, then plays the song using the PWM output on the microprocessor.

Below is a video of the player in action. Of course, the classic Mario theme was my song of choice!

Comments and suggestions are definitely welcome! I’ve attached my project files, so feel free to build on them.

Download Project Files

The post .NET Micro Framework Midi Player appeared first on DMC, Inc..

]]>
UNC Paths in LabVIEW https://www.dmcinfo.com/blog/30149/unc-paths-in-labview/ Wed, 14 Oct 2009 08:36:13 +0000 https://www.dmcinfo.com/blog/30149/unc-paths-in-labview/ Recently, a colleague here at DMC was looking for a quick method of converting a drive-based path to its corresponding universal path name. Basically, he is writing a tool in LabVIEW that will run on computers that may have the same network drive mapped to different drive letters. After a quick search, I found that […]

The post UNC Paths in LabVIEW appeared first on DMC, Inc..

]]>
Recently, a colleague here at DMC was looking for a quick method of converting a drive-based path to its corresponding universal path name. Basically, he is writing a tool in LabVIEW that will run on computers that may have the same network drive mapped to different drive letters.

After a quick search, I found that Windows has a networking function that does exactly what I’m looking for! The function is called WNetGetUniversalName, and it resides in mpr.dll.

In order to easily call this function from LabVIEW, I decided to first wrap it in a .NET class. It is rudimentary to load .NET libraries into LabVIEW, but we’ll get to that in a second.

While I was searching on WNetGetUniversalName, I ran across some .NET code that had already been written for me! Pinvoke.net already had an implementation that wraps WNetGetUniversalName and adds some error handling as well. I threw this into my own .NET class, and also made a small bug fix that was mentioned by one of the comments on pinvoke.net’s site. Here is the source:

C#
public class PathConverter
{
    [DllImport("mpr.dll")]
    [return: MarshalAs(UnmanagedType.U4)]
    static extern int WNetGetUniversalName(
        string lpLocalPath,
        [MarshalAs(UnmanagedType.U4)] int dwInfoLevel,
        IntPtr lpBuffer,
        [MarshalAs(UnmanagedType.U4)] ref int lpBufferSize);

    const int UNIVERSAL_NAME_INFO_LEVEL = 0x00000001;
    const int REMOTE_NAME_INFO_LEVEL = 0x00000002;

    const int ERROR_MORE_DATA = 234;
    const int NOERROR = 0;

    public string GetUniversalName(string localPath)
    {   
        // The return value.
        string retVal = null;
                
        // The pointer in memory to the structure.
        IntPtr buffer = IntPtr.Zero;

        // Wrap in a try/catch block for cleanup.
        try
        {
            // First, call WNetGetUniversalName to get the size.
            int size = 0;

            // Make the call.
            // Pass IntPtr.Size because the API doesn't like null, even though
            // size is zero.  We know that IntPtr.Size will be
            // aligned correctly.
            int apiRetVal = WNetGetUniversalName(localPath, UNIVERSAL_NAME_INFO_LEVEL, (IntPtr)IntPtr.Size, ref size);

            // If the return value is not ERROR_MORE_DATA, then
            // raise an exception.
            if (apiRetVal != ERROR_MORE_DATA)
                // Throw an exception.
                throw new Win32Exception(apiRetVal);

            // Allocate the memory.
            buffer = Marshal.AllocCoTaskMem(size);

            // Now make the call.
            apiRetVal = WNetGetUniversalName(localPath, UNIVERSAL_NAME_INFO_LEVEL, buffer, ref size);

            // If it didn't succeed, then throw.
            if (apiRetVal != NOERROR)
                // Throw an exception.
                throw new Win32Exception(apiRetVal);

            // Now get the string.  It's all in the same buffer, but
            // the pointer is first, so offset the pointer by IntPtr.Size
            // and pass to PtrToStringAnsi.
            retVal = Marshal.PtrToStringAnsi(new IntPtr(buffer.ToInt64() + IntPtr.Size));
        }
        finally
        {
            // Release the buffer.
            Marshal.FreeCoTaskMem(buffer);
        }

        // First, allocate the memory for the structure.

        // That's all folks.
        return retVal;
    }
}

Now all that’s left is to call this .NET function from LabVIEW. The code is shown below. The first step is to call the “Constructor Node” VI. This will load a new instance of the .NET class into memory. Next, call the “Invoke Node” VI and choose the function that we’ve created above (I named it GetUniversalName). LabVIEW will automatically detect the data types and give you the inputs/outputs that you need. Make sure to close the .NET reference when you’re done to free up resources!

LabVIEW source code

Learn more about DMC’s LabVIEW programming expertise.

The post UNC Paths in LabVIEW appeared first on DMC, Inc..

]]>